changeset b866926c8c53 in /home/hg/repos/python-nbxmpp
details:http://hg.gajim.org/python-nbxmpp?cmd=changeset;node=b866926c8c53
description: handle disconnection while doing SASL as a sasl failure rather than a connection error.
diffstat:
nbxmpp/client_nb.py | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diffs (45 lines):
diff -r 01d3262e1b92 -r b866926c8c53 nbxmpp/client_nb.py
--- a/nbxmpp/client_nb.py Thu Nov 29 14:46:27 2012 +0100
+++ b/nbxmpp/client_nb.py Thu Nov 29 14:56:33 2012 +0100
@@ -85,6 +85,7 @@
log.info('Disconnecting NBClient: %s' % message)
+ sasl_failed = False
if 'NonBlockingRoster' in self.__dict__:
self.NonBlockingRoster.PlugOut()
if 'NonBlockingBind' in self.__dict__:
@@ -92,7 +93,12 @@
if 'NonBlockingNonSASL' in self.__dict__:
self.NonBlockingNonSASL.PlugOut()
if 'SASL' in self.__dict__:
- self.SASL.PlugOut()
+ if self.SASL.startsasl == 'failure-in-process':
+ sasl_failed = True
+ self.SASL.startsasl = 'failure'
+ self._on_start_sasl()
+ else:
+ self.SASL.PlugOut()
if 'NonBlockingTCP' in self.__dict__:
self.NonBlockingTCP.PlugOut()
if 'NonBlockingHTTP' in self.__dict__:
@@ -111,7 +117,9 @@
self.disconnecting = True
log.debug('Client disconnected..')
- if connected == '':
+ # Don't call any callback when it's a SASL failure.
+ # SASL handler is already called
+ if connected == '' and not sasl_failed:
# if we're disconnecting before connection to XMPP sever is opened,
# we don't call disconnect handlers but on_connect_failure callback
if self.proxy:
@@ -121,7 +129,7 @@
else:
log.debug('calling on_connect_failure cb')
self.on_connect_failure()
- else:
+ elif not sasl_failed:
# we are connected to XMPP server
if not stream_started:
# if error occur before XML stream was opened, e.g. no response on
changeset 83e56a7e2f5e in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=83e56a7e2f5e
description: prevent connection to be called when there is no connection
diffstat:
src/common/connection.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diffs (12 lines):
diff -r b8a2f4925a43 -r 83e56a7e2f5e src/common/connection.py
--- a/src/common/connection.py Fri Nov 23 11:44:03 2012 +0400
+++ b/src/common/connection.py Fri Nov 23 21:38:36 2012 -0400
@@ -1667,7 +1667,7 @@
self._stun_servers = self._hosts = [i for i in result_array]
def _request_privacy(self):
- if not gajim.account_is_connected(self.name):
+ if not gajim.account_is_connected(self.name) or not self.connection:
return
iq = common.xmpp.Iq('get', common.xmpp.NS_PRIVACY, xmlns = '')
id_ = self.connection.getAnID()