From 83b44c863ecbecab4dbd7d05d4ad4973a1293781 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 28 Dec 2013 16:57:36 +0100 Subject: Fix #2281 (display iq results when sent with /rawxml) --- src/core.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/core.py b/src/core.py index 5450df5b..9c99fb26 100644 --- a/src/core.py +++ b/src/core.py @@ -31,6 +31,7 @@ from sleekxmpp import JID, InvalidJID from common import safeJID from sleekxmpp.xmlstream.stanzabase import StanzaBase from sleekxmpp.xmlstream.handler import Callback +from sleekxmpp.xmlstream.matcher import StanzaPath log = logging.getLogger(__name__) @@ -2526,14 +2527,35 @@ class Core(object): if not arg: return + try: - StanzaBase(self.xmpp, xml=ET.fromstring(arg)).send() + stanza = StanzaBase(self.xmpp, xml=ET.fromstring(arg)) + if stanza.xml.tag == 'iq' and \ + stanza.xml.attrib.get('type') == 'get' and \ + stanza.xml.attrib.get('id'): + iq_id = stanza.xml.attrib.get('id') + + def iqfunc(iq): + self.information('%s' % iq, 'Iq') + self.xmpp.remove_handler('Iq %s' % iq_id) + + self.xmpp.register_handler( + Callback('Iq %s' % iq_id, + StanzaPath('iq@id=%s' % iq_id), + iqfunc + ) + ) + log.debug('handler') + log.debug('%s %s', stanza.xml.tag, stanza.xml.attrib) + + stanza.send() except: self.information(_('Could not send custom stanza'), 'Error') log.debug('/rawxml: Could not send custom stanza (%s)', repr(arg), exc_info=True) + def command_load(self, arg): """ /load -- cgit v1.2.3