comparison frontends/src/quick_frontend/quick_contact_list.py @ 1397:96dd0ae1a850

quick_frontend (contact_list): rename QuickContactList.remove to QuickContactList.removeContact + remove the contact from _roster attribute (and not only from _cache)
author souliane <souliane@mailoo.org>
date Wed, 01 Apr 2015 22:07:28 +0200
parents 069ad98b360d
children 5c3d1d970b94
comparison
equal deleted inserted replaced
1396:069ad98b360d 1397:96dd0ae1a850
350 @param group(unicode): group to check 350 @param group(unicode): group to check
351 @return (bool): True if the entity is in the group 351 @return (bool): True if the entity is in the group
352 """ 352 """
353 return entity in self.getGroupData(group, "jids") 353 return entity in self.getGroupData(group, "jids")
354 354
355 def remove(self, entity): 355 def removeContact(self, entity, in_roster=False):
356 """remove a contact from the list 356 """remove a contact from the list
357 357
358 @param entity(jid.JID): jid of the entity to remove (bare jid is used) 358 @param entity(jid.JID): jid of the entity to remove (bare jid is used)
359 @param in_roster (bool): True if contact is from roster
359 """ 360 """
360 entity_bare = entity.bare 361 entity_bare = entity.bare
361 try: 362 try:
362 groups = self._cache[entity_bare].get(C.CONTACT_GROUPS, set()) 363 groups = self._cache[entity_bare].get(C.CONTACT_GROUPS, set())
363 except KeyError: 364 except KeyError:
364 log.warning(_("Trying to delete an unknow entity [{}]").format(entity)) 365 log.warning(_("Trying to delete an unknow entity [{}]").format(entity))
366 if in_roster:
367 self._roster.remove(entity_bare)
365 del self._cache[entity_bare] 368 del self._cache[entity_bare]
366 for group in groups: 369 for group in groups:
367 self._groups[group]['jids'].remove(entity_bare) 370 self._groups[group]['jids'].remove(entity_bare)
368 for set_ in (self._selected, self._alerts, self._specials, self._special_extras): 371 for set_ in (self._selected, self._alerts, self._specials, self._special_extras):
369 to_remove = set() 372 to_remove = set()