diff 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
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Tue Oct 16 01:22:40 2012 +0200
+++ b/frontends/src/quick_frontend/quick_chat.py	Wed Oct 17 00:35:48 2012 +0200
@@ -100,18 +100,28 @@
         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):