From 861d279b0822fe66cb6311898c808ab6f0e4a3b2 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sat, 10 Mar 2012 00:07:15 -0800 Subject: Correct missing pubsub#event stanzas and interfaces. --- sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py | 33 ++++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'sleekxmpp/plugins/xep_0060') diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py index c7263577..7f77d721 100644 --- a/sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py +++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub_event.py @@ -15,14 +15,14 @@ class Event(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'event' plugin_attrib = 'pubsub_event' - interfaces = set(('node',)) + interfaces = set() class EventItem(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'item' plugin_attrib = name - interfaces = set(('id', 'payload')) + interfaces = set(('id', 'payload', 'node', 'publisher')) def set_payload(self, value): self.xml.append(value) @@ -76,7 +76,7 @@ class EventConfiguration(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'configuration' plugin_attrib = name - interfaces = set(('node', 'config')) + interfaces = set(('node',)) class EventPurge(ElementBase): @@ -86,6 +86,30 @@ class EventPurge(ElementBase): interfaces = set(('node',)) +class EventDelete(ElementBase): + namespace = 'http://jabber.org/protocol/pubsub#event' + name = 'delete' + plugin_attrib = name + interfaces = set(('node', 'redirect')) + + def set_redirect(self, uri): + del self['redirect'] + redirect = ET.Element('{%s}redirect' % self.namespace) + redirect.attrib['uri'] = uri + self.xml.append(redirect) + + def get_redirect(self): + redirect = self.xml.find('{%s}redirect' % self.namespace) + if redirect is not None: + return redirect.attrib.get('uri', '') + return '' + + def del_redirect(self): + redirect = self.xml.find('{%s}redirect' % self.namespace) + if redirect is not None: + self.xml.remove(redirect) + + class EventSubscription(ElementBase): namespace = 'http://jabber.org/protocol/pubsub#event' name = 'subscription' @@ -102,8 +126,9 @@ class EventSubscription(ElementBase): 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, EventDelete) +register_stanza_plugin(Event, EventItems) register_stanza_plugin(Event, EventSubscription) register_stanza_plugin(EventCollection, EventAssociate) register_stanza_plugin(EventCollection, EventDisassociate) -- cgit v1.2.3