summaryrefslogtreecommitdiff
path: root/sleekxmpp/stanza
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-06-19 21:50:33 -0700
committerLance Stout <lancestout@gmail.com>2012-06-19 21:50:33 -0700
commit5820d49cd401a1362a8a675c4b91935adb1240fe (patch)
treef40f78839ae3004bfb0b8da1ae93d61759d8ad66 /sleekxmpp/stanza
parent1ab66e576786ecb0cfb9b6b163811735564b951b (diff)
parent36c11ad9de7c1b5a199aa5a4302e33085513c126 (diff)
downloadslixmpp-5820d49cd401a1362a8a675c4b91935adb1240fe.tar.gz
slixmpp-5820d49cd401a1362a8a675c4b91935adb1240fe.tar.bz2
slixmpp-5820d49cd401a1362a8a675c4b91935adb1240fe.tar.xz
slixmpp-5820d49cd401a1362a8a675c4b91935adb1240fe.zip
Merge branch 'master' into develop
Conflicts: sleekxmpp/basexmpp.py
Diffstat (limited to 'sleekxmpp/stanza')
-rw-r--r--sleekxmpp/stanza/error.py34
-rw-r--r--sleekxmpp/stanza/iq.py4
-rw-r--r--sleekxmpp/stanza/rootstanza.py3
-rw-r--r--sleekxmpp/stanza/roster.py5
-rw-r--r--sleekxmpp/stanza/stream_error.py17
-rw-r--r--sleekxmpp/stanza/stream_features.py6
6 files changed, 59 insertions, 10 deletions
diff --git a/sleekxmpp/stanza/error.py b/sleekxmpp/stanza/error.py
index 825287ad..60bc65bc 100644
--- a/sleekxmpp/stanza/error.py
+++ b/sleekxmpp/stanza/error.py
@@ -51,7 +51,8 @@ class Error(ElementBase):
namespace = 'jabber:client'
name = 'error'
plugin_attrib = 'error'
- interfaces = set(('code', 'condition', 'text', 'type'))
+ interfaces = set(('code', 'condition', 'text', 'type',
+ 'gone', 'redirect'))
sub_interfaces = set(('text',))
plugin_attrib_map = {}
plugin_tag_map = {}
@@ -88,7 +89,7 @@ class Error(ElementBase):
def get_condition(self):
"""Return the condition element's name."""
- for child in self.xml.getchildren():
+ for child in self.xml:
if "{%s}" % self.condition_ns in child.tag:
cond = child.tag.split('}', 1)[-1]
if cond in self.conditions:
@@ -109,7 +110,7 @@ class Error(ElementBase):
def del_condition(self):
"""Remove the condition element."""
- for child in self.xml.getchildren():
+ for child in self.xml:
if "{%s}" % self.condition_ns in child.tag:
tag = child.tag.split('}', 1)[-1]
if tag in self.conditions:
@@ -135,6 +136,33 @@ class Error(ElementBase):
self._del_sub('{%s}text' % self.condition_ns)
return self
+ def get_gone(self):
+ return self._get_sub_text('{%s}gone' % self.condition_ns, '')
+
+ def get_redirect(self):
+ return self._get_sub_text('{%s}redirect' % self.condition_ns, '')
+
+ def set_gone(self, value):
+ if value:
+ del self['condition']
+ return self._set_sub_text('{%s}gone' % self.condition_ns, value)
+ elif self['condition'] == 'gone':
+ del self['condition']
+
+ def set_redirect(self, value):
+ if value:
+ del self['condition']
+ ns = self.condition_ns
+ return self._set_sub_text('{%s}redirect' % ns, value)
+ elif self['condition'] == 'redirect':
+ del self['condition']
+
+ def del_gone(self):
+ self._del_sub('{%s}gone' % self.condition_ns)
+
+ def del_redirect(self):
+ self._del_sub('{%s}redirect' % self.condition_ns)
+
# To comply with PEP8, method names now use underscores.
# Deprecated method names are re-mapped for backwards compatibility.
diff --git a/sleekxmpp/stanza/iq.py b/sleekxmpp/stanza/iq.py
index 47d51b04..f45b3c67 100644
--- a/sleekxmpp/stanza/iq.py
+++ b/sleekxmpp/stanza/iq.py
@@ -122,7 +122,7 @@ class Iq(RootStanza):
def get_query(self):
"""Return the namespace of the <query> element."""
- for child in self.xml.getchildren():
+ for child in self.xml:
if child.tag.endswith('query'):
ns = child.tag.split('}')[0]
if '{' in ns:
@@ -132,7 +132,7 @@ class Iq(RootStanza):
def del_query(self):
"""Remove the <query> element."""
- for child in self.xml.getchildren():
+ for child in self.xml:
if child.tag.endswith('query'):
self.xml.remove(child)
return self
diff --git a/sleekxmpp/stanza/rootstanza.py b/sleekxmpp/stanza/rootstanza.py
index bb756acb..a7c2b218 100644
--- a/sleekxmpp/stanza/rootstanza.py
+++ b/sleekxmpp/stanza/rootstanza.py
@@ -78,7 +78,8 @@ class RootStanza(StanzaBase):
self['error']['type'] = 'cancel'
self.send()
# log the error
- log.exception('Error handling {%s}%s stanza' , self.namespace, self.name)
+ log.exception('Error handling {%s}%s stanza',
+ self.namespace, self.name)
# Finally raise the exception to a global exception handler
self.stream.exception(e)
diff --git a/sleekxmpp/stanza/roster.py b/sleekxmpp/stanza/roster.py
index 253c2aea..a415c482 100644
--- a/sleekxmpp/stanza/roster.py
+++ b/sleekxmpp/stanza/roster.py
@@ -47,7 +47,7 @@ class Roster(ElementBase):
roster versioning.
"""
return self.xml.attrib.get('ver', None)
-
+
def set_ver(self, ver):
"""
Ensure handling an empty ver attribute propery.
@@ -101,7 +101,8 @@ class Roster(ElementBase):
items[item['jid']] = item.values
# Remove extra JID reference to keep everything
# backward compatible
- del items[item['jid']]['jid']
+ del items[item['jid']]['jid']
+ del items[item['jid']]['lang']
return items
def del_items(self):
diff --git a/sleekxmpp/stanza/stream_error.py b/sleekxmpp/stanza/stream_error.py
index 5a6dac96..ed0078c9 100644
--- a/sleekxmpp/stanza/stream_error.py
+++ b/sleekxmpp/stanza/stream_error.py
@@ -54,7 +54,7 @@ class StreamError(Error, StanzaBase):
"""
namespace = 'http://etherx.jabber.org/streams'
- interfaces = set(('condition', 'text'))
+ interfaces = set(('condition', 'text', 'see_other_host'))
conditions = set((
'bad-format', 'bad-namespace-prefix', 'conflict',
'connection-timeout', 'host-gone', 'host-unknown',
@@ -66,3 +66,18 @@ class StreamError(Error, StanzaBase):
'unsupported-feature', 'unsupported-stanza-type',
'unsupported-version'))
condition_ns = 'urn:ietf:params:xml:ns:xmpp-streams'
+
+ def get_see_other_host(self):
+ ns = self.condition_ns
+ return self._get_sub_text('{%s}see-other-host' % ns, '')
+
+ def set_see_other_host(self, value):
+ if value:
+ del self['condition']
+ ns = self.condition_ns
+ return self._set_sub_text('{%s}see-other-host' % ns, value)
+ elif self['condition'] == 'see-other-host':
+ del self['condition']
+
+ def del_see_other_host(self):
+ self._del_sub('{%s}see-other-host' % self.condition_ns)
diff --git a/sleekxmpp/stanza/stream_features.py b/sleekxmpp/stanza/stream_features.py
index 9993c84a..e487721e 100644
--- a/sleekxmpp/stanza/stream_features.py
+++ b/sleekxmpp/stanza/stream_features.py
@@ -6,6 +6,7 @@
See the file LICENSE for copying permission.
"""
+from sleekxmpp.thirdparty import OrderedDict
from sleekxmpp.xmlstream import StanzaBase
@@ -28,7 +29,10 @@ class StreamFeatures(StanzaBase):
def get_features(self):
"""
"""
- return self.plugins
+ features = OrderedDict()
+ for (name, lang), plugin in self.plugins.items():
+ features[name] = plugin
+ return features
def set_features(self, value):
"""