diff frontends/src/quick_frontend/quick_contact_list.py @ 2122:3970ebcf8830

quick frontend (contact list): bare_default in getCache now default to True, plus added None: if None is used, bare_default will be used only if the entity is not in a room
author Goffi <goffi@goffi.org>
date Sun, 15 Jan 2017 16:00:41 +0100
parents df5cb9e7d0b7
children c42aab22c2c0
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_contact_list.py	Sun Jan 15 16:00:41 2017 +0100
+++ b/frontends/src/quick_frontend/quick_contact_list.py	Sun Jan 15 16:00:41 2017 +0100
@@ -204,7 +204,7 @@
     def fill(self):
         handler.fill(self.profile)
 
-    def getCache(self, entity, name=None, bare_default=False):
+    def getCache(self, entity, name=None, bare_default=True):
         """Return a cache value for a contact
 
         @param entity(jid.JID): entity of the contact from who we want data (resource is used if given)
@@ -212,9 +212,10 @@
                 - if no resource is given (bare jid), the main resource is used, according to priority
                 - if resource is given, it is used
         @param name(unicode): name the data to get, or None to get everything
-        @param bare_default(bool): if True and entity is a full jid, the value of bare jid
+        @param bare_default(bool, None): if True and entity is a full jid, the value of bare jid
             will be returned if not value is found for the requested resource.
             If False, None is returned if no value is found for the requested resource.
+            If None, bare_default will be set to False if entity is in a room, True else
         @return: full cache if no name is given, or value of "name", or None
         """
         # FIXME: resource handling need to be reworked
@@ -247,6 +248,8 @@
             try:
                 return cache[C.CONTACT_RESOURCES][entity.resource][name]
             except KeyError:
+                if bare_default is None:
+                    bare_default = not self.isRoom(entity.bare)
                 if not bare_default:
                     return None