mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
Fixed several errors in xep_0033 plugin.
The method getAddresses was removing addresses by mistake. Several instances of using self.attrib instead of self.xml.attrib.
This commit is contained in:
parent
309c9e74eb
commit
059cc9ccc4
1 changed files with 7 additions and 5 deletions
|
@ -34,14 +34,14 @@ class Addresses(ElementBase):
|
||||||
addresses = []
|
addresses = []
|
||||||
for addrXML in self.xml.findall('{%s}address' % Address.namespace):
|
for addrXML in self.xml.findall('{%s}address' % Address.namespace):
|
||||||
# ElementTree 1.2.6 does not support [@attr='value'] in findall
|
# ElementTree 1.2.6 does not support [@attr='value'] in findall
|
||||||
if atype is not None and addrXML.get('type') == atype:
|
if atype is None or addrXML.attrib.get('type') == atype:
|
||||||
self.xml.remove(addrXML)
|
|
||||||
addresses.append(Address(xml=addrXML, parent=None))
|
addresses.append(Address(xml=addrXML, parent=None))
|
||||||
return addresses
|
return addresses
|
||||||
|
|
||||||
def setAddresses(self, addresses, set_type=None):
|
def setAddresses(self, addresses, set_type=None):
|
||||||
self.delAddresses(set_type)
|
self.delAddresses(set_type)
|
||||||
for addr in addresses:
|
for addr in addresses:
|
||||||
|
addr = dict(addr)
|
||||||
# Remap 'type' to 'atype' to match the add method
|
# Remap 'type' to 'atype' to match the add method
|
||||||
if set_type is not None:
|
if set_type is not None:
|
||||||
addr['type'] = set_type
|
addr['type'] = set_type
|
||||||
|
@ -52,9 +52,11 @@ class Addresses(ElementBase):
|
||||||
self.addAddress(**addr)
|
self.addAddress(**addr)
|
||||||
|
|
||||||
def delAddresses(self, atype=None):
|
def delAddresses(self, atype=None):
|
||||||
|
if atype is None:
|
||||||
|
return
|
||||||
for addrXML in self.xml.findall('{%s}address' % Address.namespace):
|
for addrXML in self.xml.findall('{%s}address' % Address.namespace):
|
||||||
# ElementTree 1.2.6 does not support [@attr='value'] in findall
|
# ElementTree 1.2.6 does not support [@attr='value'] in findall
|
||||||
if atype is not None and addrXML.get('type') == atype:
|
if addrXML.attrib.get('type') == atype:
|
||||||
self.xml.remove(addrXML)
|
self.xml.remove(addrXML)
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
@ -126,7 +128,7 @@ class Address(ElementBase):
|
||||||
address_types = set(('bcc', 'cc', 'noreply', 'replyroom', 'replyto', 'to'))
|
address_types = set(('bcc', 'cc', 'noreply', 'replyroom', 'replyto', 'to'))
|
||||||
|
|
||||||
def getDelivered(self):
|
def getDelivered(self):
|
||||||
return self.attrib.get('delivered', False)
|
return self.xml.attrib.get('delivered', False)
|
||||||
|
|
||||||
def setDelivered(self, delivered):
|
def setDelivered(self, delivered):
|
||||||
if delivered:
|
if delivered:
|
||||||
|
|
Loading…
Reference in a new issue