replace _connect_to_server with a protocol/cm independent equivalent
This commit is contained in:
parent
6a58df67a0
commit
4200f1edeb
@ -60,7 +60,12 @@ class PresenceService(dbus.service.Object):
|
|||||||
self._registry = ManagerRegistry()
|
self._registry = ManagerRegistry()
|
||||||
self._registry.LoadManagers()
|
self._registry.LoadManagers()
|
||||||
|
|
||||||
self._server_client = self._connect_to_server()
|
account = {
|
||||||
|
'account': 'olpc@collabora.co.uk',
|
||||||
|
'password': 'learn',
|
||||||
|
'server': 'light.bluelinux.co.uk'
|
||||||
|
}
|
||||||
|
self._server_client = self._connect_to_connection_manager("jabber", account)
|
||||||
self._handles[self._server_client] = {}
|
self._handles[self._server_client] = {}
|
||||||
|
|
||||||
# Telepathy link local connection
|
# Telepathy link local connection
|
||||||
@ -72,15 +77,13 @@ class PresenceService(dbus.service.Object):
|
|||||||
|
|
||||||
dbus.service.Object.__init__(self, self._bus_name, _PRESENCE_PATH)
|
dbus.service.Object.__init__(self, self._bus_name, _PRESENCE_PATH)
|
||||||
|
|
||||||
def _connect_to_server(self):
|
def _connect_to_connection_manager(self, protocol, account):
|
||||||
protocol = 'jabber'
|
if protocol == "jabber":
|
||||||
account = {
|
cm = "gabble"
|
||||||
'account': 'olpc@collabora.co.uk',
|
else:
|
||||||
'password': 'learn',
|
return
|
||||||
'server': 'light.bluelinux.co.uk'
|
|
||||||
}
|
|
||||||
|
|
||||||
mgr = self._registry.GetManager('gabble')
|
mgr = self._registry.GetManager(cm)
|
||||||
conn = None
|
conn = None
|
||||||
|
|
||||||
# Search existing connections, if any, that we might be able to use
|
# Search existing connections, if any, that we might be able to use
|
||||||
@ -88,7 +91,7 @@ class PresenceService(dbus.service.Object):
|
|||||||
for item in connections:
|
for item in connections:
|
||||||
if item[CONN_INTERFACE].GetProtocol() != protocol:
|
if item[CONN_INTERFACE].GetProtocol() != protocol:
|
||||||
continue
|
continue
|
||||||
if not item.object_path.startswith("/org/freedesktop/Telepathy/Connection/gabble/jabber/"):
|
if not item.object_path.startswith("/org/freedesktop/Telepathy/Connection/%s/%s/" % (cm, protocol)):
|
||||||
continue
|
continue
|
||||||
if item[CONN_INTERFACE].GetStatus() == CONNECTION_STATUS_CONNECTED:
|
if item[CONN_INTERFACE].GetStatus() == CONNECTION_STATUS_CONNECTED:
|
||||||
self_name = account['account']
|
self_name = account['account']
|
||||||
|
Loading…
Reference in New Issue
Block a user