mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
[169680] [ftp] FTP files subsystem and service should use passive mode
This commit is contained in:
parent
06c2a488c5
commit
ef5ae9d77e
3 changed files with 61 additions and 4 deletions
|
@ -8,7 +8,8 @@ Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
org.eclipse.rse.services,
|
org.eclipse.rse.services,
|
||||||
org.apache.commons.net
|
org.apache.commons.net,
|
||||||
|
org.eclipse.rse.core
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Export-Package: org.eclipse.rse.services.files.ftp
|
Export-Package: org.eclipse.rse.services.files.ftp
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2006 IBM Corporation and others. All rights reserved.
|
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* This program and the accompanying materials are made available under the terms
|
||||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
* Javier Montalvo Orus (Symbian) - Fixing 165471 - [ftp] On wftpd-2.0, "." and ".." directory entries should be hidden
|
* Javier Montalvo Orus (Symbian) - Fixing 165471 - [ftp] On wftpd-2.0, "." and ".." directory entries should be hidden
|
||||||
* Javier Montalvo Orus (Symbian) - Fixing 165476 - [ftp] On warftpd-1.65 in MSDOS mode, cannot expand drives
|
* Javier Montalvo Orus (Symbian) - Fixing 165476 - [ftp] On warftpd-1.65 in MSDOS mode, cannot expand drives
|
||||||
* Javier Montalvo Orus (Symbian) - Fixing 168120 - [ftp] root filter resolves to home dir
|
* Javier Montalvo Orus (Symbian) - Fixing 168120 - [ftp] root filter resolves to home dir
|
||||||
|
* Javier Montalvo Orus (Symbian) - Fixing 169680 - [ftp] FTP files subsystem and service should use passive mode
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.services.files.ftp;
|
package org.eclipse.rse.services.files.ftp;
|
||||||
|
@ -60,6 +61,7 @@ import org.apache.commons.net.ftp.FTPFile;
|
||||||
import org.apache.commons.net.ftp.FTPReply;
|
import org.apache.commons.net.ftp.FTPReply;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.rse.core.model.IPropertySet;
|
||||||
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
||||||
import org.eclipse.rse.services.clientserver.IMatcher;
|
import org.eclipse.rse.services.clientserver.IMatcher;
|
||||||
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
|
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
|
||||||
|
@ -85,9 +87,27 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
private transient int _portNumber;
|
private transient int _portNumber;
|
||||||
|
|
||||||
private OutputStream _ftpLoggingOutputStream;
|
private OutputStream _ftpLoggingOutputStream;
|
||||||
|
private IPropertySet _ftpPropertySet;
|
||||||
private Exception _exception;
|
private Exception _exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a IPropertySet containing pairs of keys and values with
|
||||||
|
* the FTP Client preferences<br/>
|
||||||
|
* Supported keys and values are:<br/>
|
||||||
|
* <table border="1">
|
||||||
|
* <tr><th>KEY</th><th>VALUE</th><th>Usage</th></tr>
|
||||||
|
* <tr><th>"passive"</th><th>"true" | "false"</th><th>Enables FTP passive mode</th></tr>
|
||||||
|
* </table>
|
||||||
|
*
|
||||||
|
* @see org.eclipse.rse.core.model.IPropertySet
|
||||||
|
* @param ftpPropertySet
|
||||||
|
*/
|
||||||
|
public void setPropertySet(IPropertySet ftpPropertySet)
|
||||||
|
{
|
||||||
|
_ftpPropertySet = ftpPropertySet;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.services.IService#getName()
|
* @see org.eclipse.rse.services.IService#getName()
|
||||||
|
@ -240,6 +260,17 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
_userHome = '/'+_userHome.substring(0,_userHome.lastIndexOf(']'));
|
_userHome = '/'+_userHome.substring(0,_userHome.lastIndexOf(']'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_ftpPropertySet != null)
|
||||||
|
{
|
||||||
|
if(_ftpPropertySet.getPropertyValue("passive").equalsIgnoreCase("true")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
{
|
||||||
|
_ftpClient.enterLocalPassiveMode();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ftpClient.enterLocalActiveMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
|
@ -272,6 +303,18 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_ftpPropertySet != null)
|
||||||
|
{
|
||||||
|
if(_ftpPropertySet.getPropertyValue("passive").equalsIgnoreCase("true")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
{
|
||||||
|
_ftpClient.enterLocalPassiveMode();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ftpClient.enterLocalActiveMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(_hostName!=null)
|
if(_hostName!=null)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
* Copyright (c) 2006, 2007 IBM Corporation. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* This program and the accompanying materials are made available under the terms
|
||||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -13,6 +13,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Javier Montalvo Orus (Symbian) - Bug 140348 - FTP did not use port number
|
* Javier Montalvo Orus (Symbian) - Bug 140348 - FTP did not use port number
|
||||||
* Javier Montalvo Orus (Symbian) - Bug 161209 - Need a Log of ftp commands
|
* Javier Montalvo Orus (Symbian) - Bug 161209 - Need a Log of ftp commands
|
||||||
|
* Javier Montalvo Orus (Symbian) - Bug 169680 - [ftp] FTP files subsystem and service should use passive mode
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.subsystems.files.ftp.connectorservice;
|
package org.eclipse.rse.subsystems.files.ftp.connectorservice;
|
||||||
|
@ -21,6 +22,8 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
|
import org.eclipse.rse.core.model.IPropertySet;
|
||||||
|
import org.eclipse.rse.core.model.PropertyType;
|
||||||
import org.eclipse.rse.core.model.SystemSignonInformation;
|
import org.eclipse.rse.core.model.SystemSignonInformation;
|
||||||
import org.eclipse.rse.core.subsystems.AbstractConnectorService;
|
import org.eclipse.rse.core.subsystems.AbstractConnectorService;
|
||||||
import org.eclipse.rse.services.files.IFileService;
|
import org.eclipse.rse.services.files.IFileService;
|
||||||
|
@ -35,11 +38,20 @@ import org.eclipse.ui.console.MessageConsole;
|
||||||
public class FTPConnectorService extends AbstractConnectorService
|
public class FTPConnectorService extends AbstractConnectorService
|
||||||
{
|
{
|
||||||
protected FTPService _ftpService;
|
protected FTPService _ftpService;
|
||||||
|
private IPropertySet _propertySet;
|
||||||
|
|
||||||
public FTPConnectorService(IHost host, int port)
|
public FTPConnectorService(IHost host, int port)
|
||||||
{
|
{
|
||||||
super(SystemFileResources.RESID_FTP_CONNECTORSERVICE_NAME,SystemFileResources.RESID_FTP_CONNECTORSERVICE_DESCRIPTION, host, port);
|
super(SystemFileResources.RESID_FTP_CONNECTORSERVICE_NAME,SystemFileResources.RESID_FTP_CONNECTORSERVICE_DESCRIPTION, host, port);
|
||||||
_ftpService = new FTPService();
|
_ftpService = new FTPService();
|
||||||
|
|
||||||
|
_propertySet = getPropertySet("FTP Settings"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if(_propertySet==null)
|
||||||
|
{
|
||||||
|
_propertySet = createPropertySet("FTP Settings"); //$NON-NLS-1$
|
||||||
|
_propertySet.addProperty("passive","false",PropertyType.getEnumPropertyType(new String[]{"true","false"})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void internalConnect(IProgressMonitor monitor) throws Exception
|
public void internalConnect(IProgressMonitor monitor) throws Exception
|
||||||
|
@ -56,6 +68,7 @@ public class FTPConnectorService extends AbstractConnectorService
|
||||||
_ftpService.setPassword(info.getPassword());
|
_ftpService.setPassword(info.getPassword());
|
||||||
_ftpService.setPortNumber(getPort());
|
_ftpService.setPortNumber(getPort());
|
||||||
_ftpService.setLoggingStream(getLoggingStream(info.getHostname(),getPort()));
|
_ftpService.setLoggingStream(getLoggingStream(info.getHostname(),getPort()));
|
||||||
|
_ftpService.setPropertySet(_propertySet);
|
||||||
_ftpService.connect();
|
_ftpService.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue