Mercurial > libervia-backend
comparison src/core/xmpp.py @ 726:ade9997fabfa
core: use of Twisted JID instead of string bare jid in roster SatRosterProtocol
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 10 Dec 2013 17:25:31 +0100 |
parents | 0c84fb112d70 |
children | b26dfac8e46c |
comparison
equal
deleted
inserted
replaced
725:7c806491c76a | 726:ade9997fabfa |
---|---|
216 self.removeItem(item.jid) | 216 self.removeItem(item.jid) |
217 return | 217 return |
218 info(_("new contact in roster list: %s"), item.jid.full()) | 218 info(_("new contact in roster list: %s"), item.jid.full()) |
219 #self.host.memory.addContact(item.jid, item_attr, item.groups, self.parent.profile) | 219 #self.host.memory.addContact(item.jid, item_attr, item.groups, self.parent.profile) |
220 | 220 |
221 bare_jid = item.jid.userhost() | 221 bare_jid = item.jid.userhostJID() |
222 self._jids[bare_jid] = item | 222 self._jids[bare_jid] = item |
223 for group in item.groups: | 223 for group in item.groups: |
224 self._groups.setdefault(group, set()).add(bare_jid) | 224 self._groups.setdefault(group, set()).add(bare_jid) |
225 self.host.bridge.newContact(item.jid.full(), self.getAttributes(item), item.groups, self.parent.profile) | 225 self.host.bridge.newContact(item.jid.full(), self.getAttributes(item), item.groups, self.parent.profile) |
226 | 226 |
227 def onRosterRemove(self, entity): | 227 def onRosterRemove(self, entity): |
228 """Called when a roster removal event is received""" | 228 """Called when a roster removal event is received""" |
229 print _("removing %s from roster list") % entity.full() | 229 print _("removing %s from roster list") % entity.full() |
230 bare_jid = entity.userhost() | 230 bare_jid = entity.userhostJID() |
231 | 231 |
232 # we first remove item from local cache (self._groups and self._jids) | 232 # we first remove item from local cache (self._groups and self._jids) |
233 try: | 233 try: |
234 item = self._jids.pop(bare_jid) | 234 item = self._jids.pop(bare_jid) |
235 except KeyError: | 235 except KeyError: |
254 | 254 |
255 def getItem(self, jid): | 255 def getItem(self, jid): |
256 """Return RosterItem for a given jid | 256 """Return RosterItem for a given jid |
257 @param jid: jid of the contact | 257 @param jid: jid of the contact |
258 @return: RosterItem or None if contact is not in cache""" | 258 @return: RosterItem or None if contact is not in cache""" |
259 return self._jids.get(jid.userhost(), None) | 259 return self._jids.get(jid.userhostJID(), None) |
260 | 260 |
261 def getBareJids(self): | 261 def getBareJids(self): |
262 """Return all bare jids (as unicode) of the roster""" | 262 """Return all bare jids (as unicode) of the roster""" |
263 return self._jids.keys() | 263 return self._jids.keys() |
264 | 264 |
265 def isJidInRoster(self, entity_jid): | 265 def isJidInRoster(self, entity_jid): |
266 """Return True if jid is in roster""" | 266 """Return True if jid is in roster""" |
267 return entity_jid.userhost() in self._jids | 267 return entity_jid.userhostJID() in self._jids |
268 | 268 |
269 def getItems(self): | 269 def getItems(self): |
270 """Return all items of the roster""" | 270 """Return all items of the roster""" |
271 return self._jids.values() | 271 return self._jids.values() |
272 | 272 |