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
This commit is contained in:
Goffi 2012-10-17 00:35:48 +02:00
commit fef2b1a620

View file

@ -100,18 +100,28 @@ class QuickChat():
debug (_("now we print history"))
def onHistory(history):
for line in history:
timestamp, from_jid, to_jid, message = line
timestamp, from_jid, to_jid, message, _type = line
if ((self.type == 'group' and _type != 'groupchat') or
(self.type == 'one2one' and _type == 'groupchat')):
continue
self.printMessage(JID(from_jid), message, profile, timestamp)
def onHistoryError(err):
error (_("Can't get history"))
self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target.short, 20, callback=onHistory, errback=onHistoryError)
if self.target.startswith(const_PRIVATE_PREFIX):
target = unescapePrivate(self.target)
else:
target = self.target.short
self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, target, 20, callback=onHistory, errback=onHistoryError)
def _get_nick(self, jid):
"""Return nick of this jid when possible"""
if jid.startswith(const_PRIVATE_PREFIX):
return unescapePrivate(jid).resource
if self.target.startswith(const_PRIVATE_PREFIX):
unescaped = unescapePrivate(self.target)
if jid.startswith(const_PRIVATE_PREFIX) or unescaped.short == jid.short:
return unescaped.resource
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)
def printMessage(self, from_jid, msg, profile, timestamp):