changeset 1094:4286a19e9e8a

pluging XEP-0045: configure room dynamic menu
author Goffi <goffi@goffi.org>
date Thu, 26 Jun 2014 00:05:25 +0200 (2014-06-25)
parents 11e2bb20e896
children ef7b7dd5c5db
files src/plugins/plugin_xep_0045.py
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0045.py	Thu Jun 26 00:05:20 2014 +0200
+++ b/src/plugins/plugin_xep_0045.py	Thu Jun 26 00:05:25 2014 +0200
@@ -78,6 +78,7 @@
         host.bridge.addSignal("roomUserChangedNick", ".plugin", signature='ssss')  # args: room_jid, old_nick, new_nick, profile
         host.bridge.addSignal("roomNewSubject", ".plugin", signature='sss')  # args: room_jid, subject, profile
         self.__submit_conf_id = host.registerCallback(self._submitConfiguration, with_data=True)
+        host.importMenu((D_("MUC"), D_("configure")), self._configureRoomMenu, help_string=D_("Configure Multi-User Chat room"), type_=C.MENU_ROOM)
         try:
             self.host.plugins[C.TEXT_CMDS].registerTextCommands(self)
             self.host.plugins[C.TEXT_CMDS].addWhoIsCb(self._whois, 100)
@@ -217,8 +218,23 @@
         d.addCallback(lambda xmlui: xmlui.toXml())
         return d
 
+    def _configureRoomMenu(self, menu_data, profile):
+        """Return room configuration form
+        @param menu_data: %(menu_data)s
+        @param profile: %(doc_profile)s
+
+        """
+        try:
+            room_jid = jid.JID(menu_data['room_jid'])
+        except KeyError:
+            log.error(_("room_jid key is not present !"))
+            return defer.fail(exceptions.DataError)
+        def xmluiReceived(xmlui):
+            return {"xmlui": xmlui.toXml()}
+        return self.configureRoom(room_jid, profile).addCallback(xmluiReceived)
+
     def configureRoom(self, room_jid, profile_key=C.PROF_KEY_NONE):
-        """ return the room configuration form
+        """return the room configuration form
 
         @param room: jid of the room to configure
         @param profile_key: %(doc_profile_key)s