summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r--sleekxmpp/plugins/__init__.py2
-rw-r--r--sleekxmpp/plugins/base.py3
-rw-r--r--sleekxmpp/plugins/old_0060.py (renamed from sleekxmpp/plugins/xep_0060.py)0
-rw-r--r--sleekxmpp/plugins/stanza_pubsub.py557
-rw-r--r--sleekxmpp/plugins/xep_0009/remote.py2
-rw-r--r--sleekxmpp/plugins/xep_0050/adhoc.py2
-rw-r--r--sleekxmpp/plugins/xep_0060/__init__.py2
-rw-r--r--sleekxmpp/plugins/xep_0060/pubsub.py128
-rw-r--r--sleekxmpp/plugins/xep_0060/stanza/__init__.py3
-rw-r--r--sleekxmpp/plugins/xep_0060/stanza/base.py24
-rw-r--r--sleekxmpp/plugins/xep_0060/stanza/pubsub.py277
-rw-r--r--sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py124
-rw-r--r--sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py155
-rw-r--r--sleekxmpp/plugins/xep_0082.py10
-rw-r--r--sleekxmpp/plugins/xep_0202/__init__.py1
-rw-r--r--sleekxmpp/plugins/xep_0202/stanza.py3
16 files changed, 727 insertions, 566 deletions
diff --git a/sleekxmpp/plugins/__init__.py b/sleekxmpp/plugins/__init__.py
index b48a4c03..7fa031ef 100644
--- a/sleekxmpp/plugins/__init__.py
+++ b/sleekxmpp/plugins/__init__.py
@@ -8,4 +8,4 @@
__all__ = ['xep_0004', 'xep_0009', 'xep_0012', 'xep_0030', 'xep_0033',
'xep_0045', 'xep_0050', 'xep_0060', 'xep_0066', 'xep_0082',
'xep_0085', 'xep_0086', 'xep_0092', 'xep_0128', 'xep_0199',
- 'xep_0202', 'xep_0203', 'xep_0224', 'xep_0249', 'gmail_notify']
+ 'xep_0203', 'xep_0224', 'xep_0249', 'gmail_notify']
diff --git a/sleekxmpp/plugins/base.py b/sleekxmpp/plugins/base.py
index 2dd68c8d..561421d8 100644
--- a/sleekxmpp/plugins/base.py
+++ b/sleekxmpp/plugins/base.py
@@ -66,7 +66,8 @@ class base_plugin(object):
"""
if config is None:
config = {}
- self.xep = 'base'
+ self.xep = None
+ self.rfc = None
self.description = 'Base Plugin'
self.xmpp = xmpp
self.config = config
diff --git a/sleekxmpp/plugins/xep_0060.py b/sleekxmpp/plugins/old_0060.py
index 93124fca..93124fca 100644
--- a/sleekxmpp/plugins/xep_0060.py
+++ b/sleekxmpp/plugins/old_0060.py
diff --git a/sleekxmpp/plugins/stanza_pubsub.py b/sleekxmpp/plugins/stanza_pubsub.py
deleted file mode 100644
index b5964537..00000000
--- a/sleekxmpp/plugins/stanza_pubsub.py
+++ /dev/null
@@ -1,557 +0,0 @@
-from .. xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET, JID
-from .. stanza.iq import Iq
-from .. stanza.message import Message
-from .. basexmpp import basexmpp
-from .. xmlstream.xmlstream import XMLStream
-import logging
-from . import xep_0004
-
-
-class PubsubState(ElementBase):
- namespace = 'http://jabber.org/protocol/psstate'
- name = 'state'
- plugin_attrib = 'psstate'
- interfaces = set(('node', 'item', 'payload'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setPayload(self, value):
- self.xml.append(value)
-
- def getPayload(self):
- childs = self.xml.getchildren()
- if len(childs) > 0:
- return childs[0]
-
- def delPayload(self):
- for child in self.xml.getchildren():
- self.xml.remove(child)
-
-registerStanzaPlugin(Iq, PubsubState)
-
-class PubsubStateEvent(ElementBase):
- namespace = 'http://jabber.org/protocol/psstate#event'
- name = 'event'
- plugin_attrib = 'psstate_event'
- intefaces = set(tuple())
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Message, PubsubStateEvent)
-registerStanzaPlugin(PubsubStateEvent, PubsubState)
-
-class Pubsub(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'pubsub'
- plugin_attrib = 'pubsub'
- interfaces = set(tuple())
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Iq, Pubsub)
-
-class PubsubOwner(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- name = 'pubsub'
- plugin_attrib = 'pubsub_owner'
- interfaces = set(tuple())
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Iq, PubsubOwner)
-
-class Affiliation(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'affiliation'
- plugin_attrib = name
- interfaces = set(('node', 'affiliation'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-class Affiliations(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'affiliations'
- plugin_attrib = 'affiliations'
- interfaces = set(tuple())
- plugin_attrib_map = {}
- plugin_tag_map = {}
- subitem = (Affiliation,)
-
- def append(self, affiliation):
- if not isinstance(affiliation, Affiliation):
- raise TypeError
- self.xml.append(affiliation.xml)
- return self.iterables.append(affiliation)
-
-registerStanzaPlugin(Pubsub, Affiliations)
-
-
-class Subscription(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'subscription'
- plugin_attrib = name
- interfaces = set(('jid', 'node', 'subscription', 'subid'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setjid(self, value):
- self._setattr('jid', str(value))
-
- def getjid(self):
- return jid(self._getattr('jid'))
-
-registerStanzaPlugin(Pubsub, Subscription)
-
-class Subscriptions(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'subscriptions'
- plugin_attrib = 'subscriptions'
- interfaces = set(tuple())
- plugin_attrib_map = {}
- plugin_tag_map = {}
- subitem = (Subscription,)
-
-registerStanzaPlugin(Pubsub, Subscriptions)
-
-class OptionalSetting(object):
- interfaces = set(('required',))
-
- def setRequired(self, value):
- value = bool(value)
- if value and not self['required']:
- self.xml.append(ET.Element("{%s}required" % self.namespace))
- elif not value and self['required']:
- self.delRequired()
-
- def getRequired(self):
- required = self.xml.find("{%s}required" % self.namespace)
- if required is not None:
- return True
- else:
- return False
-
- def delRequired(self):
- required = self.xml.find("{%s}required" % self.namespace)
- if required is not None:
- self.xml.remove(required)
-
-
-class SubscribeOptions(ElementBase, OptionalSetting):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'subscribe-options'
- plugin_attrib = 'suboptions'
- plugin_attrib_map = {}
- plugin_tag_map = {}
- interfaces = set(('required',))
-
-registerStanzaPlugin(Subscription, SubscribeOptions)
-
-class Item(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'item'
- plugin_attrib = name
- interfaces = set(('id', 'payload'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setPayload(self, value):
- self.xml.append(value)
-
- def getPayload(self):
- childs = self.xml.getchildren()
- if len(childs) > 0:
- return childs[0]
-
- def delPayload(self):
- for child in self.xml.getchildren():
- self.xml.remove(child)
-
-class Items(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'items'
- plugin_attrib = 'items'
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
- subitem = (Item,)
-
-registerStanzaPlugin(Pubsub, Items)
-
-class Create(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'create'
- plugin_attrib = name
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Pubsub, Create)
-
-#class Default(ElementBase):
-# namespace = 'http://jabber.org/protocol/pubsub'
-# name = 'default'
-# plugin_attrib = name
-# interfaces = set(('node', 'type'))
-# plugin_attrib_map = {}
-# plugin_tag_map = {}
-#
-# def getType(self):
-# t = self._getAttr('type')
-# if not t: t == 'leaf'
-# return t
-#
-#registerStanzaPlugin(Pubsub, Default)
-
-class Publish(Items):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'publish'
- plugin_attrib = name
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
- subitem = (Item,)
-
-registerStanzaPlugin(Pubsub, Publish)
-
-class Retract(Items):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'retract'
- plugin_attrib = name
- interfaces = set(('node', 'notify'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Pubsub, Retract)
-
-class Unsubscribe(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'unsubscribe'
- plugin_attrib = name
- interfaces = set(('node', 'jid'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setJid(self, value):
- self._setAttr('jid', str(value))
-
- def getJid(self):
- return JID(self._getAttr('jid'))
-
-registerStanzaPlugin(Pubsub, Unsubscribe)
-
-class Subscribe(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'subscribe'
- plugin_attrib = name
- interfaces = set(('node', 'jid'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setJid(self, value):
- self._setAttr('jid', str(value))
-
- def getJid(self):
- return JID(self._getAttr('jid'))
-
-registerStanzaPlugin(Pubsub, Subscribe)
-
-class Configure(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'configure'
- plugin_attrib = name
- interfaces = set(('node', 'type'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def getType(self):
- t = self._getAttr('type')
- if not t: t == 'leaf'
- return t
-
-registerStanzaPlugin(Pubsub, Configure)
-registerStanzaPlugin(Configure, xep_0004.Form)
-
-class DefaultConfig(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- name = 'default'
- plugin_attrib = 'default'
- interfaces = set(('node', 'type', 'config'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def __init__(self, *args, **kwargs):
- ElementBase.__init__(self, *args, **kwargs)
-
- def getType(self):
- t = self._getAttr('type')
- if not t: t = 'leaf'
- return t
-
- def getConfig(self):
- return self['form']
-
- def setConfig(self, value):
- self['form'].setStanzaValues(value.getStanzaValues())
- return self
-
-registerStanzaPlugin(PubsubOwner, DefaultConfig)
-registerStanzaPlugin(DefaultConfig, xep_0004.Form)
-
-class Options(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub'
- name = 'options'
- plugin_attrib = 'options'
- interfaces = set(('jid', 'node', 'options'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def __init__(self, *args, **kwargs):
- ElementBase.__init__(self, *args, **kwargs)
-
- def getOptions(self):
- config = self.xml.find('{jabber:x:data}x')
- form = xep_0004.Form()
- if config is not None:
- form.fromXML(config)
- return form
-
- def setOptions(self, value):
- self.xml.append(value.getXML())
- return self
-
- def delOptions(self):
- config = self.xml.find('{jabber:x:data}x')
- self.xml.remove(config)
-
- def setJid(self, value):
- self._setAttr('jid', str(value))
-
- def getJid(self):
- return JID(self._getAttr('jid'))
-
-registerStanzaPlugin(Pubsub, Options)
-registerStanzaPlugin(Subscribe, Options)
-
-class OwnerAffiliations(Affiliations):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- interfaces = set(('node'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def append(self, affiliation):
- if not isinstance(affiliation, OwnerAffiliation):
- raise TypeError
- self.xml.append(affiliation.xml)
- return self.affiliations.append(affiliation)
-
-registerStanzaPlugin(PubsubOwner, OwnerAffiliations)
-
-class OwnerAffiliation(Affiliation):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- interfaces = set(('affiliation', 'jid'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-class OwnerConfigure(Configure):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- interfaces = set(('node', 'config'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(PubsubOwner, OwnerConfigure)
-
-class OwnerDefault(OwnerConfigure):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- interfaces = set(('node', 'config'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def getConfig(self):
- return self['form']
-
- def setConfig(self, value):
- self['form'].setStanzaValues(value.getStanzaValues())
- return self
-
-registerStanzaPlugin(PubsubOwner, OwnerDefault)
-registerStanzaPlugin(OwnerDefault, xep_0004.Form)
-
-class OwnerDelete(ElementBase, OptionalSetting):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- name = 'delete'
- plugin_attrib = 'delete'
- plugin_attrib_map = {}
- plugin_tag_map = {}
- interfaces = set(('node',))
-
-registerStanzaPlugin(PubsubOwner, OwnerDelete)
-
-class OwnerPurge(ElementBase, OptionalSetting):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- name = 'purge'
- plugin_attrib = name
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(PubsubOwner, OwnerPurge)
-
-class OwnerRedirect(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- name = 'redirect'
- plugin_attrib = name
- interfaces = set(('node', 'jid'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setJid(self, value):
- self._setAttr('jid', str(value))
-
- def getJid(self):
- return JID(self._getAttr('jid'))
-
-registerStanzaPlugin(OwnerDelete, OwnerRedirect)
-
-class OwnerSubscriptions(Subscriptions):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def append(self, subscription):
- if not isinstance(subscription, OwnerSubscription):
- raise TypeError
- self.xml.append(subscription.xml)
- return self.subscriptions.append(subscription)
-
-registerStanzaPlugin(PubsubOwner, OwnerSubscriptions)
-
-class OwnerSubscription(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#owner'
- name = 'subscription'
- plugin_attrib = name
- interfaces = set(('jid', 'subscription'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setJid(self, value):
- self._setAttr('jid', str(value))
-
- def getJid(self):
- return JID(self._getAttr('from'))
-
-class Event(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'event'
- plugin_attrib = 'pubsub_event'
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Message, Event)
-
-class EventItem(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'item'
- plugin_attrib = 'item'
- interfaces = set(('id', 'payload'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setPayload(self, value):
- self.xml.append(value)
-
- def getPayload(self):
- childs = self.xml.getchildren()
- if len(childs) > 0:
- return childs[0]
-
- def delPayload(self):
- for child in self.xml.getchildren():
- self.xml.remove(child)
-
-
-class EventRetract(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'retract'
- plugin_attrib = 'retract'
- interfaces = set(('id',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-class EventItems(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'items'
- plugin_attrib = 'items'
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
- subitem = (EventItem, EventRetract)
-
-registerStanzaPlugin(Event, EventItems)
-
-class EventCollection(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'collection'
- plugin_attrib = name
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Event, EventCollection)
-
-class EventAssociate(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'associate'
- plugin_attrib = name
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(EventCollection, EventAssociate)
-
-class EventDisassociate(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'disassociate'
- plugin_attrib = name
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(EventCollection, EventDisassociate)
-
-class EventConfiguration(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'configuration'
- plugin_attrib = name
- interfaces = set(('node', 'config'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Event, EventConfiguration)
-registerStanzaPlugin(EventConfiguration, xep_0004.Form)
-
-class EventPurge(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'purge'
- plugin_attrib = name
- interfaces = set(('node',))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
-registerStanzaPlugin(Event, EventPurge)
-
-class EventSubscription(ElementBase):
- namespace = 'http://jabber.org/protocol/pubsub#event'
- name = 'subscription'
- plugin_attrib = name
- interfaces = set(('node','expiry', 'jid', 'subid', 'subscription'))
- plugin_attrib_map = {}
- plugin_tag_map = {}
-
- def setJid(self, value):
- self._setAttr('jid', str(value))
-
- def getJid(self):
- return JID(self._getAttr('jid'))
-
-registerStanzaPlugin(Event, EventSubscription)
diff --git a/sleekxmpp/plugins/xep_0009/remote.py b/sleekxmpp/plugins/xep_0009/remote.py
index 8c534118..b5d10b85 100644
--- a/sleekxmpp/plugins/xep_0009/remote.py
+++ b/sleekxmpp/plugins/xep_0009/remote.py
@@ -463,7 +463,7 @@ class RemoteSession(object):
key = "%s.%s" % (endpoint, name)
log.debug("Registering call handler for %s (%s)." % (key, method))
with self._lock:
- if self._entries.has_key(key):
+ if key in self._entries:
raise KeyError("A handler for %s has already been regisered!" % endpoint)
self._entries[key] = JabberRPCEntry(endpoint, method)
return key
diff --git a/sleekxmpp/plugins/xep_0050/adhoc.py b/sleekxmpp/plugins/xep_0050/adhoc.py
index 72c6c513..dd1c88d6 100644
--- a/sleekxmpp/plugins/xep_0050/adhoc.py
+++ b/sleekxmpp/plugins/xep_0050/adhoc.py
@@ -589,5 +589,5 @@ class xep_0050(base_plugin):
elif iq['type'] == 'error':
self.terminate_command(session)
- if iq['command']['status'] == 'completed':
+ if iq['command']['status'] == 'completed':
self.terminate_command(session)
diff --git a/sleekxmpp/plugins/xep_0060/__init__.py b/sleekxmpp/plugins/xep_0060/__init__.py
new file mode 100644
index 00000000..026f7c2b
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0060/__init__.py
@@ -0,0 +1,2 @@
+from sleekxmpp.plugins.xep_0060.pubsub import xep_0060
+from sleekxmpp.plugins.xep_0060 import stanza
diff --git a/sleekxmpp/plugins/xep_0060/pubsub.py b/sleekxmpp/plugins/xep_0060/pubsub.py
new file mode 100644
index 00000000..06d148ed
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0060/pubsub.py
@@ -0,0 +1,128 @@
+from __future__ import with_statement
+from sleekxmpp.plugins import base
+import logging
+#from xml.etree import cElementTree as ET
+from sleekxmpp.xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET
+from sleekxmpp.plugins.xep_0060 import stanza
+from sleekxmpp.plugins.xep_0004 import Form
+
+
+log = logging.getLogger(__name__)
+
+
+class xep_0060(base.base_plugin):
+ """
+ XEP-0060 Publish Subscribe
+ """
+
+ def plugin_init(self):
+ self.xep = '0060'
+ self.description = 'Publish-Subscribe'
+
+ def create_node(self, jid, node, config=None, ntype=None):
+ iq = IQ(sto=jid, stype='set', sfrom=self.xmpp.jid)
+ iq['pubsub']['create']['node'] = node
+ if ntype is None:
+ ntype = 'leaf'
+ if config is not None:
+ if 'FORM_TYPE' in submitform.field:
+ config.field['FORM_TYPE'].setValue('http://jabber.org/protocol/pubsub#node_config')
+ else:
+ config.addField('FORM_TYPE', 'hidden', value='http://jabber.org/protocol/pubsub#node_config')
+ if 'pubsub#node_type' in submitform.field:
+ config.field['pubsub#node_type'].setValue(ntype)
+ else:
+ config.addField('pubsub#node_type', value=ntype)
+ iq['pubsub']['configure']['form'] = config
+ return iq.send()
+
+ def subscribe(self, jid, node, bare=True, subscribee=None):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
+ iq['pubsub']['subscribe']['node'] = node
+ if subscribee is None:
+ if bare:
+ iq['pubsub']['subscribe']['jid'] = self.xmpp.jid.bare
+ else:
+ iq['pubsub']['subscribe']['jid'] = self.xmpp.jid.full
+ else:
+ iq['pubsub']['subscribe']['jid'] = subscribee
+ return iq.send()
+
+ def unsubscribe(self, jid, node, subid=None, bare=True, subscribee=None):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
+ iq['pubsub']['unsubscribe']['node'] = node
+ if subscribee is None:
+ if bare:
+ iq['pubsub']['unsubscribe']['jid'] = self.xmpp.jid.bare
+ else:
+ iq['pubsub']['unsubscribe']['jid'] = self.xmpp.jid.full
+ else:
+ iq['pubsub']['unsubscribe']['jid'] = subscribee
+ if subid is not None:
+ iq['pubsub']['unsubscribe']['subid'] = subid
+ return iq.send()
+
+ def get_node_config(self, jid, node=None): # if no node, then grab default
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
+ if node is None:
+ iq['pubsub_owner']['default']
+ else:
+ iq['pubsub_owner']['configure']['node'] = node
+ return iq.send()
+
+ def get_node_subscriptions(self, jid, node):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
+ iq['pubsub_owner']['subscriptions']['node'] = node
+ return iq.send()
+
+ def get_node_affiliations(self, jid, node):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
+ iq['pubsub_owner']['affiliations']['node'] = node
+ return iq.send()
+
+ def delete_node(self, jid, node):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
+ iq['pubsub_owner']['delete']['node'] = node
+ return iq.send()
+
+ def set_node_config(self, jid, node, config):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
+ iq['pubsub_owner']['configure']['node'] = node
+ iq['pubsub_owner']['configure']['config'] = config
+ return iq.send()
+
+ def publish(self, jid, node, items=[]):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
+ iq['pubsub']['publish']['node'] = node
+ for id, payload in items:
+ item = stanza.pubsub.Item()
+ if id is not None:
+ item['id'] = id
+ item['payload'] = payload
+ iq['pubsub']['publish'].append(item)
+ return iq.send()
+
+ def retract(self, jid, node, item):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
+ iq['pubsub']['retract']['node'] = node
+ item = stanza.pubsub.Item()
+ item['id'] = item
+ iq['pubsub']['retract'].append(item)
+ return iq.send()
+
+ def get_nodes(self, jid):
+ return self.xmpp.plugin['xep_0030'].get_items(jid)
+
+ def getItems(self, jid, node):
+ return self.xmpp.plugin['xep_0030'].get_items(jid, node)
+
+ def modify_affiliation(self, jid, node, affiliation, user_jid=None):
+ iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
+ iq['pubsub_owner']['affiliations']
+ aff = stanza.pubsub.Affiliation()
+ aff['node'] = node
+ if user_jid is not None:
+ aff['jid'] = user_jid
+ aff['affiliation'] = affiliation
+ iq['pubsub_owner']['affiliations'].append(aff)
+ return iq.send()
diff --git a/sleekxmpp/plugins/xep_0060/stanza/__init__.py b/sleekxmpp/plugins/xep_0060/stanza/__init__.py
new file mode 100644
index 00000000..d7cd91a8
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0060/stanza/__init__.py
@@ -0,0 +1,3 @@
+from sleekxmpp.plugins.xep_0060.stanza.pubsub import Pubsub, Affiliation, Affiliations, Subscription, Subscriptions, SubscribeOptions, Item, Items, Create, Publish, Retract, Unsubscribe, Subscribe, Configure, Options, PubsubState, PubsubStateEvent
+from sleekxmpp.plugins.xep_0060.stanza.pubsub_owner import PubsubOwner, DefaultConfig, OwnerAffiliations, OwnerAffiliation, OwnerConfigure, OwnerDefault, OwnerDelete, OwnerPurge, OwnerRedirect, OwnerSubscriptions, OwnerSubscription
+from sleekxmpp.plugins.xep_0060.stanza.pubsub_event import Event, EventItem, EventRetract, EventItems, EventCollection, EventAssociate, EventDisassociate, EventConfiguration, EventPurge, EventSubscription
diff --git a/sleekxmpp/plugins/xep_0060/stanza/base.py b/sleekxmpp/plugins/xep_0060/stanza/base.py
new file mode 100644
index 00000000..9b1efe1b
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0060/stanza/base.py
@@ -0,0 +1,24 @@
+from xml.etree import cElementTree as ET
+
+class OptionalSetting(object):
+ interfaces = set(('required',))
+
+ def setRequired(self, value):
+ value = bool(value)
+ if value and not self['required']:
+ self.xml.append(ET.Element("{%s}required" % self.namespace))
+ elif not value and self['required']:
+ self.delRequired()
+
+ def getRequired(self):
+ required = self.xml.find("{%s}required" % self.namespace)
+ if required is not None:
+ return True
+ else:
+ return False
+
+ def delRequired(self):
+ required = self.xml.find("{%s}required" % self.namespace)
+ if required is not None:
+ self.xml.remove(required)
+
diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py
new file mode 100644
index 00000000..68e4f952
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py
@@ -0,0 +1,277 @@
+from sleekxmpp.xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET, JID
+from sleekxmpp.stanza.iq import Iq
+from sleekxmpp.stanza.message import Message
+from sleekxmpp.basexmpp import basexmpp
+from sleekxmpp.xmlstream.xmlstream import XMLStream
+import logging
+from sleekxmpp.plugins import xep_0004
+from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
+
+
+class Pubsub(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'pubsub'
+ plugin_attrib = 'pubsub'
+ interfaces = set(tuple())
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Iq, Pubsub)
+
+
+class Affiliation(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'affiliation'
+ plugin_attrib = name
+ interfaces = set(('node', 'affiliation', 'jid'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setJid(self, value):
+ self._setAttr('jid', str(value))
+
+ def getJid(self):
+ return JID(self._getAttr('jid'))
+
+class Affiliations(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'affiliations'
+ plugin_attrib = 'affiliations'
+ interfaces = set(tuple())
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+ subitem = (Affiliation,)
+
+registerStanzaPlugin(Pubsub, Affiliations)
+
+
+class Subscription(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'subscription'
+ plugin_attrib = name
+ interfaces = set(('jid', 'node', 'subscription', 'subid'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setjid(self, value):
+ self._setattr('jid', str(value))
+
+ def getjid(self):
+ return jid(self._getattr('jid'))
+
+registerStanzaPlugin(Pubsub, Subscription)
+
+class Subscriptions(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'subscriptions'
+ plugin_attrib = 'subscriptions'
+ interfaces = set(tuple())
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+ subitem = (Subscription,)
+
+registerStanzaPlugin(Pubsub, Subscriptions)
+
+
+class SubscribeOptions(ElementBase, OptionalSetting):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'subscribe-options'
+ plugin_attrib = 'suboptions'
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+ interfaces = set(('required',))
+
+registerStanzaPlugin(Subscription, SubscribeOptions)
+
+class Item(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'item'
+ plugin_attrib = name
+ interfaces = set(('id', 'payload'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setPayload(self, value):
+ self.xml.append(value)
+
+ def getPayload(self):
+ childs = self.xml.getchildren()
+ if len(childs) > 0:
+ return childs[0]
+
+ def delPayload(self):
+ for child in self.xml.getchildren():
+ self.xml.remove(child)
+
+class Items(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'items'
+ plugin_attrib = 'items'
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+ subitem = (Item,)
+
+registerStanzaPlugin(Pubsub, Items)
+
+class Create(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'create'
+ plugin_attrib = name
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Pubsub, Create)
+
+#class Default(ElementBase):
+# namespace = 'http://jabber.org/protocol/pubsub'
+# name = 'default'
+# plugin_attrib = name
+# interfaces = set(('node', 'type'))
+# plugin_attrib_map = {}
+# plugin_tag_map = {}
+#
+# def getType(self):
+# t = self._getAttr('type')
+# if not t: t == 'leaf'
+# return t
+#
+#registerStanzaPlugin(Pubsub, Default)
+
+class Publish(Items):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'publish'
+ plugin_attrib = name
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+ subitem = (Item,)
+
+registerStanzaPlugin(Pubsub, Publish)
+
+class Retract(Items):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'retract'
+ plugin_attrib = name
+ interfaces = set(('node', 'notify'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Pubsub, Retract)
+
+class Unsubscribe(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'unsubscribe'
+ plugin_attrib = name
+ interfaces = set(('node', 'jid', 'subid'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setJid(self, value):
+ self._setAttr('jid', str(value))
+
+ def getJid(self):
+ return JID(self._getAttr('jid'))
+
+registerStanzaPlugin(Pubsub, Unsubscribe)
+
+class Subscribe(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'subscribe'
+ plugin_attrib = name
+ interfaces = set(('node', 'jid'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setJid(self, value):
+ self._setAttr('jid', str(value))
+
+ def getJid(self):
+ return JID(self._getAttr('jid'))
+
+registerStanzaPlugin(Pubsub, Subscribe)
+
+class Configure(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'configure'
+ plugin_attrib = name
+ interfaces = set(('node', 'type'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def getType(self):
+ t = self._getAttr('type')
+ if not t: t == 'leaf'
+ return t
+
+registerStanzaPlugin(Pubsub, Configure)
+registerStanzaPlugin(Configure, xep_0004.Form)
+
+class Options(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub'
+ name = 'options'
+ plugin_attrib = 'options'
+ interfaces = set(('jid', 'node', 'options'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def __init__(self, *args, **kwargs):
+ ElementBase.__init__(self, *args, **kwargs)
+
+ def getOptions(self):
+ config = self.xml.find('{jabber:x:data}x')
+ form = xep_0004.Form()
+ if config is not None:
+ form.fromXML(config)
+ return form
+
+ def setOptions(self, value):
+ self.xml.append(value.getXML())
+ return self
+
+ def delOptions(self):
+ config = self.xml.find('{jabber:x:data}x')
+ self.xml.remove(config)
+
+ def setJid(self, value):
+ self._setAttr('jid', str(value))
+
+ def getJid(self):
+ return JID(self._getAttr('jid'))
+
+registerStanzaPlugin(Pubsub, Options)
+registerStanzaPlugin(Subscribe, Options)
+
+class PubsubState(ElementBase):
+ namespace = 'http://jabber.org/protocol/psstate'
+ name = 'state'
+ plugin_attrib = 'psstate'
+ interfaces = set(('node', 'item', 'payload'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setPayload(self, value):
+ self.xml.append(value)
+
+ def getPayload(self):
+ childs = self.xml.getchildren()
+ if len(childs) > 0:
+ return childs[0]
+
+ def delPayload(self):
+ for child in self.xml.getchildren():
+ self.xml.remove(child)
+
+registerStanzaPlugin(Iq, PubsubState)
+
+class PubsubStateEvent(ElementBase):
+ namespace = 'http://jabber.org/protocol/psstate#event'
+ name = 'event'
+ plugin_attrib = 'psstate_event'
+ intefaces = set(tuple())
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Message, PubsubStateEvent)
+registerStanzaPlugin(PubsubStateEvent, PubsubState)
diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py
new file mode 100644
index 00000000..2dfe6c4a
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py
@@ -0,0 +1,124 @@
+from sleekxmpp.xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET, JID
+from sleekxmpp.stanza.iq import Iq
+from sleekxmpp.stanza.message import Message
+from sleekxmpp.basexmpp import basexmpp
+from sleekxmpp.xmlstream.xmlstream import XMLStream
+import logging
+from sleekxmpp.plugins import xep_0004
+
+class Event(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'event'
+ plugin_attrib = 'pubsub_event'
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Message, Event)
+
+class EventItem(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'item'
+ plugin_attrib = 'item'
+ interfaces = set(('id', 'payload'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setPayload(self, value):
+ self.xml.append(value)
+
+ def getPayload(self):
+ childs = self.xml.getchildren()
+ if len(childs) > 0:
+ return childs[0]
+
+ def delPayload(self):
+ for child in self.xml.getchildren():
+ self.xml.remove(child)
+
+
+class EventRetract(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'retract'
+ plugin_attrib = 'retract'
+ interfaces = set(('id',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+class EventItems(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'items'
+ plugin_attrib = 'items'
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+ subitem = (EventItem, EventRetract)
+
+registerStanzaPlugin(Event, EventItems)
+
+class EventCollection(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'collection'
+ plugin_attrib = name
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Event, EventCollection)
+
+class EventAssociate(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'associate'
+ plugin_attrib = name
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(EventCollection, EventAssociate)
+
+class EventDisassociate(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'disassociate'
+ plugin_attrib = name
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(EventCollection, EventDisassociate)
+
+class EventConfiguration(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'configuration'
+ plugin_attrib = name
+ interfaces = set(('node', 'config'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Event, EventConfiguration)
+registerStanzaPlugin(EventConfiguration, xep_0004.Form)
+
+class EventPurge(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'purge'
+ plugin_attrib = name
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Event, EventPurge)
+
+class EventSubscription(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#event'
+ name = 'subscription'
+ plugin_attrib = name
+ interfaces = set(('node','expiry', 'jid', 'subid', 'subscription'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setJid(self, value):
+ self._setAttr('jid', str(value))
+
+ def getJid(self):
+ return JID(self._getAttr('jid'))
+
+registerStanzaPlugin(Event, EventSubscription)
diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py
new file mode 100644
index 00000000..a8ced8a9
--- /dev/null
+++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py
@@ -0,0 +1,155 @@
+from sleekxmpp.xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET, JID
+from sleekxmpp.stanza.iq import Iq
+from sleekxmpp.stanza.message import Message
+from sleekxmpp.basexmpp import basexmpp
+from sleekxmpp.xmlstream.xmlstream import XMLStream
+import logging
+from sleekxmpp.plugins import xep_0004
+from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
+from sleekxmpp.plugins.xep_0060.stanza.pubsub import Affiliations, Affiliation, Configure, Subscriptions
+
+class PubsubOwner(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ name = 'pubsub'
+ plugin_attrib = 'pubsub_owner'
+ interfaces = set(tuple())
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(Iq, PubsubOwner)
+
+class DefaultConfig(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ name = 'default'
+ plugin_attrib = 'default'
+ interfaces = set(('node', 'type', 'config'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def __init__(self, *args, **kwargs):
+ ElementBase.__init__(self, *args, **kwargs)
+
+ def getType(self):
+ t = self._getAttr('type')
+ if not t: t = 'leaf'
+ return t
+
+ def getConfig(self):
+ return self['form']
+
+ def setConfig(self, value):
+ self['form'].setStanzaValues(value.getStanzaValues())
+ return self
+
+registerStanzaPlugin(PubsubOwner, DefaultConfig)
+registerStanzaPlugin(DefaultConfig, xep_0004.Form)
+
+class OwnerAffiliations(Affiliations):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ interfaces = set(('node'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def append(self, affiliation):
+ if not isinstance(affiliation, OwnerAffiliation):
+ raise TypeError
+ self.xml.append(affiliation.xml)
+ return self.affiliations.append(affiliation)
+
+registerStanzaPlugin(PubsubOwner, OwnerAffiliations)
+
+class OwnerAffiliation(Affiliation):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ interfaces = set(('affiliation', 'jid'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+class OwnerConfigure(Configure):
+ name = 'configure'
+ plugin_attrib = 'configure'
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ interfaces = set(('node', 'config'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def getConfig(self):
+ return self['form']
+
+ def setConfig(self, value):
+ self['form'].setStanzaValues(value.getStanzaValues())
+ return self
+
+registerStanzaPlugin(PubsubOwner, OwnerConfigure)
+
+class OwnerDefault(OwnerConfigure):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ interfaces = set(('node', 'config'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+
+registerStanzaPlugin(PubsubOwner, OwnerDefault)
+registerStanzaPlugin(OwnerDefault, xep_0004.Form)
+
+class OwnerDelete(ElementBase, OptionalSetting):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ name = 'delete'
+ plugin_attrib = 'delete'
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+ interfaces = set(('node',))
+
+registerStanzaPlugin(PubsubOwner, OwnerDelete)
+
+class OwnerPurge(ElementBase, OptionalSetting):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ name = 'purge'
+ plugin_attrib = name
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+registerStanzaPlugin(PubsubOwner, OwnerPurge)
+
+class OwnerRedirect(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ name = 'redirect'
+ plugin_attrib = name
+ interfaces = set(('node', 'jid'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setJid(self, value):
+ self._setAttr('jid', str(value))
+
+ def getJid(self):
+ return JID(self._getAttr('jid'))
+
+registerStanzaPlugin(OwnerDelete, OwnerRedirect)
+
+class OwnerSubscriptions(Subscriptions):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ interfaces = set(('node',))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def append(self, subscription):
+ if not isinstance(subscription, OwnerSubscription):
+ raise TypeError
+ self.xml.append(subscription.xml)
+ return self.subscriptions.append(subscription)
+
+registerStanzaPlugin(PubsubOwner, OwnerSubscriptions)
+
+class OwnerSubscription(ElementBase):
+ namespace = 'http://jabber.org/protocol/pubsub#owner'
+ name = 'subscription'
+ plugin_attrib = name
+ interfaces = set(('jid', 'subscription'))
+ plugin_attrib_map = {}
+ plugin_tag_map = {}
+
+ def setJid(self, value):
+ self._setAttr('jid', str(value))
+
+ def getJid(self):
+ return JID(self._getAttr('from'))
diff --git a/sleekxmpp/plugins/xep_0082.py b/sleekxmpp/plugins/xep_0082.py
index 785ba36b..d3c4cc56 100644
--- a/sleekxmpp/plugins/xep_0082.py
+++ b/sleekxmpp/plugins/xep_0082.py
@@ -6,10 +6,11 @@
See the file LICENSE for copying permission.
"""
+import logging
import datetime as dt
-from dateutil import parser
-from dateutil.tz import tzoffset, tzutc
+
from sleekxmpp.plugins.base import base_plugin
+from sleekxmpp.thirdparty import tzutc, tzoffset, parse_iso
# =====================================================================
@@ -24,7 +25,8 @@ def parse(time_str):
Arguments:
time_str -- A formatted timestamp string.
"""
- return parser.parse(time_str)
+ return parse_iso(time_str)
+
def format_date(time_obj):
"""
@@ -45,7 +47,7 @@ def format_time(time_obj):
Return a formatted string version of a time object.
format:
- hh:mm:ss[.sss][TZD
+ hh:mm:ss[.sss][TZD]
arguments:
time_obj -- A time or datetime object.
diff --git a/sleekxmpp/plugins/xep_0202/__init__.py b/sleekxmpp/plugins/xep_0202/__init__.py
index 82338d3a..a34b2376 100644
--- a/sleekxmpp/plugins/xep_0202/__init__.py
+++ b/sleekxmpp/plugins/xep_0202/__init__.py
@@ -6,6 +6,7 @@
See the file LICENSE for copying permission.
"""
+
from sleekxmpp.plugins.xep_0202 import stanza
from sleekxmpp.plugins.xep_0202.stanza import EntityTime
from sleekxmpp.plugins.xep_0202.time import xep_0202
diff --git a/sleekxmpp/plugins/xep_0202/stanza.py b/sleekxmpp/plugins/xep_0202/stanza.py
index bb27692a..b6ccc960 100644
--- a/sleekxmpp/plugins/xep_0202/stanza.py
+++ b/sleekxmpp/plugins/xep_0202/stanza.py
@@ -6,11 +6,12 @@
See the file LICENSE for copying permission.
"""
+import logging
import datetime as dt
-from dateutil.tz import tzoffset, tzutc
from sleekxmpp.xmlstream import ElementBase
from sleekxmpp.plugins import xep_0082
+from sleekxmpp.thirdparty import tzutc, tzoffset
class EntityTime(ElementBase):