mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-12-17 19:16:14 +00:00
Continued reorganization and streamlining.
This commit is contained in:
parent
754ac5092a
commit
634f5d691b
19 changed files with 73 additions and 34 deletions
|
@ -167,12 +167,12 @@ class BaseXMPP(XMLStream):
|
||||||
if not module:
|
if not module:
|
||||||
try:
|
try:
|
||||||
module = sleekxmpp.plugins
|
module = sleekxmpp.plugins
|
||||||
module = __import__("%s.%s" % (module.__name__, plugin),
|
module = __import__(str("%s.%s" % (module.__name__, plugin)),
|
||||||
globals(), locals(), [plugin])
|
globals(), locals(), [str(plugin)])
|
||||||
except ImportError:
|
except ImportError:
|
||||||
module = sleekxmpp.features
|
module = sleekxmpp.features
|
||||||
module = __import__("%s.%s" % (module.__name__, plugin),
|
module = __import__(str("%s.%s" % (module.__name__, plugin)),
|
||||||
globals(), locals(), [plugin])
|
globals(), locals(), [str(plugin)])
|
||||||
if isinstance(module, str):
|
if isinstance(module, str):
|
||||||
# We probably want to load a module from outside
|
# We probably want to load a module from outside
|
||||||
# the sleekxmpp package, so leave out the globals().
|
# the sleekxmpp package, so leave out the globals().
|
||||||
|
|
|
@ -87,8 +87,6 @@ class ClientXMPP(BaseXMPP):
|
||||||
self.features = []
|
self.features = []
|
||||||
self._stream_feature_handlers = {}
|
self._stream_feature_handlers = {}
|
||||||
self._stream_feature_order = []
|
self._stream_feature_order = []
|
||||||
self._sasl_mechanism_handlers = {}
|
|
||||||
self._sasl_mechanism_priorities = []
|
|
||||||
|
|
||||||
#TODO: Use stream state here
|
#TODO: Use stream state here
|
||||||
self.authenticated = False
|
self.authenticated = False
|
||||||
|
|
|
@ -7,4 +7,5 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__all__ = ['feature_starttls', 'feature_mechanisms',
|
__all__ = ['feature_starttls', 'feature_mechanisms',
|
||||||
|
'feature_bind', 'feature_session',
|
||||||
'sasl_plain', 'sasl_anonymous']
|
'sasl_plain', 'sasl_anonymous']
|
||||||
|
|
10
sleekxmpp/features/feature_bind/__init__.py
Normal file
10
sleekxmpp/features/feature_bind/__init__.py
Normal file
|
@ -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
|
|
@ -8,6 +8,9 @@
|
||||||
|
|
||||||
import logging
|
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.matcher import *
|
||||||
from sleekxmpp.xmlstream.handler import *
|
from sleekxmpp.xmlstream.handler import *
|
||||||
from sleekxmpp.plugins.base import base_plugin
|
from sleekxmpp.plugins.base import base_plugin
|
||||||
|
@ -22,12 +25,16 @@ class feature_bind(base_plugin):
|
||||||
self.name = 'Bind Resource'
|
self.name = 'Bind Resource'
|
||||||
self.rfc = '6120'
|
self.rfc = '6120'
|
||||||
self.description = 'Resource Binding Stream Feature'
|
self.description = 'Resource Binding Stream Feature'
|
||||||
|
self.stanza = stanza
|
||||||
|
|
||||||
self.xmpp.register_feature('bind',
|
self.xmpp.register_feature('bind',
|
||||||
self._handle_bind_resource,
|
self._handle_bind_resource,
|
||||||
restart=False,
|
restart=False,
|
||||||
order=10000)
|
order=10000)
|
||||||
|
|
||||||
|
register_stanza_plugin(Iq, stanza.Bind)
|
||||||
|
register_stanza_plugin(StreamFeatures, stanza.Bind)
|
||||||
|
|
||||||
def _handle_bind_resource(self, features):
|
def _handle_bind_resource(self, features):
|
||||||
"""
|
"""
|
||||||
Handle requesting a specific resource.
|
Handle requesting a specific resource.
|
|
@ -6,8 +6,7 @@
|
||||||
See the file LICENSE for copying permission.
|
See the file LICENSE for copying permission.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from sleekxmpp.stanza import Iq
|
from sleekxmpp.stanza import Iq, StreamFeatures
|
||||||
from sleekxmpp.stanza.stream import StreamFeatures
|
|
||||||
from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin
|
from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +20,3 @@ class Bind(ElementBase):
|
||||||
interfaces = set(('resource', 'jid'))
|
interfaces = set(('resource', 'jid'))
|
||||||
sub_interfaces = interfaces
|
sub_interfaces = interfaces
|
||||||
plugin_attrib = 'bind'
|
plugin_attrib = 'bind'
|
||||||
|
|
||||||
|
|
||||||
register_stanza_plugin(Iq, Bind)
|
|
||||||
register_stanza_plugin(StreamFeatures, Bind)
|
|
10
sleekxmpp/features/feature_mechanisms/__init__.py
Normal file
10
sleekxmpp/features/feature_mechanisms/__init__.py
Normal file
|
@ -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 *
|
10
sleekxmpp/features/feature_session/__init__.py
Normal file
10
sleekxmpp/features/feature_session/__init__.py
Normal file
|
@ -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
|
|
@ -8,10 +8,14 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from sleekxmpp.stanza import Iq, StreamFeatures
|
||||||
|
from sleekxmpp.xmlstream import register_stanza_plugin
|
||||||
from sleekxmpp.xmlstream.matcher import *
|
from sleekxmpp.xmlstream.matcher import *
|
||||||
from sleekxmpp.xmlstream.handler import *
|
from sleekxmpp.xmlstream.handler import *
|
||||||
from sleekxmpp.plugins.base import base_plugin
|
from sleekxmpp.plugins.base import base_plugin
|
||||||
|
|
||||||
|
from sleekxmpp.features.feature_session import stanza
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -22,12 +26,16 @@ class feature_session(base_plugin):
|
||||||
self.name = 'Start Session'
|
self.name = 'Start Session'
|
||||||
self.rfc = '3920'
|
self.rfc = '3920'
|
||||||
self.description = 'Start Session Stream Feature'
|
self.description = 'Start Session Stream Feature'
|
||||||
|
self.stanza = stanza
|
||||||
|
|
||||||
self.xmpp.register_feature('session',
|
self.xmpp.register_feature('session',
|
||||||
self._handle_start_session,
|
self._handle_start_session,
|
||||||
restart=False,
|
restart=False,
|
||||||
order=10001)
|
order=10001)
|
||||||
|
|
||||||
|
register_stanza_plugin(Iq, stanza.Session)
|
||||||
|
register_stanza_plugin(StreamFeatures, stanza.Session)
|
||||||
|
|
||||||
def _handle_start_session(self, features):
|
def _handle_start_session(self, features):
|
||||||
"""
|
"""
|
||||||
Handle the start of the session.
|
Handle the start of the session.
|
|
@ -6,8 +6,7 @@
|
||||||
See the file LICENSE for copying permission.
|
See the file LICENSE for copying permission.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from sleekxmpp.stanza import Iq
|
from sleekxmpp.stanza import Iq, StreamFeatures
|
||||||
from sleekxmpp.stanza.stream import StreamFeatures
|
|
||||||
from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin
|
from sleekxmpp.xmlstream import ElementBase, ET, register_stanza_plugin
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +19,3 @@ class Session(ElementBase):
|
||||||
namespace = 'urn:ietf:params:xml:ns:xmpp-session'
|
namespace = 'urn:ietf:params:xml:ns:xmpp-session'
|
||||||
interfaces = set()
|
interfaces = set()
|
||||||
plugin_attrib = 'session'
|
plugin_attrib = 'session'
|
||||||
|
|
||||||
|
|
||||||
register_stanza_plugin(Iq, Session)
|
|
||||||
register_stanza_plugin(StreamFeatures, Session)
|
|
10
sleekxmpp/features/feature_starttls/__init__.py
Normal file
10
sleekxmpp/features/feature_starttls/__init__.py
Normal file
|
@ -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 *
|
|
@ -45,6 +45,3 @@ class Failure(StanzaBase):
|
||||||
name = 'failure'
|
name = 'failure'
|
||||||
namespace = 'urn:ietf:params:xml:ns:xmpp-tls'
|
namespace = 'urn:ietf:params:xml:ns:xmpp-tls'
|
||||||
interfaces = set()
|
interfaces = set()
|
||||||
|
|
||||||
|
|
||||||
register_stanza_plugin(StreamFeatures, STARTTLS)
|
|
|
@ -8,11 +8,12 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from sleekxmpp.stanza.stream import tls
|
from sleekxmpp.stanza import StreamFeatures
|
||||||
from sleekxmpp.xmlstream import RestartStream
|
from sleekxmpp.xmlstream import RestartStream, register_stanza_plugin
|
||||||
from sleekxmpp.xmlstream.matcher import *
|
from sleekxmpp.xmlstream.matcher import *
|
||||||
from sleekxmpp.xmlstream.handler import *
|
from sleekxmpp.xmlstream.handler import *
|
||||||
from sleekxmpp.plugins.base import base_plugin
|
from sleekxmpp.plugins.base import base_plugin
|
||||||
|
from sleekxmpp.features.feature_starttls import stanza
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -24,11 +25,11 @@ class feature_starttls(base_plugin):
|
||||||
self.name = "STARTTLS"
|
self.name = "STARTTLS"
|
||||||
self.rfc = '6120'
|
self.rfc = '6120'
|
||||||
self.description = "STARTTLS Stream Feature"
|
self.description = "STARTTLS Stream Feature"
|
||||||
|
self.stanza = stanza
|
||||||
|
|
||||||
self.xmpp.register_stanza(tls.Proceed)
|
|
||||||
self.xmpp.register_handler(
|
self.xmpp.register_handler(
|
||||||
Callback('STARTTLS Proceed',
|
Callback('STARTTLS Proceed',
|
||||||
MatchXPath(tls.Proceed.tag_name()),
|
MatchXPath(stanza.Proceed.tag_name()),
|
||||||
self._handle_starttls_proceed,
|
self._handle_starttls_proceed,
|
||||||
instream=True))
|
instream=True))
|
||||||
self.xmpp.register_feature('starttls',
|
self.xmpp.register_feature('starttls',
|
||||||
|
@ -36,6 +37,10 @@ class feature_starttls(base_plugin):
|
||||||
restart=True,
|
restart=True,
|
||||||
order=self.config.get('order', 0))
|
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):
|
def _handle_starttls(self, features):
|
||||||
"""
|
"""
|
||||||
Handle notification that the server supports TLS.
|
Handle notification that the server supports TLS.
|
|
@ -11,7 +11,5 @@ from sleekxmpp.stanza.error import Error
|
||||||
from sleekxmpp.stanza.iq import Iq
|
from sleekxmpp.stanza.iq import Iq
|
||||||
from sleekxmpp.stanza.message import Message
|
from sleekxmpp.stanza.message import Message
|
||||||
from sleekxmpp.stanza.presence import Presence
|
from sleekxmpp.stanza.presence import Presence
|
||||||
from sleekxmpp.stanza.stream import StreamFeatures
|
from sleekxmpp.stanza.stream_features import StreamFeatures
|
||||||
from sleekxmpp.stanza.stream import Bind
|
from sleekxmpp.stanza.stream_error import StreamError
|
||||||
from sleekxmpp.stanza.stream import Session
|
|
||||||
from sleekxmpp.stanza.stream import StreamError
|
|
||||||
|
|
|
@ -6,8 +6,3 @@
|
||||||
See the file LICENSE for copying permission.
|
See the file LICENSE for copying permission.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from sleekxmpp.stanza.stream.error import StreamError
|
|
||||||
from sleekxmpp.stanza.stream.features import StreamFeatures
|
|
||||||
from sleekxmpp.stanza.stream.bind import Bind
|
|
||||||
from sleekxmpp.stanza.stream.session import Session
|
|
||||||
|
|
Loading…
Reference in a new issue