2011-09-01 20:47:55 +00:00
|
|
|
"""
|
|
|
|
SleekXMPP: The Sleek XMPP Library
|
|
|
|
Copyright (C) 2011 Nathanael C. Fritz
|
|
|
|
This file is part of SleekXMPP.
|
|
|
|
|
|
|
|
See the file LICENSE for copying permission.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from sleekxmpp import Iq
|
|
|
|
from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase, ET, JID
|
|
|
|
from sleekxmpp.plugins.xep_0004 import Form
|
2011-08-04 18:38:14 +00:00
|
|
|
from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
|
2011-09-01 21:03:11 +00:00
|
|
|
from sleekxmpp.plugins.xep_0060.stanza.pubsub import Affiliations, Affiliation
|
|
|
|
from sleekxmpp.plugins.xep_0060.stanza.pubsub import Configure, Subscriptions
|
2011-08-04 06:56:24 +00:00
|
|
|
|
2011-09-01 20:47:55 +00:00
|
|
|
|
2011-08-04 06:56:24 +00:00
|
|
|
class PubsubOwner(ElementBase):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'pubsub'
|
|
|
|
plugin_attrib = 'pubsub_owner'
|
|
|
|
interfaces = set(tuple())
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DefaultConfig(ElementBase):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'default'
|
2011-09-01 21:03:11 +00:00
|
|
|
plugin_attrib = name
|
2011-08-31 17:43:33 +00:00
|
|
|
interfaces = set(('node', 'config'))
|
2011-08-04 18:38:14 +00:00
|
|
|
|
2011-08-12 23:35:36 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
ElementBase.__init__(self, *args, **kwargs)
|
2011-08-04 06:56:24 +00:00
|
|
|
|
2011-09-01 20:47:55 +00:00
|
|
|
def get_config(self):
|
2011-08-12 23:35:36 +00:00
|
|
|
return self['form']
|
2011-08-04 18:38:14 +00:00
|
|
|
|
2011-09-01 20:47:55 +00:00
|
|
|
def set_config(self, value):
|
2013-02-14 09:24:09 +00:00
|
|
|
del self['from']
|
|
|
|
self.append(value)
|
2011-08-12 23:35:36 +00:00
|
|
|
return self
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OwnerAffiliations(Affiliations):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
2011-09-01 19:08:35 +00:00
|
|
|
interfaces = set(('node',))
|
2011-08-04 18:38:14 +00:00
|
|
|
|
2011-08-12 23:35:36 +00:00
|
|
|
def append(self, affiliation):
|
|
|
|
if not isinstance(affiliation, OwnerAffiliation):
|
|
|
|
raise TypeError
|
|
|
|
self.xml.append(affiliation.xml)
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OwnerAffiliation(Affiliation):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
interfaces = set(('affiliation', 'jid'))
|
2011-08-04 06:56:24 +00:00
|
|
|
|
2011-09-01 19:08:35 +00:00
|
|
|
|
2011-08-04 06:56:24 +00:00
|
|
|
class OwnerConfigure(Configure):
|
2011-09-01 20:47:55 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
2011-08-12 23:32:09 +00:00
|
|
|
name = 'configure'
|
2011-09-01 21:03:11 +00:00
|
|
|
plugin_attrib = name
|
2011-08-31 21:05:29 +00:00
|
|
|
interfaces = set(('node',))
|
2011-08-31 17:43:33 +00:00
|
|
|
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
class OwnerDefault(OwnerConfigure):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
2011-09-01 04:09:25 +00:00
|
|
|
interfaces = set(('node',))
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OwnerDelete(ElementBase, OptionalSetting):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'delete'
|
2011-09-01 21:03:11 +00:00
|
|
|
plugin_attrib = name
|
2011-08-12 23:35:36 +00:00
|
|
|
interfaces = set(('node',))
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OwnerPurge(ElementBase, OptionalSetting):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'purge'
|
|
|
|
plugin_attrib = name
|
2011-09-01 21:03:11 +00:00
|
|
|
interfaces = set(('node',))
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OwnerRedirect(ElementBase):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'redirect'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('node', 'jid'))
|
2011-08-04 18:38:14 +00:00
|
|
|
|
2011-09-01 20:47:55 +00:00
|
|
|
def set_jid(self, value):
|
|
|
|
self._set_attr('jid', str(value))
|
2011-08-04 18:38:14 +00:00
|
|
|
|
2011-09-01 20:47:55 +00:00
|
|
|
def get_jid(self):
|
|
|
|
return JID(self._get_attr('jid'))
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OwnerSubscriptions(Subscriptions):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
interfaces = set(('node',))
|
2011-08-04 18:38:14 +00:00
|
|
|
|
2011-08-12 23:35:36 +00:00
|
|
|
def append(self, subscription):
|
|
|
|
if not isinstance(subscription, OwnerSubscription):
|
|
|
|
raise TypeError
|
|
|
|
self.xml.append(subscription.xml)
|
2011-08-04 06:56:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OwnerSubscription(ElementBase):
|
2011-08-12 23:35:36 +00:00
|
|
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
|
|
name = 'subscription'
|
|
|
|
plugin_attrib = name
|
|
|
|
interfaces = set(('jid', 'subscription'))
|
2011-09-01 19:08:35 +00:00
|
|
|
|
2011-09-01 20:47:55 +00:00
|
|
|
def set_jid(self, value):
|
|
|
|
self._set_attr('jid', str(value))
|
|
|
|
|
|
|
|
def get_jid(self):
|
|
|
|
return JID(self._get_attr('jid'))
|
|
|
|
|
|
|
|
|
|
|
|
register_stanza_plugin(Iq, PubsubOwner)
|
|
|
|
register_stanza_plugin(PubsubOwner, DefaultConfig)
|
|
|
|
register_stanza_plugin(PubsubOwner, OwnerAffiliations)
|
|
|
|
register_stanza_plugin(PubsubOwner, OwnerConfigure)
|
|
|
|
register_stanza_plugin(PubsubOwner, OwnerDefault)
|
|
|
|
register_stanza_plugin(PubsubOwner, OwnerDelete)
|
|
|
|
register_stanza_plugin(PubsubOwner, OwnerPurge)
|
|
|
|
register_stanza_plugin(PubsubOwner, OwnerSubscriptions)
|
|
|
|
register_stanza_plugin(DefaultConfig, Form)
|
|
|
|
register_stanza_plugin(OwnerAffiliations, OwnerAffiliation, iterable=True)
|
|
|
|
register_stanza_plugin(OwnerConfigure, Form)
|
|
|
|
register_stanza_plugin(OwnerDefault, Form)
|
|
|
|
register_stanza_plugin(OwnerDelete, OwnerRedirect)
|
|
|
|
register_stanza_plugin(OwnerSubscriptions, OwnerSubscription, iterable=True)
|