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=[]):
|
def updateRoster(self, jid, name=None, subscription=None, groups=[]):
|
||||||
"""Add or change a roster item."""
|
"""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}}
|
iq['roster']['items'] = {jid: {'name': name, 'subscription': subscription, 'groups': groups}}
|
||||||
#self.send(iq, self.Iq().setValues({'id': iq['id']}))
|
#self.send(iq, self.Iq().setValues({'id': iq['id']}))
|
||||||
r = iq.send()
|
r = iq.send()
|
||||||
|
@ -159,7 +159,7 @@ class ClientXMPP(basexmpp, XMLStream):
|
||||||
|
|
||||||
def getRoster(self):
|
def getRoster(self):
|
||||||
"""Request the roster be sent."""
|
"""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)
|
self._handleRoster(iq, request=True)
|
||||||
|
|
||||||
def _handleStreamFeatures(self, features):
|
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] = {'groups': [], 'name': '', 'subscription': 'none', 'presence': {}, 'in_roster': True}
|
||||||
self.roster[jid].update(iq['roster']['items'][jid])
|
self.roster[jid].update(iq['roster']['items'][jid])
|
||||||
if iq['type'] == 'set':
|
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)
|
self.event("roster_update", iq)
|
||||||
|
|
|
@ -144,26 +144,26 @@ class basexmpp(object):
|
||||||
return waitfor.wait(timeout)
|
return waitfor.wait(timeout)
|
||||||
|
|
||||||
def makeIq(self, id=0, ifrom=None):
|
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):
|
def makeIqGet(self, queryxmlns = None):
|
||||||
iq = self.Iq().setValues({'type': 'get'})
|
iq = self.Iq().setStanzaValues({'type': 'get'})
|
||||||
if queryxmlns:
|
if queryxmlns:
|
||||||
iq.append(ET.Element("{%s}query" % queryxmlns))
|
iq.append(ET.Element("{%s}query" % queryxmlns))
|
||||||
return iq
|
return iq
|
||||||
|
|
||||||
def makeIqResult(self, id):
|
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):
|
def makeIqSet(self, sub=None):
|
||||||
iq = self.Iq().setValues({'type': 'set'})
|
iq = self.Iq().setStanzaValues({'type': 'set'})
|
||||||
if sub != None:
|
if sub != None:
|
||||||
iq.append(sub)
|
iq.append(sub)
|
||||||
return iq
|
return iq
|
||||||
|
|
||||||
def makeIqError(self, id, type='cancel', condition='feature-not-implemented', text=None):
|
def makeIqError(self, id, type='cancel', condition='feature-not-implemented', text=None):
|
||||||
iq = self.Iq().setValues({'id': id})
|
iq = self.Iq().setStanzaValues({'id': id})
|
||||||
iq['error'].setValues({'type': type, 'condition': condition, 'text': text})
|
iq['error'].setStanzaValues({'type': type, 'condition': condition, 'text': text})
|
||||||
return iq
|
return iq
|
||||||
|
|
||||||
def makeIqQuery(self, iq, xmlns):
|
def makeIqQuery(self, iq, xmlns):
|
||||||
|
|
|
@ -134,7 +134,7 @@ class xep_0045(base.base_plugin):
|
||||||
"""
|
"""
|
||||||
if pr['muc']['room'] not in self.rooms.keys():
|
if pr['muc']['room'] not in self.rooms.keys():
|
||||||
return
|
return
|
||||||
entry = pr['muc'].getValues()
|
entry = pr['muc'].getStanzaValues()
|
||||||
if pr['type'] == 'unavailable':
|
if pr['type'] == 'unavailable':
|
||||||
del self.rooms[entry['room']][entry['nick']]
|
del self.rooms[entry['room']][entry['nick']]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -241,7 +241,7 @@ class ElementBase(tostring.ToString):
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if not isinstance(other, ElementBase):
|
if not isinstance(other, ElementBase):
|
||||||
return False
|
return False
|
||||||
values = self.getValues()
|
values = self.getStanzaValues()
|
||||||
for key in other:
|
for key in other:
|
||||||
if key not in values or values[key] != other[key]:
|
if key not in values or values[key] != other[key]:
|
||||||
return False
|
return False
|
||||||
|
@ -283,21 +283,21 @@ class ElementBase(tostring.ToString):
|
||||||
if child.tag == "{%s}%s" % (self.namespace, name):
|
if child.tag == "{%s}%s" % (self.namespace, name):
|
||||||
self.xml.remove(child)
|
self.xml.remove(child)
|
||||||
|
|
||||||
def getValues(self):
|
def getStanzaValues(self):
|
||||||
out = {}
|
out = {}
|
||||||
for interface in self.interfaces:
|
for interface in self.interfaces:
|
||||||
out[interface] = self[interface]
|
out[interface] = self[interface]
|
||||||
for pluginkey in self.plugins:
|
for pluginkey in self.plugins:
|
||||||
out[pluginkey] = self.plugins[pluginkey].getValues()
|
out[pluginkey] = self.plugins[pluginkey].getStanzaValues()
|
||||||
if self.iterables:
|
if self.iterables:
|
||||||
iterables = []
|
iterables = []
|
||||||
for stanza in self.iterables:
|
for stanza in self.iterables:
|
||||||
iterables.append(stanza.getValues())
|
iterables.append(stanza.getStanzaValues())
|
||||||
iterables[-1].update({'__childtag__': "{%s}%s" % (stanza.namespace, stanza.name)})
|
iterables[-1].update({'__childtag__': "{%s}%s" % (stanza.namespace, stanza.name)})
|
||||||
out['substanzas'] = iterables
|
out['substanzas'] = iterables
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def setValues(self, attrib):
|
def setStanzaValues(self, attrib):
|
||||||
for interface in attrib:
|
for interface in attrib:
|
||||||
if interface == 'substanzas':
|
if interface == 'substanzas':
|
||||||
for subdict in attrib['substanzas']:
|
for subdict in attrib['substanzas']:
|
||||||
|
@ -305,7 +305,7 @@ class ElementBase(tostring.ToString):
|
||||||
for subclass in self.subitem:
|
for subclass in self.subitem:
|
||||||
if subdict['__childtag__'] == "{%s}%s" % (subclass.namespace, subclass.name):
|
if subdict['__childtag__'] == "{%s}%s" % (subclass.namespace, subclass.name):
|
||||||
sub = subclass(parent=self)
|
sub = subclass(parent=self)
|
||||||
sub.setValues(subdict)
|
sub.setStanzaValues(subdict)
|
||||||
self.iterables.append(sub)
|
self.iterables.append(sub)
|
||||||
break
|
break
|
||||||
elif interface in self.interfaces:
|
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:
|
elif interface in self.plugin_attrib_map and interface not in self.plugins:
|
||||||
self.initPlugin(interface)
|
self.initPlugin(interface)
|
||||||
if interface in self.plugins:
|
if interface in self.plugins:
|
||||||
self.plugins[interface].setValues(attrib[interface])
|
self.plugins[interface].setStanzaValues(attrib[interface])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def appendxml(self, xml):
|
def appendxml(self, xml):
|
||||||
|
|
Loading…
Reference in a new issue