mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
fixed indenting and merged in exceptions branch
This commit is contained in:
parent
bd8c110f00
commit
88184ff955
3 changed files with 261 additions and 261 deletions
|
@ -11,13 +11,13 @@ log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class xep_0060(base.base_plugin):
|
class xep_0060(base.base_plugin):
|
||||||
"""
|
"""
|
||||||
XEP-0060 Publish Subscribe
|
XEP-0060 Publish Subscribe
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def plugin_init(self):
|
def plugin_init(self):
|
||||||
self.xep = '0060'
|
self.xep = '0060'
|
||||||
self.description = 'Publish-Subscribe'
|
self.description = 'Publish-Subscribe'
|
||||||
|
|
||||||
def create_node(self, jid, node, config=None, ntype=None):
|
def create_node(self, jid, node, config=None, ntype=None):
|
||||||
iq = IQ(sto=jid, stype='set', sfrom=self.xmpp.jid)
|
iq = IQ(sto=jid, stype='set', sfrom=self.xmpp.jid)
|
||||||
|
@ -26,9 +26,9 @@ class xep_0060(base.base_plugin):
|
||||||
ntype = 'leaf'
|
ntype = 'leaf'
|
||||||
if config is not None:
|
if config is not None:
|
||||||
if 'FORM_TYPE' in submitform.field:
|
if 'FORM_TYPE' in submitform.field:
|
||||||
config.field['FORM_TYPE'].setValue('http://jabber.org/protocol/pubsub#node_config')
|
config.field['FORM_TYPE'].setValue('http://jabber.org/protocol/pubsub#node_config')
|
||||||
else:
|
else:
|
||||||
config.addField('FORM_TYPE', 'hidden', value='http://jabber.org/protocol/pubsub#node_config')
|
config.addField('FORM_TYPE', 'hidden', value='http://jabber.org/protocol/pubsub#node_config')
|
||||||
if 'pubsub#node_type' in submitform.field:
|
if 'pubsub#node_type' in submitform.field:
|
||||||
config.field['pubsub#node_type'].setValue(ntype)
|
config.field['pubsub#node_type'].setValue(ntype)
|
||||||
else:
|
else:
|
||||||
|
@ -48,7 +48,7 @@ class xep_0060(base.base_plugin):
|
||||||
iq['pubsub']['subscribe']['jid'] = subscribee
|
iq['pubsub']['subscribe']['jid'] = subscribee
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def unsubscribe(self, jid, node, subid=None, bare=True, subscribee=None):
|
def unsubscribe(self, jid, node, subid=None, bare=True, subscribee=None):
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
||||||
iq['pubsub']['unsubscribe']['node'] = node
|
iq['pubsub']['unsubscribe']['node'] = node
|
||||||
if subscribee is None:
|
if subscribee is None:
|
||||||
|
@ -62,7 +62,7 @@ class xep_0060(base.base_plugin):
|
||||||
iq['pubsub']['unsubscribe']['subid'] = subid
|
iq['pubsub']['unsubscribe']['subid'] = subid
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def get_node_config(self, jid, node=None): # if no node, then grab default
|
def get_node_config(self, jid, node=None): # if no node, then grab default
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
|
||||||
if node is None:
|
if node is None:
|
||||||
iq['pubsub_owner']['default']
|
iq['pubsub_owner']['default']
|
||||||
|
@ -70,28 +70,28 @@ class xep_0060(base.base_plugin):
|
||||||
iq['pubsub_owner']['configure']['node'] = node
|
iq['pubsub_owner']['configure']['node'] = node
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def get_node_subscriptions(self, jid, node):
|
def get_node_subscriptions(self, jid, node):
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
|
||||||
iq['pubsub_owner']['subscriptions']['node'] = node
|
iq['pubsub_owner']['subscriptions']['node'] = node
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def get_node_affiliations(self, jid, node):
|
def get_node_affiliations(self, jid, node):
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
|
||||||
iq['pubsub_owner']['affiliations']['node'] = node
|
iq['pubsub_owner']['affiliations']['node'] = node
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def delete_node(self, jid, node):
|
def delete_node(self, jid, node):
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='get')
|
||||||
iq['pubsub_owner']['delete']['node'] = node
|
iq['pubsub_owner']['delete']['node'] = node
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def set_node_config(self, jid, node, config):
|
def set_node_config(self, jid, node, config):
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
||||||
iq['pubsub_owner']['configure']['node'] = node
|
iq['pubsub_owner']['configure']['node'] = node
|
||||||
iq['pubsub_owner']['configure']['config'] = config
|
iq['pubsub_owner']['configure']['config'] = config
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def publish(self, jid, node, items=[]):
|
def publish(self, jid, node, items=[]):
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
||||||
iq['pubsub']['publish']['node'] = node
|
iq['pubsub']['publish']['node'] = node
|
||||||
for id, payload in items:
|
for id, payload in items:
|
||||||
|
@ -102,7 +102,7 @@ class xep_0060(base.base_plugin):
|
||||||
iq['pubsub']['publish'].append(item)
|
iq['pubsub']['publish'].append(item)
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def retract(self, jid, node, item):
|
def retract(self, jid, node, item):
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
||||||
iq['pubsub']['retract']['node'] = node
|
iq['pubsub']['retract']['node'] = node
|
||||||
item = stanza.pubsub.Item()
|
item = stanza.pubsub.Item()
|
||||||
|
@ -110,11 +110,11 @@ class xep_0060(base.base_plugin):
|
||||||
iq['pubsub']['retract'].append(item)
|
iq['pubsub']['retract'].append(item)
|
||||||
return iq.send()
|
return iq.send()
|
||||||
|
|
||||||
def get_nodes(self, jid):
|
def get_nodes(self, jid):
|
||||||
return self.xmpp.plugin['xep_0030'].get_items(jid)
|
return self.xmpp.plugin['xep_0030'].get_items(jid)
|
||||||
|
|
||||||
def getItems(self, jid, node):
|
def getItems(self, jid, node):
|
||||||
return self.xmpp.plugin['xep_0030'].get_items(jid, node)
|
return self.xmpp.plugin['xep_0030'].get_items(jid, node)
|
||||||
|
|
||||||
def modify_affiliation(self, jid, node, affiliation, user_jid=None):
|
def modify_affiliation(self, jid, node, affiliation, user_jid=None):
|
||||||
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
iq = IQ(sto=jid, sfrom=self.xmpp.jid, stype='set')
|
||||||
|
|
|
@ -9,236 +9,236 @@ from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
|
||||||
|
|
||||||
|
|
||||||
class Pubsub(ElementBase):
|
class Pubsub(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'pubsub'
|
name = 'pubsub'
|
||||||
plugin_attrib = 'pubsub'
|
plugin_attrib = 'pubsub'
|
||||||
interfaces = set(tuple())
|
interfaces = set(tuple())
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
registerStanzaPlugin(Iq, Pubsub)
|
registerStanzaPlugin(Iq, Pubsub)
|
||||||
|
|
||||||
|
|
||||||
class Affiliation(ElementBase):
|
class Affiliation(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'affiliation'
|
name = 'affiliation'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node', 'affiliation', 'jid'))
|
interfaces = set(('node', 'affiliation', 'jid'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def setJid(self, value):
|
def setJid(self, value):
|
||||||
self._setAttr('jid', str(value))
|
self._setAttr('jid', str(value))
|
||||||
|
|
||||||
def getJid(self):
|
def getJid(self):
|
||||||
return JID(self._getAttr('jid'))
|
return JID(self._getAttr('jid'))
|
||||||
|
|
||||||
class Affiliations(ElementBase):
|
class Affiliations(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'affiliations'
|
name = 'affiliations'
|
||||||
plugin_attrib = 'affiliations'
|
plugin_attrib = 'affiliations'
|
||||||
interfaces = set(tuple())
|
interfaces = set(tuple())
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
subitem = (Affiliation,)
|
subitem = (Affiliation,)
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Affiliations)
|
registerStanzaPlugin(Pubsub, Affiliations)
|
||||||
|
|
||||||
|
|
||||||
class Subscription(ElementBase):
|
class Subscription(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'subscription'
|
name = 'subscription'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('jid', 'node', 'subscription', 'subid'))
|
interfaces = set(('jid', 'node', 'subscription', 'subid'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def setjid(self, value):
|
def setjid(self, value):
|
||||||
self._setattr('jid', str(value))
|
self._setattr('jid', str(value))
|
||||||
|
|
||||||
def getjid(self):
|
def getjid(self):
|
||||||
return jid(self._getattr('jid'))
|
return jid(self._getattr('jid'))
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Subscription)
|
registerStanzaPlugin(Pubsub, Subscription)
|
||||||
|
|
||||||
class Subscriptions(ElementBase):
|
class Subscriptions(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'subscriptions'
|
name = 'subscriptions'
|
||||||
plugin_attrib = 'subscriptions'
|
plugin_attrib = 'subscriptions'
|
||||||
interfaces = set(tuple())
|
interfaces = set(tuple())
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
subitem = (Subscription,)
|
subitem = (Subscription,)
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Subscriptions)
|
registerStanzaPlugin(Pubsub, Subscriptions)
|
||||||
|
|
||||||
|
|
||||||
class SubscribeOptions(ElementBase, OptionalSetting):
|
class SubscribeOptions(ElementBase, OptionalSetting):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'subscribe-options'
|
name = 'subscribe-options'
|
||||||
plugin_attrib = 'suboptions'
|
plugin_attrib = 'suboptions'
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
interfaces = set(('required',))
|
interfaces = set(('required',))
|
||||||
|
|
||||||
registerStanzaPlugin(Subscription, SubscribeOptions)
|
registerStanzaPlugin(Subscription, SubscribeOptions)
|
||||||
|
|
||||||
class Item(ElementBase):
|
class Item(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'item'
|
name = 'item'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('id', 'payload'))
|
interfaces = set(('id', 'payload'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def setPayload(self, value):
|
def setPayload(self, value):
|
||||||
self.xml.append(value)
|
self.xml.append(value)
|
||||||
|
|
||||||
def getPayload(self):
|
def getPayload(self):
|
||||||
childs = self.xml.getchildren()
|
childs = self.xml.getchildren()
|
||||||
if len(childs) > 0:
|
if len(childs) > 0:
|
||||||
return childs[0]
|
return childs[0]
|
||||||
|
|
||||||
def delPayload(self):
|
def delPayload(self):
|
||||||
for child in self.xml.getchildren():
|
for child in self.xml.getchildren():
|
||||||
self.xml.remove(child)
|
self.xml.remove(child)
|
||||||
|
|
||||||
class Items(ElementBase):
|
class Items(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'items'
|
name = 'items'
|
||||||
plugin_attrib = 'items'
|
plugin_attrib = 'items'
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
subitem = (Item,)
|
subitem = (Item,)
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Items)
|
registerStanzaPlugin(Pubsub, Items)
|
||||||
|
|
||||||
class Create(ElementBase):
|
class Create(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'create'
|
name = 'create'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Create)
|
registerStanzaPlugin(Pubsub, Create)
|
||||||
|
|
||||||
#class Default(ElementBase):
|
#class Default(ElementBase):
|
||||||
# namespace = 'http://jabber.org/protocol/pubsub'
|
# namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
# name = 'default'
|
# name = 'default'
|
||||||
# plugin_attrib = name
|
# plugin_attrib = name
|
||||||
# interfaces = set(('node', 'type'))
|
# interfaces = set(('node', 'type'))
|
||||||
# plugin_attrib_map = {}
|
# plugin_attrib_map = {}
|
||||||
# plugin_tag_map = {}
|
# plugin_tag_map = {}
|
||||||
#
|
#
|
||||||
# def getType(self):
|
# def getType(self):
|
||||||
# t = self._getAttr('type')
|
# t = self._getAttr('type')
|
||||||
# if not t: t == 'leaf'
|
# if not t: t == 'leaf'
|
||||||
# return t
|
# return t
|
||||||
#
|
#
|
||||||
#registerStanzaPlugin(Pubsub, Default)
|
#registerStanzaPlugin(Pubsub, Default)
|
||||||
|
|
||||||
class Publish(Items):
|
class Publish(Items):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'publish'
|
name = 'publish'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
subitem = (Item,)
|
subitem = (Item,)
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Publish)
|
registerStanzaPlugin(Pubsub, Publish)
|
||||||
|
|
||||||
class Retract(Items):
|
class Retract(Items):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'retract'
|
name = 'retract'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node', 'notify'))
|
interfaces = set(('node', 'notify'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Retract)
|
registerStanzaPlugin(Pubsub, Retract)
|
||||||
|
|
||||||
class Unsubscribe(ElementBase):
|
class Unsubscribe(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'unsubscribe'
|
name = 'unsubscribe'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node', 'jid', 'subid'))
|
interfaces = set(('node', 'jid', 'subid'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def setJid(self, value):
|
def setJid(self, value):
|
||||||
self._setAttr('jid', str(value))
|
self._setAttr('jid', str(value))
|
||||||
|
|
||||||
def getJid(self):
|
def getJid(self):
|
||||||
return JID(self._getAttr('jid'))
|
return JID(self._getAttr('jid'))
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Unsubscribe)
|
registerStanzaPlugin(Pubsub, Unsubscribe)
|
||||||
|
|
||||||
class Subscribe(ElementBase):
|
class Subscribe(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'subscribe'
|
name = 'subscribe'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node', 'jid'))
|
interfaces = set(('node', 'jid'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def setJid(self, value):
|
def setJid(self, value):
|
||||||
self._setAttr('jid', str(value))
|
self._setAttr('jid', str(value))
|
||||||
|
|
||||||
def getJid(self):
|
def getJid(self):
|
||||||
return JID(self._getAttr('jid'))
|
return JID(self._getAttr('jid'))
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Subscribe)
|
registerStanzaPlugin(Pubsub, Subscribe)
|
||||||
|
|
||||||
class Configure(ElementBase):
|
class Configure(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'configure'
|
name = 'configure'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node', 'type'))
|
interfaces = set(('node', 'type'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def getType(self):
|
def getType(self):
|
||||||
t = self._getAttr('type')
|
t = self._getAttr('type')
|
||||||
if not t: t == 'leaf'
|
if not t: t == 'leaf'
|
||||||
return t
|
return t
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Configure)
|
registerStanzaPlugin(Pubsub, Configure)
|
||||||
registerStanzaPlugin(Configure, xep_0004.Form)
|
registerStanzaPlugin(Configure, xep_0004.Form)
|
||||||
|
|
||||||
class Options(ElementBase):
|
class Options(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub'
|
namespace = 'http://jabber.org/protocol/pubsub'
|
||||||
name = 'options'
|
name = 'options'
|
||||||
plugin_attrib = 'options'
|
plugin_attrib = 'options'
|
||||||
interfaces = set(('jid', 'node', 'options'))
|
interfaces = set(('jid', 'node', 'options'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_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 getOptions(self):
|
def getOptions(self):
|
||||||
config = self.xml.find('{jabber:x:data}x')
|
config = self.xml.find('{jabber:x:data}x')
|
||||||
form = xep_0004.Form()
|
form = xep_0004.Form()
|
||||||
if config is not None:
|
if config is not None:
|
||||||
form.fromXML(config)
|
form.fromXML(config)
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def setOptions(self, value):
|
def setOptions(self, value):
|
||||||
self.xml.append(value.getXML())
|
self.xml.append(value.getXML())
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def delOptions(self):
|
def delOptions(self):
|
||||||
config = self.xml.find('{jabber:x:data}x')
|
config = self.xml.find('{jabber:x:data}x')
|
||||||
self.xml.remove(config)
|
self.xml.remove(config)
|
||||||
|
|
||||||
def setJid(self, value):
|
def setJid(self, value):
|
||||||
self._setAttr('jid', str(value))
|
self._setAttr('jid', str(value))
|
||||||
|
|
||||||
def getJid(self):
|
def getJid(self):
|
||||||
return JID(self._getAttr('jid'))
|
return JID(self._getAttr('jid'))
|
||||||
|
|
||||||
registerStanzaPlugin(Pubsub, Options)
|
registerStanzaPlugin(Pubsub, Options)
|
||||||
registerStanzaPlugin(Subscribe, Options)
|
registerStanzaPlugin(Subscribe, Options)
|
||||||
|
|
|
@ -9,147 +9,147 @@ 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_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
registerStanzaPlugin(Iq, PubsubOwner)
|
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', 'type', 'config'))
|
interfaces = set(('node', 'type', 'config'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_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 getType(self):
|
def getType(self):
|
||||||
t = self._getAttr('type')
|
t = self._getAttr('type')
|
||||||
if not t: t = 'leaf'
|
if not t: t = 'leaf'
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def getConfig(self):
|
def getConfig(self):
|
||||||
return self['form']
|
return self['form']
|
||||||
|
|
||||||
def setConfig(self, value):
|
def setConfig(self, value):
|
||||||
self['form'].setStanzaValues(value.getStanzaValues())
|
self['form'].setStanzaValues(value.getStanzaValues())
|
||||||
return self
|
return self
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, DefaultConfig)
|
registerStanzaPlugin(PubsubOwner, DefaultConfig)
|
||||||
registerStanzaPlugin(DefaultConfig, xep_0004.Form)
|
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_attrib_map = {}
|
||||||
plugin_tag_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)
|
||||||
return self.affiliations.append(affiliation)
|
return self.affiliations.append(affiliation)
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerAffiliations)
|
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_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
class OwnerConfigure(Configure):
|
class OwnerConfigure(Configure):
|
||||||
name = 'configure'
|
name = 'configure'
|
||||||
plugin_attrib = 'configure'
|
plugin_attrib = 'configure'
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
interfaces = set(('node', 'config'))
|
interfaces = set(('node', 'config'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def getConfig(self):
|
def getConfig(self):
|
||||||
return self['form']
|
return self['form']
|
||||||
|
|
||||||
def setConfig(self, value):
|
def setConfig(self, value):
|
||||||
self['form'].setStanzaValues(value.getStanzaValues())
|
self['form'].setStanzaValues(value.getStanzaValues())
|
||||||
return self
|
return self
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerConfigure)
|
registerStanzaPlugin(PubsubOwner, OwnerConfigure)
|
||||||
|
|
||||||
class OwnerDefault(OwnerConfigure):
|
class OwnerDefault(OwnerConfigure):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
namespace = 'http://jabber.org/protocol/pubsub#owner'
|
||||||
interfaces = set(('node', 'config'))
|
interfaces = set(('node', 'config'))
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerDefault)
|
registerStanzaPlugin(PubsubOwner, OwnerDefault)
|
||||||
registerStanzaPlugin(OwnerDefault, xep_0004.Form)
|
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_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerDelete)
|
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'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
plugin_attrib_map = {}
|
plugin_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerPurge)
|
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_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def setJid(self, value):
|
def setJid(self, value):
|
||||||
self._setAttr('jid', str(value))
|
self._setAttr('jid', str(value))
|
||||||
|
|
||||||
def getJid(self):
|
def getJid(self):
|
||||||
return JID(self._getAttr('jid'))
|
return JID(self._getAttr('jid'))
|
||||||
|
|
||||||
registerStanzaPlugin(OwnerDelete, OwnerRedirect)
|
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_attrib_map = {}
|
||||||
plugin_tag_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)
|
||||||
return self.subscriptions.append(subscription)
|
return self.subscriptions.append(subscription)
|
||||||
|
|
||||||
registerStanzaPlugin(PubsubOwner, OwnerSubscriptions)
|
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_attrib_map = {}
|
||||||
plugin_tag_map = {}
|
plugin_tag_map = {}
|
||||||
|
|
||||||
def setJid(self, value):
|
def setJid(self, value):
|
||||||
self._setAttr('jid', str(value))
|
self._setAttr('jid', str(value))
|
||||||
|
|
||||||
def getJid(self):
|
def getJid(self):
|
||||||
return JID(self._getAttr('from'))
|
return JID(self._getAttr('from'))
|
||||||
|
|
Loading…
Reference in a new issue