summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0013/offline.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-07-30 17:52:59 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-07-30 17:52:59 +0200
commitab03ad54aaca1725b943abf16585fa4ef6f08897 (patch)
tree66a18ee01a78b99dbcb5123ea09be523c766cc47 /slixmpp/plugins/xep_0013/offline.py
parent2e571ac95089f15df7eee8f29d519f2bef425d4d (diff)
downloadslixmpp-ab03ad54aaca1725b943abf16585fa4ef6f08897.tar.gz
slixmpp-ab03ad54aaca1725b943abf16585fa4ef6f08897.tar.bz2
slixmpp-ab03ad54aaca1725b943abf16585fa4ef6f08897.tar.xz
slixmpp-ab03ad54aaca1725b943abf16585fa4ef6f08897.zip
Fix the iq.send() function, and a bunch of places where it is called
This is a big-and-dirty commit with a bunch of cleanup, maybe breaking a few things, and not fixing all iq.send() calls yet.
Diffstat (limited to 'slixmpp/plugins/xep_0013/offline.py')
-rw-r--r--slixmpp/plugins/xep_0013/offline.py66
1 files changed, 28 insertions, 38 deletions
diff --git a/slixmpp/plugins/xep_0013/offline.py b/slixmpp/plugins/xep_0013/offline.py
index d6b500d3..51840e7b 100644
--- a/slixmpp/plugins/xep_0013/offline.py
+++ b/slixmpp/plugins/xep_0013/offline.py
@@ -48,7 +48,8 @@ class XEP_0013(BasePlugin):
local=False,
**kwargs)
- def view(self, nodes, ifrom=None, block=True, timeout=None, callback=None):
+ def view(self, nodes, ifrom=None, timeout=None, callback=None,
+ timeout_callback=None):
if not isinstance(nodes, (list, set)):
nodes = [nodes]
@@ -67,23 +68,16 @@ class XEP_0013(BasePlugin):
StanzaPath('message/offline'))
self.xmpp.register_handler(collector)
- if not block and callback is not None:
- def wrapped_cb(iq):
- results = collector.stop()
- if iq['type'] == 'result':
- iq['offline']['results'] = results
- callback(iq)
- return iq.send(block=block, timeout=timeout, callback=wrapped_cb)
- else:
- try:
- resp = iq.send(block=block, timeout=timeout, callback=callback)
- resp['offline']['results'] = collector.stop()
- return resp
- except XMPPError as e:
- collector.stop()
- raise e
-
- def remove(self, nodes, ifrom=None, block=True, timeout=None, callback=None):
+ def wrapped_cb(iq):
+ results = collector.stop()
+ if iq['type'] == 'result':
+ iq['offline']['results'] = results
+ callback(iq)
+ iq.send(timeout=timeout, callback=wrapped_cb,
+ timeout_callback=timeout_callback)
+
+ def remove(self, nodes, ifrom=None, timeout=None, callback=None,
+ timeout_callback=None):
if not isinstance(nodes, (list, set)):
nodes = [nodes]
@@ -97,9 +91,11 @@ class XEP_0013(BasePlugin):
item['action'] = 'remove'
offline.append(item)
- return iq.send(block=block, timeout=timeout, callback=callback)
+ iq.send(timeout=timeout, callback=callback,
+ timeout_callback=timeout_callback)
- def fetch(self, ifrom=None, block=True, timeout=None, callback=None):
+ def fetch(self, ifrom=None, timeout=None, callback=None,
+ timeout_callback=None):
iq = self.xmpp.Iq()
iq['type'] = 'set'
iq['from'] = ifrom
@@ -110,25 +106,19 @@ class XEP_0013(BasePlugin):
StanzaPath('message/offline'))
self.xmpp.register_handler(collector)
- if not block and callback is not None:
- def wrapped_cb(iq):
- results = collector.stop()
- if iq['type'] == 'result':
- iq['offline']['results'] = results
- callback(iq)
- return iq.send(block=block, timeout=timeout, callback=wrapped_cb)
- else:
- try:
- resp = iq.send(block=block, timeout=timeout, callback=callback)
- resp['offline']['results'] = collector.stop()
- return resp
- except XMPPError as e:
- collector.stop()
- raise e
-
- def purge(self, ifrom=None, block=True, timeout=None, callback=None):
+ def wrapped_cb(iq):
+ results = collector.stop()
+ if iq['type'] == 'result':
+ iq['offline']['results'] = results
+ callback(iq)
+ iq.send(timeout=timeout, callback=wrapped_cb,
+ timeout_callback=timeout_callback)
+
+ def purge(self, ifrom=None, timeout=None, callback=None,
+ timeout_callback=None):
iq = self.xmpp.Iq()
iq['type'] = 'set'
iq['from'] = ifrom
iq['offline']['purge'] = True
- return iq.send(block=block, timeout=timeout, callback=callback)
+ iq.send(timeout=timeout, callback=callback,
+ timeout_callback=timeout_callback)