Implement leaving an activity

This commit is contained in:
Tomeu Vizoso 2010-07-02 11:35:10 +02:00
parent 2db82c1722
commit 12cd353620

View File

@ -304,6 +304,7 @@ class Activity(gobject.GObject):
self.telepathy_text_chan = join_command.text_channel self.telepathy_text_chan = join_command.text_channel
self.telepathy_tubes_chan = join_command.tubes_channel self.telepathy_tubes_chan = join_command.tubes_channel
self._start_tracking_buddies() self._start_tracking_buddies()
self._start_tracking_channel()
self.emit('joined', error is None, str(error)) self.emit('joined', error is None, str(error))
def _start_tracking_buddies(self): def _start_tracking_buddies(self):
@ -311,6 +312,10 @@ class Activity(gobject.GObject):
group.connect_to_signal('MembersChanged', group.connect_to_signal('MembersChanged',
self.__text_channel_members_changed_cb) 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, def __text_channel_members_changed_cb(self, message, added, removed,
local_pending, remote_pending, local_pending, remote_pending,
actor, reason): actor, reason):
@ -361,6 +366,7 @@ class Activity(gobject.GObject):
self._publish_properties() self._publish_properties()
self._start_tracking_properties() self._start_tracking_properties()
self._start_tracking_buddies() self._start_tracking_buddies()
self._start_tracking_channel()
share_activity_cb(self) share_activity_cb(self)
else: else:
share_activity_error_cb(self, error) share_activity_error_cb(self, error)
@ -407,21 +413,14 @@ class Activity(gobject.GObject):
return bus_name, connection, channels return bus_name, connection, channels
# Leaving # Leaving
def __text_channel_closed_cb(self):
def _leave_cb(self): self._joined = False
"""Callback for async action of leaving shared activity."""
self.emit("joined", False, "left activity") 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): def leave(self):
"""Leave this shared activity""" """Leave this shared activity"""
_logger.debug('%r: leaving', self) _logger.debug('%r: leaving', self)
self._joined = False self.telepathy_text_chan.Close()
self._activity.Leave(reply_handler=self._leave_cb,
error_handler=self._leave_error_cb)
class _BaseCommand(gobject.GObject): class _BaseCommand(gobject.GObject):
__gsignals__ = { __gsignals__ = {