changeset 73d9c50e6736 in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=73d9c50e6736
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 02abfa8a4a5f -r 73d9c50e6736 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
@@ -1139,6 +1139,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:
@@ -1199,6 +1203,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 02abfa8a4a5f -r 73d9c50e6736 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
@@ -1254,6 +1254,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(
@@ -1988,8 +1989,6 @@
         if obj.conn.name != self.name:
             return
         self.redirected = obj.redirected
-        self.disconnect(on_purpose=True)
-        self.connect()
 
     def _StreamCB(self, con, iq_obj):
         log.debug('StreamCB')
diff -r 02abfa8a4a5f -r 73d9c50e6736 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
@@ -689,8 +689,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 02abfa8a4a5f -r 73d9c50e6736 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 02abfa8a4a5f -r 73d9c50e6736 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 02abfa8a4a5f -r 73d9c50e6736 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

Reply via email to