Bump to 1.3.1
[slixmpp.git] / sleekxmpp / plugins / xep_0060 / stanza / pubsub_owner.py
blobd975a46da300b4f2c4a9ce56f5ba01d11a2f1d05
1 """
2 SleekXMPP: The Sleek XMPP Library
3 Copyright (C) 2011 Nathanael C. Fritz
4 This file is part of SleekXMPP.
6 See the file LICENSE for copying permission.
7 """
9 from sleekxmpp import Iq
10 from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase, ET, JID
11 from sleekxmpp.plugins.xep_0004 import Form
12 from sleekxmpp.plugins.xep_0060.stanza.base import OptionalSetting
13 from sleekxmpp.plugins.xep_0060.stanza.pubsub import Affiliations, Affiliation
14 from sleekxmpp.plugins.xep_0060.stanza.pubsub import Configure, Subscriptions
17 class PubsubOwner(ElementBase):
18 namespace = 'http://jabber.org/protocol/pubsub#owner'
19 name = 'pubsub'
20 plugin_attrib = 'pubsub_owner'
21 interfaces = set(tuple())
24 class DefaultConfig(ElementBase):
25 namespace = 'http://jabber.org/protocol/pubsub#owner'
26 name = 'default'
27 plugin_attrib = name
28 interfaces = set(('node', 'config'))
30 def __init__(self, *args, **kwargs):
31 ElementBase.__init__(self, *args, **kwargs)
33 def get_config(self):
34 return self['form']
36 def set_config(self, value):
37 del self['from']
38 self.append(value)
39 return self
42 class OwnerAffiliations(Affiliations):
43 namespace = 'http://jabber.org/protocol/pubsub#owner'
44 interfaces = set(('node',))
46 def append(self, affiliation):
47 if not isinstance(affiliation, OwnerAffiliation):
48 raise TypeError
49 self.xml.append(affiliation.xml)
52 class OwnerAffiliation(Affiliation):
53 namespace = 'http://jabber.org/protocol/pubsub#owner'
54 interfaces = set(('affiliation', 'jid'))
57 class OwnerConfigure(Configure):
58 namespace = 'http://jabber.org/protocol/pubsub#owner'
59 name = 'configure'
60 plugin_attrib = name
61 interfaces = set(('node',))
64 class OwnerDefault(OwnerConfigure):
65 namespace = 'http://jabber.org/protocol/pubsub#owner'
66 interfaces = set(('node',))
69 class OwnerDelete(ElementBase, OptionalSetting):
70 namespace = 'http://jabber.org/protocol/pubsub#owner'
71 name = 'delete'
72 plugin_attrib = name
73 interfaces = set(('node',))
76 class OwnerPurge(ElementBase, OptionalSetting):
77 namespace = 'http://jabber.org/protocol/pubsub#owner'
78 name = 'purge'
79 plugin_attrib = name
80 interfaces = set(('node',))
83 class OwnerRedirect(ElementBase):
84 namespace = 'http://jabber.org/protocol/pubsub#owner'
85 name = 'redirect'
86 plugin_attrib = name
87 interfaces = set(('node', 'jid'))
89 def set_jid(self, value):
90 self._set_attr('jid', str(value))
92 def get_jid(self):
93 return JID(self._get_attr('jid'))
96 class OwnerSubscriptions(Subscriptions):
97 name = 'subscriptions'
98 namespace = 'http://jabber.org/protocol/pubsub#owner'
99 plugin_attrib = name
100 interfaces = set(('node',))
102 def append(self, subscription):
103 if not isinstance(subscription, OwnerSubscription):
104 raise TypeError
105 self.xml.append(subscription.xml)
108 class OwnerSubscription(ElementBase):
109 namespace = 'http://jabber.org/protocol/pubsub#owner'
110 name = 'subscription'
111 plugin_attrib = name
112 interfaces = set(('jid', 'subscription'))
114 def set_jid(self, value):
115 self._set_attr('jid', str(value))
117 def get_jid(self):
118 return JID(self._get_attr('jid'))
121 register_stanza_plugin(Iq, PubsubOwner)
122 register_stanza_plugin(PubsubOwner, DefaultConfig)
123 register_stanza_plugin(PubsubOwner, OwnerAffiliations)
124 register_stanza_plugin(PubsubOwner, OwnerConfigure)
125 register_stanza_plugin(PubsubOwner, OwnerDefault)
126 register_stanza_plugin(PubsubOwner, OwnerDelete)
127 register_stanza_plugin(PubsubOwner, OwnerPurge)
128 register_stanza_plugin(PubsubOwner, OwnerSubscriptions)
129 register_stanza_plugin(DefaultConfig, Form)
130 register_stanza_plugin(OwnerAffiliations, OwnerAffiliation, iterable=True)
131 register_stanza_plugin(OwnerConfigure, Form)
132 register_stanza_plugin(OwnerDefault, Form)
133 register_stanza_plugin(OwnerDelete, OwnerRedirect)
134 register_stanza_plugin(OwnerSubscriptions, OwnerSubscription, iterable=True)