summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>2010-11-30 22:16:39 (GMT)
committerLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>2010-12-03 20:51:12 (GMT)
commite804d7e68c46d301ac7797e57ffe71210f880dda (patch)
tree3ab43df82b15666a96df84157579e62af6173ed0
parentf5140e786f2faa2191479fd3599de30f71ab38df (diff)
downloadtelepathy-butterfly-e804d7e68c46d301ac7797e57ffe71210f880dda.tar.gz
telepathy-butterfly-e804d7e68c46d301ac7797e57ffe71210f880dda.tar.xz
bugfix: don't try to add/remove ourself from a contact list
-rw-r--r--butterfly/channel/contact_list.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/butterfly/channel/contact_list.py b/butterfly/channel/contact_list.py
index b7e2689..241d4ea 100644
--- a/butterfly/channel/contact_list.py
+++ b/butterfly/channel/contact_list.py
@@ -220,9 +220,11 @@ class ButterflySubscribeListChannel(ButterflyListChannel,
@Lockable(mutex, 'add_subscribe', 'finished_cb')
def _add(self, handle_id, message, finished_cb):
handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
+ if handle is self._conn.GetSelfHandle():
+ return True # don't add ourself
if handle.contact is not None and \
handle.contact.is_member(papyon.Membership.FORWARD):
- return True
+ return True # contact already there
account = handle.account
network = handle.network
@@ -287,8 +289,11 @@ class ButterflySubscribeListChannel(ButterflyListChannel,
def _remove(self, handle_id, finished_cb):
handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
contact = handle.contact
+ if handle is self._conn.GetSelfHandle():
+ return True # don't try to remove ourself
if contact is None or not contact.is_member(papyon.Membership.FORWARD):
- return True
+ return True # contact not in address book
+
ab = self._conn.msn_client.address_book
ab.delete_contact(contact, done_cb=(finished_cb,),
failed_cb=(finished_cb,))
@@ -344,14 +349,13 @@ class ButterflyPublishListChannel(ButterflyListChannel,
def _add(self, handle_id, message, finished_cb):
handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
contact = handle.contact
+ if handle is self._conn.GetSelfHandle():
+ return True # don't add ourself
if contact is not None and contact.is_member(papyon.Membership.ALLOW):
- return True
-
- # This will occur if the contact doesn't actually exist
- # (e.g. nobody@example.com).
+ return True # contact is already allowed
if contact is None:
logger.debug('Cannot allow/accept None contact %s' % handle.get_name())
- return True
+ return True # contact doesn't actually exist
account = handle.account
network = handle.network
@@ -368,6 +372,8 @@ class ButterflyPublishListChannel(ButterflyListChannel,
handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
contact = handle.contact
ab = self._conn.msn_client.address_book
+ if handle is self._conn.GetSelfHandle():
+ return True # don't try to remove ourself
if contact.is_member(papyon.Membership.PENDING):
ab.decline_contact_invitation(contact, False, done_cb=(finished_cb,),
failed_cb=(finished_cb,))
@@ -375,7 +381,7 @@ class ButterflyPublishListChannel(ButterflyListChannel,
ab.disallow_contact(contact, done_cb=(finished_cb,),
failed_cb=(finished_cb,))
else:
- return True
+ return True # contact is neither pending or allowed
# papyon.event.ContactEventInterface
def on_contact_memberships_changed(self, contact):