diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2008-10-24 13:21:13 (GMT) |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2008-10-24 13:21:13 (GMT) |
commit | ed0b5e3adc45a5127b16e63230edbc918ac54979 (patch) | |
tree | 5230b7f537edc7a78754a8ed443af10dd63641f8 | |
parent | 3a4856a069075296a0320c14dabf76fe341a505a (diff) |
Add a _handle_is_channel_specific method so we don't rely only on the roster before discarding handles
-rw-r--r-- | src/linklocal_plugin.py | 4 | ||||
-rw-r--r-- | src/server_plugin.py | 18 | ||||
-rw-r--r-- | src/telepathy_plugin.py | 6 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/linklocal_plugin.py b/src/linklocal_plugin.py index 0fd914c..250482d 100644 --- a/src/linklocal_plugin.py +++ b/src/linklocal_plugin.py @@ -222,3 +222,7 @@ class LinkLocalPlugin(TelepathyPlugin): # Salut can't connect during the next 2 minutes self._have_to_wait_id = gobject.timeout_add(120000, self._have_to_wait_cb) + + def _handle_is_channel_specific(self, handle): + # Salut doesn't have channel specific handles + return False diff --git a/src/server_plugin.py b/src/server_plugin.py index 1f5658c..d055003 100644 --- a/src/server_plugin.py +++ b/src/server_plugin.py @@ -22,6 +22,7 @@ import logging import os from itertools import izip from string import hexdigits +import re import gconf # Other libraries @@ -407,3 +408,20 @@ class ServerPlugin(TelepathyPlugin): HANDLE_TYPE_CONTACT, friends, reply_handler=got_friends_handles, error_handler=error_syncing_friends) + + def _handle_is_channel_specific(self, handle): + # FIXME: This is crack. Really. Please kids, dont't do this at home. + # As we don't have a proper TP API to test if a handle is channel + # specific or not we use this cracky heuristic: + # "Is the jid contain a '/' after the '@'?". + # This is horribly protocol specific but should, hopefully, do the + # job. + jid = self._conn.InspectHandles(1, [handle])[0] + reg = re.compile('.*@.*/.*') + + if reg.match(jid) is None: + _logger.debug('%s (%d) is not channel specific' % (jid, handle)) + return False + else: + _logger.debug('%s (%d) is channel specific' % (jid, handle)) + return True diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py index 25bbd1c..6eee900 100644 --- a/src/telepathy_plugin.py +++ b/src/telepathy_plugin.py @@ -371,6 +371,9 @@ class TelepathyPlugin(gobject.GObject): return jids + def _handle_is_channel_specific(self, handle): + raise NotImplementedError + def _contacts_online(self, handles): """Handle contacts coming online""" relevant = [] @@ -382,7 +385,8 @@ class TelepathyPlugin(gobject.GObject): pass elif (handle in self._subscribe_members or handle in self._subscribe_local_pending or - handle in self._subscribe_remote_pending): + handle in self._subscribe_remote_pending or + not self._handle_is_channel_specific(handle)): relevant.append(handle) # else it's probably a channel-specific handle - can't create a # Buddy object for those yet |