core: Roster cache refactoring: cache is now managed by client's SatRosterProtocol instance.

This commit is contained in:
Goffi 2012-03-26 00:22:49 +02:00
commit 972b4c2555

View file

@ -491,7 +491,6 @@ class Memory:
info (_("Memory manager init"))
self.initialized = defer.Deferred()
self.host = host
self.contacts={}
self.presenceStatus={}
self.lastResource={} #tmp, will be refactored with bdd integration
self.subscriptions={}
@ -655,51 +654,6 @@ class Memory:
assert(self.server_features.has_key(profile))
return feature in self.server_features[profile]
def addContact(self, contact_jid, attributes, groups, profile_key):
debug("Memory addContact: %s",contact_jid.userhost())
profile = self.getProfileName(profile_key)
if not profile:
error (_('Trying to add a contact to a non-existant profile'))
return
assert(isinstance(attributes,dict))
assert(isinstance(groups,set))
if not self.contacts.has_key(profile):
self.contacts[profile] = {}
self.contacts[profile][contact_jid.userhost()]=[attributes, groups]
def delContact(self, contact_jid, profile_key):
debug("Memory delContact: %s",contact_jid.userhost())
profile = self.getProfileName(profile_key)
if not profile:
error (_('Trying to delete a contact for a non-existant profile'))
return
if self.contacts.has_key(profile) and self.contacts[profile].has_key(contact_jid.userhost()):
del self.contacts[profile][contact_jid.userhost()]
def getContact(self, contact_jid, profile_key):
profile = self.getProfileName(profile_key)
if not profile:
error(_('Asking a contact for a non-existant profile'))
return None
if self.contacts.has_key(profile) and self.contacts[profile].has_key(contact_jid.userhost()):
return self.contacts[profile][contact_jid.userhost()]
def getContacts(self, profile_key):
"""Return list of contacts for given profile
@param profile_key: profile key
@return list of [contact, attr, groups]"""
profile = self.getProfileName(profile_key)
if not profile:
error(_('Asking contacts for a non-existant profile'))
return []
ret=[]
if self.contacts.has_key(profile):
for contact in self.contacts[profile]:
attr, groups = self.contacts[profile][contact]
ret.append([contact, attr, groups ])
return ret
def getLastResource(self, contact, profile_key):
"""Return the last resource used by a contact
@param contact: contact jid (unicode)