core: Roster cache refactoring: cache is now managed by client's SatRosterProtocol instance.
This commit is contained in:
parent
26f59a523e
commit
972b4c2555
1 changed files with 73 additions and 66 deletions
|
|
@ -123,7 +123,7 @@ class SAT(service.Service):
|
|||
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 @@ class SAT(service.Service):
|
|||
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"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue