diff src/browser/libervia_main.py @ 686:90a5a5af2550

browser_side: let the backend check for the validity of MUC JIDs that come from a user input
author souliane <souliane@mailoo.org>
date Fri, 27 Mar 2015 00:15:42 +0100
parents 9877607c719a
children 3845a086f0b3
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Mon Mar 30 10:28:47 2015 +0200
+++ b/src/browser/libervia_main.py	Fri Mar 27 00:15:42 2015 +0100
@@ -1073,6 +1073,26 @@
             log.error(_('unmanaged dialog type: %s'), type_)
         popup.show()
 
+    def showFailure(self, err_data, msg=''):
+        """Show a failure that has been returned by an asynchronous bridge method.
+
+        @param failure (defer.Failure): Failure instance
+        @param msg (unicode): message to display
+        """
+        # FIXME: message is lost by JSON, we hardcode it for now... remove msg argument when possible
+        err_code, err_obj = err_data
+        title = err_obj['message']['faultString'] if isinstance(err_obj['message'], dict) else err_obj['message']
+        self.showDialog(msg, title, 'error')
+
+    def showFailureRoomInvalid(self, err_data):
+        """Show a failure that has been returned when trying to join an invalid room.
+
+        @param failure (defer.Failure): Failure instance
+        """
+        # FIXME: remove asap, see self.showFailure
+        msg = _(u"Invalid room identifier. Please give a room short or full identifier like 'room' or 'room@%s'.") % C.DEFAULT_MUC_SERVICE
+        self.showFailure(err_data, msg)
+
 
 if __name__ == '__main__':
     app = SatWebFrontend()