From 084d6cb5d9cd017a084c4a2b30741ccf5180de98 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 14 Mar 2018 18:54:17 +0100 Subject: =?UTF-8?q?session:=20Don=E2=80=99t=20bind=20if=20it=20is=20option?= =?UTF-8?q?al.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://tools.ietf.org/html/draft-cridland-xmpp-session-01 --- slixmpp/features/feature_session/stanza.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'slixmpp/features/feature_session/stanza.py') diff --git a/slixmpp/features/feature_session/stanza.py b/slixmpp/features/feature_session/stanza.py index f68483d6..4ed8c4db 100644 --- a/slixmpp/features/feature_session/stanza.py +++ b/slixmpp/features/feature_session/stanza.py @@ -6,7 +6,7 @@ See the file LICENSE for copying permission. """ -from slixmpp.xmlstream import ElementBase +from slixmpp.xmlstream import ElementBase, ET class Session(ElementBase): @@ -16,5 +16,19 @@ class Session(ElementBase): name = 'session' namespace = 'urn:ietf:params:xml:ns:xmpp-session' - interfaces = set() + interfaces = {'optional'} plugin_attrib = 'session' + + def get_optional(self): + return self.xml.find('{%s}optional' % self.namespace) is not None + + def set_optional(self, value): + if value: + optional = ET.Element('{%s}optional' % self.namespace) + self.xml.append(optional) + else: + self.del_optional() + + def del_optional(self): + optional = self.xml.find('{%s}optional' % self.namespace) + self.xml.remove(optional) -- cgit v1.2.3