diff options
Diffstat (limited to 'slixmpp/plugins/xep_0060/pubsub.py')
-rw-r--r-- | slixmpp/plugins/xep_0060/pubsub.py | 130 |
1 files changed, 44 insertions, 86 deletions
diff --git a/slixmpp/plugins/xep_0060/pubsub.py b/slixmpp/plugins/xep_0060/pubsub.py index bf5a615f..26258bc9 100644 --- a/slixmpp/plugins/xep_0060/pubsub.py +++ b/slixmpp/plugins/xep_0060/pubsub.py @@ -13,7 +13,6 @@ from slixmpp.xmlstream.handler import Callback from slixmpp.xmlstream.matcher import StanzaPath from slixmpp.plugins.base import BasePlugin from slixmpp.plugins.xep_0060 import stanza -from slixmpp import coroutine_wrapper log = logging.getLogger(__name__) @@ -152,9 +151,8 @@ class XEP_0060(BasePlugin): """ self.node_event_map[node] = event_name - @coroutine_wrapper def create_node(self, jid, node, config=None, ntype=None, ifrom=None, - timeout_callback=None, callback=None, timeout=None, coroutine=False): + timeout_callback=None, callback=None, timeout=None): """ Create and configure a new pubsub node. @@ -200,13 +198,11 @@ class XEP_0060(BasePlugin): config.add_field(var='pubsub#node_type', value=ntype) iq['pubsub']['configure'].append(config) - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def subscribe(self, jid, node, bare=True, subscribee=None, options=None, ifrom=None, timeout_callback=None, callback=None, - timeout=None, coroutine=False): + timeout=None): """ Subscribe to updates from a pubsub node. @@ -248,13 +244,11 @@ class XEP_0060(BasePlugin): iq['pubsub']['subscribe']['jid'] = subscribee if options is not None: iq['pubsub']['options'].append(options) - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def unsubscribe(self, jid, node, subid=None, bare=True, subscribee=None, ifrom=None, timeout_callback=None, callback=None, - timeout=None, coroutine=False): + timeout=None): """ Unubscribe from updates from a pubsub node. @@ -297,52 +291,42 @@ class XEP_0060(BasePlugin): iq['pubsub']['unsubscribe']['jid'] = subscribee iq['pubsub']['unsubscribe']['subid'] = subid - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def get_subscriptions(self, jid, node=None, ifrom=None, timeout_callback=None, callback=None, - timeout=None, coroutine=False): + timeout=None): iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get') iq['pubsub']['subscriptions']['node'] = node - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper - def get_affiliations(self, jid, node=None, ifrom=None, timeout=None, - timeout_callback=None, callback=None, coroutine=False): + def get_affiliations(self, jid, node=None, ifrom=None, + timeout_callback=None, callback=None, timeout=None): iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get') iq['pubsub']['affiliations']['node'] = node - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def get_subscription_options(self, jid, node=None, user_jid=None, ifrom=None, timeout_callback=None, - callback=None, timeout=None, coroutine=False): + callback=None, timeout=None): iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get') 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(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def set_subscription_options(self, jid, node, user_jid, options, ifrom=None, timeout_callback=None, - callback=None, timeout=None, coroutine=False): + 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 iq['pubsub']['options'].append(options) - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper - def get_node_config(self, jid, node=None, ifrom=None, coroutine=False, + def get_node_config(self, jid, node=None, ifrom=None, timeout_callback=None, callback=None, timeout=None): """ Retrieve the configuration for a node, or the pubsub service's @@ -365,13 +349,11 @@ class XEP_0060(BasePlugin): iq['pubsub_owner']['default'] else: iq['pubsub_owner']['configure']['node'] = node - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def get_node_subscriptions(self, jid, node, ifrom=None, timeout_callback=None, callback=None, - timeout=None, coroutine=False): + timeout=None): """ Retrieve the subscriptions associated with a given node. @@ -387,12 +369,10 @@ class XEP_0060(BasePlugin): """ iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get') iq['pubsub_owner']['subscriptions']['node'] = node - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def get_node_affiliations(self, jid, node, ifrom=None, timeout_callback=None, - callback=None, timeout=None, coroutine=False): + callback=None, timeout=None): """ Retrieve the affiliations associated with a given node. @@ -408,12 +388,10 @@ class XEP_0060(BasePlugin): """ iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get') iq['pubsub_owner']['affiliations']['node'] = node - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def delete_node(self, jid, node, ifrom=None, timeout_callback=None, callback=None, - timeout=None, coroutine=False): + timeout=None): """ Delete a a pubsub node. @@ -429,21 +407,18 @@ class XEP_0060(BasePlugin): """ iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set') iq['pubsub_owner']['delete']['node'] = node - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - def set_node_config(self, jid, node, config, ifrom=None, coroutine=False, + def set_node_config(self, jid, node, config, ifrom=None, timeout_callback=None, callback=None, timeout=None): iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set') iq['pubsub_owner']['configure']['node'] = node iq['pubsub_owner']['configure'].append(config) - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def publish(self, jid, node, id=None, payload=None, options=None, ifrom=None, timeout_callback=None, callback=None, - timeout=None, coroutine=False): + timeout=None): """ Add a new item to a node, or edit an existing item. @@ -478,11 +453,9 @@ class XEP_0060(BasePlugin): if payload is not None: iq['pubsub']['publish']['item']['payload'] = payload iq['pubsub']['publish_options'] = options - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper - def retract(self, jid, node, id, notify=None, ifrom=None, coroutine=False, + def retract(self, jid, node, id, notify=None, ifrom=None, timeout_callback=None, callback=None, timeout=None): """ Delete a single item from a node. @@ -492,30 +465,25 @@ class XEP_0060(BasePlugin): iq['pubsub']['retract']['node'] = node iq['pubsub']['retract']['notify'] = notify iq['pubsub']['retract']['item']['id'] = id - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def purge(self, jid, node, ifrom=None, timeout_callback=None, callback=None, - timeout=None, coroutine=False): + timeout=None): """ Remove all items from a node. """ iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set') iq['pubsub_owner']['purge']['node'] = node - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def get_nodes(self, *args, **kwargs): """ Discover the nodes provided by a Pubsub service, using disco. """ return self.xmpp['xep_0030'].get_items(*args, **kwargs) - @coroutine_wrapper - def get_item(self, jid, node, item_id, ifrom=None, timeout=None, - timeout_callback=None, callback=None, coroutine=False): + def get_item(self, jid, node, item_id, ifrom=None, + timeout_callback=None, callback=None, timeout=None): """ Retrieve the content of an individual item. """ @@ -524,13 +492,11 @@ class XEP_0060(BasePlugin): item['id'] = item_id iq['pubsub']['items']['node'] = node iq['pubsub']['items'].append(item) - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def get_items(self, jid, node, item_ids=None, max_items=None, iterator=False, ifrom=None, timeout_callback=None, - callback=None, timeout=None, coroutine=False): + callback=None, timeout=None): """ Request the contents of a node's items. @@ -553,26 +519,21 @@ class XEP_0060(BasePlugin): if iterator: return self.xmpp['xep_0059'].iterate(iq, 'pubsub') else: - return iq.send(callback=callback, timeout=timeout, - coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper def get_item_ids(self, jid, node, ifrom=None, timeout_callback=None, callback=None, - timeout=None, iterator=False, coroutine=False): + timeout=None, iterator=False): """ Retrieve the ItemIDs hosted by a given node, using disco. """ self.xmpp['xep_0030'].get_items(jid, node, ifrom=ifrom, callback=callback, timeout=timeout, iterator=iterator, - timeout_callback=timeout_callback, - coroutine=coroutine) + timeout_callback=timeout_callback) - @coroutine_wrapper def modify_affiliations(self, jid, node, affiliations=None, ifrom=None, timeout_callback=None, callback=None, - timeout=None, coroutine=False): + timeout=None): iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set') iq['pubsub_owner']['affiliations']['node'] = node @@ -585,13 +546,11 @@ class XEP_0060(BasePlugin): aff['affiliation'] = affiliation iq['pubsub_owner']['affiliations'].append(aff) - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) - @coroutine_wrapper - def modify_subscriptions(self, jid, node, subscriptions=None, ifrom=None, - timeout_callback=None, callback=None, - timeout=None, coroutine=False): + def modify_subscriptions(self, jid, node, subscriptions=None, + ifrom=None, timeout_callback=None, + callback=None, timeout=None): iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set') iq['pubsub_owner']['subscriptions']['node'] = node @@ -604,5 +563,4 @@ class XEP_0060(BasePlugin): sub['subscription'] = subscription iq['pubsub_owner']['subscriptions'].append(sub) - return iq.send(callback=callback, timeout=timeout, coroutine=coroutine, - timeout_callback=timeout_callback) + return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback) |