summaryrefslogtreecommitdiff
path: root/sleekxmpp/__init__.py
diff options
context:
space:
mode:
authorThom Nichols <tmnichols@gmail.com>2010-06-01 22:55:01 -0400
committerThom Nichols <tmnichols@gmail.com>2010-06-01 22:55:01 -0400
commit060b4c39385e548d1b28bc5ea5bdb29417e156ea (patch)
treed2c9369965b77e37bb065029ac572c35a9f5f1da /sleekxmpp/__init__.py
parent49f5767aea2815211349d93aa03ce2b9dc088c1e (diff)
parent4eb210bff5753143300e5bf6ae09617901e9a28e (diff)
downloadslixmpp-060b4c39385e548d1b28bc5ea5bdb29417e156ea.tar.gz
slixmpp-060b4c39385e548d1b28bc5ea5bdb29417e156ea.tar.bz2
slixmpp-060b4c39385e548d1b28bc5ea5bdb29417e156ea.tar.xz
slixmpp-060b4c39385e548d1b28bc5ea5bdb29417e156ea.zip
Merge branch 'hacks' of github.com:tomstrummer/SleekXMPP
Diffstat (limited to 'sleekxmpp/__init__.py')
-rw-r--r--sleekxmpp/__init__.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/sleekxmpp/__init__.py b/sleekxmpp/__init__.py
index 954ca996..6995f7c9 100644
--- a/sleekxmpp/__init__.py
+++ b/sleekxmpp/__init__.py
@@ -94,6 +94,8 @@ class ClientXMPP(basexmpp, XMLStream):
"""Connect to the Jabber Server. Attempts SRV lookup, and if it fails, uses
the JID server."""
+ if self.state['connected']: return True
+
if host:
self.server = host
if port is None: port = self.port
@@ -174,6 +176,7 @@ class ClientXMPP(basexmpp, XMLStream):
self._handleRoster(iq, request=True)
def _handleStreamFeatures(self, features):
+ logging.debug('handling stream features')
self.features = []
for sub in features.xml:
self.features.append(sub.tag)
@@ -181,12 +184,16 @@ class ClientXMPP(basexmpp, XMLStream):
for feature in self.registered_features:
if feature[0].match(subelement):
#if self.maskcmp(subelement, feature[0], True):
+ # This calls the feature handler & optionally breaks
if feature[1](subelement) and feature[2]: #if breaker, don't continue
return True
def handler_starttls(self, xml):
+ logging.debug( 'TLS start handler; SSL support: %s', self.ssl_support )
if not self.authenticated and self.ssl_support:
- self.add_handler("<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls' />", self.handler_tls_start, instream=True)
+ _stanza = "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls' />"
+ if not self.event_handlers.get(_stanza,None): # don't add handler > once
+ self.add_handler( _stanza, self.handler_tls_start, instream=True )
self.sendXML(xml)
return True
else:
@@ -221,12 +228,13 @@ class ClientXMPP(basexmpp, XMLStream):
return True
def handler_auth_success(self, xml):
+ logging.debug("Authentication successful.")
self.authenticated = True
self.features = []
raise RestartStream()
def handler_auth_fail(self, xml):
- logging.info("Authentication failed.")
+ logging.warning("Authentication failed.")
self.disconnect()
self.event("failed_auth")