diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2008-08-06 08:51:36 (GMT) |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2008-08-07 09:57:55 (GMT) |
commit | 956b8b361eee86ffc31181ef14405b127123df3c (patch) | |
tree | d5930375dad0b2b84f1278abe13afd91c46047e2 | |
parent | 05cf86cd4e9d8958773e35559aea603686702fc3 (diff) |
_contacts_online: discard invalid handles if InspectHandles failed (#5618)
-rw-r--r-- | src/telepathy_plugin.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py index 2042111..295a447 100644 --- a/src/telepathy_plugin.py +++ b/src/telepathy_plugin.py @@ -356,6 +356,20 @@ class TelepathyPlugin(gobject.GObject): _logger.debug('%r: Contacts now offline: %r', self, handles) self.emit("contacts-offline", handles) + def _inspect_handles_one_by_one(self, handle_type, handles): + jids = [] + + for handle in handles: + try: + jid = self._conn[CONN_INTERFACE].InspectHandles(handle_type, + [handle]) + except DBusException: + continue + else: + jids.append(jid[0]) + + return jids + def _contacts_online(self, handles): """Handle contacts coming online""" relevant = [] @@ -375,8 +389,16 @@ class TelepathyPlugin(gobject.GObject): if not relevant: return - jids = self._conn[CONN_INTERFACE].InspectHandles( - HANDLE_TYPE_CONTACT, relevant) + try: + jids = self._conn[CONN_INTERFACE].InspectHandles( + HANDLE_TYPE_CONTACT, relevant) + except DBusException: + # InspectHandles failed so discard invalid handles by trying to + # inspect them one by one. + # FIXME: the Inspectotron should offer a proper way to do this. + jids = self._inspect_handles_one_by_one(HANDLE_TYPE_CONTACT, relevant) + if not jids: + return handle_to_objid = self.identify_contacts(None, relevant, jids) objids = [] |