comparison libervia.py @ 298:e99f578c7179

browser side: sendMessage alert on error
author Goffi <goffi@goffi.org>
date Tue, 17 Dec 2013 01:47:01 +0100
parents 92d76ab67156
children e4f586fc6101
comparison
equal deleted inserted replaced
297:19bcd39c77f6 298:e99f578c7179
745 dialog.ConfirmDialog(confirm_cb, text=data["message"], title=data["title"]).show() 745 dialog.ConfirmDialog(confirm_cb, text=data["message"], title=data["title"]).show()
746 746
747 def _newAlert(self, message, title, alert_type): 747 def _newAlert(self, message, title, alert_type):
748 dialog.InfoDialog(title, message).show() 748 dialog.InfoDialog(title, message).show()
749 749
750 def sendError(self, errorData):
751 dialog.InfoDialog("Error while sending message",
752 "Your message can't be sent", Width="400px").center()
753 print "sendError: %s" % str(errorData)
754
750 def send(self, targets, text, extra={}): 755 def send(self, targets, text, extra={}):
751 """Send a message to any target type. 756 """Send a message to any target type.
752 @param targets: list of tuples (type, entities, addr) with: 757 @param targets: list of tuples (type, entities, addr) with:
753 - type in ("PUBLIC", "GROUP", "COMMENT", "STATUS" , "groupchat" , "chat") 758 - type in ("PUBLIC", "GROUP", "COMMENT", "STATUS" , "groupchat" , "chat")
754 - entities could be a JID, a list groups, a node hash... depending the target 759 - entities could be a JID, a list groups, a node hash... depending the target
770 addresses.append((addr, entities)) 775 addresses.append((addr, entities))
771 else: 776 else:
772 print "ERROR: Unknown target type" 777 print "ERROR: Unknown target type"
773 if addresses: 778 if addresses:
774 if len(addresses) == 1 and addresses[0][0] == 'to': 779 if len(addresses) == 1 and addresses[0][0] == 'to':
775 self.bridge.call('sendMessage', None, addresses[0][1], text, '', type_, extra) 780 self.bridge.call('sendMessage', (None, self.sendError), addresses[0][1], text, '', type_, extra)
776 else: 781 else:
777 extra.update({'address': '\n'.join([('%s:%s' % entry) for entry in addresses])}) 782 extra.update({'address': '\n'.join([('%s:%s' % entry) for entry in addresses])})
778 self.bridge.call('sendMessage', None, self.whoami.domain, text, '', type_, extra) 783 self.bridge.call('sendMessage', (None, self.sendError), self.whoami.domain, text, '', type_, extra)
779 784
780 785
781 if __name__ == '__main__': 786 if __name__ == '__main__':
782 pyjd.setup("http://localhost:8080/libervia.html") 787 pyjd.setup("http://localhost:8080/libervia.html")
783 app = SatWebFrontend() 788 app = SatWebFrontend()