Commit bedf2257 authored by mathieui's avatar mathieui

Fix get_version and get_room_form

parent 2d9d22da
......@@ -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"""
......
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
......@@ -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:
......
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