From 5ab77c745270d7d5c016c1dc7ef2a82533a4b16e Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 17 Jul 2014 14:19:04 +0200 Subject: Rename to slixmpp --- slixmpp/features/feature_session/__init__.py | 19 ++++++++++ slixmpp/features/feature_session/session.py | 54 ++++++++++++++++++++++++++++ slixmpp/features/feature_session/stanza.py | 20 +++++++++++ 3 files changed, 93 insertions(+) create mode 100644 slixmpp/features/feature_session/__init__.py create mode 100644 slixmpp/features/feature_session/session.py create mode 100644 slixmpp/features/feature_session/stanza.py (limited to 'slixmpp/features/feature_session') diff --git a/slixmpp/features/feature_session/__init__.py b/slixmpp/features/feature_session/__init__.py new file mode 100644 index 00000000..0ac950c6 --- /dev/null +++ b/slixmpp/features/feature_session/__init__.py @@ -0,0 +1,19 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2011 Nathanael C. Fritz + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.base import register_plugin + +from slixmpp.features.feature_session.session import FeatureSession +from slixmpp.features.feature_session.stanza import Session + + +register_plugin(FeatureSession) + + +# Retain some backwards compatibility +feature_session = FeatureSession diff --git a/slixmpp/features/feature_session/session.py b/slixmpp/features/feature_session/session.py new file mode 100644 index 00000000..c2694a9f --- /dev/null +++ b/slixmpp/features/feature_session/session.py @@ -0,0 +1,54 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2011 Nathanael C. Fritz + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +import logging + +from slixmpp.stanza import Iq, StreamFeatures +from slixmpp.xmlstream import register_stanza_plugin +from slixmpp.plugins import BasePlugin + +from slixmpp.features.feature_session import stanza + + +log = logging.getLogger(__name__) + + +class FeatureSession(BasePlugin): + + name = 'feature_session' + description = 'RFC 3920: Stream Feature: Start Session' + dependencies = set() + stanza = stanza + + def plugin_init(self): + self.xmpp.register_feature('session', + self._handle_start_session, + restart=False, + order=10001) + + register_stanza_plugin(Iq, stanza.Session) + register_stanza_plugin(StreamFeatures, stanza.Session) + + def _handle_start_session(self, features): + """ + Handle the start of the session. + + Arguments: + feature -- The stream features element. + """ + iq = self.xmpp.Iq() + iq['type'] = 'set' + iq.enable('session') + iq.send(now=True) + + self.xmpp.features.add('session') + + log.debug("Established Session") + self.xmpp.sessionstarted = True + self.xmpp.session_started_event.set() + self.xmpp.event('session_start') diff --git a/slixmpp/features/feature_session/stanza.py b/slixmpp/features/feature_session/stanza.py new file mode 100644 index 00000000..f68483d6 --- /dev/null +++ b/slixmpp/features/feature_session/stanza.py @@ -0,0 +1,20 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2011 Nathanael C. Fritz + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.xmlstream import ElementBase + + +class Session(ElementBase): + + """ + """ + + name = 'session' + namespace = 'urn:ietf:params:xml:ns:xmpp-session' + interfaces = set() + plugin_attrib = 'session' -- cgit v1.2.3