removed unused and redundant 'makeIq...' methods from basexmpp; cleaned up the (few\!) plugins that actually used them.

This commit is contained in:
Tom Nichols
2010-07-07 15:18:59 -04:00
parent f7273affc5
commit fc952efae9
4 changed files with 13 additions and 42 deletions

View File

@@ -50,7 +50,7 @@ class gmail_notify(base.base_plugin):
iq = self.xmpp.makeIqGet()
iq.attrib['from'] = self.xmpp.fulljid
iq.attrib['to'] = self.xmpp.jid
self.xmpp.makeIqQuery(iq, 'google:mail:notify')
iq.append(ET.Element('{google:mail:notify}query'))
emails = iq.send()
mailbox = emails.find('{google:mail:notify}mailbox')
total = int(mailbox.get('total-matched', 0))

View File

@@ -226,35 +226,31 @@ class xep_0009(base.base_plugin):
else:
raise ValueError()
def makeMethodCallQuery(self,pmethod,params):
query = self.xmpp.makeIqQuery(iq,"jabber:iq:rpc")
def makeIqMethodCall(self,pto,pmethod,params):
query = ET.Element("{jabber:iq:rpc}query")
methodCall = ET.Element('methodCall')
methodName = ET.Element('methodName')
methodName.text = pmethod
methodCall.append(methodName)
methodCall.append(params)
query.append(methodCall)
return query
def makeIqMethodCall(self,pto,pmethod,params):
iq = self.xmpp.makeIqSet()
iq = self.xmpp.makeIqSet(query)
iq.set('to',pto)
iq.append(self.makeMethodCallQuery(pmethod,params))
return iq
def makeIqMethodResponse(self,pto,pid,params):
iq = self.xmpp.makeIqResult(pid)
iq.set('to',pto)
query = self.xmpp.makeIqQuery(iq,"jabber:iq:rpc")
query = ET.Element("{jabber:iq:rpc}query")
methodResponse = ET.Element('methodResponse')
methodResponse.append(params)
query.append(methodResponse)
iq = self.xmpp.makeIqResult(pid)
iq.set('to',pto)
iq.append(query)
return iq
def makeIqMethodError(self,pto,id,pmethod,params,condition):
iq = self.xmpp.makeIqError(id)
iq.set('to',pto)
iq.append(self.makeMethodCallQuery(pmethod,params))
def makeIqMethodError(self,pto,pid,pmethod,params,condition):
iq = self.self.makeMethodCallQuery(pto,pmethod,params)
iq.setValues({'id':pid,'type':'error'})
iq.append(self.xmpp['xep_0086'].makeError(condition))
return iq

View File

@@ -56,17 +56,13 @@ class xep_0199(base.base_plugin):
Sends a ping to the specified jid, returning the time (in seconds)
to receive a reply, or None if no reply is received in timeout seconds.
"""
id = self.xmpp.getNewId()
iq = self.xmpp.makeIq(id)
iq.attrib['type'] = 'get'
iq = self.xmpp.makeIqGet()
iq.attrib['to'] = jid
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 = iq.send()
endTime = time.clock()
if pingresult == False:
#self.xmpp.disconnect(reconnect=True)
return False
return endTime - startTime