core: fixed items registration in roster management

This commit is contained in:
Goffi 2015-02-06 18:54:44 +01:00
commit b4937bef76

View file

@ -180,6 +180,8 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
def rosterCb(self, roster):
assert roster is not None # FIXME: must be managed with roster versioning
self._jids = roster
for roster_item in roster.itervalues():
self._registerItem(roster_item)
def _registerItem(self, item):
"""Register item in local cache
@ -265,13 +267,13 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
"""Return a list of groups"""
return self._groups.keys()
def getItem(self, jid):
def getItem(self, entity_jid):
"""Return RosterItem for a given jid
@param jid: jid of the contact
@param entity_jid: jid of the contact
@return: RosterItem or None if contact is not in cache
"""
return self._jids.get(jid, None)
return self._jids.get(entity_jid, None)
def getJids(self):
"""Return all jids of the roster"""
@ -289,7 +291,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
try:
return self._groups[group]
except KeyError:
raise exceptions.UnknownGroupError
raise exceptions.UnknownGroupError(group)
class SatPresenceProtocol(xmppim.PresenceClientProtocol):