Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
424:72c13313b6d6 | 425:e4e9187e3b5b |
---|---|
85 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here | 85 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here |
86 | 86 |
87 def historyPrint(self, size=20, keep_last=False, profile='@NONE@'): | 87 def historyPrint(self, size=20, keep_last=False, profile='@NONE@'): |
88 """Print the initial history""" | 88 """Print the initial history""" |
89 debug (_("now we print history")) | 89 debug (_("now we print history")) |
90 history=self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target, 20) | 90 def onHistory(history): |
91 stamps=history.keys() | 91 stamps=history.keys() |
92 stamps.sort() | 92 stamps.sort() |
93 for stamp in stamps: | 93 for stamp in stamps: |
94 self.printMessage(JID(history[stamp][0]), history[stamp][1], profile, stamp) | 94 from_jid, to_jid, message = history[stamp] |
95 if keep_last: ##FIXME hack for sortilege | 95 self.printMessage(JID(from_jid), message, profile, stamp) |
96 self.last_history = stamps[-1] if stamps else None | 96 if keep_last: ##FIXME hack for sortilege |
97 self.last_history = stamps[-1] if stamps else None | |
98 def onHistoryError(err): | |
99 error (_("Can't get history")) | |
100 | |
101 history=self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError) | |
97 | 102 |
98 def _get_nick(self, jid): | 103 def _get_nick(self, jid): |
99 """Return nick of this jid when possible""" | 104 """Return nick of this jid when possible""" |
100 return jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid.node) | 105 return jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid.node) |
101 | 106 |