From 00a069872054b79fec1e29172df995e065485585 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 4 Sep 2015 01:05:56 +0200 Subject: Add timeout_callback to a bunch of plugins as a parameter --- slixmpp/plugins/xep_0054/vcard_temp.py | 10 +++++---- slixmpp/plugins/xep_0080/geoloc.py | 11 ++++++---- slixmpp/plugins/xep_0084/avatar.py | 21 +++++++++++------- slixmpp/plugins/xep_0092/version.py | 6 ++++-- slixmpp/plugins/xep_0118/user_tune.py | 10 +++++---- slixmpp/plugins/xep_0152/reachability.py | 13 ++++++----- slixmpp/plugins/xep_0153/vcard_avatar.py | 8 ++++--- slixmpp/plugins/xep_0191/blocking.py | 18 ++++++++++------ slixmpp/plugins/xep_0257/client_cert_management.py | 25 +++++++++++++--------- slixmpp/plugins/xep_0279/ipcheck.py | 6 ++++-- 10 files changed, 80 insertions(+), 48 deletions(-) diff --git a/slixmpp/plugins/xep_0054/vcard_temp.py b/slixmpp/plugins/xep_0054/vcard_temp.py index 85736b29..f0173386 100644 --- a/slixmpp/plugins/xep_0054/vcard_temp.py +++ b/slixmpp/plugins/xep_0054/vcard_temp.py @@ -62,7 +62,7 @@ class XEP_0054(BasePlugin): @future_wrapper def get_vcard(self, jid=None, ifrom=None, local=None, cached=False, - callback=None, timeout=None): + callback=None, timeout=None, timeout_callback=None): if local is None: if jid is not None and not isinstance(jid, JID): jid = JID(jid) @@ -101,11 +101,12 @@ class XEP_0054(BasePlugin): iq['type'] = 'get' iq.enable('vcard_temp') - return iq.send(callback=callback, timeout=timeout) + return iq.send(callback=callback, timeout=timeout, + timeout_callback=timeout_callback) @future_wrapper def publish_vcard(self, vcard=None, jid=None, ifrom=None, - callback=None, timeout=None): + callback=None, timeout=None, timeout_callback=None): self.api['set_vcard'](jid, None, ifrom, vcard) if self.xmpp.is_component: return @@ -115,7 +116,8 @@ class XEP_0054(BasePlugin): iq['from'] = ifrom iq['type'] = 'set' iq.append(vcard) - return iq.send(callback=callback, timeout=timeout) + return iq.send(callback=callback, timeout=timeout, + timeout_callback=timeout_callback) def _handle_get_vcard(self, iq): if iq['type'] == 'result': diff --git a/slixmpp/plugins/xep_0080/geoloc.py b/slixmpp/plugins/xep_0080/geoloc.py index 3f0285bd..c9d97edb 100644 --- a/slixmpp/plugins/xep_0080/geoloc.py +++ b/slixmpp/plugins/xep_0080/geoloc.py @@ -86,7 +86,8 @@ class XEP_0080(BasePlugin): ifrom = kwargs.get('ifrom', None) callback = kwargs.get('callback', None) timeout = kwargs.get('timeout', None) - for param in ('ifrom', 'block', 'callback', 'timeout', 'options'): + timeout_callback = kwargs.get('timeout_callback', None) + for param in ('ifrom', 'block', 'callback', 'timeout', 'options', 'timeout_callback'): if param in kwargs: del kwargs[param] @@ -97,9 +98,10 @@ class XEP_0080(BasePlugin): options=options, ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) - def stop(self, ifrom=None, callback=None, timeout=None): + def stop(self, ifrom=None, callback=None, timeout=None, timeout_callback=None): """ Clear existing user location information to stop notifications. @@ -115,4 +117,5 @@ class XEP_0080(BasePlugin): return self.xmpp['xep_0163'].publish(geoloc, ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=None) diff --git a/slixmpp/plugins/xep_0084/avatar.py b/slixmpp/plugins/xep_0084/avatar.py index 2bae765a..e5f9dfaa 100644 --- a/slixmpp/plugins/xep_0084/avatar.py +++ b/slixmpp/plugins/xep_0084/avatar.py @@ -45,25 +45,28 @@ class XEP_0084(BasePlugin): return hashlib.sha1(data).hexdigest() def retrieve_avatar(self, jid, id, url=None, ifrom=None, - callback=None, timeout=None): + callback=None, timeout=None, timeout_callback=None): return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id, ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) def publish_avatar(self, data, ifrom=None, callback=None, - timeout=None): + timeout=None, timeout_callback=None): payload = Data() payload['value'] = data return self.xmpp['xep_0163'].publish(payload, id=self.generate_id(data), ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) def publish_avatar_metadata(self, items=None, pointers=None, ifrom=None, - callback=None, timeout=None): + callback=None, timeout=None, + timeout_callback=None): metadata = MetaData() if items is None: items = [] @@ -83,9 +86,10 @@ class XEP_0084(BasePlugin): id=info['id'], ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) - def stop(self, ifrom=None, callback=None, timeout=None): + def stop(self, ifrom=None, callback=None, timeout=None, timeout_callback=None): """ Clear existing avatar metadata information to stop notifications. @@ -102,4 +106,5 @@ class XEP_0084(BasePlugin): node=MetaData.namespace, ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) diff --git a/slixmpp/plugins/xep_0092/version.py b/slixmpp/plugins/xep_0092/version.py index 9dbdc4e6..ff0317da 100644 --- a/slixmpp/plugins/xep_0092/version.py +++ b/slixmpp/plugins/xep_0092/version.py @@ -70,7 +70,8 @@ class XEP_0092(BasePlugin): iq['software_version']['os'] = self.os iq.send() - def get_version(self, jid, ifrom=None, timeout=None, callback=None): + def get_version(self, jid, ifrom=None, timeout=None, callback=None, + timeout_callback=None): """ Retrieve the software version of a remote agent. @@ -82,4 +83,5 @@ class XEP_0092(BasePlugin): iq['from'] = ifrom iq['type'] = 'get' iq['query'] = Version.namespace - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, + timeout_callback=timeout_callback) diff --git a/slixmpp/plugins/xep_0118/user_tune.py b/slixmpp/plugins/xep_0118/user_tune.py index bfb1762a..0882a5ba 100644 --- a/slixmpp/plugins/xep_0118/user_tune.py +++ b/slixmpp/plugins/xep_0118/user_tune.py @@ -35,7 +35,7 @@ class XEP_0118(BasePlugin): def publish_tune(self, artist=None, length=None, rating=None, source=None, title=None, track=None, uri=None, options=None, - ifrom=None, callback=None, timeout=None): + ifrom=None, callback=None, timeout=None, timeout_callback=None): """ Publish the user's current tune. @@ -68,9 +68,10 @@ class XEP_0118(BasePlugin): options=options, ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) - def stop(self, ifrom=None, callback=None, timeout=None): + def stop(self, ifrom=None, callback=None, timeout=None, timeout_callback=None): """ Clear existing user tune information to stop notifications. @@ -87,4 +88,5 @@ class XEP_0118(BasePlugin): node=UserTune.namespace, ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) diff --git a/slixmpp/plugins/xep_0152/reachability.py b/slixmpp/plugins/xep_0152/reachability.py index 897269ee..e6d94b65 100644 --- a/slixmpp/plugins/xep_0152/reachability.py +++ b/slixmpp/plugins/xep_0152/reachability.py @@ -33,8 +33,9 @@ class XEP_0152(BasePlugin): def session_bind(self, jid): self.xmpp['xep_0163'].register_pep('reachability', Reachability) - def publish_reachability(self, addresses, options=None, - ifrom=None, callback=None, timeout=None): + def publish_reachability(self, addresses, options=None, ifrom=None, + callback=None, timeout=None, + timeout_callback=None): """ Publish alternative addresses where the user can be reached. @@ -65,9 +66,10 @@ class XEP_0152(BasePlugin): options=options, ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) - def stop(self, ifrom=None, callback=None, timeout=None): + def stop(self, ifrom=None, callback=None, timeout=None, timeout_callback=None): """ Clear existing user activity information to stop notifications. @@ -84,4 +86,5 @@ class XEP_0152(BasePlugin): node=Reachability.namespace, ifrom=ifrom, callback=callback, - timeout=timeout) + timeout=timeout, + timeout_callback=timeout_callback) diff --git a/slixmpp/plugins/xep_0153/vcard_avatar.py b/slixmpp/plugins/xep_0153/vcard_avatar.py index 8cfe97fa..b2c4caf5 100644 --- a/slixmpp/plugins/xep_0153/vcard_avatar.py +++ b/slixmpp/plugins/xep_0153/vcard_avatar.py @@ -59,7 +59,7 @@ class XEP_0153(BasePlugin): @future_wrapper def set_avatar(self, jid=None, avatar=None, mtype=None, timeout=None, - callback=None): + callback=None, timeout_callback=None): if jid is None: jid = self.xmpp.boundjid.bare @@ -79,7 +79,8 @@ class XEP_0153(BasePlugin): new_future = self.xmpp['xep_0054'].publish_vcard(jid=jid, vcard=vcard, timeout=timeout, - callback=next_callback) + callback=next_callback, + timeout_callback=timeout_callback) new_future.add_done_callback(propagate_timeout_exception) def next_callback(result): @@ -92,7 +93,8 @@ class XEP_0153(BasePlugin): future.set_result(result) first_future = self.xmpp['xep_0054'].get_vcard(jid, cached=False, timeout=timeout, - callback=custom_callback) + callback=custom_callback, + timeout_callback=timeout_callback) first_future.add_done_callback(propagate_timeout_exception) return future diff --git a/slixmpp/plugins/xep_0191/blocking.py b/slixmpp/plugins/xep_0191/blocking.py index 22610d78..fa2a013e 100644 --- a/slixmpp/plugins/xep_0191/blocking.py +++ b/slixmpp/plugins/xep_0191/blocking.py @@ -45,14 +45,17 @@ class XEP_0191(BasePlugin): self.xmpp.remove_handler('Blocked Contact') self.xmpp.remove_handler('Unblocked Contact') - def get_blocked(self, ifrom=None, timeout=None, callback=None): + def get_blocked(self, ifrom=None, timeout=None, callback=None, + timeout_callback=None): iq = self.xmpp.Iq() iq['type'] = 'get' iq['from'] = ifrom iq.enable('blocklist') - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, + timeout_callback=timeout_callback) - def block(self, jids, ifrom=None, timeout=None, callback=None): + def block(self, jids, ifrom=None, timeout=None, callback=None, + timeout_callback=None): iq = self.xmpp.Iq() iq['type'] = 'set' iq['from'] = ifrom @@ -61,9 +64,11 @@ class XEP_0191(BasePlugin): jids = [jids] iq['block']['items'] = jids - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, + timeout_callback=timeout_callback) - def unblock(self, jids=None, ifrom=None, timeout=None, callback=None): + def unblock(self, jids=None, ifrom=None, timeout=None, callback=None, + timeout_callback=None): iq = self.xmpp.Iq() iq['type'] = 'set' iq['from'] = ifrom @@ -74,7 +79,8 @@ class XEP_0191(BasePlugin): jids = [jids] iq['unblock']['items'] = jids - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, + timeout_callback=timeout_callback) def _handle_blocked(self, iq): self.xmpp.event('blocked', iq) diff --git a/slixmpp/plugins/xep_0257/client_cert_management.py b/slixmpp/plugins/xep_0257/client_cert_management.py index 729197e0..a6d07506 100644 --- a/slixmpp/plugins/xep_0257/client_cert_management.py +++ b/slixmpp/plugins/xep_0257/client_cert_management.py @@ -31,35 +31,40 @@ class XEP_0257(BasePlugin): register_stanza_plugin(Iq, DisableCert) register_stanza_plugin(Iq, RevokeCert) - def get_certs(self, ifrom=None, timeout=None, callback=None): + def get_certs(self, ifrom=None, timeout=None, callback=None, + timeout_callback=None): iq = self.xmpp.Iq() iq['type'] = 'get' iq['from'] = ifrom iq.enable('sasl_certs') - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, + timeout_callback=timeout_callback) def add_cert(self, name, cert, allow_management=True, ifrom=None, - timeout=None, callback=None): + timeout=None, callback=None, timeout_callback=None): iq = self.xmpp.Iq() iq['type'] = 'set' iq['from'] = ifrom iq['sasl_cert_append']['name'] = name iq['sasl_cert_append']['x509cert'] = cert iq['sasl_cert_append']['cert_management'] = allow_management - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, + timeout_callback=timeout_callback) - def disable_cert(self, name, ifrom=None, - timeout=None, callback=None): + def disable_cert(self, name, ifrom=None, timeout=None, callback=None, + timeout_callback=None): iq = self.xmpp.Iq() iq['type'] = 'set' iq['from'] = ifrom iq['sasl_cert_disable']['name'] = name - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, + timeout_callback=timeout_callback) - def revoke_cert(self, name, ifrom=None, - timeout=None, callback=None): + def revoke_cert(self, name, ifrom=None, timeout=None, callback=None, + timeout_callback=None): iq = self.xmpp.Iq() iq['type'] = 'set' iq['from'] = ifrom iq['sasl_cert_revoke']['name'] = name - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, + timeout_callback=timeout_callback) diff --git a/slixmpp/plugins/xep_0279/ipcheck.py b/slixmpp/plugins/xep_0279/ipcheck.py index b0c0a6ca..e8cea46f 100644 --- a/slixmpp/plugins/xep_0279/ipcheck.py +++ b/slixmpp/plugins/xep_0279/ipcheck.py @@ -31,9 +31,11 @@ class XEP_0279(BasePlugin): def plugin_end(self): self.xmpp['xep_0030'].del_feature(feature='urn:xmpp:sic:0') - def check_ip(self, ifrom=None, block=True, timeout=None, callback=None): + def check_ip(self, ifrom=None, block=True, timeout=None, callback=None, + timeout_callback=None): iq = self.xmpp.Iq() iq['type'] = 'get' iq['from'] = ifrom iq.enable('ip_check') - return iq.send(block=block, timeout=timeout, callback=callback) + return iq.send(block=block, timeout=timeout, callback=callback, + timeout_callback=timeout_callback) -- cgit v1.2.3