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

131 lines
3.8 KiB
Python
Raw Normal View History

2011-09-01 13:47:55 -07: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 11:38:14 -07:00
from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
from sleekxmpp.plugins.xep_0060.stanza.pubsub import Affiliations, Affiliation, Configure, Subscriptions
2011-09-01 13:47:55 -07: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'
plugin_attrib = 'default'
interfaces = set(('node', 'config'))
2011-08-04 11:38:14 -07:00
def __init__(self, *args, **kwargs):
ElementBase.__init__(self, *args, **kwargs)
2011-09-01 13:47:55 -07:00
def get_config(self):
return self['form']
2011-08-04 11:38:14 -07:00
2011-09-01 13:47:55 -07: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 11:38:14 -07: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 13:47:55 -07:00
namespace = 'http://jabber.org/protocol/pubsub#owner'
2011-08-12 16:32:09 -07:00
name = 'configure'
plugin_attrib = 'configure'
2011-08-31 14:05:29 -07:00
interfaces = set(('node',))
class OwnerDefault(OwnerConfigure):
namespace = 'http://jabber.org/protocol/pubsub#owner'
2011-08-31 21:09:25 -07:00
interfaces = set(('node',))
class OwnerDelete(ElementBase, OptionalSetting):
namespace = 'http://jabber.org/protocol/pubsub#owner'
name = 'delete'
plugin_attrib = 'delete'
interfaces = set(('node',))
class OwnerPurge(ElementBase, OptionalSetting):
namespace = 'http://jabber.org/protocol/pubsub#owner'
name = 'purge'
2011-08-31 21:09:25 -07:00
interfaces = set(('node',))
plugin_attrib = name
class OwnerRedirect(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
name = 'redirect'
plugin_attrib = name
interfaces = set(('node', 'jid'))
2011-08-04 11:38:14 -07:00
2011-09-01 13:47:55 -07:00
def set_jid(self, value):
self._set_attr('jid', str(value))
2011-08-04 11:38:14 -07:00
2011-09-01 13:47:55 -07: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 11:38:14 -07: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 13:47:55 -07: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)