All pastes #829993 Raw Edit

Untitled

public text v1 · immutable
#829993 ·published 2007-12-23 18:00 UTC
rendered paste body
=== modified file 'telepathy_butterfly/channel.py'
--- telepathy_butterfly/channel.py	2007-11-13 17:56:59 +0000
+++ telepathy_butterfly/channel.py	2007-12-23 17:57:32 +0000
@@ -124,6 +124,7 @@
 class ButterflySubscribeListChannel(ButterflyListChannel):
 
     def __init__(self, connection, handle):
+        self.__pending_remove = []
         ButterflyListChannel.__init__(self, connection, handle)
         self.GroupFlagsChanged(0, 0) # no contact Management for now
 
@@ -136,6 +137,22 @@
             self.MembersChanged('', added, (), (), (), 0,
                                 telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
 
+    def _release_pendings(self):
+        self.RemoveMembers(self.__pending_remove, None)
+        self.__pending_remove = []
+
+    def RemoveMembers(self, contacts, message):
+        ab = self._conn._pymsn_client.address_book
+        # TODO: use proper pending system
+        for h in contacts:
+            handle = self._conn._handle_manager.\
+                handle_for_handle_id(telepathy.HANDLE_TYPE_CONTACT, h)
+            contact = self._conn._contact_for_handle(handle)
+            ab.delete_contact(contact)
+
+        self.MembersChanged(message, (), contacts, (), (), 0,
+                            telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
+
 class ButterflyPublishListChannel(ButterflyListChannel):
 
     def __init__(self, connection, handle):