resuming before binding
This commit is contained in:
		
							parent
							
								
									39a960f3e7
								
							
						
					
					
						commit
						d73e277f40
					
				
					 4 changed files with 26 additions and 13 deletions
				
			
		| 
						 | 
					@ -712,7 +712,7 @@ class Connection(CommonConnection, ConnectionHandlers):
 | 
				
			||||||
        self.streamError = ''
 | 
					        self.streamError = ''
 | 
				
			||||||
        self.secret_hmac = str(random.random())[2:]
 | 
					        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,
 | 
					        gajim.ged.register_event_handler('privacy-list-received', ged.CORE,
 | 
				
			||||||
            self._nec_privacy_list_received)
 | 
					            self._nec_privacy_list_received)
 | 
				
			||||||
| 
						 | 
					@ -805,8 +805,9 @@ class Connection(CommonConnection, ConnectionHandlers):
 | 
				
			||||||
            self.old_show = gajim.SHOW_LIST[self.connected]
 | 
					            self.old_show = gajim.SHOW_LIST[self.connected]
 | 
				
			||||||
        self.connected = 0
 | 
					        self.connected = 0
 | 
				
			||||||
        if not self.on_purpose:
 | 
					        if not self.on_purpose:
 | 
				
			||||||
            gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
 | 
					            if not (self.sm and self.sm.resumption):
 | 
				
			||||||
                show='offline'))
 | 
					                gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
 | 
				
			||||||
 | 
					                                                           show='offline'))
 | 
				
			||||||
            self.disconnect()
 | 
					            self.disconnect()
 | 
				
			||||||
            if gajim.config.get_per('accounts', self.name, 'autoreconnect'):
 | 
					            if gajim.config.get_per('accounts', self.name, 'autoreconnect'):
 | 
				
			||||||
                self.connected = -1
 | 
					                self.connected = -1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -574,6 +574,7 @@ class NonBlockingBind(PlugIn):
 | 
				
			||||||
        PlugIn.__init__(self)
 | 
					        PlugIn.__init__(self)
 | 
				
			||||||
        self.bound = None
 | 
					        self.bound = None
 | 
				
			||||||
        self.supports_sm = False
 | 
					        self.supports_sm = False
 | 
				
			||||||
 | 
					        self.resuming = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def plugin(self, owner):
 | 
					    def plugin(self, owner):
 | 
				
			||||||
        ''' Start resource binding, if allowed at this time. Used internally. '''
 | 
					        ''' 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):
 | 
					        if feats.getTag('sm', namespace=NS_STREAM_MGMT):
 | 
				
			||||||
            self.supports_sm = True # server supports stream management
 | 
					            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):
 | 
					        if not feats.getTag('bind', namespace=NS_BIND):
 | 
				
			||||||
            log.info('Server does not requested binding.')
 | 
					            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).
 | 
					        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.on_bound = on_bound
 | 
				
			||||||
        self._resource = resource
 | 
					        self._resource = resource
 | 
				
			||||||
        if self._resource:
 | 
					        if self._resource:
 | 
				
			||||||
| 
						 | 
					@ -646,13 +651,8 @@ class NonBlockingBind(PlugIn):
 | 
				
			||||||
                sm = self._owner._caller.sm
 | 
					                sm = self._owner._caller.sm
 | 
				
			||||||
                if self.supports_sm:
 | 
					                if self.supports_sm:
 | 
				
			||||||
                    # starts negociation
 | 
					                    # starts negociation
 | 
				
			||||||
                    if sm._owner and sm.resumption:
 | 
					                    sm.set_owner(self._owner)
 | 
				
			||||||
                        sm.set_owner(self._owner)
 | 
					                    sm.negociate()    
 | 
				
			||||||
                        sm.resume_request()
 | 
					 | 
				
			||||||
                    else:
 | 
					 | 
				
			||||||
                        sm.set_owner(self._owner)
 | 
					 | 
				
			||||||
                        sm.negociate()
 | 
					 | 
				
			||||||
                        
 | 
					 | 
				
			||||||
                    self._owner.Dispatcher.sm = sm
 | 
					                    self._owner.Dispatcher.sm = sm
 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
                if hasattr(self, 'session') and self.session == -1:
 | 
					                if hasattr(self, 'session') and self.session == -1:
 | 
				
			||||||
| 
						 | 
					@ -670,7 +670,7 @@ class NonBlockingBind(PlugIn):
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            log.info('Binding failed: timeout expired.')
 | 
					            log.info('Binding failed: timeout expired.')
 | 
				
			||||||
            self.on_bound(None)
 | 
					            self.on_bound(None)
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
    def _on_session(self, resp):
 | 
					    def _on_session(self, resp):
 | 
				
			||||||
        self._owner.onreceive(None)
 | 
					        self._owner.onreceive(None)
 | 
				
			||||||
        if isResultNode(resp):
 | 
					        if isResultNode(resp):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -521,8 +521,20 @@ class NonBlockingClient:
 | 
				
			||||||
            self.connected = None # FIXME: is this intended? We use ''elsewhere
 | 
					            self.connected = None # FIXME: is this intended? We use ''elsewhere
 | 
				
			||||||
            self._on_sasl_auth(None)
 | 
					            self._on_sasl_auth(None)
 | 
				
			||||||
        elif self.SASL.startsasl == 'success':
 | 
					        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)
 | 
					            self.onreceive(self._on_auth_bind)
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					           
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _on_auth_bind(self, data):
 | 
					    def _on_auth_bind(self, data):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,7 +73,7 @@ class Smacks():
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        resume = Acks()
 | 
					        resume = Acks()
 | 
				
			||||||
        resume.buildResume(self.in_h, self.session_id)
 | 
					        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):
 | 
					    def send_ack(self, disp, stanza):
 | 
				
			||||||
        ack = Acks()
 | 
					        ack = Acks()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue