changeset 1328:7a3a232d4938 frontends_multi_profiles

quick_frontend (quick_contact_list): add property roster_entities_connected and method getSpecials
author souliane <souliane@mailoo.org>
date Sat, 21 Feb 2015 12:39:04 +0100
parents 89dc29afe01c
children f8bd40509a2d
files frontends/src/quick_frontend/quick_contact_list.py
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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()