From c94d22dcb120a040a5f1211ddc9b9bd231b16345 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sat, 1 Dec 2007 11:46:46 +0000 Subject: [PATCH] correctly answer on disco#items on our ad hoc commands --- src/common/commands.py | 20 ++++++++++++++++++-- src/common/connection_handlers.py | 4 +++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/common/commands.py b/src/common/commands.py index 3aae5d53e..8edaf4356 100644 --- a/src/common/commands.py +++ b/src/common/commands.py @@ -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) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 92e6be95f..20c2aadcd 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -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: