mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 11:09:56 +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
|
||||
from sleekxmpp.stanza.message import Message
|
||||
from sleekxmpp.basexmpp import basexmpp
|
||||
from sleekxmpp.xmlstream.xmlstream import XMLStream
|
||||
import logging
|
||||
from sleekxmpp.plugins import xep_0004
|
||||
"""
|
||||
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
|
||||
from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
|
||||
from sleekxmpp.plugins.xep_0060.stanza.pubsub import Affiliations, Affiliation, Configure, Subscriptions
|
||||
|
||||
|
||||
class PubsubOwner(ElementBase):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'pubsub'
|
||||
plugin_attrib = 'pubsub_owner'
|
||||
interfaces = set(tuple())
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
registerStanzaPlugin(Iq, PubsubOwner)
|
||||
|
||||
class DefaultConfig(ElementBase):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'default'
|
||||
plugin_attrib = 'default'
|
||||
interfaces = set(('node', 'config'))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
ElementBase.__init__(self, *args, **kwargs)
|
||||
|
||||
def getConfig(self):
|
||||
def get_config(self):
|
||||
return self['form']
|
||||
|
||||
def setConfig(self, value):
|
||||
self['form'].setStanzaValues(value.getStanzaValues())
|
||||
def set_config(self, value):
|
||||
self['form'].values = value.values
|
||||
return self
|
||||
|
||||
registerStanzaPlugin(PubsubOwner, DefaultConfig)
|
||||
registerStanzaPlugin(DefaultConfig, xep_0004.Form)
|
||||
|
||||
class OwnerAffiliations(Affiliations):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
interfaces = set(('node',))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
def append(self, affiliation):
|
||||
if not isinstance(affiliation, OwnerAffiliation):
|
||||
raise TypeError
|
||||
self.xml.append(affiliation.xml)
|
||||
|
||||
registerStanzaPlugin(PubsubOwner, OwnerAffiliations)
|
||||
|
||||
class OwnerAffiliation(Affiliation):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
interfaces = set(('affiliation', 'jid'))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
registerStanzaPlugin(OwnerAffiliations, OwnerAffiliation, iterable=True)
|
||||
|
||||
class OwnerConfigure(Configure):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'configure'
|
||||
plugin_attrib = 'configure'
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
interfaces = set(('node',))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
registerStanzaPlugin(PubsubOwner, OwnerConfigure)
|
||||
registerStanzaPlugin(OwnerConfigure, xep_0004.Form)
|
||||
|
||||
class OwnerDefault(OwnerConfigure):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
interfaces = set(('node',))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
|
||||
registerStanzaPlugin(PubsubOwner, OwnerDefault)
|
||||
registerStanzaPlugin(OwnerDefault, xep_0004.Form)
|
||||
|
||||
class OwnerDelete(ElementBase, OptionalSetting):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'delete'
|
||||
plugin_attrib = 'delete'
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
interfaces = set(('node',))
|
||||
|
||||
registerStanzaPlugin(PubsubOwner, OwnerDelete)
|
||||
|
||||
class OwnerPurge(ElementBase, OptionalSetting):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'purge'
|
||||
interfaces = set(('node',))
|
||||
plugin_attrib = name
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
registerStanzaPlugin(PubsubOwner, OwnerPurge)
|
||||
|
||||
class OwnerRedirect(ElementBase):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'redirect'
|
||||
plugin_attrib = name
|
||||
interfaces = set(('node', 'jid'))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
def setJid(self, value):
|
||||
self._setAttr('jid', str(value))
|
||||
def set_jid(self, value):
|
||||
self._set_attr('jid', str(value))
|
||||
|
||||
def getJid(self):
|
||||
return JID(self._getAttr('jid'))
|
||||
def get_jid(self):
|
||||
return JID(self._get_attr('jid'))
|
||||
|
||||
registerStanzaPlugin(OwnerDelete, OwnerRedirect)
|
||||
|
||||
class OwnerSubscriptions(Subscriptions):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
interfaces = set(('node',))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
def append(self, subscription):
|
||||
if not isinstance(subscription, OwnerSubscription):
|
||||
raise TypeError
|
||||
self.xml.append(subscription.xml)
|
||||
|
||||
registerStanzaPlugin(PubsubOwner, OwnerSubscriptions)
|
||||
|
||||
class OwnerSubscription(ElementBase):
|
||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||
name = 'subscription'
|
||||
plugin_attrib = name
|
||||
interfaces = set(('jid', 'subscription'))
|
||||
plugin_attrib_map = {}
|
||||
plugin_tag_map = {}
|
||||
|
||||
def setJid(self, value):
|
||||
self._setAttr('jid', str(value))
|
||||
def set_jid(self, value):
|
||||
self._set_attr('jid', str(value))
|
||||
|
||||
def getJid(self):
|
||||
return JID(self._getAttr('jid'))
|
||||
def get_jid(self):
|
||||
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