Add timeout_callback to a bunch of plugins as a parameter
This commit is contained in:
parent
804b23d390
commit
00a0698720
@ -62,7 +62,7 @@ class XEP_0054(BasePlugin):
|
|||||||
|
|
||||||
@future_wrapper
|
@future_wrapper
|
||||||
def get_vcard(self, jid=None, ifrom=None, local=None, cached=False,
|
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 local is None:
|
||||||
if jid is not None and not isinstance(jid, JID):
|
if jid is not None and not isinstance(jid, JID):
|
||||||
jid = JID(jid)
|
jid = JID(jid)
|
||||||
@ -101,11 +101,12 @@ class XEP_0054(BasePlugin):
|
|||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq.enable('vcard_temp')
|
iq.enable('vcard_temp')
|
||||||
|
|
||||||
return iq.send(callback=callback, timeout=timeout)
|
return iq.send(callback=callback, timeout=timeout,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
|
|
||||||
@future_wrapper
|
@future_wrapper
|
||||||
def publish_vcard(self, vcard=None, jid=None, ifrom=None,
|
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)
|
self.api['set_vcard'](jid, None, ifrom, vcard)
|
||||||
if self.xmpp.is_component:
|
if self.xmpp.is_component:
|
||||||
return
|
return
|
||||||
@ -115,7 +116,8 @@ class XEP_0054(BasePlugin):
|
|||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq.append(vcard)
|
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):
|
def _handle_get_vcard(self, iq):
|
||||||
if iq['type'] == 'result':
|
if iq['type'] == 'result':
|
||||||
|
@ -86,7 +86,8 @@ class XEP_0080(BasePlugin):
|
|||||||
ifrom = kwargs.get('ifrom', None)
|
ifrom = kwargs.get('ifrom', None)
|
||||||
callback = kwargs.get('callback', None)
|
callback = kwargs.get('callback', None)
|
||||||
timeout = kwargs.get('timeout', 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:
|
if param in kwargs:
|
||||||
del kwargs[param]
|
del kwargs[param]
|
||||||
|
|
||||||
@ -97,9 +98,10 @@ class XEP_0080(BasePlugin):
|
|||||||
options=options,
|
options=options,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
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.
|
Clear existing user location information to stop notifications.
|
||||||
|
|
||||||
@ -115,4 +117,5 @@ class XEP_0080(BasePlugin):
|
|||||||
return self.xmpp['xep_0163'].publish(geoloc,
|
return self.xmpp['xep_0163'].publish(geoloc,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout)
|
timeout=timeout,
|
||||||
|
timeout_callback=None)
|
||||||
|
@ -45,25 +45,28 @@ class XEP_0084(BasePlugin):
|
|||||||
return hashlib.sha1(data).hexdigest()
|
return hashlib.sha1(data).hexdigest()
|
||||||
|
|
||||||
def retrieve_avatar(self, jid, id, url=None, ifrom=None,
|
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,
|
return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout)
|
timeout=timeout,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
|
|
||||||
def publish_avatar(self, data, ifrom=None, callback=None,
|
def publish_avatar(self, data, ifrom=None, callback=None,
|
||||||
timeout=None):
|
timeout=None, timeout_callback=None):
|
||||||
payload = Data()
|
payload = Data()
|
||||||
payload['value'] = data
|
payload['value'] = data
|
||||||
return self.xmpp['xep_0163'].publish(payload,
|
return self.xmpp['xep_0163'].publish(payload,
|
||||||
id=self.generate_id(data),
|
id=self.generate_id(data),
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout)
|
timeout=timeout,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
|
|
||||||
def publish_avatar_metadata(self, items=None, pointers=None,
|
def publish_avatar_metadata(self, items=None, pointers=None,
|
||||||
ifrom=None,
|
ifrom=None,
|
||||||
callback=None, timeout=None):
|
callback=None, timeout=None,
|
||||||
|
timeout_callback=None):
|
||||||
metadata = MetaData()
|
metadata = MetaData()
|
||||||
if items is None:
|
if items is None:
|
||||||
items = []
|
items = []
|
||||||
@ -83,9 +86,10 @@ class XEP_0084(BasePlugin):
|
|||||||
id=info['id'],
|
id=info['id'],
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
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.
|
Clear existing avatar metadata information to stop notifications.
|
||||||
|
|
||||||
@ -102,4 +106,5 @@ class XEP_0084(BasePlugin):
|
|||||||
node=MetaData.namespace,
|
node=MetaData.namespace,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout)
|
timeout=timeout,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
|
@ -70,7 +70,8 @@ class XEP_0092(BasePlugin):
|
|||||||
iq['software_version']['os'] = self.os
|
iq['software_version']['os'] = self.os
|
||||||
iq.send()
|
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.
|
Retrieve the software version of a remote agent.
|
||||||
|
|
||||||
@ -82,4 +83,5 @@ class XEP_0092(BasePlugin):
|
|||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['query'] = Version.namespace
|
iq['query'] = Version.namespace
|
||||||
return iq.send(timeout=timeout, callback=callback)
|
return iq.send(timeout=timeout, callback=callback,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
|
@ -35,7 +35,7 @@ class XEP_0118(BasePlugin):
|
|||||||
|
|
||||||
def publish_tune(self, artist=None, length=None, rating=None, source=None,
|
def publish_tune(self, artist=None, length=None, rating=None, source=None,
|
||||||
title=None, track=None, uri=None, options=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.
|
Publish the user's current tune.
|
||||||
|
|
||||||
@ -68,9 +68,10 @@ class XEP_0118(BasePlugin):
|
|||||||
options=options,
|
options=options,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
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.
|
Clear existing user tune information to stop notifications.
|
||||||
|
|
||||||
@ -87,4 +88,5 @@ class XEP_0118(BasePlugin):
|
|||||||
node=UserTune.namespace,
|
node=UserTune.namespace,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout)
|
timeout=timeout,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
|
@ -33,8 +33,9 @@ class XEP_0152(BasePlugin):
|
|||||||
def session_bind(self, jid):
|
def session_bind(self, jid):
|
||||||
self.xmpp['xep_0163'].register_pep('reachability', Reachability)
|
self.xmpp['xep_0163'].register_pep('reachability', Reachability)
|
||||||
|
|
||||||
def publish_reachability(self, addresses, options=None,
|
def publish_reachability(self, addresses, options=None, ifrom=None,
|
||||||
ifrom=None, callback=None, timeout=None):
|
callback=None, timeout=None,
|
||||||
|
timeout_callback=None):
|
||||||
"""
|
"""
|
||||||
Publish alternative addresses where the user can be reached.
|
Publish alternative addresses where the user can be reached.
|
||||||
|
|
||||||
@ -65,9 +66,10 @@ class XEP_0152(BasePlugin):
|
|||||||
options=options,
|
options=options,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
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.
|
Clear existing user activity information to stop notifications.
|
||||||
|
|
||||||
@ -84,4 +86,5 @@ class XEP_0152(BasePlugin):
|
|||||||
node=Reachability.namespace,
|
node=Reachability.namespace,
|
||||||
ifrom=ifrom,
|
ifrom=ifrom,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
timeout=timeout)
|
timeout=timeout,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
|
@ -59,7 +59,7 @@ class XEP_0153(BasePlugin):
|
|||||||
|
|
||||||
@future_wrapper
|
@future_wrapper
|
||||||
def set_avatar(self, jid=None, avatar=None, mtype=None, timeout=None,
|
def set_avatar(self, jid=None, avatar=None, mtype=None, timeout=None,
|
||||||
callback=None):
|
callback=None, timeout_callback=None):
|
||||||
if jid is None:
|
if jid is None:
|
||||||
jid = self.xmpp.boundjid.bare
|
jid = self.xmpp.boundjid.bare
|
||||||
|
|
||||||
@ -79,7 +79,8 @@ class XEP_0153(BasePlugin):
|
|||||||
new_future = self.xmpp['xep_0054'].publish_vcard(jid=jid,
|
new_future = self.xmpp['xep_0054'].publish_vcard(jid=jid,
|
||||||
vcard=vcard,
|
vcard=vcard,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
callback=next_callback)
|
callback=next_callback,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
new_future.add_done_callback(propagate_timeout_exception)
|
new_future.add_done_callback(propagate_timeout_exception)
|
||||||
|
|
||||||
def next_callback(result):
|
def next_callback(result):
|
||||||
@ -92,7 +93,8 @@ class XEP_0153(BasePlugin):
|
|||||||
future.set_result(result)
|
future.set_result(result)
|
||||||
|
|
||||||
first_future = self.xmpp['xep_0054'].get_vcard(jid, cached=False, timeout=timeout,
|
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)
|
first_future.add_done_callback(propagate_timeout_exception)
|
||||||
return future
|
return future
|
||||||
|
|
||||||
|
@ -45,14 +45,17 @@ class XEP_0191(BasePlugin):
|
|||||||
self.xmpp.remove_handler('Blocked Contact')
|
self.xmpp.remove_handler('Blocked Contact')
|
||||||
self.xmpp.remove_handler('Unblocked 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 = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('blocklist')
|
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 = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
@ -61,9 +64,11 @@ class XEP_0191(BasePlugin):
|
|||||||
jids = [jids]
|
jids = [jids]
|
||||||
|
|
||||||
iq['block']['items'] = 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 = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
@ -74,7 +79,8 @@ class XEP_0191(BasePlugin):
|
|||||||
jids = [jids]
|
jids = [jids]
|
||||||
|
|
||||||
iq['unblock']['items'] = 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):
|
def _handle_blocked(self, iq):
|
||||||
self.xmpp.event('blocked', iq)
|
self.xmpp.event('blocked', iq)
|
||||||
|
@ -31,35 +31,40 @@ class XEP_0257(BasePlugin):
|
|||||||
register_stanza_plugin(Iq, DisableCert)
|
register_stanza_plugin(Iq, DisableCert)
|
||||||
register_stanza_plugin(Iq, RevokeCert)
|
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 = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('sasl_certs')
|
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,
|
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 = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['sasl_cert_append']['name'] = name
|
iq['sasl_cert_append']['name'] = name
|
||||||
iq['sasl_cert_append']['x509cert'] = cert
|
iq['sasl_cert_append']['x509cert'] = cert
|
||||||
iq['sasl_cert_append']['cert_management'] = allow_management
|
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,
|
def disable_cert(self, name, ifrom=None, timeout=None, callback=None,
|
||||||
timeout=None, callback=None):
|
timeout_callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['sasl_cert_disable']['name'] = name
|
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,
|
def revoke_cert(self, name, ifrom=None, timeout=None, callback=None,
|
||||||
timeout=None, callback=None):
|
timeout_callback=None):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['sasl_cert_revoke']['name'] = name
|
iq['sasl_cert_revoke']['name'] = name
|
||||||
return iq.send(timeout=timeout, callback=callback)
|
return iq.send(timeout=timeout, callback=callback,
|
||||||
|
timeout_callback=timeout_callback)
|
||||||
|
@ -31,9 +31,11 @@ class XEP_0279(BasePlugin):
|
|||||||
def plugin_end(self):
|
def plugin_end(self):
|
||||||
self.xmpp['xep_0030'].del_feature(feature='urn:xmpp:sic:0')
|
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 = self.xmpp.Iq()
|
||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq.enable('ip_check')
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user