comparison frontends/src/quick_frontend/quick_chat.py @ 448:17c7e48bf68f

core: - history management improved - better timestamp precision for history bridge + core: history signature change (now return a list instead of a dict, and timestamp is now float) quick_frontend: - use of new history API - removed deprecated keep_last argument in getHistory (was only used by Sortilège)
author Goffi <goffi@goffi.org>
date Sun, 04 Dec 2011 16:18:56 +0100
parents e4e9187e3b5b
children cf005701624b
comparison
equal deleted inserted replaced
447:485a6d125498 448:17c7e48bf68f
82 debug(_("Setting subject to %s") % subject) 82 debug(_("Setting subject to %s") % subject)
83 if self.type != "group": 83 if self.type != "group":
84 error (_("[INTERNAL] trying to set subject for a non group chat window")) 84 error (_("[INTERNAL] trying to set subject for a non group chat window"))
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, 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 def onHistory(history): 90 def onHistory(history):
91 stamps=history.keys() 91 for line in history:
92 stamps.sort() 92 timestamp, from_jid, to_jid, message = line
93 for stamp in stamps: 93 self.printMessage(JID(from_jid), message, profile, timestamp)
94 from_jid, to_jid, message = history[stamp] 94
95 self.printMessage(JID(from_jid), message, profile, stamp)
96 if keep_last: ##FIXME hack for sortilege
97 self.last_history = stamps[-1] if stamps else None
98 def onHistoryError(err): 95 def onHistoryError(err):
99 error (_("Can't get history")) 96 error (_("Can't get history"))
100 97
101 history=self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError) 98 self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError)
102 99
103 def _get_nick(self, jid): 100 def _get_nick(self, jid):
104 """Return nick of this jid when possible""" 101 """Return nick of this jid when possible"""
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) 102 return jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid.node)
106 103