2010-01-07 23:52:52 +00:00
|
|
|
from .. xmlstream.stanzabase import ElementBase, ET, JID
|
2010-01-05 21:56:48 +00:00
|
|
|
from .. stanza.iq import Iq
|
2010-04-20 07:53:13 +00:00
|
|
|
from .. stanza.message import Message
|
2010-01-05 21:56:48 +00:00
|
|
|
from .. basexmpp import basexmpp
|
|
|
|
from .. xmlstream.xmlstream import XMLStream
|
2010-04-19 08:03:27 +00:00
|
|
|
import logging
|
2010-01-05 21:56:48 +00:00
|
|
|
from . import xep_0004
|
|
|
|
|
|
|
|
def stanzaPlugin(stanza, plugin):
|
2010-01-08 01:45:11 +00:00
|
|
|
stanza.plugin_attrib_map[plugin.plugin_attrib] = plugin
|
|
|
|
stanza.plugin_tag_map["{%s}%s" % (plugin.namespace, plugin.name)] = plugin
|
2010-01-05 21:56:48 +00:00
|
|
|
|
2010-05-27 11:58:57 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
stanzaPlugin(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 = {}
|
|
|
|
|
2010-05-31 10:36:25 +00:00
|
|
|
stanzaPlugin(Message, PubsubStateEvent)
|
|
|
|
stanzaPlugin(PubsubStateEvent, PubsubState)
|
2010-05-27 11:58:57 +00:00
|
|
|
|
2010-01-05 21:56:48 +00:00
|
|
|
class Pubsub(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'pubsub'
|
|
|
|
plugin_attrib = 'pubsub'
|
2010-01-07 23:52:52 +00:00
|
|
|
interfaces = set(tuple())
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-05 21:56:48 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Iq, Pubsub)
|
|
|
|
|
2010-01-07 23:52:52 +00:00
|
|
|
class PubsubOwner(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
2010-01-08 01:45:11 +00:00
|
|
|
name = 'pubsub'
|
|
|
|
plugin_attrib = 'pubsub_owner'
|
2010-01-07 23:52:52 +00:00
|
|
|
interfaces = set(tuple())
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Iq, PubsubOwner)
|
|
|
|
|
2010-01-08 01:45:11 +00:00
|
|
|
class Affiliation(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'affiliation'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node', 'affiliation'))
|
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
|
|
|
|
2010-01-05 21:56:48 +00:00
|
|
|
class Affiliations(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'affiliations'
|
|
|
|
plugin_attrib = 'affiliations'
|
|
|
|
interfaces = set(tuple())
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-04-22 06:51:37 +00:00
|
|
|
subitem = (Affiliation,)
|
2010-01-05 21:56:48 +00:00
|
|
|
|
|
|
|
def append(self, affiliation):
|
|
|
|
if not isinstance(affiliation, Affiliation):
|
|
|
|
raise TypeError
|
|
|
|
self.xml.append(affiliation.xml)
|
2010-01-08 01:45:11 +00:00
|
|
|
return self.iterables.append(affiliation)
|
|
|
|
|
2010-01-05 21:56:48 +00:00
|
|
|
stanzaPlugin(Pubsub, Affiliations)
|
|
|
|
|
2010-01-13 17:04:05 +00:00
|
|
|
|
|
|
|
class Subscription(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'subscription'
|
|
|
|
plugin_attrib = name
|
2010-01-16 05:07:28 +00:00
|
|
|
interfaces = set(('jid', 'node', 'subscription', 'subid'))
|
2010-01-13 17:04:05 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
|
|
|
|
2010-04-22 06:51:37 +00:00
|
|
|
def setjid(self, value):
|
|
|
|
self._setattr('jid', str(value))
|
2010-01-13 17:04:05 +00:00
|
|
|
|
2010-04-22 06:51:37 +00:00
|
|
|
def getjid(self):
|
|
|
|
return jid(self._getattr('jid'))
|
2010-01-13 17:04:05 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Pubsub, Subscription)
|
|
|
|
|
2010-01-07 23:52:52 +00:00
|
|
|
class Subscriptions(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'subscriptions'
|
|
|
|
plugin_attrib = 'subscriptions'
|
|
|
|
interfaces = set(tuple())
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-04-22 06:51:37 +00:00
|
|
|
subitem = (Subscription,)
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Pubsub, Subscriptions)
|
|
|
|
|
|
|
|
class OptionalSetting(object):
|
2010-01-13 17:04:05 +00:00
|
|
|
interfaces = set(('required',))
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
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'
|
2010-01-13 17:04:05 +00:00
|
|
|
plugin_attrib = 'suboptions'
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-13 17:04:05 +00:00
|
|
|
interfaces = set(('required',))
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Subscription, SubscribeOptions)
|
|
|
|
|
2010-01-05 21:56:48 +00:00
|
|
|
class Item(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
2010-01-07 23:52:52 +00:00
|
|
|
name = 'item'
|
2010-01-05 21:56:48 +00:00
|
|
|
plugin_attrib = name
|
2010-01-07 23:52:52 +00:00
|
|
|
interfaces = set(('id', 'payload'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2010-01-13 17:04:05 +00:00
|
|
|
class Items(ElementBase):
|
2010-01-07 23:52:52 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
2010-01-13 17:04:05 +00:00
|
|
|
name = 'items'
|
|
|
|
plugin_attrib = 'items'
|
|
|
|
interfaces = set(tuple())
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-04-22 06:51:37 +00:00
|
|
|
subitem = (Item,)
|
2010-01-07 23:52:52 +00:00
|
|
|
|
2010-01-13 17:04:05 +00:00
|
|
|
stanzaPlugin(Pubsub, Items)
|
2010-01-07 23:52:52 +00:00
|
|
|
|
2010-01-13 17:04:05 +00:00
|
|
|
class Create(ElementBase):
|
2010-01-07 23:52:52 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
2010-01-13 17:04:05 +00:00
|
|
|
name = 'create'
|
2010-01-07 23:52:52 +00:00
|
|
|
plugin_attrib = name
|
2010-01-13 17:04:05 +00:00
|
|
|
interfaces = set(('node',))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
2010-01-13 17:04:05 +00:00
|
|
|
stanzaPlugin(Pubsub, Create)
|
2010-01-07 23:52:52 +00:00
|
|
|
|
2010-01-13 17:04:05 +00:00
|
|
|
#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
|
|
|
|
#
|
|
|
|
#stanzaPlugin(Pubsub, Default)
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
class Publish(Items):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'publish'
|
|
|
|
plugin_attrib = name
|
2010-01-16 05:07:28 +00:00
|
|
|
interfaces = set(('node',))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-04-22 06:51:37 +00:00
|
|
|
subitem = (Item,)
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Pubsub, Publish)
|
|
|
|
|
|
|
|
class Retract(Items):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'retract'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node', 'notify'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Pubsub, Retract)
|
|
|
|
|
|
|
|
class Unsubscribe(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'unsubscribe'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node', 'jid'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
def setJid(self, value):
|
|
|
|
self._setAttr('jid', str(value))
|
|
|
|
|
|
|
|
def getJid(self):
|
2010-04-22 06:51:37 +00:00
|
|
|
return JID(self._getAttr('jid'))
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
class Subscribe(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'subscribe'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node', 'jid'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
def setJid(self, value):
|
|
|
|
self._setAttr('jid', str(value))
|
|
|
|
|
|
|
|
def getJid(self):
|
2010-01-13 17:04:05 +00:00
|
|
|
return JID(self._getAttr('jid'))
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Pubsub, Subscribe)
|
|
|
|
|
|
|
|
class Configure(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'configure'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node', 'type', 'config'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
def getType(self):
|
|
|
|
t = self._getAttr('type')
|
|
|
|
if not t: t == 'leaf'
|
|
|
|
return t
|
|
|
|
|
|
|
|
def getConfig(self):
|
|
|
|
config = self.xml.find('{jabber:x:data}x')
|
|
|
|
form = xep_0004.Form()
|
|
|
|
if config is not None:
|
|
|
|
form.fromXML(config)
|
|
|
|
return form
|
|
|
|
|
|
|
|
def setConfig(self, value):
|
|
|
|
self.xml.append(value.getXML())
|
|
|
|
return self
|
|
|
|
|
|
|
|
def delConfig(self):
|
|
|
|
config = self.xml.find('{jabber:x:data}x')
|
|
|
|
self.xml.remove(config)
|
|
|
|
|
|
|
|
stanzaPlugin(Pubsub, Configure)
|
|
|
|
|
2010-01-05 21:56:48 +00:00
|
|
|
class DefaultConfig(ElementBase):
|
2010-04-14 02:48:35 +00:00
|
|
|
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 getConfig(self):
|
|
|
|
config = self.xml.find('{jabber:x:data}x')
|
|
|
|
form = xep_0004.Form()
|
|
|
|
if config is not None:
|
|
|
|
form.fromXML(config)
|
|
|
|
return form
|
|
|
|
|
|
|
|
def setConfig(self, value):
|
|
|
|
self.xml.append(value.getXML())
|
|
|
|
return self
|
|
|
|
|
|
|
|
def delConfig(self):
|
|
|
|
config = self.xml.find('{jabber:x:data}x')
|
|
|
|
self.xml.remove(config)
|
|
|
|
|
|
|
|
def getType(self):
|
|
|
|
t = self._getAttr('type')
|
2010-05-25 02:33:24 +00:00
|
|
|
if not t: t = 'leaf'
|
2010-04-14 02:48:35 +00:00
|
|
|
return t
|
|
|
|
|
|
|
|
stanzaPlugin(PubsubOwner, DefaultConfig)
|
|
|
|
|
2010-01-07 23:52:52 +00:00
|
|
|
class Options(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub'
|
|
|
|
name = 'options'
|
|
|
|
plugin_attrib = 'options'
|
|
|
|
interfaces = set(('jid', 'node', 'options'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
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):
|
2010-01-13 17:04:05 +00:00
|
|
|
return JID(self._getAttr('jid'))
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Pubsub, Options)
|
2010-01-13 17:04:05 +00:00
|
|
|
stanzaPlugin(Subscribe, Options)
|
2010-01-08 01:45:11 +00:00
|
|
|
|
2010-01-05 21:56:48 +00:00
|
|
|
class OwnerAffiliations(Affiliations):
|
2010-01-07 23:52:52 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
interfaces = set(('node'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
def append(self, affiliation):
|
|
|
|
if not isinstance(affiliation, OwnerAffiliation):
|
|
|
|
raise TypeError
|
|
|
|
self.xml.append(affiliation.xml)
|
|
|
|
return self.affiliations.append(affiliation)
|
|
|
|
|
|
|
|
stanzaPlugin(PubsubOwner, OwnerAffiliations)
|
|
|
|
|
|
|
|
class OwnerAffiliation(Affiliation):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
interfaces = set(('affiliation', 'jid'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
class OwnerConfigure(Configure):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
interfaces = set(('node', 'config'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(PubsubOwner, OwnerConfigure)
|
|
|
|
|
|
|
|
class OwnerDefault(OwnerConfigure):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
interfaces = set(('node', 'config'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-05 21:56:48 +00:00
|
|
|
|
2010-01-07 23:52:52 +00:00
|
|
|
stanzaPlugin(PubsubOwner, OwnerDefault)
|
|
|
|
|
|
|
|
class OwnerDelete(ElementBase, OptionalSetting):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'delete'
|
|
|
|
plugin_attrib = 'delete'
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-04-14 08:23:17 +00:00
|
|
|
interfaces = set(('node',))
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(PubsubOwner, OwnerDelete)
|
|
|
|
|
|
|
|
class OwnerPurge(ElementBase, OptionalSetting):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'purge'
|
|
|
|
plugin_attrib = name
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(PubsubOwner, OwnerPurge)
|
|
|
|
|
|
|
|
class OwnerRedirect(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'redirect'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node', 'jid'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
def setJid(self, value):
|
|
|
|
self._setAttr('jid', str(value))
|
|
|
|
|
|
|
|
def getJid(self):
|
2010-04-22 06:51:37 +00:00
|
|
|
return JID(self._getAttr('jid'))
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
stanzaPlugin(OwnerDelete, OwnerRedirect)
|
|
|
|
|
|
|
|
class OwnerSubscriptions(Subscriptions):
|
2010-01-05 21:56:48 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
2010-01-07 23:52:52 +00:00
|
|
|
interfaces = set(('node',))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
def append(self, subscription):
|
|
|
|
if not isinstance(subscription, OwnerSubscription):
|
|
|
|
raise TypeError
|
|
|
|
self.xml.append(subscription.xml)
|
|
|
|
return self.subscriptions.append(subscription)
|
|
|
|
|
|
|
|
stanzaPlugin(PubsubOwner, OwnerSubscriptions)
|
2010-01-05 21:56:48 +00:00
|
|
|
|
2010-01-07 23:52:52 +00:00
|
|
|
class OwnerSubscription(ElementBase):
|
2010-01-05 21:56:48 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
2010-01-07 23:52:52 +00:00
|
|
|
name = 'subscription'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('jid', 'subscription'))
|
2010-01-08 01:45:11 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-01-07 23:52:52 +00:00
|
|
|
|
|
|
|
def setJid(self, value):
|
|
|
|
self._setAttr('jid', str(value))
|
|
|
|
|
|
|
|
def getJid(self):
|
|
|
|
return JID(self._getAttr('from'))
|
2010-04-20 07:53:13 +00:00
|
|
|
|
|
|
|
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 = {}
|
|
|
|
|
|
|
|
stanzaPlugin(Message, Event)
|
|
|
|
|
2010-04-22 06:51:37 +00:00
|
|
|
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 = {}
|
|
|
|
|
2010-04-20 07:53:13 +00:00
|
|
|
class EventItems(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
|
|
|
name = 'items'
|
|
|
|
plugin_attrib = 'items'
|
2010-04-22 06:51:37 +00:00
|
|
|
interfaces = set(('node',))
|
2010-04-20 07:53:13 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
2010-04-22 06:51:37 +00:00
|
|
|
subitem = (EventItem, EventRetract)
|
2010-04-20 07:53:13 +00:00
|
|
|
|
|
|
|
stanzaPlugin(Event, EventItems)
|
|
|
|
|
2010-04-22 06:51:37 +00:00
|
|
|
class EventCollection(ElementBase):
|
2010-04-20 07:53:13 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
2010-04-22 06:51:37 +00:00
|
|
|
name = 'collection'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node',))
|
2010-04-20 07:53:13 +00:00
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
|
|
|
|
2010-04-22 06:51:37 +00:00
|
|
|
stanzaPlugin(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 = {}
|
|
|
|
|
|
|
|
stanzaPlugin(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 = {}
|
|
|
|
|
|
|
|
stanzaPlugin(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 = {}
|
|
|
|
|
|
|
|
def getConfig(self):
|
|
|
|
config = self.xml.find('{jabber:x:data}x')
|
|
|
|
form = xep_0004.Form()
|
|
|
|
if config is not None:
|
|
|
|
form.fromXML(config)
|
|
|
|
return form
|
|
|
|
|
|
|
|
def setConfig(self, value):
|
|
|
|
self.xml.append(value.getXML())
|
|
|
|
return self
|
|
|
|
|
|
|
|
def delConfig(self):
|
|
|
|
config = self.xml.find('{jabber:x:data}x')
|
|
|
|
self.xml.remove(config)
|
|
|
|
|
|
|
|
stanzaPlugin(Event, EventConfiguration)
|
|
|
|
|
|
|
|
class EventPurge(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
|
|
|
name = 'purge'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node',))
|
|
|
|
plugin_attrib_map = {}
|
|
|
|
plugin_tag_map = {}
|
|
|
|
|
|
|
|
stanzaPlugin(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'))
|
|
|
|
|
|
|
|
stanzaPlugin(Event, EventSubscription)
|