summaryrefslogtreecommitdiff
path: root/src/fixes.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/fixes.py')
-rw-r--r--src/fixes.py43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/fixes.py b/src/fixes.py
index 18c117d8..1c5da7c8 100644
--- a/src/fixes.py
+++ b/src/fixes.py
@@ -1,25 +1,26 @@
"""
-Module used to provide fixes for sleekxmpp functions not yet fixed
+Module used to provide fixes for slixmpp functions not yet fixed
upstream.
TODO: Check that they are fixed and remove those hacks
"""
-from sleekxmpp.stanza import Message
-from sleekxmpp.xmlstream import ET
+from slixmpp.stanza import Message
+from slixmpp.xmlstream import ET
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):
@@ -37,20 +38,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):
"""