diff frontends/src/quick_frontend/quick_app.py @ 1172:e15d8a01cf6a

frontends: use of new "info" type in newMessage
author Goffi <goffi@goffi.org>
date Fri, 05 Sep 2014 19:29:30 +0200
parents 75025461141f
children 802b7e6bf098
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py	Fri Sep 05 19:29:30 2014 +0200
+++ b/frontends/src/quick_frontend/quick_app.py	Fri Sep 05 19:29:30 2014 +0200
@@ -271,16 +271,20 @@
         _groups = list(groups)
         self.contact_list.replace(entity, _groups, attributes)
 
-    def _newMessage(self, from_jid_s, msg, _type, to_jid_s, extra, profile):
+    def _newMessage(self, from_jid_s, msg, type_, to_jid_s, extra, profile):
         """newMessage premanagement: a dirty hack to manage private messages
-        if a private MUC message is detected, from_jid or to_jid is prefixed and resource is escaped"""
+
+        if a private MUC message is detected, from_jid or to_jid is prefixed and resource is escaped
+        """
+        # FIXME: must be refactored for 0.6
         from_jid = JID(from_jid_s)
         to_jid = JID(to_jid_s)
 
         from_me = from_jid.bare == self.profiles[profile]['whoami'].bare
         win = to_jid if from_me else from_jid
 
-        if _type != "groupchat" and self.contact_list.getSpecial(win) == "MUC":
+        if ((type_ != "groupchat" and self.contact_list.getSpecial(win) == "MUC") and
+            (type_ != C.MESS_TYPE_INFO or (type_ == C.MESS_TYPE_INFO and win.resource))):
             #we have a private message in a MUC room
             #XXX: normaly we use bare jid as key, here we need the full jid
             #     so we cheat by replacing the "/" before the resource by
@@ -293,9 +297,9 @@
             if new_jid not in self.contact_list:
                 self.contact_list.add(new_jid, [C.GROUP_NOT_IN_ROSTER])
 
-        self.newMessageHandler(from_jid, to_jid, msg, _type, extra, profile)
+        self.newMessageHandler(from_jid, to_jid, msg, type_, extra, profile)
 
-    def newMessageHandler(self, from_jid, to_jid, msg, _type, extra, profile):
+    def newMessageHandler(self, from_jid, to_jid, msg, type_, extra, profile):
         from_me = from_jid.bare == self.profiles[profile]['whoami'].bare
         win = to_jid if from_me else from_jid
 
@@ -303,7 +307,10 @@
         self.current_action_ids_cb = {}
 
         timestamp = extra.get('archive')
-        self.chat_wins[win.bare].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '')
+        if type_ == C.MESS_TYPE_INFO:
+            self.chat_wins[win.bare].printInfo( msg, timestamp = float(timestamp) if timestamp else '')
+        else:
+            self.chat_wins[win.bare].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '')
 
     def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key="@NONE@"):
         if to_jid.startswith(C.PRIVATE_PREFIX):