From 12cd353620167a087daf50f220993997324699e1 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Fri, 2 Jul 2010 11:35:10 +0200 Subject: [PATCH] Implement leaving an activity --- src/sugar/presence/activity.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/sugar/presence/activity.py b/src/sugar/presence/activity.py index c3266e89..ba80e84c 100644 --- a/src/sugar/presence/activity.py +++ b/src/sugar/presence/activity.py @@ -304,6 +304,7 @@ class Activity(gobject.GObject): self.telepathy_text_chan = join_command.text_channel self.telepathy_tubes_chan = join_command.tubes_channel self._start_tracking_buddies() + self._start_tracking_channel() self.emit('joined', error is None, str(error)) def _start_tracking_buddies(self): @@ -311,6 +312,10 @@ class Activity(gobject.GObject): group.connect_to_signal('MembersChanged', self.__text_channel_members_changed_cb) + def _start_tracking_channel(self): + channel = self.telepathy_text_chan[CHANNEL] + channel.connect_to_signal('Closed', self.__text_channel_closed_cb) + def __text_channel_members_changed_cb(self, message, added, removed, local_pending, remote_pending, actor, reason): @@ -361,6 +366,7 @@ class Activity(gobject.GObject): self._publish_properties() self._start_tracking_properties() self._start_tracking_buddies() + self._start_tracking_channel() share_activity_cb(self) else: share_activity_error_cb(self, error) @@ -407,21 +413,14 @@ class Activity(gobject.GObject): return bus_name, connection, channels # Leaving - - def _leave_cb(self): - """Callback for async action of leaving shared activity.""" + def __text_channel_closed_cb(self): + self._joined = False self.emit("joined", False, "left activity") - def _leave_error_cb(self, err): - """Callback for error in async leaving of shared activity.""" - _logger.debug('Failed to leave activity: %s', err) - def leave(self): """Leave this shared activity""" _logger.debug('%r: leaving', self) - self._joined = False - self._activity.Leave(reply_handler=self._leave_cb, - error_handler=self._leave_error_cb) + self.telepathy_text_chan.Close() class _BaseCommand(gobject.GObject): __gsignals__ = {