diff src/core/sat_main.py @ 466:448ce3c9e2ac

core: Roster cache refactoring: cache is now managed by client's SatRosterProtocol instance.
author Goffi <goffi@goffi.org>
date Mon, 26 Mar 2012 00:22:49 +0200
parents fb1abc0f8c6a
children 6cd04adddaea
line wrap: on
line diff
--- a/src/core/sat_main.py	Sat Mar 24 17:48:12 2012 +0100
+++ b/src/core/sat_main.py	Mon Mar 26 00:22:49 2012 +0200
@@ -123,7 +123,7 @@
         self.bridge.register("connect", self.connect)
         self.bridge.register("asyncConnect", self.asyncConnect)
         self.bridge.register("disconnect", self.disconnect)
-        self.bridge.register("getContacts", self.memory.getContacts)
+        self.bridge.register("getContacts", self.getContacts)
         self.bridge.register("getLastResource", self.memory.getLastResource)
         self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus)
         self.bridge.register("getWaitingSub", self.memory.getWaitingSub)
@@ -270,6 +270,18 @@
             if disconnected_cb:
                 disconnected_cb(profile)
 
+    def getContacts(self, profile_key):
+        client = self.getClient(profile_key)
+        if not client:
+            error(_('Asking contacts for a non-existant profile'))
+            return []
+        ret = []
+        for item in client.roster.getItems(): #we get all item for client's roster
+            #and convert them to expected format
+            attr = client.roster.getAttributes(item)
+            ret.append([item.jid.userhost(), attr, item.groups])
+        return ret
+
     def purgeClient(self, profile):
         """Remove reference to a profile client and purge cache
         the garbage collector can then free the memory"""