From 805afa4bc1f44598d786fddc92c5129c62464227 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Tue, 22 Dec 2009 10:05:53 +0000 Subject: [PATCH] * fixed unhandled iqs --- sleekxmpp/stanza/iq.py | 14 ++++++-------- sleekxmpp/xmlstream/stanzabase.py | 4 ++-- sleekxmpp/xmlstream/xmlstream.py | 7 ++++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sleekxmpp/stanza/iq.py b/sleekxmpp/stanza/iq.py index 3961ead..a9c9c4b 100644 --- a/sleekxmpp/stanza/iq.py +++ b/sleekxmpp/stanza/iq.py @@ -65,21 +65,19 @@ class Iq(StanzaBase): return ns return '' + def reply(self): + self['type'] = 'result' + StanzaBase.reply(self) + return self + def delQuery(self): for child in self.getchildren(): if child.tag.endswith('query'): self.xml.remove(child) return self - def unhandled(self): - pass - # returned unhandled error - - def exception(self, traceback=None): - pass - def send(self, block=True, timeout=10): - if block: + if block and self['type'] in ('get', 'set'): waitfor = Waiter('IqWait_%s' % self['id'], MatcherId(self['id'])) self.stream.registerHandler(waitfor) StanzaBase.send(self) diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 49ddc30..d941b8c 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -214,8 +214,8 @@ class StanzaBase(ElementBase): def clear(self): for child in self.xml.getchildren(): self.xml.remove(child) - for plugin in self.plugins: - del self.plugins[plugin] + #for plugin in list(self.plugins.keys()): + # del self.plugins[plugin] def reply(self): self['from'], self['to'] = self['to'], self['from'] diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 7372903..ee88450 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -257,14 +257,15 @@ class XMLStream(object): break if stanza is None: stanza = StanzaBase(self, xmlobj) + unhandled = True for handler in self.__handlers: if handler.match(xmlobj): handler.prerun(stanza) self.eventqueue.put(('stanza', handler, stanza)) if handler.checkDelete(): self.__handlers.pop(self.__handlers.index(handler)) - else: - stanza.unhandled() - + unhandled = False + if unhandled: + stanza.unhandled() #loop through handlers and test match #spawn threads as necessary, call handlers, sending Stanza