mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-30 19:19:55 +00:00
Merge branch 'master' of git@github.com:fritzy/SleekXMPP
This commit is contained in:
commit
f165b4b52b
4 changed files with 11 additions and 4 deletions
|
@ -86,7 +86,7 @@ class basexmpp(object):
|
||||||
self.username = jid.split('@', 1)[0]
|
self.username = jid.split('@', 1)[0]
|
||||||
self.server = jid.split('@',1)[-1].split('/', 1)[0]
|
self.server = jid.split('@',1)[-1].split('/', 1)[0]
|
||||||
|
|
||||||
def registerPlugin(self, plugin, pconfig = {}):
|
def registerPlugin(self, plugin, pconfig = {}, run_post=True):
|
||||||
"""Register a plugin not in plugins.__init__.__all__ but in the plugins
|
"""Register a plugin not in plugins.__init__.__all__ but in the plugins
|
||||||
directory."""
|
directory."""
|
||||||
# discover relative "path" to the plugins module from the main app, and import it.
|
# discover relative "path" to the plugins module from the main app, and import it.
|
||||||
|
@ -100,6 +100,8 @@ class basexmpp(object):
|
||||||
if hasattr(self.plugin[plugin], 'xep'):
|
if hasattr(self.plugin[plugin], 'xep'):
|
||||||
xep = "(XEP-%s) " % self.plugin[plugin].xep
|
xep = "(XEP-%s) " % self.plugin[plugin].xep
|
||||||
logging.debug("Loaded Plugin %s%s" % (xep, self.plugin[plugin].description))
|
logging.debug("Loaded Plugin %s%s" % (xep, self.plugin[plugin].description))
|
||||||
|
if run_post:
|
||||||
|
self.plugin[plugin].post_init()
|
||||||
|
|
||||||
def register_plugins(self):
|
def register_plugins(self):
|
||||||
"""Initiates all plugins in the plugins/__init__.__all__"""
|
"""Initiates all plugins in the plugins/__init__.__all__"""
|
||||||
|
@ -109,7 +111,7 @@ class basexmpp(object):
|
||||||
plugin_list = plugins.__all__
|
plugin_list = plugins.__all__
|
||||||
for plugin in plugin_list:
|
for plugin in plugin_list:
|
||||||
if plugin in plugins.__all__:
|
if plugin in plugins.__all__:
|
||||||
self.registerPlugin(plugin, self.plugin_config.get(plugin, {}))
|
self.registerPlugin(plugin, self.plugin_config.get(plugin, {}), False)
|
||||||
else:
|
else:
|
||||||
raise NameError("No plugin by the name of %s listed in plugins.__all__." % plugin)
|
raise NameError("No plugin by the name of %s listed in plugins.__all__." % plugin)
|
||||||
# run post_init() for cross-plugin interaction
|
# run post_init() for cross-plugin interaction
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Error(ElementBase):
|
||||||
name = 'error'
|
name = 'error'
|
||||||
plugin_attrib = 'error'
|
plugin_attrib = 'error'
|
||||||
conditions = set(('bad-request', 'conflict', 'feature-not-implemented', 'forbidden', 'gone', 'item-not-found', 'jid-malformed', 'not-acceptable', 'not-allowed', 'not-authorized', 'payment-required', 'recipient-unavailable', 'redirect', 'registration-required', 'remote-server-not-found', 'remote-server-timeout', 'service-unavailable', 'subscription-required', 'undefined-condition', 'unexpected-request'))
|
conditions = set(('bad-request', 'conflict', 'feature-not-implemented', 'forbidden', 'gone', 'item-not-found', 'jid-malformed', 'not-acceptable', 'not-allowed', 'not-authorized', 'payment-required', 'recipient-unavailable', 'redirect', 'registration-required', 'remote-server-not-found', 'remote-server-timeout', 'service-unavailable', 'subscription-required', 'undefined-condition', 'unexpected-request'))
|
||||||
interfaces = set(('condition', 'text', 'type'))
|
interfaces = set(('code', 'condition', 'text', 'type'))
|
||||||
types = set(('cancel', 'continue', 'modify', 'auth', 'wait'))
|
types = set(('cancel', 'continue', 'modify', 'auth', 'wait'))
|
||||||
sub_interfaces = set(('text',))
|
sub_interfaces = set(('text',))
|
||||||
condition_ns = 'urn:ietf:params:xml:ns:xmpp-stanzas'
|
condition_ns = 'urn:ietf:params:xml:ns:xmpp-stanzas'
|
||||||
|
|
|
@ -37,6 +37,7 @@ class Iq(RootStanza):
|
||||||
def setPayload(self, value):
|
def setPayload(self, value):
|
||||||
self.clear()
|
self.clear()
|
||||||
StanzaBase.setPayload(self, value)
|
StanzaBase.setPayload(self, value)
|
||||||
|
return self
|
||||||
|
|
||||||
def setQuery(self, value):
|
def setQuery(self, value):
|
||||||
query = self.xml.find("{%s}query" % value)
|
query = self.xml.find("{%s}query" % value)
|
||||||
|
|
|
@ -340,15 +340,18 @@ class StanzaBase(ElementBase):
|
||||||
|
|
||||||
def setPayload(self, value):
|
def setPayload(self, value):
|
||||||
self.xml.append(value)
|
self.xml.append(value)
|
||||||
|
return self
|
||||||
|
|
||||||
def delPayload(self):
|
def delPayload(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
|
return self
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
for child in self.xml.getchildren():
|
for child in self.xml.getchildren():
|
||||||
self.xml.remove(child)
|
self.xml.remove(child)
|
||||||
for plugin in list(self.plugins.keys()):
|
for plugin in list(self.plugins.keys()):
|
||||||
del self.plugins[plugin]
|
del self.plugins[plugin]
|
||||||
|
return self
|
||||||
|
|
||||||
def reply(self):
|
def reply(self):
|
||||||
self['from'], self['to'] = self['to'], self['from']
|
self['from'], self['to'] = self['to'], self['from']
|
||||||
|
@ -357,6 +360,7 @@ class StanzaBase(ElementBase):
|
||||||
|
|
||||||
def error(self):
|
def error(self):
|
||||||
self['type'] = 'error'
|
self['type'] = 'error'
|
||||||
|
return self
|
||||||
|
|
||||||
def getTo(self):
|
def getTo(self):
|
||||||
return JID(self._getAttr('to'))
|
return JID(self._getAttr('to'))
|
||||||
|
|
Loading…
Reference in a new issue