comparison src/browser/libervia_main.py @ 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 1735aaeac652
children 048ae7314156
comparison
equal deleted inserted replaced
532:1fa173107fde 533:19fc2ebc02dd
715 if not plugin.messageReceivedTrigger(from_jid, msg, msg_type, to_jid, extra): 715 if not plugin.messageReceivedTrigger(from_jid, msg, msg_type, to_jid, extra):
716 return # plugin returned False to interrupt the process 716 return # plugin returned False to interrupt the process
717 self.newMessageCb(from_jid, msg, msg_type, to_jid, extra) 717 self.newMessageCb(from_jid, msg, msg_type, to_jid, extra)
718 718
719 def newMessageCb(self, from_jid, msg, msg_type, to_jid, extra): 719 def newMessageCb(self, from_jid, msg, msg_type, to_jid, extra):
720 # FIXME: newMessage should manage system message, so they don't appear as coming from the contact
721 other = to_jid if from_jid.bare == self.whoami.bare else from_jid 720 other = to_jid if from_jid.bare == self.whoami.bare else from_jid
722 lib_wid = self.getLiberviaWidget(panels.ChatPanel, other, ignoreOtherTabs=False) 721 lib_wid = self.getLiberviaWidget(panels.ChatPanel, other, ignoreOtherTabs=False)
723 self.displayNotification(from_jid, msg) 722 self.displayNotification(from_jid, msg)
724 if msg_type == 'headline' and from_jid.full() == self._defaultDomain: 723 if msg_type == 'headline' and from_jid.full() == self._defaultDomain:
725 try: 724 try:
726 assert(extra['subject']) # subject is defined and not empty 725 assert extra['subject'] # subject is defined and not empty
727 title = extra['subject'] 726 title = extra['subject']
728 except (KeyError, AssertionError): 727 except (KeyError, AssertionError):
729 title = _('Announcement from %s') % from_jid.full() 728 title = _('Announcement from %s') % from_jid.full()
730 msg = strings.addURLToText(html_tools.XHTML2Text(msg)) 729 msg = strings.addURLToText(html_tools.XHTML2Text(msg))
731 dialog.InfoDialog(title, msg).show() 730 dialog.InfoDialog(title, msg).show()
732 return 731 return
733 if lib_wid is not None: 732 if lib_wid is not None:
734 lib_wid.printMessage(from_jid, msg, extra) 733 if msg_type == C.MESS_TYPE_INFO:
735 else: 734 lib_wid.printInfo(msg)
735 else:
736 lib_wid.printMessage(from_jid, msg, extra)
737 else:
738 # FIXME: "info" message will be lost here
736 if not self.contact_panel.isContactInRoster(other.bare): 739 if not self.contact_panel.isContactInRoster(other.bare):
737 self.contact_panel.updateContact(other.bare, {}, [C.GROUP_NOT_IN_ROSTER]) 740 self.contact_panel.updateContact(other.bare, {}, [C.GROUP_NOT_IN_ROSTER])
738 # The message has not been shown, we must indicate it 741 # The message has not been shown, we must indicate it
739 self.contact_panel.setContactMessageWaiting(other.bare, True) 742 self.contact_panel.setContactMessageWaiting(other.bare, True)
740 743