custom host/port now works
This commit is contained in:
		
							parent
							
								
									de5edd389b
								
							
						
					
					
						commit
						c6a53d8732
					
				
					 3 changed files with 49 additions and 23 deletions
				
			
		|  | @ -110,7 +110,6 @@ class Config: | |||
| 		'accounts': ({ | ||||
| 			'name': [ opt_str, '' ], | ||||
| 			'hostname': [ opt_str, '' ], | ||||
| 			'port': [ opt_int, 5222 ], | ||||
| 			'savepass': [ opt_bool, False ], | ||||
| 			'password': [ opt_str, '' ], | ||||
| 			'resource': [ opt_str, 'gajim' ], | ||||
|  | @ -120,6 +119,9 @@ class Config: | |||
| 			'keyid': [ opt_str, '' ], | ||||
| 			'keyname': [ opt_str, '' ], | ||||
| 			'usessl': [ opt_bool, False ], | ||||
| 			'use_custom_host': [ opt_bool, False ], | ||||
| 			'custom_port': [ opt_int, 5222 ], | ||||
| 			'custom_host': [ opt_str, '' ], | ||||
| 			'savegpgpass': [ opt_bool, False ], | ||||
| 			'gpgpassword': [ opt_str, '' ], | ||||
| 			'sync_with_global_status': [ opt_bool, True ], | ||||
|  |  | |||
|  | @ -594,7 +594,6 @@ class Connection: | |||
| 		"""Connect and authenticate to the Jabber server""" | ||||
| 		name = gajim.config.get_per('accounts', self.name, 'name') | ||||
| 		hostname = gajim.config.get_per('accounts', self.name, 'hostname') | ||||
| 		port = gajim.config.get_per('accounts', self.name, 'port') | ||||
| 		resource = gajim.config.get_per('accounts', self.name, 'resource') | ||||
| 		usessl = gajim.config.get_per('accounts', self.name, 'usessl') | ||||
| 
 | ||||
|  | @ -618,8 +617,15 @@ class Connection: | |||
| 		con.UnregisterDisconnectHandler(con.DisconnectHandler) | ||||
| 		con.RegisterDisconnectHandler(self._disconnectedCB) | ||||
| 
 | ||||
| 		#pass ssl optional arg if neccessary when client.py is patched | ||||
| 		con_type = con.connect((hostname, port), proxy = proxy) #FIXME: blocking | ||||
| 		h = hostname | ||||
| 		p = 5222 | ||||
| 		if usessl: | ||||
| 			p = 5223 | ||||
| 		if gajim.config.get_per('accounts', self.name, 'use_custom_host'): | ||||
| 			h = gajim.config.get_per('accounts', self.name, 'custom_host') | ||||
| 			p = gajim.config.get_per('accounts', self.name, 'custom_port') | ||||
| 		#TODO: pass ssl optional arg if neccessary when client.py is patched | ||||
| 		con_type = con.connect((h, p), proxy = proxy) #FIXME: blocking | ||||
| 		if not con_type: | ||||
| 			gajim.log.debug("Couldn't connect to %s" % self.name) | ||||
| 			self.connected = 0 | ||||
|  | @ -894,16 +900,19 @@ class Connection: | |||
| 		common.xmpp.dispatcher.DefaultTimeout = 45 | ||||
| 		c.UnregisterDisconnectHandler(c.DisconnectHandler) | ||||
| 		c.RegisterDisconnectHandler(self._disconnectedCB) | ||||
| 		port = gajim.config.get_per('accounts', self.name, 'port') | ||||
| 		#FIXME: use ssl | ||||
| 		#if usessl: | ||||
| 			#port = 5223 | ||||
| 		h = hostname | ||||
| 		p = 5222 | ||||
| 		if usessl: | ||||
| 			p = 5223 | ||||
| 		if config['use_custom_host']: | ||||
| 			h = config['custom_host'] | ||||
| 			p = config['custom_port'] | ||||
| 		#FIXME: blocking | ||||
| 		con_type = c.connect((config['hostname'], port), proxy = proxy) | ||||
| 		con_type = c.connect((h, p), proxy = proxy) | ||||
| 		if not con_type: | ||||
| 			gajim.log.debug("Couldn't connect to %s" % name) | ||||
| 			self.dispatch('ERROR', (_('Could not connect to "%s"') % name, | ||||
| 				_('Check your connection or try again later'))) | ||||
| 				_('Check your connection or try again later.'))) | ||||
| 			return False | ||||
| 		gajim.log.debug('Connected to server') | ||||
| 		# FIXME! This blocks! | ||||
|  |  | |||
|  | @ -1005,8 +1005,21 @@ class AccountModificationWindow: | |||
| 		usessl = gajim.config.get_per('accounts', self.account, 'usessl') | ||||
| 		self.xml.get_widget('use_ssl_checkbutton').set_active(usessl) | ||||
| 
 | ||||
