From 7b1a38af1cefe3aed5436a62fa5ddcdd68bb3082 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 22 May 2007 16:43:45 +0100 Subject: [PATCH] services/presence/: keep track of the owner's Telepathy handles --- services/presence/presenceservice.py | 7 +++++++ services/presence/server_plugin.py | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/services/presence/presenceservice.py b/services/presence/presenceservice.py index 6273a22c..0add4730 100644 --- a/services/presence/presenceservice.py +++ b/services/presence/presenceservice.py @@ -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) diff --git a/services/presence/server_plugin.py b/services/presence/server_plugin.py index a886fdb8..6b21888f 100644 --- a/services/presence/server_plugin.py +++ b/services/presence/server_plugin.py @@ -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))