# HG changeset patch # User souliane # Date 1424518744 -3600 # Node ID 7a3a232d4938ce6e8a94bf16302686b8c58215fe # Parent 89dc29afe01cfe1ac687bc9a0291c07aef1e4769 quick_frontend (quick_contact_list): add property roster_entities_connected and method getSpecials diff -r 89dc29afe01c -r 7a3a232d4938 frontends/src/quick_frontend/quick_contact_list.py --- a/frontends/src/quick_frontend/quick_contact_list.py Sun Feb 22 14:13:42 2015 +0100 +++ b/frontends/src/quick_frontend/quick_contact_list.py Sat Feb 21 12:39:04 2015 +0100 @@ -92,16 +92,26 @@ return self._roster @property + def roster_entities_connected(self): + """Return all the bare JIDs of the roster entities that are connected. + + @return: set(jid.JID) + """ + return set([entity for entity in self._roster if self.getCache(entity, C.PRESENCE_SHOW) is not None]) + + @property def roster_entities_by_group(self): - """Return a dictionary binding the roster groups to their entities bare JIDs. + """Return a dictionary binding the roster groups to their entities bare + JIDs. This also includes the empty group (None key). @return: dict{unicode: set(jid.JID)} """ return {group: self._groups[group]['jids'] for group in self._groups} @property - def roster_groups_by_entity(self, contact_jid_s): - """Return a dictionary binding the entities bare JIDs to their roster groups. + def roster_groups_by_entity(self): + """Return a dictionary binding the entities bare JIDs to their roster + groups. The empty group is filtered out. @return: dict{jid.JID: set(unicode)} """ @@ -197,6 +207,17 @@ assert special_type in C.CONTACT_SPECIAL_ALLOWED + (None,) self.setCache(entity, C.CONTACT_SPECIAL, special_type) + def getSpecials(self, special_type=None): + """Return all the bare JIDs of the special roster entities of the type + specified by special_type. If special_type is None, return all specials. + + @param special_type: one of special type (e.g. C.CONTACT_SPECIAL_GROUP) or None to return all specials. + @return: set(jid.JID) + """ + if special_type is None: + return self._specials + return set([entity for entity in self._specials if self.getCache(entity, C.CONTACT_SPECIAL) == special_type]) + def clearContacts(self): """Clear all the contact list""" self.unselectAll()