changeset 533:19fc2ebc02dd

browser_side: management of new "info" newMessage type
author Goffi <goffi@goffi.org>
date Fri, 05 Sep 2014 19:29:35 +0200
parents 1fa173107fde
children d2bf317b2d28
files src/browser/libervia_main.py src/browser/sat_browser/plugin_sec_otr.py
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Fri Sep 05 12:26:33 2014 +0200
+++ b/src/browser/libervia_main.py	Fri Sep 05 19:29:35 2014 +0200
@@ -717,13 +717,12 @@
         self.newMessageCb(from_jid, msg, msg_type, to_jid, extra)
 
     def newMessageCb(self, from_jid, msg, msg_type, to_jid, extra):
-        # FIXME: newMessage should manage system message, so they don't appear as coming from the contact
         other = to_jid if from_jid.bare == self.whoami.bare else from_jid
         lib_wid = self.getLiberviaWidget(panels.ChatPanel, other, ignoreOtherTabs=False)
         self.displayNotification(from_jid, msg)
         if msg_type == 'headline' and from_jid.full() == self._defaultDomain:
             try:
-                assert(extra['subject'])  # subject is defined and not empty
+                assert extra['subject']  # subject is defined and not empty
                 title = extra['subject']
             except (KeyError, AssertionError):
                 title = _('Announcement from %s') % from_jid.full()
@@ -731,8 +730,12 @@
             dialog.InfoDialog(title, msg).show()
             return
         if lib_wid is not None:
-            lib_wid.printMessage(from_jid, msg, extra)
+            if msg_type == C.MESS_TYPE_INFO:
+                lib_wid.printInfo(msg)
+            else:
+                lib_wid.printMessage(from_jid, msg, extra)
         else:
+            # FIXME: "info" message will be lost here
             if not self.contact_panel.isContactInRoster(other.bare):
                 self.contact_panel.updateContact(other.bare, {}, [C.GROUP_NOT_IN_ROSTER])
             # The message has not been shown, we must indicate it
--- a/src/browser/sat_browser/plugin_sec_otr.py	Fri Sep 05 12:26:33 2014 +0200
+++ b/src/browser/sat_browser/plugin_sec_otr.py	Fri Sep 05 19:29:35 2014 +0200
@@ -332,6 +332,8 @@
             self.host.bridge.call('getLastResource', gotResource, jid.full())
 
     def messageReceivedTrigger(self, from_jid, msg, msg_type, to_jid, extra):
+        if msg_type == C.MESS_TYPE_INFO:
+            return True
         other_jid = to_jid if from_jid.bare == self.host.whoami.bare else from_jid
 
         def cb(jid):