diff libervia.py @ 299:e4f586fc6101

server and browser side: updated callback system to follow core changes
author Goffi <goffi@goffi.org>
date Tue, 24 Dec 2013 02:00:30 +0100
parents e99f578c7179
children 2ab513a47e3b
line wrap: on
line diff
--- a/libervia.py	Tue Dec 17 01:47:01 2013 +0100
+++ b/libervia.py	Tue Dec 24 02:00:30 2013 +0100
@@ -173,7 +173,6 @@
         self.room_list = []  # list of rooms
         self.mblog_cache = []  # used to keep our own blog entries in memory, to show them in new mblog panel
         self.avatars_cache = {}  # keep track of jid's avatar hash (key=jid, value=file)
-        self.current_action_ids = set()
         #self.discuss_panel.addWidget(panels.EmptyPanel(self))
         self.discuss_panel.addWidget(panels.MicroblogPanel(self, []))
         #self.discuss_panel.addWidget(panels.EmptyPanel(self))
@@ -342,6 +341,36 @@
                 # this would eventually set the browser saved password
                 Timer(5, lambda: self._register_box._form.login_pass_box.setFocus(True))
 
+
+    def _actionCb(data):
+        if not data:
+            # action was a one shot, nothing to do
+            pass
+        elif "xmlui" in data:
+            ui = XMLUI(self, xml_data = data['xmlui'])
+            _dialog = dialog.GenericDialog(ui.title, ui)
+            ui.setCloseCb(_dialog.close)
+            _dialog.setSize('80%', '80%')
+            _dialog.show()
+        else:
+            dialog.InfoDialog("Error",
+                              "Unmanaged action result", Width="400px").center()
+
+    def _actionEb(err_data):
+        err_code, err_obj = err_data
+        dialog.InfoDialog("Error",
+                          str(err_obj), Width="400px").center()
+
+    def launchAction(self, callback_id, data):
+        """ Launch a dynamic action
+        @param callback_id: id of the action to launch
+        @param data: data needed only for certain actions
+
+        """
+        if data is None:
+            data = {}
+        self.bridge.call('launchAction', (self._actionCb, self._actionEb), callback_id, data)
+
     def _getContactsCB(self, contacts_data):
         for contact in contacts_data:
             jid, attributes, groups = contact