| 		port = gajim.config.get_per('accounts', self.account, 'port') | ||||
| 		self.xml.get_widget('custom_port_entry').set_text(str(port)) | ||||
| 		use_custom_host = gajim.config.get_per('accounts', self.account, | ||||
| 			'use_custom_host') | ||||
| 		self.xml.get_widget('custom_host_port_checkbutton').set_active( | ||||
| 			use_custom_host) | ||||
| 		custom_host = gajim.config.get_per('accounts', self.account, | ||||
| 			'custom_host') | ||||
| 		if not custom_host: | ||||
| 			custom_host = gajim.config.get_per('accounts', | ||||
| 				self.account, 'hostname') | ||||
| 		self.xml.get_widget('custom_host_entry').set_text(custom_host) | ||||
| 		custom_port = gajim.config.get_per('accounts', self.account, | ||||
| 			'custom_port') | ||||
| 		if not custom_port: | ||||
| 			custom_port = 5222 | ||||
| 		self.xml.get_widget('custom_port_entry').set_text(str(custom_port)) | ||||
| 
 | ||||
| 		gpg_key_label = self.xml.get_widget('gpg_key_label') | ||||
| 		if gajim.config.get('usegpg'): | ||||
|  | @ -1082,18 +1095,20 @@ _('To change the account name, it must be disconnected.')).get_response() | |||
| 		config['proxy'] = proxy | ||||
| 		 | ||||
| 		config['usessl'] = self.xml.get_widget('use_ssl_checkbutton').get_active() | ||||
| 		(config['name'], config['hostname']) = jid.split('@') | ||||
| 
 | ||||
| 		if self.xml.get_widget('custom_host_port_checkbutton').get_active(): | ||||
| 			config['name'] = jid.split('@')[0] | ||||
| 			config['hostname'] = self.xml.get_widget('custom_host_entry').get_text() | ||||
| 			config['port'] = int(self.xml.get_widget('custom_port_entry').get_text()) | ||||
| 		else: | ||||
| 			(config['name'], config['hostname']) = jid.split('@') | ||||
| 			if config['usessl']: | ||||
| 				port = 5223 #FIXME: better way | ||||
| 			else: | ||||
| 				port = 5222 | ||||
| 			config['port'] = port | ||||
| 		config['use_custom_host'] = self.xml.get_widget( | ||||
| 			'custom_host_port_checkbutton').get_active() | ||||
| 		custom_port = self.xml.get_widget('custom_port_entry').get_text() | ||||
| 		try: | ||||
| 			custom_port = int(custom_port) | ||||
| 		except: | ||||
| 			dialogs.ErrorDialog(_('Invalid entry'), | ||||
| 				_('Custom port must be a port number.')).get_response() | ||||
| 			return | ||||
| 		config['custom_port'] = custom_port | ||||
| 		config['custom_host'] = self.xml.get_widget( | ||||
| 			'custom_host_entry').get_text() | ||||
| 
 | ||||
| 		config['keyname'] = self.xml.get_widget('gpg_name_label').get_text() | ||||
| 		if config['keyname'] == '': #no key selected | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue