summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0060/pubsub.py
diff options
context:
space:
mode:
Diffstat (limited to 'slixmpp/plugins/xep_0060/pubsub.py')
-rw-r--r--slixmpp/plugins/xep_0060/pubsub.py135
1 files changed, 62 insertions, 73 deletions
diff --git a/slixmpp/plugins/xep_0060/pubsub.py b/slixmpp/plugins/xep_0060/pubsub.py
index 223b014f..26258bc9 100644
--- a/slixmpp/plugins/xep_0060/pubsub.py
+++ b/slixmpp/plugins/xep_0060/pubsub.py
@@ -152,7 +152,7 @@ class XEP_0060(BasePlugin):
self.node_event_map[node] = event_name
def create_node(self, jid, node, config=None, ntype=None, ifrom=None,
- block=True, callback=None, timeout=None):
+ timeout_callback=None, callback=None, timeout=None):
"""
Create and configure a new pubsub node.
@@ -174,8 +174,6 @@ class XEP_0060(BasePlugin):
ntype -- The type of node to create. Servers typically default
to using 'leaf' if no type is provided.
ifrom -- Specify the sender's JID.
- block -- Specify if the send call will block until a response
- is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@@ -200,10 +198,11 @@ class XEP_0060(BasePlugin):
config.add_field(var='pubsub#node_type', value=ntype)
iq['pubsub']['configure'].append(config)
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
def subscribe(self, jid, node, bare=True, subscribee=None, options=None,
- ifrom=None, block=True, callback=None, timeout=None):
+ ifrom=None, timeout_callback=None, callback=None,
+ timeout=None):
"""
Subscribe to updates from a pubsub node.
@@ -220,8 +219,6 @@ class XEP_0060(BasePlugin):
subscribee -- The JID that is subscribing to the node.
options --
ifrom -- Specify the sender's JID.
- block -- Specify if the send call will block until a response
- is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a
response before exiting the send call if blocking
is used.
@@ -247,10 +244,11 @@ class XEP_0060(BasePlugin):
iq['pubsub']['subscribe']['jid'] = subscribee
if options is not None:
iq['pubsub']['options'].append(options)
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
def unsubscribe(self, jid, node, subid=None, bare=True, subscribee=None,
- ifrom=None, block=True, callback=None, timeout=None):
+ ifrom=None, timeout_callback=None, callback=None,
+ timeout=None):
"""
Unubscribe from updates from a pubsub node.
@@ -269,8 +267,6 @@ class XEP_0060(BasePlugin):
Defaults to True for a bare JID.
subscribee -- The JID that is subscribing to the node.
ifrom -- Specify the sender's JID.
- block -- Specify if the send call will block until a response
- is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a
response before exiting the send call if blocking
is used.
@@ -295,42 +291,43 @@ class XEP_0060(BasePlugin):
iq['pubsub']['unsubscribe']['jid'] = subscribee
iq['pubsub']['unsubscribe']['subid'] = subid
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def get_subscriptions(self, jid, node=None, ifrom=None, block=True,
- callback=None, timeout=None):
+ def get_subscriptions(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']['subscriptions']['node'] = node
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def get_affiliations(self, jid, node=None, ifrom=None, block=True,
- callback=None, timeout=None):
+ 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(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
def get_subscription_options(self, jid, node=None, user_jid=None,
- ifrom=None, block=True, callback=None,
- timeout=None):
+ ifrom=None, timeout_callback=None,
+ 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(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
def set_subscription_options(self, jid, node, user_jid, options,
- ifrom=None, block=True, callback=None,
- timeout=None):
+ ifrom=None, timeout_callback=None,
+ 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(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def get_node_config(self, jid, node=None, ifrom=None, block=True,
- callback=None, timeout=None):
+ 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
default configuration for new nodes.
@@ -341,8 +338,6 @@ class XEP_0060(BasePlugin):
the default configuration for new nodes will be
requested. Defaults to None.
ifrom -- Specify the sender's JID.
- block -- Specify if the send call will block until a response
- is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@@ -354,10 +349,11 @@ class XEP_0060(BasePlugin):
iq['pubsub_owner']['default']
else:
iq['pubsub_owner']['configure']['node'] = node
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def get_node_subscriptions(self, jid, node, ifrom=None, block=True,
- callback=None, timeout=None):
+ def get_node_subscriptions(self, jid, node, ifrom=None,
+ timeout_callback=None, callback=None,
+ timeout=None):
"""
Retrieve the subscriptions associated with a given node.
@@ -365,8 +361,6 @@ class XEP_0060(BasePlugin):
jid -- The JID of the pubsub service.
node -- The node to retrieve subscriptions from.
ifrom -- Specify the sender's JID.
- block -- Specify if the send call will block until a response
- is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@@ -375,9 +369,9 @@ class XEP_0060(BasePlugin):
"""
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get')
iq['pubsub_owner']['subscriptions']['node'] = node
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def get_node_affiliations(self, jid, node, ifrom=None, block=True,
+ def get_node_affiliations(self, jid, node, ifrom=None, timeout_callback=None,
callback=None, timeout=None):
"""
Retrieve the affiliations associated with a given node.
@@ -386,8 +380,6 @@ class XEP_0060(BasePlugin):
jid -- The JID of the pubsub service.
node -- The node to retrieve affiliations from.
ifrom -- Specify the sender's JID.
- block -- Specify if the send call will block until a response
- is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@@ -396,10 +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(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def delete_node(self, jid, node, ifrom=None, block=True,
- callback=None, timeout=None):
+ def delete_node(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
+ timeout=None):
"""
Delete a a pubsub node.
@@ -407,8 +399,6 @@ class XEP_0060(BasePlugin):
jid -- The JID of the pubsub service.
node -- The node to delete.
ifrom -- Specify the sender's JID.
- block -- Specify if the send call will block until a response
- is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@@ -417,17 +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(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def set_node_config(self, jid, node, config, ifrom=None, block=True,
- callback=None, timeout=None):
+ 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(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
def publish(self, jid, node, id=None, payload=None, options=None,
- ifrom=None, block=True, callback=None, timeout=None):
+ ifrom=None, timeout_callback=None, callback=None,
+ timeout=None):
"""
Add a new item to a node, or edit an existing item.
@@ -449,8 +440,6 @@ class XEP_0060(BasePlugin):
payload -- The item content to publish.
options -- A form of publish options.
ifrom -- Specify the sender's JID.
- block -- Specify if the send call will block until a response
- is received, or a timeout occurs. Defaults to True.
timeout -- The length of time (in seconds) to wait for a response
before exiting the send call if blocking is used.
Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
@@ -464,10 +453,10 @@ class XEP_0060(BasePlugin):
if payload is not None:
iq['pubsub']['publish']['item']['payload'] = payload
iq['pubsub']['publish_options'] = options
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def retract(self, jid, node, id, notify=None, ifrom=None, block=True,
- callback=None, timeout=None):
+ def retract(self, jid, node, id, notify=None, ifrom=None,
+ timeout_callback=None, callback=None, timeout=None):
"""
Delete a single item from a node.
"""
@@ -476,16 +465,16 @@ class XEP_0060(BasePlugin):
iq['pubsub']['retract']['node'] = node
iq['pubsub']['retract']['notify'] = notify
iq['pubsub']['retract']['item']['id'] = id
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def purge(self, jid, node, ifrom=None, block=True, callback=None,
+ def purge(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
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(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
def get_nodes(self, *args, **kwargs):
"""
@@ -493,8 +482,8 @@ class XEP_0060(BasePlugin):
"""
return self.xmpp['xep_0030'].get_items(*args, **kwargs)
- def get_item(self, jid, node, item_id, ifrom=None, block=True,
- callback=None, timeout=None):
+ def get_item(self, jid, node, item_id, ifrom=None,
+ timeout_callback=None, callback=None, timeout=None):
"""
Retrieve the content of an individual item.
"""
@@ -503,10 +492,10 @@ class XEP_0060(BasePlugin):
item['id'] = item_id
iq['pubsub']['items']['node'] = node
iq['pubsub']['items'].append(item)
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
def get_items(self, jid, node, item_ids=None, max_items=None,
- iterator=False, ifrom=None, block=False,
+ iterator=False, ifrom=None, timeout_callback=None,
callback=None, timeout=None):
"""
Request the contents of a node's items.
@@ -530,22 +519,21 @@ class XEP_0060(BasePlugin):
if iterator:
return self.xmpp['xep_0059'].iterate(iq, 'pubsub')
else:
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def get_item_ids(self, jid, node, ifrom=None, block=True,
- callback=None, timeout=None, iterator=False):
+ def get_item_ids(self, jid, node, ifrom=None, timeout_callback=None, callback=None,
+ timeout=None, iterator=False):
"""
Retrieve the ItemIDs hosted by a given node, using disco.
"""
- return self.xmpp['xep_0030'].get_items(jid, node,
- ifrom=ifrom,
- block=block,
- callback=callback,
- timeout=timeout,
- iterator=iterator)
+ self.xmpp['xep_0030'].get_items(jid, node, ifrom=ifrom,
+ callback=callback, timeout=timeout,
+ iterator=iterator,
+ timeout_callback=timeout_callback)
def modify_affiliations(self, jid, node, affiliations=None, ifrom=None,
- block=True, callback=None, timeout=None):
+ timeout_callback=None, callback=None,
+ timeout=None):
iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='set')
iq['pubsub_owner']['affiliations']['node'] = node
@@ -558,10 +546,11 @@ class XEP_0060(BasePlugin):
aff['affiliation'] = affiliation
iq['pubsub_owner']['affiliations'].append(aff)
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)
- def modify_subscriptions(self, jid, node, subscriptions=None, ifrom=None,
- block=True, callback=None, timeout=None):
+ 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
@@ -574,4 +563,4 @@ class XEP_0060(BasePlugin):
sub['subscription'] = subscription
iq['pubsub_owner']['subscriptions'].append(sub)
- return iq.send(block=block, callback=callback, timeout=timeout)
+ return iq.send(callback=callback, timeout=timeout, timeout_callback=timeout_callback)