diff options
author | mathieui <mathieui@mathieui.net> | 2013-01-19 16:20:17 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-01-19 16:20:17 +0100 |
commit | bedf22574934fa569e3c6fcd487033366c7408e4 (patch) | |
tree | a03f54138ed2275eff6c6ad57400f77c54742306 /src/fixes.py | |
parent | 2d9d22dae90f48e439d038f2a37c976a95937698 (diff) | |
download | poezio-bedf22574934fa569e3c6fcd487033366c7408e4.tar.gz poezio-bedf22574934fa569e3c6fcd487033366c7408e4.tar.bz2 poezio-bedf22574934fa569e3c6fcd487033366c7408e4.tar.xz poezio-bedf22574934fa569e3c6fcd487033366c7408e4.zip |
Fix get_version and get_room_form
Diffstat (limited to 'src/fixes.py')
-rw-r--r-- | src/fixes.py | 41 |
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 + + + |