summaryrefslogtreecommitdiff
path: root/src/fixes.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/fixes.py')
-rw-r--r--src/fixes.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/fixes.py b/src/fixes.py
new file mode 100644
index 00000000..47455258
--- /dev/null
+++ b/src/fixes.py
@@ -0,0 +1,41 @@
+from sleekxmpp import ET
+"""
+Module used to provide fixes for sleekxmpp functions not yet fixed
+upstream.
+
+TODO: Check that they are fixed and remove those hacks
+"""
+
+
+def get_version(xmpp, jid, callback=None, **kwargs):
+ def handle_result(res):
+ if res and res['type'] != 'error':
+ ret = res['software_version'].values
+ else:
+ ret = False
+ if callback:
+ callback(ret)
+ return ret
+ iq = xmpp.make_iq_get(ito=jid)
+ iq['query'] = 'jabber:iq:version'
+ result = iq.send(callback=handle_result if callback else None)
+ if not callback:
+ return handle_result(result)
+
+
+def get_room_form(xmpp, room):
+ 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
+
+
+