mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-12-28 11:14:19 +00:00
replaced usage of deprecated iq result on send. Fixed old send result to use stanzas instead of ElementTree
This commit is contained in:
parent
935ee4d14e
commit
ecd5a172ed
9 changed files with 23 additions and 22 deletions
|
@ -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")
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 id='%s' />" % 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': []}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % 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("<iq id='%s'/>" % id, self.handlerCreateNodeResponse)
|
||||
result = self.xmpp.send(iq, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % 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, "<iq id='%s'/>" % id)
|
||||
result = iq.send()
|
||||
if result is None or result is False or result['type'] == 'error':
|
||||
return False
|
||||
return True
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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, "<iq xmlns='%s' id='%s'/>" % (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 = {}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue