changeset 298:e99f578c7179

browser side: sendMessage alert on error
author Goffi <goffi@goffi.org>
date Tue, 17 Dec 2013 01:47:01 +0100
parents 19bcd39c77f6
children e4f586fc6101
files libervia.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libervia.py	Tue Dec 17 01:36:57 2013 +0100
+++ b/libervia.py	Tue Dec 17 01:47:01 2013 +0100
@@ -747,6 +747,11 @@
     def _newAlert(self, message, title, alert_type):
         dialog.InfoDialog(title, message).show()
 
+    def sendError(self, errorData):
+        dialog.InfoDialog("Error while sending message",
+                          "Your message can't be sent", Width="400px").center()
+        print "sendError: %s" % str(errorData)
+
     def send(self, targets, text, extra={}):
         """Send a message to any target type.
         @param targets: list of tuples (type, entities, addr) with:
@@ -772,10 +777,10 @@
                 print "ERROR: Unknown target type"
         if addresses:
             if len(addresses) == 1 and addresses[0][0] == 'to':
-                self.bridge.call('sendMessage', None, addresses[0][1], text, '', type_, extra)
+                self.bridge.call('sendMessage', (None, self.sendError), addresses[0][1], text, '', type_, extra)
             else:
                 extra.update({'address': '\n'.join([('%s:%s' % entry) for entry in addresses])})
-                self.bridge.call('sendMessage', None, self.whoami.domain, text, '', type_, extra)
+                self.bridge.call('sendMessage', (None, self.sendError), self.whoami.domain, text, '', type_, extra)
 
 
 if __name__ == '__main__':