diff options
author | Lance Stout <lancestout@gmail.com> | 2011-09-01 13:25:35 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-09-01 13:25:35 -0700 |
commit | d7fc2aaa9cd8427f73c78f1e6bfbc1c9e1569cf6 (patch) | |
tree | 00e289fb37f49efb011d4c21d051cea316be9bca /sleekxmpp | |
parent | 8471a485d1f9be3dc1f1c022ff49bee0b292cb6d (diff) | |
download | slixmpp-d7fc2aaa9cd8427f73c78f1e6bfbc1c9e1569cf6.tar.gz slixmpp-d7fc2aaa9cd8427f73c78f1e6bfbc1c9e1569cf6.tar.bz2 slixmpp-d7fc2aaa9cd8427f73c78f1e6bfbc1c9e1569cf6.tar.xz slixmpp-d7fc2aaa9cd8427f73c78f1e6bfbc1c9e1569cf6.zip |
Add ability to get global/node default subscription options.
Diffstat (limited to 'sleekxmpp')
-rw-r--r-- | sleekxmpp/plugins/xep_0060/pubsub.py | 9 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0060/stanza/pubsub.py | 29 |
2 files changed, 22 insertions, 16 deletions
diff --git a/sleekxmpp/plugins/xep_0060/pubsub.py b/sleekxmpp/plugins/xep_0060/pubsub.py index 5a9fe70c..2a31e374 100644 --- a/sleekxmpp/plugins/xep_0060/pubsub.py +++ b/sleekxmpp/plugins/xep_0060/pubsub.py @@ -183,11 +183,14 @@ class xep_0060(base_plugin): iq['pubsub']['affiliations']['node'] = node return iq.send(block=block, callback=callback, timeout=timeout) - def get_subscription_options(self, jid, node, user_jid, ifrom=None, + def get_subscription_options(self, jid, node=None, user_jid=None, ifrom=None, block=True, callback=None, timeout=None): iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get') - iq['pubsub']['options']['node'] = node - iq['pubsub']['options']['jid'] = user_jid + if user_jid is None: + iq['pubsub']['default']['node'] = node + else: + iq['pubsub']['options']['node'] = node + iq['pubsub']['options']['jid'] = user_jid return iq.send(block=block, callback=callback, timeout=timeout) def set_subscription_options(self, jid, node, user_jid, options, diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py index 1e661743..1a1de17a 100644 --- a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py +++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py @@ -85,6 +85,7 @@ class Item(ElementBase): for child in self.xml.getchildren(): self.xml.remove(child) + class Items(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'items' @@ -102,18 +103,18 @@ class Create(ElementBase): interfaces = set(('node',)) -#class Default(ElementBase): -# namespace = 'http://jabber.org/protocol/pubsub' -# name = 'default' -# plugin_attrib = name -# interfaces = set(('node', 'type')) -# -# def getType(self): -# t = self._get_attr('type') -# if not t: t == 'leaf' -# return t -# -#register_stanza_plugin(Pubsub, Default) +class Default(ElementBase): + namespace = 'http://jabber.org/protocol/pubsub' + name = 'default' + plugin_attrib = name + interfaces = set(('node', 'type')) + + def get_type(self): + t = self._get_attr('type') + if not t: + return 'leaf' + return t + class Publish(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' @@ -163,7 +164,8 @@ class Configure(ElementBase): def getType(self): t = self._get_attr('type') - if not t: t == 'leaf' + if not t: + t == 'leaf' return t @@ -254,6 +256,7 @@ register_stanza_plugin(Iq, Pubsub) register_stanza_plugin(Pubsub, Affiliations) register_stanza_plugin(Pubsub, Configure) register_stanza_plugin(Pubsub, Create) +register_stanza_plugin(Pubsub, Default) register_stanza_plugin(Pubsub, Items) register_stanza_plugin(Pubsub, Options) register_stanza_plugin(Pubsub, Publish) |