mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
Clean up pubsub#owner stanzas.
This commit is contained in:
parent
7e5e9542e9
commit
d6b0158ddb
1 changed files with 39 additions and 56 deletions
|
@ -1,147 +1,130 @@
|
||||||
from sleekxmpp.xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET, JID
|
"""
|
||||||
from sleekxmpp.stanza.iq import Iq
|
SleekXMPP: The Sleek XMPP Library
|
||||||
from sleekxmpp.stanza.message import Message
|
Copyright (C) 2011 Nathanael C. Fritz
|
||||||
from sleekxmpp.basexmpp import basexmpp
|
This file is part of SleekXMPP.
|
||||||
from sleekxmpp.xmlstream.xmlstream import XMLStream
|
|
||||||
import logging
|
See the file LICENSE for copying permission.
|
||||||
from sleekxmpp.plugins import xep_0004
|
"""
|
||||||
|
|
||||||
|
from sleekxmpp import Iq
|
||||||
|
from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase, ET, JID
|
||||||
|
from sleekxmpp.plugins.xep_0004 import Form
|
||||||
from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
|
from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
|
||||||
from sleekxmpp.plugins.xep_0060.stanza.pubsub import Affiliations, Affiliation, Configure, Subscriptions
|
from sleekxmpp.plugins.xep_0060.stanza.pubsub import Affiliations, Affiliation, Configure, Subscriptions
|
||||||
|
|
||||||
|
|
||||||
class PubsubOwner(ElementBase):
|
class PubsubOwner(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
name = 'pubsub'
|
name = 'pubsub'
|
||||||
plugin_attrib = 'pubsub_owner'
|
plugin_attrib = 'pubsub_owner'
|
||||||
interfaces = set(tuple())
|
interfaces = set(tuple())
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(Iq, PubsubOwner)
|
|
||||||
|
|
||||||
class DefaultConfig(ElementBase):
|
class DefaultConfig(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
name = 'default'
|
name = 'default'
|
||||||
plugin_attrib = 'default'
|
plugin_attrib = 'default'
|
||||||
interfaces = set(('node', 'config'))
|
interfaces = set(('node', 'config'))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
ElementBase.__init__(self, *args, **kwargs)
|
ElementBase.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
def getConfig(self):
|
def get_config(self):
|
||||||
return self['form']
|
return self['form']
|
||||||
|
|
||||||
def setConfig(self, value):
|
def set_config(self, value):
|
||||||
self['form'].setStanzaValues(value.getStanzaValues())
|
self['form'].values = value.values
|
||||||
return self
|
return self
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, DefaultConfig)
|
|
||||||
registerStanzaPlugin(DefaultConfig, xep_0004.Form)
|
|
||||||
|
|
||||||
class OwnerAffiliations(Affiliations):
|
class OwnerAffiliations(Affiliations):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
def append(self, affiliation):
|
def append(self, affiliation):
|
||||||
if not isinstance(affiliation, OwnerAffiliation):
|
if not isinstance(affiliation, OwnerAffiliation):
|
||||||
raise TypeError
|
raise TypeError
|
||||||
self.xml.append(affiliation.xml)
|
self.xml.append(affiliation.xml)
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerAffiliations)
|
|
||||||
|
|
||||||
class OwnerAffiliation(Affiliation):
|
class OwnerAffiliation(Affiliation):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
interfaces = set(('affiliation', 'jid'))
|
interfaces = set(('affiliation', 'jid'))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(OwnerAffiliations, OwnerAffiliation, iterable=True)
|
|
||||||
|
|
||||||
class OwnerConfigure(Configure):
|
class OwnerConfigure(Configure):
|
||||||
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
name = 'configure'
|
name = 'configure'
|
||||||
plugin_attrib = 'configure'
|
plugin_attrib = 'configure'
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerConfigure)
|
|
||||||
registerStanzaPlugin(OwnerConfigure, xep_0004.Form)
|
|
||||||
|
|
||||||
class OwnerDefault(OwnerConfigure):
|
class OwnerDefault(OwnerConfigure):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerDefault)
|
|
||||||
registerStanzaPlugin(OwnerDefault, xep_0004.Form)
|
|
||||||
|
|
||||||
class OwnerDelete(ElementBase, OptionalSetting):
|
class OwnerDelete(ElementBase, OptionalSetting):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
name = 'delete'
|
name = 'delete'
|
||||||
plugin_attrib = 'delete'
|
plugin_attrib = 'delete'
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerDelete)
|
|
||||||
|
|
||||||
class OwnerPurge(ElementBase, OptionalSetting):
|
class OwnerPurge(ElementBase, OptionalSetting):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
name = 'purge'
|
name = 'purge'
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerPurge)
|
|
||||||
|
|
||||||
class OwnerRedirect(ElementBase):
|
class OwnerRedirect(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
name = 'redirect'
|
name = 'redirect'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node', 'jid'))
|
interfaces = set(('node', 'jid'))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
def setJid(self, value):
|
def set_jid(self, value):
|
||||||
self._setAttr('jid', str(value))
|
self._set_attr('jid', str(value))
|
||||||
|
|
||||||
def getJid(self):
|
def get_jid(self):
|
||||||
return JID(self._getAttr('jid'))
|
return JID(self._get_attr('jid'))
|
||||||
|
|
||||||
registerStanzaPlugin(OwnerDelete, OwnerRedirect)
|
|
||||||
|
|
||||||
class OwnerSubscriptions(Subscriptions):
|
class OwnerSubscriptions(Subscriptions):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
def append(self, subscription):
|
def append(self, subscription):
|
||||||
if not isinstance(subscription, OwnerSubscription):
|
if not isinstance(subscription, OwnerSubscription):
|
||||||
raise TypeError
|
raise TypeError
|
||||||
self.xml.append(subscription.xml)
|
self.xml.append(subscription.xml)
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerSubscriptions)
|
|
||||||
|
|
||||||
class OwnerSubscription(ElementBase):
|
class OwnerSubscription(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
name = 'subscription'
|
name = 'subscription'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('jid', 'subscription'))
|
interfaces = set(('jid', 'subscription'))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
def setJid(self, value):
|
def set_jid(self, value):
|
||||||
self._setAttr('jid', str(value))
|
self._set_attr('jid', str(value))
|
||||||
|
|
||||||
def getJid(self):
|
def get_jid(self):
|
||||||
return JID(self._getAttr('jid'))
|
return JID(self._get_attr('jid'))
|
||||||
|
|
||||||
registerStanzaPlugin(OwnerSubscriptions, OwnerSubscription, iterable=True)
|
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in a new issue