minor adjustments to how sessions are handled (partially fixes #3407)
This commit is contained in:
		
							parent
							
								
									ed0f54cbc5
								
							
						
					
					
						commit
						abec26cdfc
					
				
					 2 changed files with 13 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -1696,10 +1696,13 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
 | 
			
		|||
			return None
 | 
			
		||||
 | 
			
		||||
	def delete_session(self, jid, thread_id):
 | 
			
		||||
		try:
 | 
			
		||||
			del self.sessions[jid][thread_id]
 | 
			
		||||
			
 | 
			
		||||
			if not self.sessions[jid]:
 | 
			
		||||
				del self.sessions[jid]
 | 
			
		||||
		except KeyError
 | 
			
		||||
			print "jid %s should have been in %s, but it wasn't. missing session?" % (repr(jid), repr(self.sessions.keys())
 | 
			
		||||
 | 
			
		||||
	def move_session(self, original_jid, thread_id, to_resource):
 | 
			
		||||
		'''moves a session to another resource.'''
 | 
			
		||||
| 
						 | 
				
			
			@ -1722,9 +1725,12 @@ returns the session that we last sent a message to.'''
 | 
			
		|||
		
 | 
			
		||||
		sessions_with_jid = self.sessions[jid].values()
 | 
			
		||||
		no_threadid_sessions = filter(lambda s: not s.received_thread_id, sessions_with_jid)
 | 
			
		||||
		no_threadid_sessions.sort(key=lambda s: s.last_send)
 | 
			
		||||
 | 
			
		||||
		if no_threadid_sessions:
 | 
			
		||||
			no_threadid_sessions.sort(key=lambda s: s.last_send)
 | 
			
		||||
			return no_threadid_sessions[-1]
 | 
			
		||||
		else:
 | 
			
		||||
			return None
 | 
			
		||||
 | 
			
		||||
	def make_new_session(self, jid, thread_id = None, type = 'chat'):
 | 
			
		||||
		sess = EncryptedStanzaSession(self, common.xmpp.JID(jid), thread_id, type)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,7 +117,7 @@ class MessageControl:
 | 
			
		|||
 | 
			
		||||
		if self.session:
 | 
			
		||||
			print "starting a new session, dropping the old one!"
 | 
			
		||||
			gajim.connections[self.account].delete_session(self.contact.get_full_jid(), self.session.thread_id)
 | 
			
		||||
			gajim.connections[self.account].delete_session(self.session.jid, self.session.thread_id)
 | 
			
		||||
 | 
			
		||||
		self.session = session
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue