cleanup connection.connect(). fixes #3061
This commit is contained in:
		
							parent
							
								
									0ff2c40973
								
							
						
					
					
						commit
						090218e780
					
				
					 2 changed files with 7 additions and 14 deletions
				
			
		| 
						 | 
					@ -292,16 +292,13 @@ class Connection(ConnectionHandlers):
 | 
				
			||||||
	def connect(self, data = None):
 | 
						def connect(self, data = None):
 | 
				
			||||||
		''' Start a connection to the Jabber server.
 | 
							''' Start a connection to the Jabber server.
 | 
				
			||||||
		Returns connection, and connection type ('tls', 'ssl', 'tcp', '')
 | 
							Returns connection, and connection type ('tls', 'ssl', 'tcp', '')
 | 
				
			||||||
		data MUST contain name, hostname, resource, usessl, proxy,
 | 
							data MUST contain hostname, usessl, proxy, use_custom_host,
 | 
				
			||||||
		use_custom_host, custom_host (if use_custom_host), custom_port (if
 | 
							custom_host (if use_custom_host), custom_port (if use_custom_host)'''
 | 
				
			||||||
		use_custom_host), '''
 | 
					 | 
				
			||||||
		if self.connection:
 | 
							if self.connection:
 | 
				
			||||||
			return self.connection, ''
 | 
								return self.connection, ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if data:
 | 
							if data:
 | 
				
			||||||
			name = data['name']
 | 
					 | 
				
			||||||
			hostname = data['hostname']
 | 
								hostname = data['hostname']
 | 
				
			||||||
			resource = data['resource']
 | 
					 | 
				
			||||||
			usessl = data['usessl']
 | 
								usessl = data['usessl']
 | 
				
			||||||
			self.try_connecting_for_foo_secs = 45
 | 
								self.try_connecting_for_foo_secs = 45
 | 
				
			||||||
			p = data['proxy']
 | 
								p = data['proxy']
 | 
				
			||||||
| 
						 | 
					@ -311,9 +308,7 @@ class Connection(ConnectionHandlers):
 | 
				
			||||||
				custom_h = data['custom_host']
 | 
									custom_h = data['custom_host']
 | 
				
			||||||
				custom_p = data['custom_port']
 | 
									custom_p = data['custom_port']
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			name = gajim.config.get_per('accounts', self.name, 'name')
 | 
					 | 
				
			||||||
			hostname = gajim.config.get_per('accounts', self.name, 'hostname')
 | 
								hostname = gajim.config.get_per('accounts', self.name, 'hostname')
 | 
				
			||||||
			resource = gajim.config.get_per('accounts', self.name, 'resource')
 | 
					 | 
				
			||||||
			usessl = gajim.config.get_per('accounts', self.name, 'usessl')
 | 
								usessl = gajim.config.get_per('accounts', self.name, 'usessl')
 | 
				
			||||||
			self.try_connecting_for_foo_secs = gajim.config.get_per('accounts',
 | 
								self.try_connecting_for_foo_secs = gajim.config.get_per('accounts',
 | 
				
			||||||
				self.name, 'try_connecting_for_foo_secs')
 | 
									self.name, 'try_connecting_for_foo_secs')
 | 
				
			||||||
| 
						 | 
					@ -324,7 +319,7 @@ class Connection(ConnectionHandlers):
 | 
				
			||||||
			custom_h = gajim.config.get_per('accounts', self.name, 'custom_host')
 | 
								custom_h = gajim.config.get_per('accounts', self.name, 'custom_host')
 | 
				
			||||||
			custom_p = gajim.config.get_per('accounts', self.name, 'custom_port')
 | 
								custom_p = gajim.config.get_per('accounts', self.name, 'custom_port')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		#create connection if it doesn't already exist
 | 
							# create connection if it doesn't already exist
 | 
				
			||||||
		self.connected = 1
 | 
							self.connected = 1
 | 
				
			||||||
		if p and p in gajim.config.get_per('proxies'):
 | 
							if p and p in gajim.config.get_per('proxies'):
 | 
				
			||||||
			proxy = {'host': gajim.config.get_per('proxies', p, 'host')}
 | 
								proxy = {'host': gajim.config.get_per('proxies', p, 'host')}
 | 
				
			||||||
| 
						 | 
					@ -448,8 +443,6 @@ class Connection(ConnectionHandlers):
 | 
				
			||||||
		self._register_handlers(con, con_type)
 | 
							self._register_handlers(con, con_type)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		name = gajim.config.get_per('accounts', self.name, 'name')
 | 
							name = gajim.config.get_per('accounts', self.name, 'name')
 | 
				
			||||||
		hostname = gajim.config.get_per('accounts', self.name, 'hostname')
 | 
					 | 
				
			||||||
		resource = gajim.config.get_per('accounts', self.name, 'resource')
 | 
					 | 
				
			||||||
		self.connection = con
 | 
							self.connection = con
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fpr_good = self._check_fingerprint(con, con_type)
 | 
							fpr_good = self._check_fingerprint(con, con_type)
 | 
				
			||||||
| 
						 | 
					@ -470,7 +463,7 @@ class Connection(ConnectionHandlers):
 | 
				
			||||||
		if fpr_good == True:
 | 
							if fpr_good == True:
 | 
				
			||||||
			log.info("Fingerprint found and matched for %s.", hostname)
 | 
								log.info("Fingerprint found and matched for %s.", hostname)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		con.auth(name, self.password, resource, 1, self.__on_auth)
 | 
							con.auth(name, self.password, self.server_resource, 1, self.__on_auth)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return True
 | 
							return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -971,6 +964,7 @@ class Connection(ConnectionHandlers):
 | 
				
			||||||
		if self.connection:
 | 
							if self.connection:
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		self._hostname = config['hostname']
 | 
							self._hostname = config['hostname']
 | 
				
			||||||
 | 
							self.server_resource = config['resource']
 | 
				
			||||||
		self.new_account_info = config
 | 
							self.new_account_info = config
 | 
				
			||||||
		self.name = name
 | 
							self.name = name
 | 
				
			||||||
		self.on_connect_success = self._on_new_account
 | 
							self.on_connect_success = self._on_new_account
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1327,8 +1327,7 @@ class RosterWindow:
 | 
				
			||||||
				contact = gajim.contacts.create_contact(jid = jid,
 | 
									contact = gajim.contacts.create_contact(jid = jid,
 | 
				
			||||||
					name = account_name, show = connection.get_status(), sub = '',
 | 
										name = account_name, show = connection.get_status(), sub = '',
 | 
				
			||||||
					status = connection.status,
 | 
										status = connection.status,
 | 
				
			||||||
					resource = gajim.config.get_per('accounts', connection.name,
 | 
										resource = connection.server_resource,
 | 
				
			||||||
						'resource'),
 | 
					 | 
				
			||||||
					priority = connection.priority,
 | 
										priority = connection.priority,
 | 
				
			||||||
					keyID = gajim.config.get_per('accounts', connection.name,
 | 
										keyID = gajim.config.get_per('accounts', connection.name,
 | 
				
			||||||
						'keyid'))
 | 
											'keyid'))
 | 
				
			||||||
| 
						 | 
					@ -2663,7 +2662,7 @@ class RosterWindow:
 | 
				
			||||||
				gajim.connections[account].unsubscribe(contact.jid, remove_auth)
 | 
									gajim.connections[account].unsubscribe(contact.jid, remove_auth)
 | 
				
			||||||
				for c in gajim.contacts.get_contact(account, contact.jid):
 | 
									for c in gajim.contacts.get_contact(account, contact.jid):
 | 
				
			||||||
					self.remove_contact(c, account)
 | 
										self.remove_contact(c, account)
 | 
				
			||||||
				gajim.contacts.remove_jid(account, c.jid)
 | 
									gajim.contacts.remove_jid(account, contact.jid)
 | 
				
			||||||
				# redraw group rows for contact numbers
 | 
									# redraw group rows for contact numbers
 | 
				
			||||||
				for group in c.groups:
 | 
									for group in c.groups:
 | 
				
			||||||
					self.draw_group(group, account)
 | 
										self.draw_group(group, account)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue