Remove invite when the activiy disappear from the mesh. (#3514)

This commit is contained in:
Guillaume Desmottes 2007-09-17 14:03:15 +02:00
parent 30edb542b1
commit d21e4c7cee
3 changed files with 20 additions and 4 deletions

1
NEWS
View File

@ -1,3 +1,4 @@
* #3514 Remove invite when the activiy disappear from the mesh. (cassidy)
* #3003 Make image drags on the clipboard work consistently. (marco)
Snapshot 8ef6c57f8b

View File

@ -39,16 +39,26 @@ class Invites(gobject.GObject):
def __init__(self):
gobject.GObject.__init__(self)
self._list = []
self._dict = {}
def add_invite(self, issuer, bundle_id, activity_id):
if activity_id in self._dict:
# there is no point to add more than one time
# an invite for the same activity
return
invite = Invite(issuer, bundle_id, activity_id)
self._list.append(invite)
self._dict[activity_id] = invite
self.emit('invite-added', invite)
def remove_invite(self, invite):
self._list.remove(invite)
self._dict.pop(invite.get_activity_id())
self.emit('invite-removed', invite)
def remove_activity(self, activity_id):
invite = self._dict.get(activity_id)
if invite is not None:
self.remove_invite(invite)
def __iter__(self):
return self._list.__iter__()
return self._dict.values().__iter__()

View File

@ -68,6 +68,8 @@ class ShellOwner(gobject.GObject):
self._pservice = presenceservice.get_instance()
self._pservice.connect('activity-invitation',
self._activity_invitation_cb)
self._pservice.connect('activity-disappeared',
self._activity_disappeared_cb)
self._invites = Invites()
@ -80,3 +82,6 @@ class ShellOwner(gobject.GObject):
def _activity_invitation_cb(self, pservice, activity, buddy, message):
self._invites.add_invite(buddy, activity.props.type,
activity.props.id)
def _activity_disappeared_cb(self, pservice, activity):
self._invites.remove_activity(activity.props.id)