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
				
			
		| 
						 | 
					@ -493,7 +493,6 @@ class Connection:
 | 
				
			||||||
			self.disconnect_transfer(file_props)
 | 
								self.disconnect_transfer(file_props)
 | 
				
			||||||
			file_props['error'] = -3
 | 
								file_props['error'] = -3
 | 
				
			||||||
			self.dispatch('FILE_REQUEST_ERROR', (to, file_props))
 | 
								self.dispatch('FILE_REQUEST_ERROR', (to, file_props))
 | 
				
			||||||
			
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	def _bytestreamResultCB(self, con, iq_obj):
 | 
						def _bytestreamResultCB(self, con, iq_obj):
 | 
				
			||||||
		gajim.log.debug('_bytestreamResultCB')
 | 
							gajim.log.debug('_bytestreamResultCB')
 | 
				
			||||||
| 
						 | 
					@ -592,6 +591,8 @@ class Connection:
 | 
				
			||||||
		self.files_props = {}
 | 
							self.files_props = {}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	def remove_transfer(self, file_props, remove_from_list = True):
 | 
						def remove_transfer(self, file_props, remove_from_list = True):
 | 
				
			||||||
 | 
							if file_props is None:
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
		if file_props.has_key('hash'):
 | 
							if file_props.has_key('hash'):
 | 
				
			||||||
			gajim.socks5queue.remove_sender(file_props['hash'])
 | 
								gajim.socks5queue.remove_sender(file_props['hash'])
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
| 
						 | 
					@ -608,6 +609,8 @@ class Connection:
 | 
				
			||||||
				del(self.files_props['sid'])
 | 
									del(self.files_props['sid'])
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
	def disconnect_transfer(self, file_props):
 | 
						def disconnect_transfer(self, file_props):
 | 
				
			||||||
 | 
							if file_props is None:
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
		if file_props.has_key('hash'):
 | 
							if file_props.has_key('hash'):
 | 
				
			||||||
			gajim.socks5queue.remove_sender(file_props['hash'])
 | 
								gajim.socks5queue.remove_sender(file_props['hash'])
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
| 
						 | 
					@ -750,7 +753,10 @@ class Connection:
 | 
				
			||||||
		listener = gajim.socks5queue.start_listener(self.peerhost[0], port, 
 | 
							listener = gajim.socks5queue.start_listener(self.peerhost[0], port, 
 | 
				
			||||||
			sha_str, self.result_socks5_sid, file_props['sid'])
 | 
								sha_str, self.result_socks5_sid, file_props['sid'])
 | 
				
			||||||
		if listener == None:
 | 
							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
 | 
								return
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		iq = common.xmpp.Protocol(name = 'iq', to = str(receiver), 
 | 
							iq = common.xmpp.Protocol(name = 'iq', to = str(receiver), 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,12 @@ class SocksQueue:
 | 
				
			||||||
			self.listener = Socks5Listener(host, port)
 | 
								self.listener = Socks5Listener(host, port)
 | 
				
			||||||
			self.listener.bind()
 | 
								self.listener.bind()
 | 
				
			||||||
			if self.listener.started is False:
 | 
								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
 | 
									return None
 | 
				
			||||||
			self.connected += 1
 | 
								self.connected += 1
 | 
				
			||||||
		return self.listener
 | 
							return self.listener
 | 
				
			||||||
| 
						 | 
					@ -82,6 +88,7 @@ class SocksQueue:
 | 
				
			||||||
			file_props = self.files_props[account][sid]
 | 
								file_props = self.files_props[account][sid]
 | 
				
			||||||
		file_props['success_cb'] = on_success
 | 
							file_props['success_cb'] = on_success
 | 
				
			||||||
		file_props['failure_cb'] = on_failure
 | 
							file_props['failure_cb'] = on_failure
 | 
				
			||||||
 | 
							
 | 
				
			||||||
		# add streamhosts to the queue 
 | 
							# add streamhosts to the queue 
 | 
				
			||||||
		for streamhost in file_props['streamhosts']:
 | 
							for streamhost in file_props['streamhosts']:
 | 
				
			||||||
			receiver = Socks5Receiver(streamhost, sid, file_props)
 | 
								receiver = Socks5Receiver(streamhost, sid, file_props)
 | 
				
			||||||
| 
						 | 
					@ -123,12 +130,9 @@ class SocksQueue:
 | 
				
			||||||
		result = sock5_receiver.connect()
 | 
							result = sock5_receiver.connect()
 | 
				
			||||||
		self.connected += 1
 | 
							self.connected += 1
 | 
				
			||||||
		if result != None:
 | 
							if result != None:
 | 
				
			||||||
			self.connected += 1
 | 
					 | 
				
			||||||
			result = sock5_receiver.main()
 | 
								result = sock5_receiver.main()
 | 
				
			||||||
			self.process_result(result, sock5_receiver)
 | 
								self.process_result(result, sock5_receiver)
 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			return 1
 | 
								return 1
 | 
				
			||||||
			
 | 
					 | 
				
			||||||
		return None
 | 
							return None
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	def get_file_from_sender(self, file_props, account):
 | 
						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')
 | 
							ft.set_status(file_props['type'], file_props['sid'], 'stop')
 | 
				
			||||||
		if gajim.config.get('notify_on_new_message'):
 | 
							if gajim.config.get('notify_on_new_message'):
 | 
				
			||||||
			# check if we should be notified
 | 
								# check if we should be notified
 | 
				
			||||||
			if errno == -4:
 | 
								if errno == -4 or errno == -5:
 | 
				
			||||||
				msg_type = 'file-error'
 | 
									msg_type = 'file-error'
 | 
				
			||||||
			else:
 | 
								else:
 | 
				
			||||||
				msg_type = 'file-request-error'
 | 
									msg_type = 'file-request-error'
 | 
				
			||||||
| 
						 | 
					@ -725,7 +725,7 @@ class Interface:
 | 
				
			||||||
		elif (gajim.connections[account].connected in (2, 3)
 | 
							elif (gajim.connections[account].connected in (2, 3)
 | 
				
			||||||
			and gajim.config.get('autopopup')) or \
 | 
								and gajim.config.get('autopopup')) or \
 | 
				
			||||||
			gajim.config.get('autopopupaway'):
 | 
								gajim.config.get('autopopupaway'):
 | 
				
			||||||
			if errno == -4:
 | 
								if errno == -4 or errno == -5:
 | 
				
			||||||
				self.windows['file_transfers'].show_stopped(jid, file_props)
 | 
									self.windows['file_transfers'].show_stopped(jid, file_props)
 | 
				
			||||||
			else:
 | 
								else:
 | 
				
			||||||
				self.windows['file_transfers'].show_request_error(file_props)
 | 
									self.windows['file_transfers'].show_request_error(file_props)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue