Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0045.py @ 1094:4286a19e9e8a
pluging XEP-0045: configure room dynamic menu
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Jun 2014 00:05:25 +0200 |
parents | e8731b02f5ea |
children | ad4ec8d9235e |
comparison
equal
deleted
inserted
replaced
1093:11e2bb20e896 | 1094:4286a19e9e8a |
---|---|
76 host.bridge.addSignal("roomUserJoined", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile | 76 host.bridge.addSignal("roomUserJoined", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile |
77 host.bridge.addSignal("roomUserLeft", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile | 77 host.bridge.addSignal("roomUserLeft", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile |
78 host.bridge.addSignal("roomUserChangedNick", ".plugin", signature='ssss') # args: room_jid, old_nick, new_nick, profile | 78 host.bridge.addSignal("roomUserChangedNick", ".plugin", signature='ssss') # args: room_jid, old_nick, new_nick, profile |
79 host.bridge.addSignal("roomNewSubject", ".plugin", signature='sss') # args: room_jid, subject, profile | 79 host.bridge.addSignal("roomNewSubject", ".plugin", signature='sss') # args: room_jid, subject, profile |
80 self.__submit_conf_id = host.registerCallback(self._submitConfiguration, with_data=True) | 80 self.__submit_conf_id = host.registerCallback(self._submitConfiguration, with_data=True) |
81 host.importMenu((D_("MUC"), D_("configure")), self._configureRoomMenu, help_string=D_("Configure Multi-User Chat room"), type_=C.MENU_ROOM) | |
81 try: | 82 try: |
82 self.host.plugins[C.TEXT_CMDS].registerTextCommands(self) | 83 self.host.plugins[C.TEXT_CMDS].registerTextCommands(self) |
83 self.host.plugins[C.TEXT_CMDS].addWhoIsCb(self._whois, 100) | 84 self.host.plugins[C.TEXT_CMDS].addWhoIsCb(self._whois, 100) |
84 except KeyError: | 85 except KeyError: |
85 log.info(_("Text commands not available")) | 86 log.info(_("Text commands not available")) |
215 def _configureRoom(self, room_jid_s, profile_key=C.PROF_KEY_NONE): | 216 def _configureRoom(self, room_jid_s, profile_key=C.PROF_KEY_NONE): |
216 d = self.configureRoom(jid.JID(room_jid_s), profile_key) | 217 d = self.configureRoom(jid.JID(room_jid_s), profile_key) |
217 d.addCallback(lambda xmlui: xmlui.toXml()) | 218 d.addCallback(lambda xmlui: xmlui.toXml()) |
218 return d | 219 return d |
219 | 220 |
221 def _configureRoomMenu(self, menu_data, profile): | |
222 """Return room configuration form | |
223 @param menu_data: %(menu_data)s | |
224 @param profile: %(doc_profile)s | |
225 | |
226 """ | |
227 try: | |
228 room_jid = jid.JID(menu_data['room_jid']) | |
229 except KeyError: | |
230 log.error(_("room_jid key is not present !")) | |
231 return defer.fail(exceptions.DataError) | |
232 def xmluiReceived(xmlui): | |
233 return {"xmlui": xmlui.toXml()} | |
234 return self.configureRoom(room_jid, profile).addCallback(xmluiReceived) | |
235 | |
220 def configureRoom(self, room_jid, profile_key=C.PROF_KEY_NONE): | 236 def configureRoom(self, room_jid, profile_key=C.PROF_KEY_NONE): |
221 """ return the room configuration form | 237 """return the room configuration form |
222 | 238 |
223 @param room: jid of the room to configure | 239 @param room: jid of the room to configure |
224 @param profile_key: %(doc_profile_key)s | 240 @param profile_key: %(doc_profile_key)s |
225 @return: configuration form as XMLUI | 241 @return: configuration form as XMLUI |
226 """ | 242 """ |