summaryrefslogtreecommitdiff
path: root/src/fixes.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-08-01 15:01:25 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-08-01 15:01:25 +0200
commit992fe72554de694750519f3f12886023314a8278 (patch)
tree5ac5f4774cbc81c8505ac8d2f2295cf968ce23d2 /src/fixes.py
parent3ec9e80de48225c7f27c19cdc0546762c042d0d1 (diff)
downloadpoezio-992fe72554de694750519f3f12886023314a8278.tar.gz
poezio-992fe72554de694750519f3f12886023314a8278.tar.bz2
poezio-992fe72554de694750519f3f12886023314a8278.tar.xz
poezio-992fe72554de694750519f3f12886023314a8278.zip
Fix a few blocking iq, and remove all block=False function arguments
Diffstat (limited to 'src/fixes.py')
-rw-r--r--src/fixes.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/fixes.py b/src/fixes.py
index da00c48e..1c5da7c8 100644
--- a/src/fixes.py
+++ b/src/fixes.py
@@ -12,14 +12,15 @@ import logging
log = logging.getLogger(__name__)
-def has_identity(xmpp, jid, identity):
- try:
- iq = xmpp.plugin['xep_0030'].get_info(jid=jid, block=True, timeout=1)
+def has_identity(xmpp, jid, identity, on_true=None, on_false=None):
+ def _cb(iq):
ident = lambda x: x[0]
- return identity in map(ident, iq['disco_info']['identities'])
- except:
- log.debug('Traceback while retrieving identity', exc_info=True)
- return False
+ res = identity in map(ident, iq['disco_info']['identities'])
+ if res and on_true is not None:
+ on_true()
+ if not res and on_false is not None:
+ on_false()
+ xmpp.plugin['xep_0030'].get_info(jid=jid, callback=_cb)
def get_version(xmpp, jid, callback=None, **kwargs):
def handle_result(res):