changeset dd85d8b743c2 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=dd85d8b743c2
description: correctly handle see-other-host (earlier in the connection
process). Fixes #7179
diffstat:
src/common/connection.py | 5 +++++
src/common/connection_handlers.py | 3 +--
src/common/connection_handlers_events.py | 6 ++++--
src/common/resolver.py | 2 ++
src/common/xmpp/client_nb.py | 11 ++++++++---
src/common/xmpp/dispatcher_nb.py | 3 +++
6 files changed, 23 insertions(+), 7 deletions(-)
diffs (132 lines):
diff -r c10af231f45f -r dd85d8b743c2 src/common/connection.py
--- a/src/common/connection.py Sun Jun 17 22:11:17 2012 +0200
+++ b/src/common/connection.py Tue Jun 19 19:19:24 2012 +0200
@@ -1134,6 +1134,10 @@
self._disconnectedReconnCB()
def connect_to_next_type(self, retry=False):
+ if self.redirected:
+ self.disconnect(on_purpose=True)
+ self.connect()
+ return
if len(self._connection_types):
self._current_type = self._connection_types.pop(0)
if self.last_connection:
@@ -1194,6 +1198,7 @@
on_connect=self.on_connect_success,
on_proxy_failure=self.on_proxy_failure,
on_connect_failure=self.connect_to_next_type,
+ on_stream_error_cb=self._StreamCB,
proxy=self._proxy,
secure_tuple = secure_tuple)
diff -r c10af231f45f -r dd85d8b743c2 src/common/connection_handlers.py
--- a/src/common/connection_handlers.py Sun Jun 17 22:11:17 2012 +0200
+++ b/src/common/connection_handlers.py Tue Jun 19 19:19:24 2012 +0200
@@ -1257,6 +1257,7 @@
PrivateStorageRosternotesReceivedEvent)
gajim.nec.register_incoming_event(RosternotesReceivedEvent)
gajim.nec.register_incoming_event(StreamConflictReceivedEvent)
+ gajim.nec.register_incoming_event(StreamOtherHostReceivedEvent)
gajim.nec.register_incoming_event(MessageReceivedEvent)
gajim.nec.register_incoming_event(ArchivingErrorReceivedEvent)
gajim.nec.register_incoming_event(
@@ -2018,8 +2019,6 @@
if obj.conn.name != self.name:
return
self.redirected = obj.redirected
- self.disconnect(on_purpose=True)
- self.connect()
def _StreamCB(self, con, obj):
log.debug('StreamCB')
diff -r c10af231f45f -r dd85d8b743c2 src/common/connection_handlers_events.py
--- a/src/common/connection_handlers_events.py Sun Jun 17 22:11:17 2012 +0200
+++ b/src/common/connection_handlers_events.py Tue Jun 19 19:19:24 2012 +0200
@@ -680,8 +680,10 @@
base_network_events = ['stream-received']
def generate(self):
- other_host = obj.getTag('see-other-host')
- if other_host and self.conn.last_connection_type in ('ssl', 'tls'):
+ self.conn = self.base_event.conn
+ self.stanza = self.base_event.stanza
+ other_host = self.stanza.getTag('see-other-host')
+ if other_host and self.conn._current_type in ('ssl', 'tls'):
host = other_host.getData()
if ':' in host:
host_l = host.split(':', 1)
diff -r c10af231f45f -r dd85d8b743c2 src/common/resolver.py
--- a/src/common/resolver.py Sun Jun 17 22:11:17 2012 +0200
+++ b/src/common/resolver.py Tue Jun 19 19:19:24 2012 +0200
@@ -63,6 +63,7 @@
self.handlers = {}
def resolve(self, host, on_ready, type='srv'):
+ host = host.lower()
log.debug('resolve %s type=%s' % (host, type))
assert(type in ['srv', 'txt'])
if not host:
@@ -88,6 +89,7 @@
def _on_ready(self, host, type, result_list):
# practically it is impossible to be the opposite, but who knows :)
+ host = host.lower()
log.debug('Resolving result for %s: %s' % (host, result_list))
if not self.resolved_hosts.has_key(host+type):
self.resolved_hosts[host+type] = result_list
diff -r c10af231f45f -r dd85d8b743c2 src/common/xmpp/client_nb.py
--- a/src/common/xmpp/client_nb.py Sun Jun 17 22:11:17 2012 +0200
+++ b/src/common/xmpp/client_nb.py Tue Jun 19 19:19:24 2012 +0200
@@ -67,6 +67,7 @@
self.on_connect_failure = None
self.proxy = None
self.got_features = False
+ self.got_see_other_host = None
self.stream_started = False
self.disconnecting = False
self.protocol_type = 'XMPP'
@@ -138,8 +139,8 @@
self.disconnecting = False
def connect(self, on_connect, on_connect_failure, hostname=None, port=5222,
- on_proxy_failure=None, proxy=None, secure_tuple=('plain',
None,
- None)):
+ on_proxy_failure=None, on_stream_error_cb=None, proxy=None,
+ secure_tuple=('plain', None, None)):
"""
Open XMPP connection (open XML streams in both directions)
@@ -161,6 +162,7 @@
self.on_connect = on_connect
self.on_connect_failure=on_connect_failure
self.on_proxy_failure = on_proxy_failure
+ self.on_stream_error_cb = on_stream_error_cb
self.desired_security, self.cacerts, self.mycerts = secure_tuple
self.Connection = None
self.Port = port
@@ -350,7 +352,10 @@
# sometimes <features> are received together with document
# attributes and sometimes on next receive...
self.Dispatcher.ProcessNonBlocking(data)
- if not self.got_features:
+ if self.got_see_other_host:
+ log.info('got see-other-host')
+ self.on_stream_error_cb(self, self.got_see_other_host)
+ elif not self.got_features:
self._xmpp_connect_machine(
mode='FAILURE',
data='Missing <features> in 1.0 stream')
diff -r c10af231f45f -r dd85d8b743c2 src/common/xmpp/dispatcher_nb.py
--- a/src/common/xmpp/dispatcher_nb.py Sun Jun 17 22:11:17 2012 +0200
+++ b/src/common/xmpp/dispatcher_nb.py Tue Jun 19 19:19:24 2012 +0200
@@ -415,6 +415,9 @@
if name == 'features':
self._owner.got_features = True
session.Stream.features = stanza
+ if name == 'error':
+ if stanza.getTag('see-other-host'):
+ self._owner.got_see_other_host = stanza
xmlns = stanza.getNamespace()
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits