Commit c94d22dc authored by Yann Leboulanger's avatar Yann Leboulanger

correctly answer on disco#items on our ad hoc commands

parent eba69596
......@@ -306,8 +306,8 @@ class ConnectionCommands:
self.connection.send(iq)
def commandQuery(self, con, iq_obj):
''' Send disco result for query for command (JEP-0050, example 6.).
def commandInfoQuery(self, con, iq_obj):
''' Send disco#info result for query for command (JEP-0050, example 6.).
Return True if the result was sent, False if not. '''
jid = helpers.get_full_jid_from_iq(iq_obj)
node = iq_obj.getTagAttr('query', 'node')
......@@ -330,6 +330,22 @@ class ConnectionCommands:
return False
def commandItemsQuery(self, con, iq_obj):
''' Send disco#items result for query for command.
Return True if the result was sent, False if not. '''
jid = helpers.get_full_jid_from_iq(iq_obj)
node = iq_obj.getTagAttr('query', 'node')
if node not in self.__commands: return False
cmd = self.__commands[node]
if cmd.isVisibleFor(self.isSameJID(jid)):
iq = iq_obj.buildReply('result')
self.connection.send(iq)
return True
return False
def _CommandExecuteCB(self, con, iq_obj):
jid = helpers.get_full_jid_from_iq(iq_obj)
......
......@@ -711,6 +711,8 @@ class ConnectionDisco:
def _DiscoverItemsGetCB(self, con, iq_obj):
gajim.log.debug('DiscoverItemsGetCB')
if self.commandItemsQuery(con, iq_obj):
raise common.xmpp.NodeProcessed
node = iq_obj.getTagAttr('query', 'node')
if node is None:
result = iq_obj.buildReply('result')
......@@ -725,7 +727,7 @@ class ConnectionDisco:
q = iq_obj.getTag('query')
node = q.getAttr('node')
if self.commandQuery(con, iq_obj):
if self.commandInfoQuery(con, iq_obj):
raise common.xmpp.NodeProcessed
else:
......
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