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.
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'
20 plugin_attrib
= 'pubsub_owner'
21 interfaces
= set(tuple())
24 class DefaultConfig(ElementBase
):
25 namespace
= 'http://jabber.org/protocol/pubsub#owner'
28 interfaces
= set(('node', 'config'))
30 def __init__(self
, *args
, **kwargs
):
31 ElementBase
.__init
__(self
, *args
, **kwargs
)
36 def set_config(self
, value
):
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
):
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'
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'
73 interfaces
= set(('node',))
76 class OwnerPurge(ElementBase
, OptionalSetting
):
77 namespace
= 'http://jabber.org/protocol/pubsub#owner'
80 interfaces
= set(('node',))
83 class OwnerRedirect(ElementBase
):
84 namespace
= 'http://jabber.org/protocol/pubsub#owner'
87 interfaces
= set(('node', 'jid'))
89 def set_jid(self
, value
):
90 self
._set
_attr
('jid', str(value
))
93 return JID(self
._get
_attr
('jid'))
96 class OwnerSubscriptions(Subscriptions
):
97 name
= 'subscriptions'
98 namespace
= 'http://jabber.org/protocol/pubsub#owner'
100 interfaces
= set(('node',))
102 def append(self
, subscription
):
103 if not isinstance(subscription
, OwnerSubscription
):
105 self
.xml
.append(subscription
.xml
)
108 class OwnerSubscription(ElementBase
):
109 namespace
= 'http://jabber.org/protocol/pubsub#owner'
110 name
= 'subscription'
112 interfaces
= set(('jid', 'subscription'))
114 def set_jid(self
, value
):
115 self
._set
_attr
('jid', str(value
))
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)