services/presence/: keep track of the owner's Telepathy handles

This commit is contained in:
Simon McVittie 2007-05-22 16:43:45 +01:00
parent 10e1daf8c6
commit 7b1a38af1c
2 changed files with 10 additions and 2 deletions

View File

@ -107,12 +107,19 @@ class PresenceService(ExportedGObject):
_logger.debug("Disconnected from session bus!!!")
def _server_status_cb(self, plugin, status, reason):
# FIXME: figure out connection status when we have a salut plugin too
old_status = self._connected
if status == CONNECTION_STATUS_CONNECTED:
self._connected = True
self._handles_buddies[plugin][plugin.self_handle] = self._owner
self._owner.add_telepathy_handle(plugin, plugin.self_handle)
else:
self._connected = False
if plugin.self_handle is not None:
self._handles_buddies.setdefault(plugin, {}).pop(
plugin.self_handle, None)
self._owner.remove_telepathy_handle(plugin, plugin.self_handle)
if self._connected != old_status:
self.emit('connection-status', self._connected)

View File

@ -137,6 +137,7 @@ class ServerPlugin(gobject.GObject):
self._owner = owner
self._owner.connect("property-changed", self._owner_property_changed_cb)
self._owner.connect("icon-changed", self._owner_icon_changed_cb)
self.self_handle = None
self._account = self._get_account_info()
self._conn_status = CONNECTION_STATUS_DISCONNECTED
@ -348,8 +349,8 @@ class ServerPlugin(gobject.GObject):
# accept pending subscriptions
publish[CHANNEL_INTERFACE_GROUP].AddMembers(local_pending, '')
self_handle = self._conn[CONN_INTERFACE].GetSelfHandle()
self._online_contacts[self_handle] = self._account['account']
self.self_handle = self._conn[CONN_INTERFACE].GetSelfHandle()
self._online_contacts[self.self_handle] = self._account['account']
# request subscriptions from people subscribed to us if we're not subscribed to them
not_subscribed = list(set(publish_handles) - set(subscribe_handles))