Commit 6250ba34 authored by louiz’'s avatar louiz’

Fix the data form retrieval, by making it non-blocking

parent 52f50cd9
......@@ -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):
"""
......
......@@ -361,13 +361,15 @@ class MucTab(ChatTab):
"""
/configure
"""
form = fixes.get_room_form(self.core.xmpp, self.name)
if not form:
self.core.information(
def on_form_received(form):
if not form:
self.core.information(
_('Could not retrieve the configuration form'),
_('Error'))
return
self.core.open_new_form(form, self.cancel_config, self.send_config)
return
self.core.open_new_form(form, self.cancel_config, self.send_config)
form = fixes.get_room_form(self.core.xmpp, self.name, on_form_received)
def cancel_config(self, form):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment