diff frontends/src/quick_frontend/quick_chat.py @ 425:e4e9187e3b5b

backend, bridge: asynchronous history quick_frontend: use of asynchronous history
author Goffi <goffi@goffi.org>
date Tue, 08 Nov 2011 01:08:11 +0100
parents ede26abf6ca1
children 17c7e48bf68f
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Mon Nov 07 22:27:07 2011 +0100
+++ b/frontends/src/quick_frontend/quick_chat.py	Tue Nov 08 01:08:11 2011 +0100
@@ -87,13 +87,18 @@
     def historyPrint(self, size=20, keep_last=False, profile='@NONE@'):
         """Print the initial history"""
         debug (_("now we print history"))
-        history=self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target, 20)
-        stamps=history.keys()
-        stamps.sort()
-        for stamp in stamps: 
-            self.printMessage(JID(history[stamp][0]), history[stamp][1], profile, stamp)
-        if keep_last:  ##FIXME hack for sortilege
-            self.last_history = stamps[-1] if stamps else None
+        def onHistory(history):
+            stamps=history.keys()
+            stamps.sort()
+            for stamp in stamps: 
+                from_jid, to_jid, message = history[stamp]
+                self.printMessage(JID(from_jid), message, profile, stamp)
+            if keep_last:  ##FIXME hack for sortilege
+                self.last_history = stamps[-1] if stamps else None
+        def onHistoryError(err):
+            error (_("Can't get history"))
+
+        history=self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError)
 
     def _get_nick(self, jid):
         """Return nick of this jid when possible"""