diff frontends/src/quick_frontend/quick_chat.py @ 1125:d6c3fea5ecfe

quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
author souliane <souliane@mailoo.org>
date Sat, 23 Aug 2014 20:26:04 +0200
parents d1084f7e56a5
children 75025461141f
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Sun Aug 24 18:23:55 2014 +0200
+++ b/frontends/src/quick_frontend/quick_chat.py	Sat Aug 23 20:26:04 2014 +0200
@@ -96,9 +96,17 @@
             log.error (_("[INTERNAL] trying to set subject for a non group chat window"))
             raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
 
+    def afterHistoryPrint(self):
+        """Refresh or scroll down the focus after the history is printed"""
+        pass
+
     def historyPrint(self, size=20, profile='@NONE@'):
-        """Print the initial history"""
-        log.debug (_("now we print history"))
+        """Print the current history
+        @param size (int): number of messages
+        @param profile (str): %(doc_profile)s
+        """
+        log.debug(_("now we print the history (%d messages)") % size)
+
         def onHistory(history):
             for line in history:
                 timestamp, from_jid, to_jid, message, _type, extra = line
@@ -106,16 +114,17 @@
                    (self.type == 'one2one' and _type == 'groupchat')):
                     continue
                 self.printMessage(JID(from_jid), message, profile, timestamp)
+            self.afterHistoryPrint()
 
         def onHistoryError(err):
-            log.error (_("Can't get history"))
+            log.error(_("Can't get history"))
 
         if self.target.startswith(Const.PRIVATE_PREFIX):
             target = unescapePrivate(self.target)
         else:
             target = self.target.bare
 
-        self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].bare, target, 20, profile=profile, callback=onHistory, errback=onHistoryError)
+        return self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].bare, target, size, profile=profile, callback=onHistory, errback=onHistoryError)
 
     def _get_nick(self, jid):
         """Return nick of this jid when possible"""