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)

This commit is contained in:
souliane 2015-04-09 11:27:13 +02:00
commit bf04fcf780
3 changed files with 13 additions and 6 deletions

View file

@ -738,7 +738,7 @@ class PrimitivusApp(QuickApp, InputHistory):
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):

View file

@ -41,11 +41,6 @@ class Const(constants.Const):
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'

View file

@ -48,6 +48,10 @@ PLUGIN_INFO = {
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 @@ class XEP_0045(object):
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 @@ class XEP_0045(object):
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()