diff src/plugins/plugin_xep_0050.py @ 773:eac23b1aad90

core: dynamics menus refactoring: - menu now use generic callback system, with extra data - asyncMenuCall is removed in favor of launchAction - menu_id (== callback_id) is used to identify menu instead of category/name/type tuple - i18n is managed throught deferred translation, and returned with _i18n suffix e.g.: menu (D_('File'), D_('Open')): (u'File', u'Open') is menu_path, (u'Fichier', u'Ouvrir') is french menu_path_i18n. - type actually can have the following values: - NORMAL: classical menu - JID_CONTEXT: contextual menu, used with any jid - ROSTER_JID_CONTEXT: like JID_CONTEXT, but restricted to jids in roster. - ROSTER_GROUP_CONTEXT: contextual menu, use with groups - security_limit is used, in the same way as for parameters - when using importMenu, callback can be an actual callback, or one already registered with registerCallback
author Goffi <goffi@goffi.org>
date Sun, 29 Dec 2013 17:10:14 +0100
parents bfabeedbf32e
children 8f5479f8709a
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0050.py	Sun Dec 29 17:10:10 2013 +0100
+++ b/src/plugins/plugin_xep_0050.py	Sun Dec 29 17:10:14 2013 +0100
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from sat.core.i18n import _
+from sat.core.i18n import _, D_
 from logging import debug, info, warning, error
 from twisted.words.protocols.jabber import jid
 from twisted.words.protocols.jabber import error as xmpp_error
@@ -212,7 +212,7 @@
                               method=self._requestCommandsList,
                               async=True)
         self.__requesting_id = host.registerCallback(self._requestingEntity, with_data=True)
-        host.importMenu("Service", "commands", self._commandsMenu, help_string=_("Execute ad-hoc commands"))
+        host.importMenu((D_("Service"), D_("commands")), self._commandsMenu, help_string=D_("Execute ad-hoc commands"))
 
     def getHandler(self, profile):
         return XEP_0050_handler(self)
@@ -322,7 +322,7 @@
 
         return d
 
-    def _commandsMenu(self, profile):
+    def _commandsMenu(self, menu_data, profile):
         """ First XMLUI activated by menu: ask for target jid
         @param profile: %(doc_profile)s
 
@@ -332,7 +332,7 @@
         form_ui.changeLayout("pairs")
         form_ui.addLabel("jid")
         form_ui.addString("jid")
-        return form_ui.toXml()
+        return {'xmlui': form_ui.toXml()}
 
     def _statusCallback(self, command_elt, session_data, action, node, profile):
         """ Ad-hoc command used to change the "show" part of status """