SleekXMPP/sleekxmpp/plugins/xep_0060/stanza/pubsub_owner.py

132 lines
3.9 KiB
Python
Raw Normal View History

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-09-01 20:47:55 +00:00
class PubsubOwner(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
name = 'pubsub'
plugin_attrib = 'pubsub_owner'
interfaces = set(tuple())
class DefaultConfig(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
name = 'default'
2011-09-01 21:03:11 +00:00
plugin_attrib = name
interfaces = set(('node', 'config'))
2011-08-04 18:38:14 +00:00
def __init__(self, *args, **kwargs):
ElementBase.__init__(self, *args, **kwargs)
2011-09-01 20:47:55 +00:00
def get_config(self):
return self['form']
2011-08-04 18:38:14 +00:00
2011-09-01 20:47:55 +00:00
def set_config(self, value):
self['form'].values = value.values
return self
class OwnerAffiliations(Affiliations):
namespace = 'http://jabber.org/protocol/pubsub#owner'
interfaces = set(('node',))
2011-08-04 18:38:14 +00:00
def append(self, affiliation):
if not isinstance(affiliation, OwnerAffiliation):
raise TypeError
self.xml.append(affiliation.xml)
class OwnerAffiliation(Affiliation):
namespace = 'http://jabber.org/protocol/pubsub#owner'
interfaces = set(('affiliation', 'jid'))
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',))
class OwnerDefault(OwnerConfigure):
namespace = 'http://jabber.org/protocol/pubsub#owner'
2011-09-01 04:09:25 +00:00
interfaces = set(('node',))
class OwnerDelete(ElementBase, OptionalSetting):
namespace = 'http://jabber.org/protocol/pubsub#owner'
name = 'delete'
2011-09-01 21:03:11 +00:00
plugin_attrib = name
interfaces = set(('node',))
class OwnerPurge(ElementBase, OptionalSetting):
namespace = 'http://jabber.org/protocol/pubsub#owner'
name = 'purge'
plugin_attrib = name
2011-09-01 21:03:11 +00:00
interfaces = set(('node',))
class OwnerRedirect(ElementBase):
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'))
class OwnerSubscriptions(Subscriptions):
namespace = 'http://jabber.org/protocol/pubsub#owner'
interfaces = set(('node',))
2011-08-04 18:38:14 +00:00
def append(self, subscription):
if not isinstance(subscription, OwnerSubscription):
raise TypeError
self.xml.append(subscription.xml)
class OwnerSubscription(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
name = 'subscription'
plugin_attrib = name
interfaces = set(('jid', 'subscription'))
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)