diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-08-01 13:03:18 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-08-01 13:03:18 +0200 |
commit | 6250ba345e8077ee913bd1fa2a3d5e2c5ae0c416 (patch) | |
tree | 252ff564d9780b112a8d7b2c57189f3b2408d074 /src/fixes.py | |
parent | 52f50cd949cbfb55d05f1eea1d0619bba573ec7c (diff) | |
download | poezio-6250ba345e8077ee913bd1fa2a3d5e2c5ae0c416.tar.gz poezio-6250ba345e8077ee913bd1fa2a3d5e2c5ae0c416.tar.bz2 poezio-6250ba345e8077ee913bd1fa2a3d5e2c5ae0c416.tar.xz poezio-6250ba345e8077ee913bd1fa2a3d5e2c5ae0c416.zip |
Fix the data form retrieval, by making it non-blocking
Diffstat (limited to 'src/fixes.py')
-rw-r--r-- | src/fixes.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/fixes.py b/src/fixes.py index 39610aa7..da00c48e 100644 --- a/src/fixes.py +++ b/src/fixes.py @@ -37,20 +37,20 @@ def get_version(xmpp, jid, callback=None, **kwargs): return handle_result(result) -def get_room_form(xmpp, room): +def get_room_form(xmpp, room, callback): + def _cb(result): + if result["type"] == "error": + callback(None) + xform = result.xml.find('{http://jabber.org/protocol/muc#owner}query/{jabber:x:data}x') + if xform is None: + callback(None) + form = xmpp.plugin['xep_0004'].buildForm(xform) + callback(form) + iq = xmpp.make_iq_get(ito=room) query = ET.Element('{http://jabber.org/protocol/muc#owner}query') iq.append(query) - try: - result = iq.send() - except: - return False - xform = result.xml.find('{http://jabber.org/protocol/muc#owner}query/{jabber:x:data}x') - if xform is None: - return False - form = xmpp.plugin['xep_0004'].buildForm(xform) - return form - + iq.send(callback=_cb) def _filter_add_receipt_request(self, stanza): """ |