diff frontends/src/primitivus/primitivus @ 1385:0dca4f9b264d

primitivus: prefill "Join MUC" dialog with only the JID's node part when in debug version + display error directly from the DBus object
author souliane <souliane@mailoo.org>
date Tue, 24 Mar 2015 07:38:40 +0100
parents ba87b940f07a
children 069ad98b360d
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Tue Mar 24 07:34:32 2015 +0100
+++ b/frontends/src/primitivus/primitivus	Tue Mar 24 07:38:40 2015 +0100
@@ -622,13 +622,17 @@
             if callback and 'validated' in data:
                 callback(callback_id, data, profile)
 
-        def action_eb(failure):
-            self.showPopUp(sat_widgets.Alert(failure.fullname, failure.message, ok_cb=self.removePopUp))
+        self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=self.showFailure)
 
-        self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=action_eb)
+    def showFailure(self, failure):
+        """Show a failure that has been returned by an asynchronous bridge method.
+
+        @param failure (defer.Failure): Failure instance
+        """
+        self.showPopUp(sat_widgets.Alert(failure.classname, failure.message, ok_cb=self.removePopUp))
 
     def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile):
-        answer_data={}
+        answer_data = {}
 
         def dir_selected_cb(path):
             dest_path = join(path, data['filename'])
@@ -710,12 +714,7 @@
     def onJoinRoom(self, button, edit):
         self.removePopUp()
         room_jid = jid.JID(edit.get_edit_text())
-        if room_jid.is_valid():
-            self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile)
-        else:
-            message = _("'%s' is an invalid jid.JID !") % room_jid
-            log.error (message)
-            self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp))
+        self.bridge.joinMUC(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self.showFailure)
 
     #MENU EVENTS#
     def onConnectRequest(self, menu):
@@ -739,7 +738,7 @@
 
     def onJoinRoomRequest(self, menu):
         """User wants to join a MUC room"""
-        pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
+        pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt=C.DEFAULT_MUC, cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
         self.showPopUp(pop_up_widget)
 
     def onAboutRequest(self, menu):