From 628c07688d1dc86a6c494e07b37301cad8f5907c Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 08 Aug 2010 09:06:52 +0000 Subject: Request again the current activity when we get to know about a new activity through a buddy's ActivitiesChanged. --- diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py index 92ce47a..0fea384 100644 --- a/src/jarabe/desktop/meshbox.py +++ b/src/jarabe/desktop/meshbox.py @@ -502,7 +502,7 @@ class MeshBox(gtk.VBox): icon.destroy() def __buddy_notify_current_activity_cb(self, buddy_model, pspec): - logging.debug('MeshBox.__buddy_notify_current_activity_cb') + logging.debug('MeshBox.__buddy_notify_current_activity_cb %s', buddy_model.props.current_activity) if buddy_model.props.current_activity is None: if not buddy_model.props.key in self._buddies: self._add_buddy(buddy_model) diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py index c355e25..022a35a 100644 --- a/src/jarabe/model/neighborhood.py +++ b/src/jarabe/model/neighborhood.py @@ -336,6 +336,8 @@ class _Account(gobject.GObject): logging.debug('_Account.__current_activity_changed_cb %r %r %r', contact_handle, activity_id, room_handle) if contact_handle in self._buddy_handles: contact_id = self._buddy_handles[contact_handle] + if not activity_id and room_handle: + activity_id = self._activity_handles.get(room_handle, '') self.emit('current-activity-updated', contact_id, activity_id) def __get_current_activity_cb(self, contact_handle, activity_id, room_handle): @@ -366,6 +368,16 @@ class _Account(gobject.GObject): error_handler=partial(self.__error_handler_cb, 'ActivityProperties.GetProperties')) + # Sometimes we'll get CurrentActivityChanged before we get to + # know about the activity so we miss the event. In that case, + # request again the current activity for this buddy. + connection = self._connection[CONNECTION_INTERFACE_BUDDY_INFO] + connection.GetCurrentActivity( + buddy_handle, + reply_handler=partial(self.__get_current_activity_cb, buddy_handle), + error_handler=partial(self.__error_handler_cb, + 'BuddyInfo.GetCurrentActivity')) + if not activity_id in self._buddies_per_activity: self._buddies_per_activity[activity_id] = set() self._buddies_per_activity[activity_id].add(buddy_handle) @@ -746,6 +758,10 @@ class Neighborhood(gobject.GObject): logging.debug('__current_activity_updated_cb Unknown buddy with ' 'contact_id %r', contact_id) return + if activity_id and activity_id not in self._activities: + logging.debug('__current_activity_updated_cb Unknown activity with ' + 'id %s', activity_id) + activity_id = '' buddy = self._buddies[contact_id] if buddy.props.current_activity is not None: -- cgit v0.9.1