mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-30 11:09:56 +00:00
Clean up pubsub#event stanzas.
This commit is contained in:
parent
d6b0158ddb
commit
24c5f8d374
1 changed files with 83 additions and 95 deletions
|
@ -1,124 +1,112 @@
|
||||||
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 Message
|
||||||
|
from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase, ET, JID
|
||||||
|
from sleekxmpp.plugins.xep_0004 import Form
|
||||||
|
|
||||||
|
|
||||||
class Event(ElementBase):
|
class Event(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'event'
|
name = 'event'
|
||||||
plugin_attrib = 'pubsub_event'
|
plugin_attrib = 'pubsub_event'
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(Message, Event)
|
|
||||||
|
|
||||||
class EventItem(ElementBase):
|
class EventItem(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'item'
|
name = 'item'
|
||||||
plugin_attrib = 'item'
|
plugin_attrib = name
|
||||||
interfaces = set(('id', 'payload'))
|
interfaces = set(('id', 'payload'))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
def setPayload(self, value):
|
def set_payload(self, value):
|
||||||
self.xml.append(value)
|
self.xml.append(value)
|
||||||
|
|
||||||
def getPayload(self):
|
def get_payload(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 del_payload(self):
|
||||||
for child in self.xml.getchildren():
|
for child in self.xml.getchildren():
|
||||||
self.xml.remove(child)
|
self.xml.remove(child)
|
||||||
|
|
||||||
|
|
||||||
class EventRetract(ElementBase):
|
class EventRetract(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'retract'
|
name = 'retract'
|
||||||
plugin_attrib = 'retract'
|
plugin_attrib = name
|
||||||
interfaces = set(('id',))
|
interfaces = set(('id',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
class EventItems(ElementBase):
|
class EventItems(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'items'
|
name = 'items'
|
||||||
plugin_attrib = 'items'
|
plugin_attrib = name
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
subitem = (EventItem, EventRetract)
|
|
||||||
|
|
||||||
registerStanzaPlugin(Event, EventItems)
|
|
||||||
|
|
||||||
class EventCollection(ElementBase):
|
class EventCollection(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'collection'
|
name = 'collection'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(Event, EventCollection)
|
|
||||||
|
|
||||||
class EventAssociate(ElementBase):
|
class EventAssociate(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'associate'
|
name = 'associate'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(EventCollection, EventAssociate)
|
|
||||||
|
|
||||||
class EventDisassociate(ElementBase):
|
class EventDisassociate(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'disassociate'
|
name = 'disassociate'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(EventCollection, EventDisassociate)
|
|
||||||
|
|
||||||
class EventConfiguration(ElementBase):
|
class EventConfiguration(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'configuration'
|
name = 'configuration'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node', 'config'))
|
interfaces = set(('node', 'config'))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(Event, EventConfiguration)
|
|
||||||
registerStanzaPlugin(EventConfiguration, xep_0004.Form)
|
|
||||||
|
|
||||||
class EventPurge(ElementBase):
|
class EventPurge(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'purge'
|
name = 'purge'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node',))
|
interfaces = set(('node',))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
registerStanzaPlugin(Event, EventPurge)
|
|
||||||
|
|
||||||
class EventSubscription(ElementBase):
|
class EventSubscription(ElementBase):
|
||||||
namespace = 'http://jabber.org/protocol/pubsub#event'
|
namespace = 'http://jabber.org/protocol/pubsub#event'
|
||||||
name = 'subscription'
|
name = 'subscription'
|
||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node','expiry', 'jid', 'subid', 'subscription'))
|
interfaces = set(('node', 'expiry', 'jid', 'subid', 'subscription'))
|
||||||
plugin_attrib_map = {}
|
|
||||||
plugin_tag_map = {}
|
|
||||||
|
|
||||||
def setJid(self, value):
|
|
||||||
self._setAttr('jid', str(value))
|
|
||||||
|
|
||||||
def getJid(self):
|
|
||||||
return JID(self._getAttr('jid'))
|
|
||||||
|
|
||||||
registerStanzaPlugin(Event, EventSubscription)
|
def set_jid(self, value):
|
||||||
|
self._set_attr('jid', str(value))
|
||||||
|
|
||||||
|
def get_jid(self):
|
||||||
|
return JID(self._get_attr('jid'))
|
||||||
|
|
||||||
|
|
||||||
|
register_stanza_plugin(Message, Event)
|
||||||
|
register_stanza_plugin(Event, EventCollection)
|
||||||
|
register_stanza_plugin(Event, EventConfiguration)
|
||||||
|
register_stanza_plugin(Event, EventItems)
|
||||||
|
register_stanza_plugin(Event, EventPurge)
|
||||||
|
register_stanza_plugin(Event, EventSubscription)
|
||||||
|
register_stanza_plugin(EventCollection, EventAssociate)
|
||||||
|
register_stanza_plugin(EventCollection, EventDisassociate)
|
||||||
|
register_stanza_plugin(EventConfiguration, Form)
|
||||||
|
register_stanza_plugin(EventItems, EventItem, iterable=True)
|
||||||
|
register_stanza_plugin(EventItems, EventRetract, iterable=True)
|
||||||
|
|
Loading…
Reference in a new issue