mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
stanza should not have setValues/getValues because that conflicts with attribute accessors
This commit is contained in:
parent
f80b3285d4
commit
fec8578cf6
4 changed files with 17 additions and 17 deletions
|
@ -145,7 +145,7 @@ class ClientXMPP(basexmpp, XMLStream):
|
|||
|
||||
def updateRoster(self, jid, name=None, subscription=None, groups=[]):
|
||||
"""Add or change a roster item."""
|
||||
iq = self.Iq().setValues({'type': 'set'})
|
||||
iq = self.Iq().setStanzaValues({'type': 'set'})
|
||||
iq['roster']['items'] = {jid: {'name': name, 'subscription': subscription, 'groups': groups}}
|
||||
#self.send(iq, self.Iq().setValues({'id': iq['id']}))
|
||||
r = iq.send()
|
||||
|
@ -159,7 +159,7 @@ class ClientXMPP(basexmpp, XMLStream):
|
|||
|
||||
def getRoster(self):
|
||||
"""Request the roster be sent."""
|
||||
iq = self.Iq().setValues({'type': 'get'}).enable('roster').send()
|
||||
iq = self.Iq().setStanzaValues({'type': 'get'}).enable('roster').send()
|
||||
self._handleRoster(iq, request=True)
|
||||
|
||||
def _handleStreamFeatures(self, features):
|
||||
|
@ -254,5 +254,5 @@ class ClientXMPP(basexmpp, XMLStream):
|
|||
self.roster[jid] = {'groups': [], 'name': '', 'subscription': 'none', 'presence': {}, 'in_roster': True}
|
||||
self.roster[jid].update(iq['roster']['items'][jid])
|
||||
if iq['type'] == 'set':
|
||||
self.send(self.Iq().setValues({'type': 'result', 'id': iq['id']}).enable('roster'))
|
||||
self.send(self.Iq().setStanzaValues({'type': 'result', 'id': iq['id']}).enable('roster'))
|
||||
self.event("roster_update", iq)
|
||||
|
|
|
@ -144,26 +144,26 @@ class basexmpp(object):
|
|||
return waitfor.wait(timeout)
|
||||
|
||||
def makeIq(self, id=0, ifrom=None):
|
||||
return self.Iq().setValues({'id': str(id), 'from': ifrom})
|
||||
return self.Iq().setStanzaValues({'id': str(id), 'from': ifrom})
|
||||
|
||||
def makeIqGet(self, queryxmlns = None):
|
||||
iq = self.Iq().setValues({'type': 'get'})
|
||||
iq = self.Iq().setStanzaValues({'type': 'get'})
|
||||
if queryxmlns:
|
||||
iq.append(ET.Element("{%s}query" % queryxmlns))
|
||||
return iq
|
||||
|
||||
def makeIqResult(self, id):
|
||||
return self.Iq().setValues({'id': id, 'type': 'result'})
|
||||
return self.Iq().setStanzaValues({'id': id, 'type': 'result'})
|
||||
|
||||
def makeIqSet(self, sub=None):
|
||||
iq = self.Iq().setValues({'type': 'set'})
|
||||
iq = self.Iq().setStanzaValues({'type': 'set'})
|
||||
if sub != None:
|
||||
iq.append(sub)
|
||||
return iq
|
||||
|
||||
def makeIqError(self, id, type='cancel', condition='feature-not-implemented', text=None):
|
||||
iq = self.Iq().setValues({'id': id})
|
||||
iq['error'].setValues({'type': type, 'condition': condition, 'text': text})
|
||||
iq = self.Iq().setStanzaValues({'id': id})
|
||||
iq['error'].setStanzaValues({'type': type, 'condition': condition, 'text': text})
|
||||
return iq
|
||||
|
||||
def makeIqQuery(self, iq, xmlns):
|
||||
|
|
|
@ -134,7 +134,7 @@ class xep_0045(base.base_plugin):
|
|||
"""
|
||||
if pr['muc']['room'] not in self.rooms.keys():
|
||||
return
|
||||
entry = pr['muc'].getValues()
|
||||
entry = pr['muc'].getStanzaValues()
|
||||
if pr['type'] == 'unavailable':
|
||||
del self.rooms[entry['room']][entry['nick']]
|
||||
else:
|
||||
|
|
|
@ -241,7 +241,7 @@ class ElementBase(tostring.ToString):
|
|||
def __eq__(self, other):
|
||||
if not isinstance(other, ElementBase):
|
||||
return False
|
||||
values = self.getValues()
|
||||
values = self.getStanzaValues()
|
||||
for key in other:
|
||||
if key not in values or values[key] != other[key]:
|
||||
return False
|
||||
|
@ -283,21 +283,21 @@ class ElementBase(tostring.ToString):
|
|||
if child.tag == "{%s}%s" % (self.namespace, name):
|
||||
self.xml.remove(child)
|
||||
|
||||
def getValues(self):
|
||||
def getStanzaValues(self):
|
||||
out = {}
|
||||
for interface in self.interfaces:
|
||||
out[interface] = self[interface]
|
||||
for pluginkey in self.plugins:
|
||||
out[pluginkey] = self.plugins[pluginkey].getValues()
|
||||
out[pluginkey] = self.plugins[pluginkey].getStanzaValues()
|
||||
if self.iterables:
|
||||
iterables = []
|
||||
for stanza in self.iterables:
|
||||
iterables.append(stanza.getValues())
|
||||
iterables.append(stanza.getStanzaValues())
|
||||
iterables[-1].update({'__childtag__': "{%s}%s" % (stanza.namespace, stanza.name)})
|
||||
out['substanzas'] = iterables
|
||||
return out
|
||||
|
||||
def setValues(self, attrib):
|
||||
def setStanzaValues(self, attrib):
|
||||
for interface in attrib:
|
||||
if interface == 'substanzas':
|
||||
for subdict in attrib['substanzas']:
|
||||
|
@ -305,7 +305,7 @@ class ElementBase(tostring.ToString):
|
|||
for subclass in self.subitem:
|
||||
if subdict['__childtag__'] == "{%s}%s" % (subclass.namespace, subclass.name):
|
||||
sub = subclass(parent=self)
|
||||
sub.setValues(subdict)
|
||||
sub.setStanzaValues(subdict)
|
||||
self.iterables.append(sub)
|
||||
break
|
||||
elif interface in self.interfaces:
|
||||
|
@ -313,7 +313,7 @@ class ElementBase(tostring.ToString):
|
|||
elif interface in self.plugin_attrib_map and interface not in self.plugins:
|
||||
self.initPlugin(interface)
|
||||
if interface in self.plugins:
|
||||
self.plugins[interface].setValues(attrib[interface])
|
||||
self.plugins[interface].setStanzaValues(attrib[interface])
|
||||
return self
|
||||
|
||||
def appendxml(self, xml):
|
||||
|
|
Loading…
Reference in a new issue