diff options
author | Lance Stout <lancestout@gmail.com> | 2012-03-12 16:53:41 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-03-12 19:32:20 -0700 |
commit | 3467ac18ccba41765f6151b2fa59aea97d2f4854 (patch) | |
tree | 70f40f286ea383da13fd664dcc812890abc0bce0 | |
parent | cabf27424fca40883d301bba09fc854abff6de77 (diff) | |
download | slixmpp-3467ac18ccba41765f6151b2fa59aea97d2f4854.tar.gz slixmpp-3467ac18ccba41765f6151b2fa59aea97d2f4854.tar.bz2 slixmpp-3467ac18ccba41765f6151b2fa59aea97d2f4854.tar.xz slixmpp-3467ac18ccba41765f6151b2fa59aea97d2f4854.zip |
Move XEP-0163 to new system.
Also includes new register_pep() method for doing the necessary stanza
and disco registration, plus pubsub node event mapping.
-rw-r--r-- | sleekxmpp/plugins/xep_0163.py | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/sleekxmpp/plugins/xep_0163.py b/sleekxmpp/plugins/xep_0163.py index af07cd70..5a6df1c8 100644 --- a/sleekxmpp/plugins/xep_0163.py +++ b/sleekxmpp/plugins/xep_0163.py @@ -8,21 +8,41 @@ import logging -from sleekxmpp.plugins.base import base_plugin +from sleekxmpp.xmlstream import register_stanza_plugin +from sleekxmpp.plugins.base import BasePlugin, register_plugin log = logging.getLogger(__name__) -class xep_0163(base_plugin): +class XEP_0163(BasePlugin): """ XEP-0163: Personal Eventing Protocol (PEP) """ - def plugin_init(self): - self.xep = '0163' - self.description = 'Personal Eventing Protocol' + name = 'xep_0163' + description = 'XEP-0163: Personal Eventing Protocol (PEP)' + dependencies = set(['xep_0030', 'xep_0060', 'xep_0115']) + + def register_pep(self, name, stanza): + """ + Setup and configure events and stanza registration for + the given PEP stanza: + + - Add disco feature for the PEP content. + - Register disco interest in the PEP content. + - Map events from the PEP content's namespace to the given name. + + :param str name: The event name prefix to use for PEP events. + :param stanza: The stanza class for the PEP content. + """ + pubsub_stanza = self.xmpp['xep_0060'].stanza + register_stanza_plugin(pubsub_stanza.EventItem, stanza) + + self.add_interest(stanza.namespace) + self.xmpp['xep_0030'].add_feature(stanza.namespace) + self.xmpp['xep_0060'].map_node_event(stanza.namespace, name) def add_interest(self, namespace, jid=None): """ @@ -67,8 +87,8 @@ class xep_0163(base_plugin): """ Publish a PEP update. - This is just a thin wrapper around the XEP-0060 publish() method - to set the defaults expected by PEP. + This is just a (very) thin wrapper around the XEP-0060 publish() + method to set the defaults expected by PEP. Arguments: stanza -- The PEP update stanza to publish. @@ -95,3 +115,6 @@ class xep_0163(base_plugin): block=block, callback=callback, timeout=timeout) + + +register_plugin(XEP_0163) |