From ecd5a172ed49cbdf69cb3eaf0786fd18d801ee65 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Wed, 7 Apr 2010 23:10:32 -0700 Subject: [PATCH] replaced usage of deprecated iq result on send. Fixed old send result to use stanzas instead of ElementTree --- sleekxmpp/__init__.py | 3 ++- sleekxmpp/basexmpp.py | 3 ++- sleekxmpp/plugins/gmail_notify.py | 2 +- sleekxmpp/plugins/xep_0030.py | 4 ++-- sleekxmpp/plugins/xep_0045.py | 2 -- sleekxmpp/plugins/xep_0060.py | 22 +++++++++++----------- sleekxmpp/plugins/xep_0078.py | 4 ++-- sleekxmpp/plugins/xep_0092.py | 2 +- sleekxmpp/plugins/xep_0199.py | 3 ++- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/sleekxmpp/__init__.py b/sleekxmpp/__init__.py index c788313..773f793 100644 --- a/sleekxmpp/__init__.py +++ b/sleekxmpp/__init__.py @@ -229,7 +229,8 @@ class ClientXMPP(basexmpp, XMLStream): def handler_start_session(self, xml): if self.authenticated: - response = self.send(self.makeIqSet(xml), self.makeIq(self.getId())) + iq = self.makeIqSet(xml) + response = iq.send() logging.debug("Established Session") self.sessionstarted = True self.event("session_start") diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py index 34b8d76..585ecac 100644 --- a/sleekxmpp/basexmpp.py +++ b/sleekxmpp/basexmpp.py @@ -14,6 +14,7 @@ from . xmlstream.matcher.xmlmask import MatchXMLMask from . xmlstream.matcher.many import MatchMany from . xmlstream.handler.xmlcallback import XMLCallback from . xmlstream.handler.xmlwaiter import XMLWaiter +from . xmlstream.handler.waiter import Waiter from . xmlstream.handler.callback import Callback from . import plugins from . stanza.message import Message @@ -138,7 +139,7 @@ class basexmpp(object): mask = mask.xml data = str(data) if mask is not None: - waitfor = XMLWaiter('SendWait_%s' % self.getNewId(), MatchXMLMask(mask)) + waitfor = Waiter('SendWait_%s' % self.getNewId(), MatchXMLMask(mask)) self.registerHandler(waitfor) self.sendRaw(data) if mask is not None: diff --git a/sleekxmpp/plugins/gmail_notify.py b/sleekxmpp/plugins/gmail_notify.py index 330bf2a..b709ef6 100644 --- a/sleekxmpp/plugins/gmail_notify.py +++ b/sleekxmpp/plugins/gmail_notify.py @@ -51,7 +51,7 @@ class gmail_notify(base.base_plugin): iq.attrib['from'] = self.xmpp.fulljid iq.attrib['to'] = self.xmpp.jid self.xmpp.makeIqQuery(iq, 'google:mail:notify') - emails = self.xmpp.send(iq, self.xmpp.makeIq(self.xmpp.id)) + emails = iq.send() mailbox = emails.find('{google:mail:notify}mailbox') total = int(mailbox.get('total-matched', 0)) logging.info("%s New Gmail Messages" % total) diff --git a/sleekxmpp/plugins/xep_0030.py b/sleekxmpp/plugins/xep_0030.py index bff0dc1..5432dd5 100644 --- a/sleekxmpp/plugins/xep_0030.py +++ b/sleekxmpp/plugins/xep_0030.py @@ -93,7 +93,7 @@ class xep_0030(base.base_plugin): self.xmpp.makeIqQuery(iq, 'http://jabber.org/protocol/disco#items') if node: iq.find('{http://jabber.org/protocol/disco#items}query').attrib['node'] = node - return self.xmpp.send(iq, "" % iq.get('id')) + return iq.send() def getInfo(self, jid, node=None): iq = self.xmpp.makeIqGet() @@ -102,7 +102,7 @@ class xep_0030(base.base_plugin): self.xmpp.makeIqQuery(iq, 'http://jabber.org/protocol/disco#info') if node: iq.find('{http://jabber.org/protocol/disco#info}query').attrib['node'] = node - return self.xmpp.send(iq, self.xmpp.makeIq(iq.get('id'))) + return iq.send() def parseInfo(self, xml): result = {'identity': {}, 'feature': []} diff --git a/sleekxmpp/plugins/xep_0045.py b/sleekxmpp/plugins/xep_0045.py index 1e69523..7fc8a2b 100644 --- a/sleekxmpp/plugins/xep_0045.py +++ b/sleekxmpp/plugins/xep_0045.py @@ -182,7 +182,6 @@ class xep_0045(base.base_plugin): form = form.getXML('submit') query.append(form) iq.append(query) - #result = self.xmpp.send(iq, self.xmpp.makeIq(iq.get('id'))) result = iq.send() if result['type'] == 'error': return False @@ -224,7 +223,6 @@ class xep_0045(base.base_plugin): destroy.append(xreason) query.append(destroy) iq.append(query) - #r = self.xmpp.send(iq, self.xmpp.makeIq(iq.get('id'))) r = iq.send() if r is False or r['type'] == 'error': return False diff --git a/sleekxmpp/plugins/xep_0060.py b/sleekxmpp/plugins/xep_0060.py index cbc89df..8c6acd0 100644 --- a/sleekxmpp/plugins/xep_0060.py +++ b/sleekxmpp/plugins/xep_0060.py @@ -44,7 +44,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is False or result is None or result['type'] == 'error': return False return True @@ -64,7 +64,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is False or result is None or result['type'] == 'error': return False return True @@ -84,7 +84,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is False or result is None or result['type'] == 'error': return False return True @@ -103,7 +103,7 @@ class xep_0060(base.base_plugin): iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] #self.xmpp.add_handler("" % id, self.handlerCreateNodeResponse) - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is None or result == False or result['type'] == 'error': logging.warning("got error instead of config") return False @@ -126,7 +126,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is None or result == False or result['type'] == 'error': logging.warning("got error instead of config") return False @@ -149,7 +149,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is None or result == False or result['type'] == 'error': logging.warning("got error instead of config") return False @@ -172,7 +172,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is not None and result is not False and result.attrib.get('type', 'error') != 'error': return True else: @@ -190,7 +190,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is None or result['type'] == 'error': return False return True @@ -211,7 +211,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is None or result is False or result['type'] == 'error': return False return True @@ -227,7 +227,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is None or result is False or result['type'] == 'error': return False return True @@ -281,7 +281,7 @@ class xep_0060(base.base_plugin): iq.attrib['to'] = ps_jid iq.attrib['from'] = self.xmpp.fulljid id = iq['id'] - result = self.xmpp.send(iq, "" % id) + result = iq.send() if result is None or result is False or result['type'] == 'error': return False return True diff --git a/sleekxmpp/plugins/xep_0078.py b/sleekxmpp/plugins/xep_0078.py index 8cce0eb..f873290 100644 --- a/sleekxmpp/plugins/xep_0078.py +++ b/sleekxmpp/plugins/xep_0078.py @@ -50,7 +50,7 @@ class xep_0078(base.base_plugin): username.text = self.xmpp.username auth_request_query.append(username) auth_request.append(auth_request_query) - result = self.xmpp.send(auth_request, self.xmpp.makeIqResult(self.xmpp.id)) + result = auth_request.send() rquery = result.find('{jabber:iq:auth}query') attempt = self.xmpp.makeIqSet() query = ET.Element('{jabber:iq:auth}query') @@ -69,7 +69,7 @@ class xep_0078(base.base_plugin): digest.text = hashlib.sha1(b"%s%s" % (self.streamid, self.xmpp.password)).hexdigest() query.append(digest) attempt.append(query) - result = self.xmpp.send(attempt, self.xmpp.makeIq(self.xmpp.id)) + result = attempt.send() if result.attrib['type'] == 'result': with self.xmpp.lock: self.xmpp.authenticated = True diff --git a/sleekxmpp/plugins/xep_0092.py b/sleekxmpp/plugins/xep_0092.py index 97346d9..3d02638 100644 --- a/sleekxmpp/plugins/xep_0092.py +++ b/sleekxmpp/plugins/xep_0092.py @@ -55,7 +55,7 @@ class xep_0092(base.base_plugin): iq.attrib['to'] = jid iq.attrib['from'] = self.xmpp.fulljid id = iq.get('id') - result = self.xmpp.send(iq, "" % (self.xmpp.default_ns, id)) + result = iq.send() if result and result is not None and result.get('type', 'error') != 'error': qry = result.find('{jabber:iq:version}query') version = {} diff --git a/sleekxmpp/plugins/xep_0199.py b/sleekxmpp/plugins/xep_0199.py index 57d56c0..989e645 100644 --- a/sleekxmpp/plugins/xep_0199.py +++ b/sleekxmpp/plugins/xep_0199.py @@ -62,7 +62,8 @@ class xep_0199(base.base_plugin): ping = ET.Element('{http://www.xmpp.org/extensions/xep-0199.html#ns}ping') iq.append(ping) startTime = time.clock() - pingresult = self.xmpp.send(iq, self.xmpp.makeIq(id), timeout) + #pingresult = self.xmpp.send(iq, self.xmpp.makeIq(id), timeout) + pingresult = iq.send() endTime = time.clock() if pingresult == False: #self.xmpp.disconnect(reconnect=True)