comparison frontends/src/quick_frontend/quick_chat.py @ 512:862c0d6ab974

core, bridge, quick_frontend: MUC private messages history management: - history now store message type - sqlite3 storage: fixed resource management in getHistory - bridge: added message type in getHistory return value - quick_chats: (ugly) hacks to manage private history filtering/nickname printing
author Goffi <goffi@goffi.org>
date Wed, 17 Oct 2012 00:35:48 +0200
parents 886754295efe
children 8ee9113d307b
comparison
equal deleted inserted replaced
511:62f7f2403093 512:862c0d6ab974
98 def historyPrint(self, size=20, profile='@NONE@'): 98 def historyPrint(self, size=20, profile='@NONE@'):
99 """Print the initial history""" 99 """Print the initial history"""
100 debug (_("now we print history")) 100 debug (_("now we print history"))
101 def onHistory(history): 101 def onHistory(history):
102 for line in history: 102 for line in history:
103 timestamp, from_jid, to_jid, message = line 103 timestamp, from_jid, to_jid, message, _type = line
104 if ((self.type == 'group' and _type != 'groupchat') or
105 (self.type == 'one2one' and _type == 'groupchat')):
106 continue
104 self.printMessage(JID(from_jid), message, profile, timestamp) 107 self.printMessage(JID(from_jid), message, profile, timestamp)
105 108
106 def onHistoryError(err): 109 def onHistoryError(err):
107 error (_("Can't get history")) 110 error (_("Can't get history"))
108 111
109 self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError) 112 if self.target.startswith(const_PRIVATE_PREFIX):
113 target = unescapePrivate(self.target)
114 else:
115 target = self.target.short
116
117 self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, target, 20, callback=onHistory, errback=onHistoryError)
110 118
111 def _get_nick(self, jid): 119 def _get_nick(self, jid):
112 """Return nick of this jid when possible""" 120 """Return nick of this jid when possible"""
113 if jid.startswith(const_PRIVATE_PREFIX): 121 if self.target.startswith(const_PRIVATE_PREFIX):
114 return unescapePrivate(jid).resource 122 unescaped = unescapePrivate(self.target)
123 if jid.startswith(const_PRIVATE_PREFIX) or unescaped.short == jid.short:
124 return unescaped.resource
115 return jid.resource if self.type == "group" else (self.host.contact_list.getCache(jid,'nick') or self.host.contact_list.getCache(jid,'name') or jid.node) 125 return jid.resource if self.type == "group" else (self.host.contact_list.getCache(jid,'nick') or self.host.contact_list.getCache(jid,'name') or jid.node)
116 126
117 def printMessage(self, from_jid, msg, profile, timestamp): 127 def printMessage(self, from_jid, msg, profile, timestamp):
118 """Print message in chat window. Must be implemented by child class""" 128 """Print message in chat window. Must be implemented by child class"""
119 jid=JID(from_jid) 129 jid=JID(from_jid)