diff frontends/src/quick_frontend/quick_chat.py @ 2013:b536dd121da1

backend (memory), frontends: improved history filtering: a "filters" dictionnary is now use to filter, it can have, for now, filtering on: - "body": filter only on the body (equivalent to former "search" parameter, but not case sensitive) - "search": fitler on body + source resource - "types": allowed types - "not_types": forbidden types primitivus now do searching using "search", i.e. source resource is now taken into account (and search is now case insensitive)
author Goffi <goffi@goffi.org>
date Mon, 18 Jul 2016 00:52:02 +0200
parents 19b9d3f8a6c7
children 20fb71b656e3
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Sun Jul 17 19:44:15 2016 +0200
+++ b/frontends/src/quick_frontend/quick_chat.py	Mon Jul 18 00:52:02 2016 +0200
@@ -278,18 +278,18 @@
                 return True
         return False
 
-    def updateHistory(self, size=C.HISTORY_LIMIT_DEFAULT, search='', profile='@NONE@'):
+    def updateHistory(self, size=C.HISTORY_LIMIT_DEFAULT, filters=None, profile='@NONE@'):
         """Called when history need to be recreated
 
         Remove all message from history then call historyPrint
         Must probably be overriden by frontend to clear widget
         @param size (int): number of messages
-        @param search (str): pattern to filter the history results
+        @param filters (str): patterns to filter the history results
         @param profile (str): %(doc_profile)s
         """
         self._locked = True
         self.messages.clear()
-        self.historyPrint(size, search, profile)
+        self.historyPrint(size, filters, profile)
 
     def _onHistoryPrinted(self):
         """Method called when history is printed (or failed)
@@ -301,13 +301,15 @@
         for data in self._cache:
             self.messageNew(*data)
 
-    def historyPrint(self, size=C.HISTORY_LIMIT_DEFAULT, search='', profile='@NONE@'):
+    def historyPrint(self, size=C.HISTORY_LIMIT_DEFAULT, filters=None, profile='@NONE@'):
         """Print the current history
 
         @param size (int): number of messages
         @param search (str): pattern to filter the history results
         @param profile (str): %(doc_profile)s
         """
+        if filters is None:
+            filters = {}
         if size == 0:
             log.debug(u"Empty history requested, skipping")
             self._onHistoryPrinted()
@@ -340,7 +342,7 @@
             log.error(_(u"Can't get history"))
             self._onHistoryPrinted()
 
-        self.host.bridge.historyGet(unicode(self.host.profiles[profile].whoami.bare), unicode(target), size, True, search, profile, callback=_historyGetCb, errback=_historyGetEb)
+        self.host.bridge.historyGet(unicode(self.host.profiles[profile].whoami.bare), unicode(target), size, True, filters, profile, callback=_historyGetCb, errback=_historyGetEb)
 
     def messageNew(self, uid, timestamp, from_jid, to_jid, msg, subject, type_, extra, profile):
         log.debug(u"messageNew ==> {}".format((uid, timestamp, from_jid, to_jid, msg, subject, type_, extra, profile)))