1
0
Fork 0
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:
Javier Montalvo Orus 2007-02-15 15:29:00 +00:00
parent 06c2a488c5
commit ef5ae9d77e
3 changed files with 61 additions and 4 deletions

View file

@ -8,7 +8,8 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.rse.services,
org.apache.commons.net
org.apache.commons.net,
org.eclipse.rse.core
Eclipse-LazyStart: true
Export-Package: org.eclipse.rse.services.files.ftp
Bundle-RequiredExecutionEnvironment: J2SE-1.4

View file

@ -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
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* 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 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 169680 - [ftp] FTP files subsystem and service should use passive mode
********************************************************************************/
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.eclipse.core.runtime.IProgressMonitor;
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.IMatcher;
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
@ -85,9 +87,27 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
private transient int _portNumber;
private OutputStream _ftpLoggingOutputStream;
private IPropertySet _ftpPropertySet;
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)
* @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(']'));
}
if(_ftpPropertySet != null)
{
if(_ftpPropertySet.getPropertyValue("passive").equalsIgnoreCase("true")) //$NON-NLS-1$ //$NON-NLS-2$
{
_ftpClient.enterLocalPassiveMode();
}
else
{
_ftpClient.enterLocalActiveMode();
}
}
}
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)
{
try{

View file

@ -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
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@ -13,6 +13,7 @@
* Contributors:
* 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 169680 - [ftp] FTP files subsystem and service should use passive mode
********************************************************************************/
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.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.subsystems.AbstractConnectorService;
import org.eclipse.rse.services.files.IFileService;
@ -35,11 +38,20 @@ import org.eclipse.ui.console.MessageConsole;
public class FTPConnectorService extends AbstractConnectorService
{
protected FTPService _ftpService;
private IPropertySet _propertySet;
public FTPConnectorService(IHost host, int port)
{
super(SystemFileResources.RESID_FTP_CONNECTORSERVICE_NAME,SystemFileResources.RESID_FTP_CONNECTORSERVICE_DESCRIPTION, host, port);
_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
@ -56,6 +68,7 @@ public class FTPConnectorService extends AbstractConnectorService
_ftpService.setPassword(info.getPassword());
_ftpService.setPortNumber(getPort());
_ftpService.setLoggingStream(getLoggingStream(info.getHostname(),getPort()));
_ftpService.setPropertySet(_propertySet);
_ftpService.connect();
}