Lots more bug fixes
[theonering] / src / channel / contact_list.py
index e2a8493..f82c090 100644 (file)
@@ -4,6 +4,7 @@ import telepathy
 
 import util.go_utils as gobject_utils
 import util.coroutines as coroutines
+import gtk_toolbox
 import handle
 
 
@@ -30,8 +31,13 @@ class AllContactsListChannel(AbstractListChannel):
 
        def __init__(self, connection, h):
                AbstractListChannel.__init__(self, connection, h)
+               self._callback = coroutines.func_sink(
+                       coroutines.expand_positional(
+                               self._on_contacts_refreshed
+                       )
+               )
                self._session.addressbook.updateSignalHandler.register_sink(
-                       self._on_contacts_refreshed
+                       self._callback
                )
                self.GroupFlagsChanged(0, 0)
 
@@ -39,9 +45,16 @@ class AllContactsListChannel(AbstractListChannel):
                contacts = addressbook.get_contacts()
                self._process_refresh(addressbook, contacts, [])
 
-       @coroutines.func_sink
-       @coroutines.expand_positional
+       @gtk_toolbox.log_exception(_moduleLogger)
+       def Close(self):
+               telepathy.server.ChannelTypeContactList.Close(self)
+               self.remove_from_connection()
+               self._session.addressbook.updateSignalHandler.unregister_sink(
+                       self._callback
+               )
+
        @gobject_utils.async
+       @gtk_toolbox.log_exception(_moduleLogger)
        def _on_contacts_refreshed(self, addressbook, added, removed, changed):
                self._process_refresh(addressbook, added, removed)