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.
This commit is contained in:
parent
cabf27424f
commit
3467ac18cc
1 changed files with 30 additions and 7 deletions
|
@ -8,21 +8,41 @@
|
||||||
|
|
||||||
import logging
|
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__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class xep_0163(base_plugin):
|
class XEP_0163(BasePlugin):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
XEP-0163: Personal Eventing Protocol (PEP)
|
XEP-0163: Personal Eventing Protocol (PEP)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def plugin_init(self):
|
name = 'xep_0163'
|
||||||
self.xep = '0163'
|
description = 'XEP-0163: Personal Eventing Protocol (PEP)'
|
||||||
self.description = 'Personal Eventing Protocol'
|
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):
|
def add_interest(self, namespace, jid=None):
|
||||||
"""
|
"""
|
||||||
|
@ -67,8 +87,8 @@ class xep_0163(base_plugin):
|
||||||
"""
|
"""
|
||||||
Publish a PEP update.
|
Publish a PEP update.
|
||||||
|
|
||||||
This is just a thin wrapper around the XEP-0060 publish() method
|
This is just a (very) thin wrapper around the XEP-0060 publish()
|
||||||
to set the defaults expected by PEP.
|
method to set the defaults expected by PEP.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
stanza -- The PEP update stanza to publish.
|
stanza -- The PEP update stanza to publish.
|
||||||
|
@ -95,3 +115,6 @@ class xep_0163(base_plugin):
|
||||||
block=block,
|
block=block,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
|
|
||||||
|
|
||||||
|
register_plugin(XEP_0163)
|
||||||
|
|
Loading…
Reference in a new issue