summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/stanza_pubsub.py
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-08-19 16:09:47 -0700
committerNathan Fritz <nathan@andyet.net>2010-08-19 16:09:47 -0700
commitd150b35464742de7af9b3105bc7eeb55171b96ee (patch)
treef1dce9115efbe4c85d37bc27d6ae35f1e937a043 /sleekxmpp/plugins/stanza_pubsub.py
parent21b7109c06695955632692814fed11b3717e0fc7 (diff)
parente4240dd593207a5912de996c42451b3946f113b2 (diff)
downloadslixmpp-d150b35464742de7af9b3105bc7eeb55171b96ee.tar.gz
slixmpp-d150b35464742de7af9b3105bc7eeb55171b96ee.tar.bz2
slixmpp-d150b35464742de7af9b3105bc7eeb55171b96ee.tar.xz
slixmpp-d150b35464742de7af9b3105bc7eeb55171b96ee.zip
fixed todo merge
Diffstat (limited to 'sleekxmpp/plugins/stanza_pubsub.py')
-rw-r--r--sleekxmpp/plugins/stanza_pubsub.py123
1 files changed, 39 insertions, 84 deletions
diff --git a/sleekxmpp/plugins/stanza_pubsub.py b/sleekxmpp/plugins/stanza_pubsub.py
index 1a1526f0..96d02f93 100644
--- a/sleekxmpp/plugins/stanza_pubsub.py
+++ b/sleekxmpp/plugins/stanza_pubsub.py
@@ -1,4 +1,4 @@
-from .. xmlstream.stanzabase import ElementBase, ET, JID
+from .. xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET, JID
from .. stanza.iq import Iq
from .. stanza.message import Message
from .. basexmpp import basexmpp
@@ -6,9 +6,6 @@ from .. xmlstream.xmlstream import XMLStream
import logging
from . import xep_0004
-def stanzaPlugin(stanza, plugin):
- stanza.plugin_attrib_map[plugin.plugin_attrib] = plugin
- stanza.plugin_tag_map["{%s}%s" % (plugin.namespace, plugin.name)] = plugin
class PubsubState(ElementBase):
namespace = 'http://jabber.org/protocol/psstate'
@@ -30,7 +27,7 @@ class PubsubState(ElementBase):
for child in self.xml.getchildren():
self.xml.remove(child)
-stanzaPlugin(Iq, PubsubState)
+registerStanzaPlugin(Iq, PubsubState)
class PubsubStateEvent(ElementBase):
namespace = 'http://jabber.org/protocol/psstate#event'
@@ -40,8 +37,8 @@ class PubsubStateEvent(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(Message, PubsubStateEvent)
-stanzaPlugin(PubsubStateEvent, PubsubState)
+registerStanzaPlugin(Message, PubsubStateEvent)
+registerStanzaPlugin(PubsubStateEvent, PubsubState)
class Pubsub(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -51,7 +48,7 @@ class Pubsub(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(Iq, Pubsub)
+registerStanzaPlugin(Iq, Pubsub)
class PubsubOwner(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -61,7 +58,7 @@ class PubsubOwner(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(Iq, PubsubOwner)
+registerStanzaPlugin(Iq, PubsubOwner)
class Affiliation(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -86,7 +83,7 @@ class Affiliations(ElementBase):
self.xml.append(affiliation.xml)
return self.iterables.append(affiliation)
-stanzaPlugin(Pubsub, Affiliations)
+registerStanzaPlugin(Pubsub, Affiliations)
class Subscription(ElementBase):
@@ -103,7 +100,7 @@ class Subscription(ElementBase):
def getjid(self):
return jid(self._getattr('jid'))
-stanzaPlugin(Pubsub, Subscription)
+registerStanzaPlugin(Pubsub, Subscription)
class Subscriptions(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -114,7 +111,7 @@ class Subscriptions(ElementBase):
plugin_tag_map = {}
subitem = (Subscription,)
-stanzaPlugin(Pubsub, Subscriptions)
+registerStanzaPlugin(Pubsub, Subscriptions)
class OptionalSetting(object):
interfaces = set(('required',))
@@ -147,7 +144,7 @@ class SubscribeOptions(ElementBase, OptionalSetting):
plugin_tag_map = {}
interfaces = set(('required',))
-stanzaPlugin(Subscription, SubscribeOptions)
+registerStanzaPlugin(Subscription, SubscribeOptions)
class Item(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -178,7 +175,7 @@ class Items(ElementBase):
plugin_tag_map = {}
subitem = (Item,)
-stanzaPlugin(Pubsub, Items)
+registerStanzaPlugin(Pubsub, Items)
class Create(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -188,7 +185,7 @@ class Create(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(Pubsub, Create)
+registerStanzaPlugin(Pubsub, Create)
#class Default(ElementBase):
# namespace = 'http://jabber.org/protocol/pubsub'
@@ -203,7 +200,7 @@ stanzaPlugin(Pubsub, Create)
# if not t: t == 'leaf'
# return t
#
-#stanzaPlugin(Pubsub, Default)
+#registerStanzaPlugin(Pubsub, Default)
class Publish(Items):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -214,7 +211,7 @@ class Publish(Items):
plugin_tag_map = {}
subitem = (Item,)
-stanzaPlugin(Pubsub, Publish)
+registerStanzaPlugin(Pubsub, Publish)
class Retract(Items):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -224,7 +221,7 @@ class Retract(Items):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(Pubsub, Retract)
+registerStanzaPlugin(Pubsub, Retract)
class Unsubscribe(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -254,13 +251,13 @@ class Subscribe(ElementBase):
def getJid(self):
return JID(self._getAttr('jid'))
-stanzaPlugin(Pubsub, Subscribe)
+registerStanzaPlugin(Pubsub, Subscribe)
class Configure(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub'
name = 'configure'
plugin_attrib = name
- interfaces = set(('node', 'type', 'config'))
+ interfaces = set(('node', 'type'))
plugin_attrib_map = {}
plugin_tag_map = {}
@@ -269,22 +266,8 @@ class Configure(ElementBase):
if not t: t == 'leaf'
return t
- def getConfig(self):
- config = self.xml.find('{jabber:x:data}x')
- form = xep_0004.Form()
- if config is not None:
- form.fromXML(config)
- return form
-
- def setConfig(self, value):
- self.xml.append(value.getXML())
- return self
-
- def delConfig(self):
- config = self.xml.find('{jabber:x:data}x')
- self.xml.remove(config)
-
-stanzaPlugin(Pubsub, Configure)
+registerStanzaPlugin(Pubsub, Configure)
+registerStanzaPlugin(Configure, xep_0004.Form)
class DefaultConfig(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -296,28 +279,14 @@ class DefaultConfig(ElementBase):
def __init__(self, *args, **kwargs):
ElementBase.__init__(self, *args, **kwargs)
-
- def getConfig(self):
- config = self.xml.find('{jabber:x:data}x')
- form = xep_0004.Form()
- if config is not None:
- form.fromXML(config)
- return form
-
- def setConfig(self, value):
- self.xml.append(value.getXML())
- return self
-
- def delConfig(self):
- config = self.xml.find('{jabber:x:data}x')
- self.xml.remove(config)
def getType(self):
t = self._getAttr('type')
if not t: t = 'leaf'
return t
-stanzaPlugin(PubsubOwner, DefaultConfig)
+registerStanzaPlugin(PubsubOwner, DefaultConfig)
+registerStanzaPlugin(DefaultConfig, xep_0004.Form)
class Options(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub'
@@ -351,8 +320,8 @@ class Options(ElementBase):
def getJid(self):
return JID(self._getAttr('jid'))
-stanzaPlugin(Pubsub, Options)
-stanzaPlugin(Subscribe, Options)
+registerStanzaPlugin(Pubsub, Options)
+registerStanzaPlugin(Subscribe, Options)
class OwnerAffiliations(Affiliations):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -366,7 +335,7 @@ class OwnerAffiliations(Affiliations):
self.xml.append(affiliation.xml)
return self.affiliations.append(affiliation)
-stanzaPlugin(PubsubOwner, OwnerAffiliations)
+registerStanzaPlugin(PubsubOwner, OwnerAffiliations)
class OwnerAffiliation(Affiliation):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -380,7 +349,7 @@ class OwnerConfigure(Configure):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(PubsubOwner, OwnerConfigure)
+registerStanzaPlugin(PubsubOwner, OwnerConfigure)
class OwnerDefault(OwnerConfigure):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -388,7 +357,7 @@ class OwnerDefault(OwnerConfigure):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(PubsubOwner, OwnerDefault)
+registerStanzaPlugin(PubsubOwner, OwnerDefault)
class OwnerDelete(ElementBase, OptionalSetting):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -398,7 +367,7 @@ class OwnerDelete(ElementBase, OptionalSetting):
plugin_tag_map = {}
interfaces = set(('node',))
-stanzaPlugin(PubsubOwner, OwnerDelete)
+registerStanzaPlugin(PubsubOwner, OwnerDelete)
class OwnerPurge(ElementBase, OptionalSetting):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -407,7 +376,7 @@ class OwnerPurge(ElementBase, OptionalSetting):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(PubsubOwner, OwnerPurge)
+registerStanzaPlugin(PubsubOwner, OwnerPurge)
class OwnerRedirect(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -423,7 +392,7 @@ class OwnerRedirect(ElementBase):
def getJid(self):
return JID(self._getAttr('jid'))
-stanzaPlugin(OwnerDelete, OwnerRedirect)
+registerStanzaPlugin(OwnerDelete, OwnerRedirect)
class OwnerSubscriptions(Subscriptions):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -437,7 +406,7 @@ class OwnerSubscriptions(Subscriptions):
self.xml.append(subscription.xml)
return self.subscriptions.append(subscription)
-stanzaPlugin(PubsubOwner, OwnerSubscriptions)
+registerStanzaPlugin(PubsubOwner, OwnerSubscriptions)
class OwnerSubscription(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#owner'
@@ -461,7 +430,7 @@ class Event(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(Message, Event)
+registerStanzaPlugin(Message, Event)
class EventItem(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#event'
@@ -501,7 +470,7 @@ class EventItems(ElementBase):
plugin_tag_map = {}
subitem = (EventItem, EventRetract)
-stanzaPlugin(Event, EventItems)
+registerStanzaPlugin(Event, EventItems)
class EventCollection(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#event'
@@ -511,7 +480,7 @@ class EventCollection(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(Event, EventCollection)
+registerStanzaPlugin(Event, EventCollection)
class EventAssociate(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#event'
@@ -521,7 +490,7 @@ class EventAssociate(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(EventCollection, EventAssociate)
+registerStanzaPlugin(EventCollection, EventAssociate)
class EventDisassociate(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#event'
@@ -531,7 +500,7 @@ class EventDisassociate(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(EventCollection, EventDisassociate)
+registerStanzaPlugin(EventCollection, EventDisassociate)
class EventConfiguration(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#event'
@@ -541,22 +510,8 @@ class EventConfiguration(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
- def getConfig(self):
- config = self.xml.find('{jabber:x:data}x')
- form = xep_0004.Form()
- if config is not None:
- form.fromXML(config)
- return form
-
- def setConfig(self, value):
- self.xml.append(value.getXML())
- return self
-
- def delConfig(self):
- config = self.xml.find('{jabber:x:data}x')
- self.xml.remove(config)
-
-stanzaPlugin(Event, EventConfiguration)
+registerStanzaPlugin(Event, EventConfiguration)
+registerStanzaPlugin(EventConfiguration, xep_0004.Form)
class EventPurge(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#event'
@@ -566,7 +521,7 @@ class EventPurge(ElementBase):
plugin_attrib_map = {}
plugin_tag_map = {}
-stanzaPlugin(Event, EventPurge)
+registerStanzaPlugin(Event, EventPurge)
class EventSubscription(ElementBase):
namespace = 'http://jabber.org/protocol/pubsub#event'
@@ -582,4 +537,4 @@ class EventSubscription(ElementBase):
def getJid(self):
return JID(self._getAttr('jid'))
-stanzaPlugin(Event, EventSubscription)
+registerStanzaPlugin(Event, EventSubscription)