changeset 1407:77f07ea90420

plugin XEP-0045, quick_frontend, primitivus: replace C.DEFAULT_MUC by bridge method getDefaultMUC (value is defined in plugin XEP-0045 and can be overriden with the config file)
author souliane <souliane@mailoo.org>
date Thu, 09 Apr 2015 11:27:13 +0200
parents d3e02159f26c
children 8a7145138330
files frontends/src/primitivus/primitivus frontends/src/quick_frontend/constants.py src/plugins/plugin_xep_0045.py
diffstat 3 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Thu Apr 09 11:24:25 2015 +0200
+++ b/frontends/src/primitivus/primitivus	Thu Apr 09 11:27:13 2015 +0200
@@ -738,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=C.DEFAULT_MUC, 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=self.bridge.getDefaultMUC(), cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
         self.showPopUp(pop_up_widget)
 
     def onAboutRequest(self, menu):
--- a/frontends/src/quick_frontend/constants.py	Thu Apr 09 11:24:25 2015 +0200
+++ b/frontends/src/quick_frontend/constants.py	Thu Apr 09 11:27:13 2015 +0200
@@ -41,11 +41,6 @@
     XMLUI_STATUS_VALIDATED = "validated"
     XMLUI_STATUS_CANCELLED = constants.Const.XMLUI_DATA_CANCELLED
 
-    # MUC
-    DEFAULT_MUC_NODE = u'sat'
-    DEFAULT_MUC_SERVICE = u'chat.jabberfr.org'
-    DEFAULT_MUC = DEFAULT_MUC_NODE if constants.Const.APP_VERSION.endswith(u'D') else u"%s@%s" % (DEFAULT_MUC_NODE, DEFAULT_MUC_SERVICE)
-
     # Roster
     CONTACT_GROUPS = 'groups'
     CONTACT_RESOURCES = 'resources'
--- a/src/plugins/plugin_xep_0045.py	Thu Apr 09 11:24:25 2015 +0200
+++ b/src/plugins/plugin_xep_0045.py	Thu Apr 09 11:27:13 2015 +0200
@@ -48,6 +48,10 @@
 
 AFFILIATIONS = ('owner', 'admin', 'member', 'none', 'outcast')
 
+CONFIG_SECTION = u'plugin muc'
+
+default_conf = {"default_muc": u'sat@chat.jabberfr.org'}
+
 
 class UnknownRoom(Exception):
     pass
@@ -72,6 +76,7 @@
         host.bridge.addMethod("getRoomsSubjects", ".plugin", in_sign='s', out_sign='a(ss)', method=self.getRoomsSubjects)
         host.bridge.addMethod("getUniqueRoomName", ".plugin", in_sign='ss', out_sign='s', method=self._getUniqueName)
         host.bridge.addMethod("configureRoom", ".plugin", in_sign='ss', out_sign='s', method=self._configureRoom, async=True)
+        host.bridge.addMethod("getDefaultMUC", ".plugin", in_sign='', out_sign='s', method=self.getDefaultMUC)
         host.bridge.addSignal("roomJoined", ".plugin", signature='sasss')  # args: room_jid, room_nicks, user_nick, profile
         host.bridge.addSignal("roomLeft", ".plugin", signature='ss')  # args: room_jid, profile
         host.bridge.addSignal("roomUserJoined", ".plugin", signature='ssa{ss}s')  # args: room_jid, user_nick, user_data, profile
@@ -337,6 +342,13 @@
         muc_service = muc_service.userhost()
         return jid.JID("%s@%s" % (room_name, muc_service))
 
+    def getDefaultMUC(self):
+        """Return the default MUC.
+
+        @return: unicode
+        """
+        return self.host.memory.getConfig(CONFIG_SECTION, 'default_muc', default_conf['default_muc'])
+
     def join(self, room_jid, nick, options, profile_key=C.PROF_KEY_NONE):
         def _errDeferred(exc_obj=Exception, txt='Error while joining room'):
             d = defer.Deferred()