changeset 2121:df5cb9e7d0b7

quick frontend (contact list): added isSpecial and isRoom to quickly now if an entity is specific
author Goffi <goffi@goffi.org>
date Sun, 15 Jan 2017 16:00:41 +0100
parents 4d9aeae5d9d0
children 3970ebcf8830
files frontends/src/quick_frontend/quick_contact_list.py
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_contact_list.py	Sun Jan 15 16:00:40 2017 +0100
+++ b/frontends/src/quick_frontend/quick_contact_list.py	Sun Jan 15 16:00:41 2017 +0100
@@ -296,6 +296,26 @@
             return self._groups[group]
         return self._groups[group][name]
 
+    def isRoom(self, entity):
+        """Helper method to know if entity is a MUC room
+
+        @param entity(jid.JID): jid of the entity
+            hint: use bare jid here, as room can't be full jid with MUC
+        @return (bool): True if entity is a room
+        """
+        assert entity.resource is None  # FIXME: this may change when MIX will be handled
+        return self.isSpecial(entity, C.CONTACT_SPECIAL_GROUP)
+
+    def isSpecial(self, entity, special_type):
+        """Tell if an entity is of a specialy _type
+
+        @param entity(jid.JID): jid of the special entity
+            if the jid is full, will be added to special extras
+        @param special_type: one of special type (e.g. C.CONTACT_SPECIAL_GROUP)
+        @return (bool): True if entity is from this special type
+        """
+        return self.getCache(entity, C.CONTACT_SPECIAL) == special_type
+
     def setSpecial(self, entity, special_type):
         """Set special flag on an entity