comparison src/plugins/plugin_xep_0045.py @ 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 069ad98b360d
children 3265a2639182
comparison
equal deleted inserted replaced
1406:d3e02159f26c 1407:77f07ea90420
45 "handler": "yes", 45 "handler": "yes",
46 "description": _("""Implementation of Multi-User Chat""") 46 "description": _("""Implementation of Multi-User Chat""")
47 } 47 }
48 48
49 AFFILIATIONS = ('owner', 'admin', 'member', 'none', 'outcast') 49 AFFILIATIONS = ('owner', 'admin', 'member', 'none', 'outcast')
50
51 CONFIG_SECTION = u'plugin muc'
52
53 default_conf = {"default_muc": u'sat@chat.jabberfr.org'}
50 54
51 55
52 class UnknownRoom(Exception): 56 class UnknownRoom(Exception):
53 pass 57 pass
54 58
70 host.bridge.addMethod("mucLeave", ".plugin", in_sign='ss', out_sign='', method=self.mucLeave, async=True) 74 host.bridge.addMethod("mucLeave", ".plugin", in_sign='ss', out_sign='', method=self.mucLeave, async=True)
71 host.bridge.addMethod("getRoomsJoined", ".plugin", in_sign='s', out_sign='a(sass)', method=self.getRoomsJoined) 75 host.bridge.addMethod("getRoomsJoined", ".plugin", in_sign='s', out_sign='a(sass)', method=self.getRoomsJoined)
72 host.bridge.addMethod("getRoomsSubjects", ".plugin", in_sign='s', out_sign='a(ss)', method=self.getRoomsSubjects) 76 host.bridge.addMethod("getRoomsSubjects", ".plugin", in_sign='s', out_sign='a(ss)', method=self.getRoomsSubjects)
73 host.bridge.addMethod("getUniqueRoomName", ".plugin", in_sign='ss', out_sign='s', method=self._getUniqueName) 77 host.bridge.addMethod("getUniqueRoomName", ".plugin", in_sign='ss', out_sign='s', method=self._getUniqueName)
74 host.bridge.addMethod("configureRoom", ".plugin", in_sign='ss', out_sign='s', method=self._configureRoom, async=True) 78 host.bridge.addMethod("configureRoom", ".plugin", in_sign='ss', out_sign='s', method=self._configureRoom, async=True)
79 host.bridge.addMethod("getDefaultMUC", ".plugin", in_sign='', out_sign='s', method=self.getDefaultMUC)
75 host.bridge.addSignal("roomJoined", ".plugin", signature='sasss') # args: room_jid, room_nicks, user_nick, profile 80 host.bridge.addSignal("roomJoined", ".plugin", signature='sasss') # args: room_jid, room_nicks, user_nick, profile
76 host.bridge.addSignal("roomLeft", ".plugin", signature='ss') # args: room_jid, profile 81 host.bridge.addSignal("roomLeft", ".plugin", signature='ss') # args: room_jid, profile
77 host.bridge.addSignal("roomUserJoined", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile 82 host.bridge.addSignal("roomUserJoined", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile
78 host.bridge.addSignal("roomUserLeft", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile 83 host.bridge.addSignal("roomUserLeft", ".plugin", signature='ssa{ss}s') # args: room_jid, user_nick, user_data, profile
79 host.bridge.addSignal("roomUserChangedNick", ".plugin", signature='ssss') # args: room_jid, old_nick, new_nick, profile 84 host.bridge.addSignal("roomUserChangedNick", ".plugin", signature='ssss') # args: room_jid, old_nick, new_nick, profile
334 log.warning(_("No MUC service found on main server")) 339 log.warning(_("No MUC service found on main server"))
335 raise exceptions.FeatureNotFound 340 raise exceptions.FeatureNotFound
336 341
337 muc_service = muc_service.userhost() 342 muc_service = muc_service.userhost()
338 return jid.JID("%s@%s" % (room_name, muc_service)) 343 return jid.JID("%s@%s" % (room_name, muc_service))
344
345 def getDefaultMUC(self):
346 """Return the default MUC.
347
348 @return: unicode
349 """
350 return self.host.memory.getConfig(CONFIG_SECTION, 'default_muc', default_conf['default_muc'])
339 351
340 def join(self, room_jid, nick, options, profile_key=C.PROF_KEY_NONE): 352 def join(self, room_jid, nick, options, profile_key=C.PROF_KEY_NONE):
341 def _errDeferred(exc_obj=Exception, txt='Error while joining room'): 353 def _errDeferred(exc_obj=Exception, txt='Error while joining room'):
342 d = defer.Deferred() 354 d = defer.Deferred()
343 d.errback(exc_obj(txt)) 355 d.errback(exc_obj(txt))