summaryrefslogtreecommitdiff
path: root/sleekxmpp/features
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-07-01 14:45:55 -0700
committerLance Stout <lancestout@gmail.com>2011-07-01 14:45:55 -0700
commit634f5d691bab9855deddc4c201389bb60470d76e (patch)
tree29303420af94646ddac01824ebb4a201606b18e1 /sleekxmpp/features
parent754ac5092a3a37819a71f6565a1e54b3f2547940 (diff)
downloadslixmpp-634f5d691bab9855deddc4c201389bb60470d76e.tar.gz
slixmpp-634f5d691bab9855deddc4c201389bb60470d76e.tar.bz2
slixmpp-634f5d691bab9855deddc4c201389bb60470d76e.tar.xz
slixmpp-634f5d691bab9855deddc4c201389bb60470d76e.zip
Continued reorganization and streamlining.
Diffstat (limited to 'sleekxmpp/features')
-rw-r--r--sleekxmpp/features/__init__.py1
-rw-r--r--sleekxmpp/features/feature_bind/__init__.py10
-rw-r--r--sleekxmpp/features/feature_bind/bind.py (renamed from sleekxmpp/features/feature_bind.py)7
-rw-r--r--sleekxmpp/features/feature_bind/stanza.py22
-rw-r--r--sleekxmpp/features/feature_mechanisms/__init__.py10
-rw-r--r--sleekxmpp/features/feature_mechanisms/mechanisms.py (renamed from sleekxmpp/features/feature_mechanisms.py)0
-rw-r--r--sleekxmpp/features/feature_mechanisms/stanza.py104
-rw-r--r--sleekxmpp/features/feature_session/__init__.py10
-rw-r--r--sleekxmpp/features/feature_session/session.py (renamed from sleekxmpp/features/feature_session.py)8
-rw-r--r--sleekxmpp/features/feature_session/stanza.py21
-rw-r--r--sleekxmpp/features/feature_starttls/__init__.py10
-rw-r--r--sleekxmpp/features/feature_starttls/stanza.py47
-rw-r--r--sleekxmpp/features/feature_starttls/starttls.py (renamed from sleekxmpp/features/feature_starttls.py)13
13 files changed, 259 insertions, 4 deletions
diff --git a/sleekxmpp/features/__init__.py b/sleekxmpp/features/__init__.py
index 940a37f1..65d2bdbf 100644
--- a/sleekxmpp/features/__init__.py
+++ b/sleekxmpp/features/__init__.py
@@ -7,4 +7,5 @@
"""
__all__ = ['feature_starttls', 'feature_mechanisms',
+ 'feature_bind', 'feature_session',
'sasl_plain', 'sasl_anonymous']
diff --git a/sleekxmpp/features/feature_bind/__init__.py b/sleekxmpp/features/feature_bind/__init__.py
new file mode 100644
index 00000000..fce94dd6
--- /dev/null
+++ b/sleekxmpp/features/feature_bind/__init__.py
@@ -0,0 +1,10 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.features.feature_bind.bind import feature_bind
+from sleekxmpp.features.feature_bind.stanza import Bind
diff --git a/sleekxmpp/features/feature_bind.py b/sleekxmpp/features/feature_bind/bind.py
index caa3844b..e177d7b2 100644
--- a/sleekxmpp/features/feature_bind.py
+++ b/sleekxmpp/features/feature_bind/bind.py
@@ -8,6 +8,9 @@
import logging
+from sleekxmpp.stanza import Iq, StreamFeatures
+from sleekxmpp.features.feature_bind import stanza
+from sleekxmpp.xmlstream import register_stanza_plugin
from sleekxmpp.xmlstream.matcher import *
from sleekxmpp.xmlstream.handler import *
from sleekxmpp.plugins.base import base_plugin
@@ -22,12 +25,16 @@ class feature_bind(base_plugin):
self.name = 'Bind Resource'
self.rfc = '6120'
self.description = 'Resource Binding Stream Feature'
+ self.stanza = stanza
self.xmpp.register_feature('bind',
self._handle_bind_resource,
restart=False,
order=10000)
+ register_stanza_plugin(Iq, stanza.Bind)
+ register_stanza_plugin(StreamFeatures, stanza.Bind)
+
def _handle_bind_resource(self, features):
"""
Handle requesting a specific resource.
diff --git a/sleekxmpp/features/feature_bind/stanza.py b/sleekxmpp/features/feature_bind/stanza.py
new file mode 100644
index 00000000..f3e025fa
--- /dev/null
+++ b/sleekxmpp/features/feature_bind/stanza.py
@@ -0,0 +1,22 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.stanza import Iq, StreamFeatures
+from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin
+
+
+class Bind(ElementBase):
+
+ """
+ """
+
+ name = 'bind'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-bind'
+ interfaces = set(('resource', 'jid'))
+ sub_interfaces = interfaces
+ plugin_attrib = 'bind'
diff --git a/sleekxmpp/features/feature_mechanisms/__init__.py b/sleekxmpp/features/feature_mechanisms/__init__.py
new file mode 100644
index 00000000..a93b2b6f
--- /dev/null
+++ b/sleekxmpp/features/feature_mechanisms/__init__.py
@@ -0,0 +1,10 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.features.feature_mechanisms.mechanisms import feature_mechanisms
+from sleekxmpp.features.feature_mechanisms.stanza import *
diff --git a/sleekxmpp/features/feature_mechanisms.py b/sleekxmpp/features/feature_mechanisms/mechanisms.py
index 994c9bed..994c9bed 100644
--- a/sleekxmpp/features/feature_mechanisms.py
+++ b/sleekxmpp/features/feature_mechanisms/mechanisms.py
diff --git a/sleekxmpp/features/feature_mechanisms/stanza.py b/sleekxmpp/features/feature_mechanisms/stanza.py
new file mode 100644
index 00000000..e55a72ad
--- /dev/null
+++ b/sleekxmpp/features/feature_mechanisms/stanza.py
@@ -0,0 +1,104 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.stanza import StreamFeatures
+from sleekxmpp.xmlstream import ElementBase, StanzaBase, ET
+from sleekxmpp.xmlstream import register_stanza_plugin
+
+
+class Mechanisms(ElementBase):
+
+ """
+ """
+
+ name = 'mechanisms'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
+ interfaces = set(('mechanisms', 'required'))
+ plugin_attrib = name
+ is_extension = True
+
+ def get_required(self):
+ """
+ """
+ return True
+
+ def get_mechanisms(self):
+ """
+ """
+ results = []
+ mechs = self.findall('{%s}mechanism' % self.namespace)
+ if mechs:
+ for mech in mechs:
+ results.append(mech.text)
+ return results
+
+ def set_mechanisms(self, values):
+ """
+ """
+ self.del_mechanisms()
+ for val in values:
+ mech = ET.Element('{%s}mechanism' % self.namespace)
+ mech.text = val
+ self.append(mech)
+
+ def del_mechanisms(self):
+ """
+ """
+ mechs = self.findall('{%s}mechanism' % self.namespace)
+ if mechs:
+ for mech in mechs:
+ self.xml.remove(mech)
+
+
+class Success(StanzaBase):
+
+ """
+ """
+
+ name = 'success'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
+ interfaces = set()
+ plugin_attrib = name
+
+
+class Failure(StanzaBase):
+
+ """
+ """
+
+ name = 'failure'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
+ interfaces = set()
+ plugin_attrib = name
+
+
+class Auth(StanzaBase):
+
+ """
+ """
+
+ name = 'auth'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-sasl'
+ interfaces = set(('mechanism', 'value'))
+ plugin_attrib = name
+
+ def setup(self, xml):
+ StanzaBase.setup(self, xml)
+ self.xml.tag = self.tag_name()
+
+ def set_value(self, value):
+ self.xml.text = value
+
+ def get_value(self):
+ return self.xml.text
+
+ def del_value(self):
+ self.xml.text = ''
+
+
+register_stanza_plugin(StreamFeatures, Mechanisms)
diff --git a/sleekxmpp/features/feature_session/__init__.py b/sleekxmpp/features/feature_session/__init__.py
new file mode 100644
index 00000000..1399f73b
--- /dev/null
+++ b/sleekxmpp/features/feature_session/__init__.py
@@ -0,0 +1,10 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.features.feature_session.session import feature_session
+from sleekxmpp.features.feature_session.stanza import Session
diff --git a/sleekxmpp/features/feature_session.py b/sleekxmpp/features/feature_session/session.py
index 5bae358c..4d17b2d2 100644
--- a/sleekxmpp/features/feature_session.py
+++ b/sleekxmpp/features/feature_session/session.py
@@ -8,10 +8,14 @@
import logging
+from sleekxmpp.stanza import Iq, StreamFeatures
+from sleekxmpp.xmlstream import register_stanza_plugin
from sleekxmpp.xmlstream.matcher import *
from sleekxmpp.xmlstream.handler import *
from sleekxmpp.plugins.base import base_plugin
+from sleekxmpp.features.feature_session import stanza
+
log = logging.getLogger(__name__)
@@ -22,12 +26,16 @@ class feature_session(base_plugin):
self.name = 'Start Session'
self.rfc = '3920'
self.description = 'Start Session Stream Feature'
+ self.stanza = stanza
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.
diff --git a/sleekxmpp/features/feature_session/stanza.py b/sleekxmpp/features/feature_session/stanza.py
new file mode 100644
index 00000000..2047a4f0
--- /dev/null
+++ b/sleekxmpp/features/feature_session/stanza.py
@@ -0,0 +1,21 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.stanza import Iq, StreamFeatures
+from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin
+
+
+class Session(ElementBase):
+
+ """
+ """
+
+ name = 'session'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-session'
+ interfaces = set()
+ plugin_attrib = 'session'
diff --git a/sleekxmpp/features/feature_starttls/__init__.py b/sleekxmpp/features/feature_starttls/__init__.py
new file mode 100644
index 00000000..042e37fa
--- /dev/null
+++ b/sleekxmpp/features/feature_starttls/__init__.py
@@ -0,0 +1,10 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.features.feature_starttls.starttls import feature_starttls
+from sleekxmpp.features.feature_starttls.stanza import *
diff --git a/sleekxmpp/features/feature_starttls/stanza.py b/sleekxmpp/features/feature_starttls/stanza.py
new file mode 100644
index 00000000..5fdafabd
--- /dev/null
+++ b/sleekxmpp/features/feature_starttls/stanza.py
@@ -0,0 +1,47 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.stanza import StreamFeatures
+from sleekxmpp.xmlstream import StanzaBase, ElementBase
+from sleekxmpp.xmlstream import register_stanza_plugin
+
+
+class STARTTLS(ElementBase):
+
+ """
+ """
+
+ name = 'starttls'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-tls'
+ interfaces = set(('required',))
+ plugin_attrib = name
+
+ def get_required(self):
+ """
+ """
+ return True
+
+
+class Proceed(StanzaBase):
+
+ """
+ """
+
+ name = 'proceed'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-tls'
+ interfaces = set()
+
+
+class Failure(StanzaBase):
+
+ """
+ """
+
+ name = 'failure'
+ namespace = 'urn:ietf:params:xml:ns:xmpp-tls'
+ interfaces = set()
diff --git a/sleekxmpp/features/feature_starttls.py b/sleekxmpp/features/feature_starttls/starttls.py
index 5367fa49..cbb94be0 100644
--- a/sleekxmpp/features/feature_starttls.py
+++ b/sleekxmpp/features/feature_starttls/starttls.py
@@ -8,11 +8,12 @@
import logging
-from sleekxmpp.stanza.stream import tls
-from sleekxmpp.xmlstream import RestartStream
+from sleekxmpp.stanza import StreamFeatures
+from sleekxmpp.xmlstream import RestartStream, register_stanza_plugin
from sleekxmpp.xmlstream.matcher import *
from sleekxmpp.xmlstream.handler import *
from sleekxmpp.plugins.base import base_plugin
+from sleekxmpp.features.feature_starttls import stanza
log = logging.getLogger(__name__)
@@ -24,11 +25,11 @@ class feature_starttls(base_plugin):
self.name = "STARTTLS"
self.rfc = '6120'
self.description = "STARTTLS Stream Feature"
+ self.stanza = stanza
- self.xmpp.register_stanza(tls.Proceed)
self.xmpp.register_handler(
Callback('STARTTLS Proceed',
- MatchXPath(tls.Proceed.tag_name()),
+ MatchXPath(stanza.Proceed.tag_name()),
self._handle_starttls_proceed,
instream=True))
self.xmpp.register_feature('starttls',
@@ -36,6 +37,10 @@ class feature_starttls(base_plugin):
restart=True,
order=self.config.get('order', 0))
+ self.xmpp.register_stanza(stanza.Proceed)
+ self.xmpp.register_stanza(stanza.Failure)
+ register_stanza_plugin(StreamFeatures, stanza.STARTTLS)
+
def _handle_starttls(self, features):
"""
Handle notification that the server supports TLS.