diff frontends/src/quick_frontend/quick_app.py @ 2009:90134b2e3dc4

primitivus, quick_frontends: show global notifications counter in contact_list + method to get these notifications in QuickApp
author Goffi <goffi@goffi.org>
date Sun, 17 Jul 2016 17:32:46 +0200
parents 19b9d3f8a6c7
children f09562b0704d
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py	Sun Jul 17 17:12:42 2016 +0200
+++ b/frontends/src/quick_frontend/quick_app.py	Sun Jul 17 17:32:46 2016 +0200
@@ -607,18 +607,24 @@
     def getNotifs(self, entity, type_=None, profile=C.PROF_KEY_NONE):
         """return notifications for given entity
 
-        @param entity(jid.JID, None): bare jid of the entity to check
+        @param entity(jid.JID, None, C.ENTITY_ALL): bare jid of the entity to check
             None to get general notifications
+            C.ENTITY_ALL to get all notifications
         @param type_(unicode, None): notification type to filter
             None to get all notifications
         @return (list[dict]): list of notifications
         """
         notif_dict = self.profiles[profile].notifications
+        ret = []
+        if entity == C.ENTITY_ALL:
+            for type_notifs in notif_dict.itervalues():
+                for notifs_list in type_notifs.itervalues():
+                    ret.extend(notifs_list)
+            return ret
         key = '' if entity is None else entity.bare
         key_notifs = notif_dict.setdefault(key, {})
         if type_ is not None:
-            return key_notifs.get(type_, [])
-        ret = []
+            return key_notifs.get(type_, ret)
         for notifs_list in key_notifs.itervalues():
             ret.extend(notifs_list)
         return ret