summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core.py7
-rw-r--r--src/fixes.py41
-rw-r--r--src/tabs.py9
3 files changed, 50 insertions, 7 deletions
diff --git a/src/core.py b/src/core.py
index f3455e75..e06007bf 100644
--- a/src/core.py
+++ b/src/core.py
@@ -36,6 +36,7 @@ log = logging.getLogger(__name__)
import multiuserchat as muc
import tabs
+import fixes
import decorators
import xhtml
import events
@@ -1620,12 +1621,12 @@ class Core(object):
return self.command_help('version')
jid = safeJID(args[0])
if jid.resource or jid not in roster:
- self.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
+ fixes.get_version(self.xmpp, jid, callback=callback)
elif jid in roster:
for resource in roster[jid].resources:
- self.xmpp.plugin['xep_0092'].get_version(resource.jid, callback=callback)
+ fixes.get_version(self.xmpp, resource.jid, callback=callback)
else:
- self.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
+ fixes.get_version(self.xmpp, jid, callback=callback)
def completion_version(self, the_input):
"""Completion for /version"""
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
+
+
+
diff --git a/src/tabs.py b/src/tabs.py
index ce58f8fd..2e39988d 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -23,6 +23,7 @@ from gettext import gettext as _
import windows
import curses
+import fixes
import difflib
import string
import common
@@ -898,7 +899,7 @@ class MucTab(ChatTab):
self.core.information(info, 'Info')
def command_configure(self, arg):
- form = self.core.xmpp.plugin['xep_0045'].getRoomForm(self.get_name())
+ form = fixes.get_room_form(self.core.xmpp, self.get_name())
if not form:
self.core.information('Could not retrieve the configuration form', 'Error')
return
@@ -971,7 +972,7 @@ class MucTab(ChatTab):
jid = safeJID(jid + '/' + arg)
else:
jid = safeJID(arg)
- self.core.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
+ fixes.get_version(self.core.xmpp, jid, callback=callback)
def command_nick(self, arg):
"""
@@ -1878,7 +1879,7 @@ class PrivateTab(ChatTab):
if arg:
return self.core.command_version(arg)
jid = safeJID(self.name)
- self.core.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
+ fixes.get_version(self.core.xmpp, jid, callback=callback)
def command_info(self, arg):
"""
@@ -3058,7 +3059,7 @@ class ConversationTab(ChatTab):
if jid in roster:
resource = roster[jid].get_highest_priority_resource()
jid = resource.jid if resource else jid
- self.core.xmpp.plugin['xep_0092'].get_version(jid, callback=callback)
+ fixes.get_version(self.core.xmpp, jid, callback=callback)
def resize(self):
if self.core.information_win_size >= self.height-3 or not self.visible: