mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
plugins now are checked for post_init having ran when process() is called
This commit is contained in:
parent
9cfe19c1e1
commit
f4bc9d9722
7 changed files with 13 additions and 4 deletions
|
@ -86,7 +86,12 @@ class basexmpp(object):
|
|||
self.username = jid.split('@', 1)[0]
|
||||
self.server = jid.split('@',1)[-1].split('/', 1)[0]
|
||||
|
||||
def registerPlugin(self, plugin, pconfig = {}, run_post=True):
|
||||
def process(self, *args, **kwargs):
|
||||
for idx in self.plugin:
|
||||
if not self.plugin[idx].post_inited: self.plugin[idx].post_init()
|
||||
return super(basexmpp, self).process(*args, **kwargs)
|
||||
|
||||
def registerPlugin(self, plugin, pconfig = {}):
|
||||
"""Register a plugin not in plugins.__init__.__all__ but in the plugins
|
||||
directory."""
|
||||
# discover relative "path" to the plugins module from the main app, and import it.
|
||||
|
@ -100,8 +105,6 @@ class basexmpp(object):
|
|||
if hasattr(self.plugin[plugin], 'xep'):
|
||||
xep = "(XEP-%s) " % self.plugin[plugin].xep
|
||||
logging.debug("Loaded Plugin %s%s" % (xep, self.plugin[plugin].description))
|
||||
if run_post:
|
||||
self.plugin[plugin].post_init()
|
||||
|
||||
def register_plugins(self):
|
||||
"""Initiates all plugins in the plugins/__init__.__all__"""
|
||||
|
|
|
@ -24,6 +24,7 @@ class base_plugin(object):
|
|||
self.description = 'Base Plugin'
|
||||
self.xmpp = xmpp
|
||||
self.config = config
|
||||
self.post_inited = False
|
||||
self.enable = config.get('enable', True)
|
||||
if self.enable:
|
||||
self.plugin_init()
|
||||
|
@ -32,4 +33,4 @@ class base_plugin(object):
|
|||
pass
|
||||
|
||||
def post_init(self):
|
||||
pass
|
||||
self.post_inited = True
|
||||
|
|
|
@ -31,6 +31,7 @@ class xep_0004(base.base_plugin):
|
|||
self.xmpp.add_handler("<message><x xmlns='jabber:x:data' /></message>", self.handler_message_xform)
|
||||
|
||||
def post_init(self):
|
||||
base.base_plugin.post_init(self)
|
||||
self.xmpp.plugin['xep_0030'].add_feature('jabber:x:data')
|
||||
|
||||
def handler_message_xform(self, xml):
|
||||
|
|
|
@ -185,6 +185,7 @@ class xep_0009(base.base_plugin):
|
|||
self.activeCalls = []
|
||||
|
||||
def post_init(self):
|
||||
base.base_plugin.post_init(self)
|
||||
self.xmpp.plugin['xep_0030'].add_feature('jabber:iq:rpc')
|
||||
self.xmpp.plugin['xep_0030'].add_identity('automatition','rpc')
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ class xep_0050(base.base_plugin):
|
|||
self.sd = self.xmpp.plugin['xep_0030']
|
||||
|
||||
def post_init(self):
|
||||
base.base_plugin.post_init(self)
|
||||
self.sd.add_feature('http://jabber.org/protocol/commands')
|
||||
|
||||
def addCommand(self, node, name, form, pointer=None, multi=False):
|
||||
|
|
|
@ -33,6 +33,7 @@ class xep_0092(base.base_plugin):
|
|||
self.xmpp.add_handler("<iq type='get' xmlns='%s'><query xmlns='jabber:iq:version' /></iq>" % self.xmpp.default_ns, self.report_version)
|
||||
|
||||
def post_init(self):
|
||||
base.base_plugin.post_init(self)
|
||||
self.xmpp.plugin['xep_0030'].add_feature('jabber:iq:version')
|
||||
|
||||
def report_version(self, xml):
|
||||
|
|
|
@ -35,6 +35,7 @@ class xep_0199(base.base_plugin):
|
|||
#self.xmpp.add_event_handler('session_start', self.handler_pingserver, threaded=True)
|
||||
|
||||
def post_init(self):
|
||||
base.base_plugin.post_init(self)
|
||||
self.xmpp.plugin['xep_0030'].add_feature('http://www.xmpp.org/extensions/xep-0199.html#ns')
|
||||
|
||||
def handler_pingserver(self, xml):
|
||||
|
|
Loading…
Reference in a new issue