diff options
Diffstat (limited to 'sleekxmpp/stanza')
-rw-r--r-- | sleekxmpp/stanza/error.py | 26 | ||||
-rw-r--r-- | sleekxmpp/stanza/stream_error.py | 16 |
2 files changed, 40 insertions, 2 deletions
diff --git a/sleekxmpp/stanza/error.py b/sleekxmpp/stanza/error.py index 825287ad..35a8913a 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 = {} @@ -135,6 +136,29 @@ 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): + del self['condition'] + if value: + return self._set_sub_text('{%s}gone' % self.condition_ns, value) + + def set_redirect(self, value): + del self['condition'] + if value: + ns = self.condition_ns + return self._set_sub_text('{%s}redirect' % ns, value) + + 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/stream_error.py b/sleekxmpp/stanza/stream_error.py index 5a6dac96..bf77d932 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,17 @@ 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): + del self['condition'] + if value: + ns = self.condition_ns + return self._set_sub_text('{%s}see-other-host' % ns, value) + + def del_see_other_host(self): + self._del_sub('{%s}see-other-host' % self.condition_ns) + |