diff --git a/src/common/connection.py b/src/common/connection.py index 46daadfa0c61330f269d739d1f0a01b732f10ad0..e5ac4b86d4d7921e87cd2d1a7950c455ba1d59f7 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -712,7 +712,7 @@ class Connection(CommonConnection, ConnectionHandlers): self.streamError = '' self.secret_hmac = str(random.random())[2:] - self.sm = Smacks(self) + self.sm = Smacks(self) # Stream Management gajim.ged.register_event_handler('privacy-list-received', ged.CORE, self._nec_privacy_list_received) @@ -805,8 +805,9 @@ class Connection(CommonConnection, ConnectionHandlers): self.old_show = gajim.SHOW_LIST[self.connected] self.connected = 0 if not self.on_purpose: - gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, - show='offline')) + if not (self.sm and self.sm.resumption): + gajim.nec.push_incoming_event(OurShowEvent(None, conn=self, + show='offline')) self.disconnect() if gajim.config.get_per('accounts', self.name, 'autoreconnect'): self.connected = -1 diff --git a/src/common/xmpp/auth_nb.py b/src/common/xmpp/auth_nb.py index 9039b12f5fbdfffed4facf7f94e75758d37c5507..79b967c204ca193c2e0bdbe8d35438b0635fc38f 100644 --- a/src/common/xmpp/auth_nb.py +++ b/src/common/xmpp/auth_nb.py @@ -574,6 +574,7 @@ class NonBlockingBind(PlugIn): PlugIn.__init__(self) self.bound = None self.supports_sm = False + self.resuming = False def plugin(self, owner): ''' Start resource binding, if allowed at this time. Used internally. ''' @@ -597,6 +598,8 @@ class NonBlockingBind(PlugIn): if feats.getTag('sm', namespace=NS_STREAM_MGMT): self.supports_sm = True # server supports stream management + if self.resuming: + self._owner._caller.sm.resume_request() if not feats.getTag('bind', namespace=NS_BIND): log.info('Server does not requested binding.') @@ -621,6 +624,8 @@ class NonBlockingBind(PlugIn): """ Perform binding. Use provided resource name or random (if not provided). """ + if self.resuming: # We don't bind if we resume the stream + return self.on_bound = on_bound self._resource = resource if self._resource: @@ -646,13 +651,8 @@ class NonBlockingBind(PlugIn): sm = self._owner._caller.sm if self.supports_sm: # starts negociation - if sm._owner and sm.resumption: - sm.set_owner(self._owner) - sm.resume_request() - else: - sm.set_owner(self._owner) - sm.negociate() - + sm.set_owner(self._owner) + sm.negociate() self._owner.Dispatcher.sm = sm if hasattr(self, 'session') and self.session == -1: @@ -670,7 +670,7 @@ class NonBlockingBind(PlugIn): else: log.info('Binding failed: timeout expired.') self.on_bound(None) - + def _on_session(self, resp): self._owner.onreceive(None) if isResultNode(resp): diff --git a/src/common/xmpp/client_nb.py b/src/common/xmpp/client_nb.py index dc4c4476b8381e00f28104ca8a5098f01032278d..aafb5f775ac90aa22dcd9232d1dd3352cf97df89 100644 --- a/src/common/xmpp/client_nb.py +++ b/src/common/xmpp/client_nb.py @@ -521,8 +521,20 @@ class NonBlockingClient: self.connected = None # FIXME: is this intended? We use ''elsewhere self._on_sasl_auth(None) elif self.SASL.startsasl == 'success': - auth_nb.NonBlockingBind.get_instance().PlugIn(self) + nb_bind = auth_nb.NonBlockingBind.get_instance() + sm = self._caller.sm + if sm._owner and sm.resumption: + nb_bind.resuming = True + sm.set_owner(self) + self.Dispatcher.sm = sm + nb_bind.PlugIn(self) + return + + + nb_bind.PlugIn(self) self.onreceive(self._on_auth_bind) + + return True def _on_auth_bind(self, data): diff --git a/src/common/xmpp/smacks.py b/src/common/xmpp/smacks.py index b1b6dac03d33ba1656b9d735308e1d59640b4c42..182ef00741c82597df882bff660808eca472bba5 100644 --- a/src/common/xmpp/smacks.py +++ b/src/common/xmpp/smacks.py @@ -73,7 +73,7 @@ class Smacks(): return resume = Acks() resume.buildResume(self.in_h, self.session_id) - self._owner.Connection.send(resume, True) + self._owner.Connection.send(resume, False) def send_ack(self, disp, stanza): ack = Acks()