send error to stderr if another instance of
gajim is running on the same ft port
This commit is contained in:
		
							parent
							
								
									d8b71a5d7e
								
							
						
					
					
						commit
						8eb530b91c
					
				
					 3 changed files with 17 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -494,7 +494,6 @@ class Connection:
 | 
			
		|||
			file_props['error'] = -3
 | 
			
		||||
			self.dispatch('FILE_REQUEST_ERROR', (to, file_props))
 | 
			
		||||
		
 | 
			
		||||
		
 | 
			
		||||
	def _bytestreamResultCB(self, con, iq_obj):
 | 
			
		||||
		gajim.log.debug('_bytestreamResultCB')
 | 
			
		||||
		frm = str(iq_obj.getFrom())
 | 
			
		||||
| 
						 | 
				
			
			@ -592,6 +591,8 @@ class Connection:
 | 
			
		|||
		self.files_props = {}
 | 
			
		||||
	
 | 
			
		||||
	def remove_transfer(self, file_props, remove_from_list = True):
 | 
			
		||||
		if file_props is None:
 | 
			
		||||
			return
 | 
			
		||||
		if file_props.has_key('hash'):
 | 
			
		||||
			gajim.socks5queue.remove_sender(file_props['hash'])
 | 
			
		||||
		
 | 
			
		||||
| 
						 | 
				
			
			@ -608,6 +609,8 @@ class Connection:
 | 
			
		|||
				del(self.files_props['sid'])
 | 
			
		||||
				
 | 
			
		||||
	def disconnect_transfer(self, file_props):
 | 
			
		||||
		if file_props is None:
 | 
			
		||||
			return
 | 
			
		||||
		if file_props.has_key('hash'):
 | 
			
		||||
			gajim.socks5queue.remove_sender(file_props['hash'])
 | 
			
		||||
		
 | 
			
		||||
| 
						 | 
				
			
			@ -750,7 +753,10 @@ class Connection:
 | 
			
		|||
		listener = gajim.socks5queue.start_listener(self.peerhost[0], port, 
 | 
			
		||||
			sha_str, self.result_socks5_sid, file_props['sid'])
 | 
			
		||||
		if listener == None:
 | 
			
		||||
			# FIXME - raise error dialog that address is in use
 | 
			
		||||
			file_props['error'] = -5
 | 
			
		||||
			self.dispatch('FILE_REQUEST_ERROR', (str(receiver), file_props))
 | 
			
		||||
			self._connect_error(str(receiver), file_props['sid'], 
 | 
			
		||||
				code = 406)
 | 
			
		||||
			return
 | 
			
		||||
		
 | 
			
		||||
		iq = common.xmpp.Protocol(name = 'iq', to = str(receiver), 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,6 +49,12 @@ class SocksQueue:
 | 
			
		|||
			self.listener = Socks5Listener(host, port)
 | 
			
		||||
			self.listener.bind()
 | 
			
		||||
			if self.listener.started is False:
 | 
			
		||||
				self.listener = None
 | 
			
		||||
				import sys
 | 
			
		||||
				sys.stderr.write('\n\n\n========================================\
 | 
			
		||||
========================\nUnable to bind to port %s. \nMaybe you have another \
 | 
			
		||||
running instance of Gajim. \nFile Transfer will be canceled.\n==================\
 | 
			
		||||
==============================================\n\n\n' % port)
 | 
			
		||||
				return None
 | 
			
		||||
			self.connected += 1
 | 
			
		||||
		return self.listener
 | 
			
		||||
| 
						 | 
				
			
			@ -82,6 +88,7 @@ class SocksQueue:
 | 
			
		|||
			file_props = self.files_props[account][sid]
 | 
			
		||||
		file_props['success_cb'] = on_success
 | 
			
		||||
		file_props['failure_cb'] = on_failure
 | 
			
		||||
		
 | 
			
		||||
		# add streamhosts to the queue 
 | 
			
		||||
		for streamhost in file_props['streamhosts']:
 | 
			
		||||
			receiver = Socks5Receiver(streamhost, sid, file_props)
 | 
			
		||||
| 
						 | 
				
			
			@ -123,12 +130,9 @@ class SocksQueue:
 | 
			
		|||
		result = sock5_receiver.connect()
 | 
			
		||||
		self.connected += 1
 | 
			
		||||
		if result != None:
 | 
			
		||||
			self.connected += 1
 | 
			
		||||
			result = sock5_receiver.main()
 | 
			
		||||
			self.process_result(result, sock5_receiver)
 | 
			
		||||
			
 | 
			
		||||
			return 1
 | 
			
		||||
			
 | 
			
		||||
		return None
 | 
			
		||||
		
 | 
			
		||||
	def get_file_from_sender(self, file_props, account):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -715,7 +715,7 @@ class Interface:
 | 
			
		|||
		ft.set_status(file_props['type'], file_props['sid'], 'stop')
 | 
			
		||||
		if gajim.config.get('notify_on_new_message'):
 | 
			
		||||
			# check if we should be notified
 | 
			
		||||
			if errno == -4:
 | 
			
		||||
			if errno == -4 or errno == -5:
 | 
			
		||||
				msg_type = 'file-error'
 | 
			
		||||
			else:
 | 
			
		||||
				msg_type = 'file-request-error'
 | 
			
		||||
| 
						 | 
				
			
			@ -725,7 +725,7 @@ class Interface:
 | 
			
		|||
		elif (gajim.connections[account].connected in (2, 3)
 | 
			
		||||
			and gajim.config.get('autopopup')) or \
 | 
			
		||||
			gajim.config.get('autopopupaway'):
 | 
			
		||||
			if errno == -4:
 | 
			
		||||
			if errno == -4 or errno == -5:
 | 
			
		||||
				self.windows['file_transfers'].show_stopped(jid, file_props)
 | 
			
		||||
			else:
 | 
			
		||||
				self.windows['file_transfers'].show_request_error(file_props)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue