1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 01:05:38 +02:00

Start of new remote interface.

Change-Id: I078456841dd4b6ddec3852178c307dbd2cf465f5
This commit is contained in:
Doug Schaefer 2014-12-11 10:56:27 -05:00
parent 8f8c2e02b6
commit 74797fe6e3
13 changed files with 850 additions and 1 deletions

View file

@ -6,7 +6,9 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.launchbar.core.internal.Activator Bundle-Activator: org.eclipse.launchbar.core.internal.Activator
Bundle-Vendor: Eclipse CDT Bundle-Vendor: Eclipse CDT
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,
org.eclipse.debug.core org.eclipse.debug.core,
org.eclipse.remote.core;bundle-version="[1.1.0,2.0.0)";visibility:=reexport,
org.eclipse.core.filesystem
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.launchbar.core, Export-Package: org.eclipse.launchbar.core,

View file

@ -0,0 +1,337 @@
/*******************************************************************************
* Copyright (c) 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
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.core.api2;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.IRemoteProcessBuilder;
import org.eclipse.remote.core.exception.RemoteConnectionException;
/**
* Abstraction of a connection to a remote system. Clients should use the set methods to provide information on the remote system,
* then call the {{@link #open(IProgressMonitor)} method. Once the connection is completed, call the {@link #close()} method to
* terminate the connection.
*/
public interface IRemoteConnection extends Comparable<IRemoteConnection> {
public final static String OS_NAME_PROPERTY = "os.name"; //$NON-NLS-1$
public final static String OS_VERSION_PROPERTY = "os.version"; //$NON-NLS-1$
public final static String OS_ARCH_PROPERTY = "os.arch"; //$NON-NLS-1$
/**
* @since 6.0
*/
public final static String FILE_SEPARATOR_PROPERTY = "file.separator"; //$NON-NLS-1$
/**
* @since 6.0
*/
public final static String PATH_SEPARATOR_PROPERTY = "path.separator"; //$NON-NLS-1$
/**
* @since 6.0
*/
public final static String LINE_SEPARATOR_PROPERTY = "line.separator"; //$NON-NLS-1$
/**
* @since 4.0
*/
public final static String USER_HOME_PROPERTY = "user.home"; //$NON-NLS-1$
/**
* Return the specified service.
*
* @param service interface
* @return service
*/
public <T extends IRemoteConnectionService> T getService(Class<T> service);
/**
* Register a listener that will be notified when this connection's status changes.
*
* @param listener
*/
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener);
/**
* Close the connection. Must be called to terminate the connection.
*/
public void close();
/**
* Notify all listeners when this connection's status changes. See {{@link IRemoteConnectionChangeEvent} for a list of event
* types.
*
* @param event
* event type indicating the nature of the event
*/
public void fireConnectionChangeEvent(int type);
/**
* Forward local port localPort to remote port fwdPort on remote machine fwdAddress. If this IRemoteConnection is not to
* fwdAddress, the port will be routed via the connection machine to fwdAddress.
*
* @param localPort
* local port to forward
* @param fwdAddress
* address of remote machine
* @param fwdPort
* remote port on remote machine
* @throws RemoteConnectionException
*/
public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
/**
* Forward a local port to remote port fwdPort on remote machine fwdAddress. The local port is chosen dynamically and returned
* by the method. If this IRemoteConnection is not to fwdAddress, the port will be routed via the connection machine to
* fwdAddress.
*
* @param fwdAddress
* @param fwdPort
* @param monitor
* @return local port number
* @throws RemoteConnectionException
*/
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
/**
* Forward remote port remotePort to port fwdPort on machine fwdAddress. When a connection is made to remotePort on the remote
* machine, it is forwarded via this IRemoteConnection to fwdPort on machine fwdAddress.
*
* @param remotePort
* remote port to forward
* @param fwdAddress
* address of recipient machine
* @param fwdPort
* port on recipient machine
* @throws RemoteConnectionException
*/
public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
/**
* Forward a remote port to port fwdPort on remote machine fwdAddress. The remote port is chosen dynamically and returned by the
* method. When a connection is made to this port on the remote machine, it is forwarded via this IRemoteConnection to fwdPort
* on machine fwdAddress.
*
* If fwdAddress is the empty string ("") then the fwdPort will be bound to any address on all interfaces. Note that this
* requires enabling the GatewayPort sshd option on some systems.
*
* @param fwdAddress
* @param fwdPort
* @param monitor
* @return remote port number
* @throws RemoteConnectionException
*/
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
/**
* Gets the implementation dependent address for this connection
*
* return address
*/
public String getAddress();
/**
* Get the implementation specific attributes for the connection.
*
* NOTE: the attributes do not include any security related information (e.g. passwords, keys, etc.)
*
* @return a map containing the connection attribute keys and values
*/
public Map<String, String> getAttributes();
/**
* Get a remote process that runs a command shell on the remote system. The shell will be the user's default shell on the remote
* system. The flags may be used to modify behavior of the remote process. These flags may only be supported by specific types
* of remote service providers. Clients can use {@link IRemoteProcessBuilder#getSupportedFlags()} to find out the flags
* supported by the service provider.
*
* <pre>
* Current flags are:
* {@link IRemoteProcessBuilder#NONE} - disable any flags
* {@link IRemoteProcessBuilder#ALLOCATE_PTY} - allocate a pseudo-terminal for the process (RFC-4254 Sec. 6.2)
* {@link IRemoteProcessBuilder#FORWARD_X11} - enable X11 forwarding (RFC-4254 Sec. 6.3)
* </pre>
*
* @param flags
* bitwise-or of flags
* @return remote process object
* @throws IOException
* @since 7.0
*/
public IRemoteProcess getCommandShell(int flags) throws IOException;
/**
* Returns an unmodifiable string map view of the remote environment. The connection must be open prior to calling this method.
*
* @return the remote environment
* @since 5.0
*/
public Map<String, String> getEnv();
/**
* Returns the value of an environment variable. The connection must be open prior to calling this method.
*
* @param name
* name of the environment variable
* @return value of the environment variable or null if the variable is not defined
*/
public String getEnv(String name);
/**
* Get a file manager for managing remote files
*
* @return file manager or null if connection is not open
*/
public IRemoteFileManager getFileManager();
/**
* Get unique name for this connection.
*
* @return connection name
*/
public String getName();
/**
* Gets the port for this connection. Only valid if supported by the service provider.
*
* return port number
*
* @since 5.0
*/
public int getPort();
/**
* Get a process builder for creating remote processes
*
* @return process builder or null if connection is not open
*/
public IRemoteProcessBuilder getProcessBuilder(List<String> command);
/**
* Get a process builder for creating remote processes
*
* @return process builder or null if connection is not open
*/
public IRemoteProcessBuilder getProcessBuilder(String... command);
/**
* Gets the remote system property indicated by the specified key. The connection must be open prior to calling this method.
*
* The following keys are supported:
*
* <pre>
* os.name Operating system name
* os.arch Operating system architecture
* os.version Operating system version
* file.separator File separator ("/" on UNIX)
* path.separator Path separator (":" on UNIX)
* line.separator Line separator ("\n" on UNIX)
* user.home Home directory
* </pre>
*
* @param key
* the name of the property
* @return the string value of the property, or null if no property has that key
*/
public String getProperty(String key);
/**
* Get the remote services provider for this connection.
*
* @return remote services provider
* @since 4.0
*/
public IRemoteServices getRemoteServices();
/**
* Gets the username for this connection
*
* return username
*/
public String getUsername();
public IRemoteConnectionWorkingCopy getWorkingCopy();
/**
* Get the working directory. Relative paths will be resolved using this path.
*
* The remote connection does not need to be open to use this method, however a default directory path, rather than the actual
* working directory, may be returned in this case.
*
* @return String representing the current working directory
* @since 4.0
*/
public String getWorkingDirectory();
/**
* Test if the connection is open.
*
* @return true if connection is open.
*/
public boolean isOpen();
/**
* Open the connection. Must be called before the connection can be used.
*
* @param monitor
* the progress monitor to use for reporting progress to the user. It is the caller's responsibility to call done()
* on the given monitor. Accepts null, indicating that no progress should be reported and that the operation cannot
* be cancelled.
* @throws RemoteConnectionException
*/
public void open(IProgressMonitor monitor) throws RemoteConnectionException;
/**
* Remove a listener that will be notified when this connection's status changes.
*
* @param listener
*/
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener);
/**
* Remove the local port forwarding associated with the given port.
*
* @param port
* forwarded port
* @throws RemoteConnectionException
* @since 7.0
*/
public void removeLocalPortForwarding(int port) throws RemoteConnectionException;
/**
* Remove the remote port forwarding associated with the given port.
*
* @param port
* forwarded port
* @throws RemoteConnectionException
* @since 7.0
*/
public void removeRemotePortForwarding(int port) throws RemoteConnectionException;
/**
* Set the working directory while the connection is open. The working directory will revert to the default when the connection
* is closed then subsequently reopened.
*
* Relative paths will be resolved using this path. The path must be valid and absolute for any changes to be made.
*
* @param path
* String representing the current working directory
* @since 4.0
*/
public void setWorkingDirectory(String path);
/**
* Test if this connection supports forwarding of TCP connections
*
* @return true if TCP port forwarding is supported
*/
public boolean supportsTCPPortForwarding();
}

View file

@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright (c) 2008 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
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.core.api2;
/**
* Event representing a change in connection status. The {@link #getType()} method can be used to obtain information about the type
* of event that occurred.
*/
public interface IRemoteConnectionChangeEvent {
/**
* Event indicating that the connection was closed.
*/
public static final int CONNECTION_CLOSED = 1 << 0;
/**
* Event indicating that the connection was opened.
*/
public static final int CONNECTION_OPENED = 1 << 1;
/**
* Event indicating that the connection was closed abnormally.
*/
public static final int CONNECTION_ABORTED = 1 << 2;
/**
* Event indicating that the connection name was changed.
*/
public static final int CONNECTION_RENAMED = 1 << 3;
/**
* Get the connection that has changed.
*
* @return IRemoteConnection
*/
public IRemoteConnection getConnection();
/**
* Returns the type of event being reported. This type
* is obtained by bitwise OR'ing the event types together.
*
* {@link #CONNECTION_CLOSED} {@link #CONNECTION_OPENED} {@link #CONNECTION_ABORTED} {@link #CONNECTION_RENAMED}
*
* @return a bitwise OR of event type constants
*/
public int getType();
}

View file

@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2008 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
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.core.api2;
import java.util.EventListener;
/**
* Listener used to register for notification of connection status changes. Clients should register a listener using the
* {@link IRemoteConnection#addConnectionChangeListener(IRemoteConnectionChangeListener)} method.
*/
public interface IRemoteConnectionChangeListener extends EventListener {
/**
* Notifies this listener that the status of a connection has changed.
*
* @param event
* the connection change event
*/
public void connectionChanged(IRemoteConnectionChangeEvent event);
}

View file

@ -0,0 +1,92 @@
/*******************************************************************************
* Copyright (c) 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
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.core.api2;
import java.net.URI;
import java.util.List;
import org.eclipse.remote.core.IUserAuthenticator;
import org.eclipse.remote.core.exception.RemoteConnectionException;
/**
* Interface for managing connections to remote systems.
*/
public interface IRemoteConnectionManager {
/**
* The name of the connection for local services. There is only one connection for local services.
*
* @since 7.0
*/
public static String LOCAL_CONNECTION_NAME = "Local"; //$NON-NLS-1$
/**
* Gets the remote connection corresponding to the supplied name.
*
* @param name
* name of the connection (as returned by {@link IRemoteConnection#getName()})
* @return remote connection or null if no connection exists
*/
public IRemoteConnection getConnection(String name);
/**
* Gets the remote connection corresponding to the supplied URI.
*
* @param uri
* URI containing a schema for this remote connection
* @return remote connection or null if no connection exists or the schema
* is incorrect
* @since 4.0
*/
public IRemoteConnection getConnection(URI uri);
/**
* Get all the connections for this service provider.
*
* @return connections that we know about
*/
public List<IRemoteConnection> getConnections();
/**
* Get the user authenticator that will be used when opening connections. The user authenticator is specified using the
* org.eclipse.remote.core.authenticator extension point.
*
* @param connection
* connection that will use this authenticator
* @return user authenticator
*/
public IUserAuthenticator getUserAuthenticator(IRemoteConnection connection);
/**
* Creates a new remote connection named with supplied name. The connection attributes will be the default for the
* implementation.
*
* Returns a working copy of the remote connection. Callers must call {@link IRemoteConnectionWorkingCopy#save()} before the
* connection can be used.
*
* @param name
* name of the connection
* @return a new connection working copy with the supplied name
* @throws RemoteConnectionException
* if connection creation failed
* @since 5.0
*/
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException;
/**
* Remove a connection and all resources associated with it.
*
* @param connection
* connection to remove
* @throws RemoteConnectionException
* if the connection could not be removed
*/
public void removeConnection(IRemoteConnection connection) throws RemoteConnectionException;
}

View file

@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2014 QNX Software Systems 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
*
* Contributors:
* Doug Schaefer (QNX) - initial
*******************************************************************************/
package org.eclipse.remote.core.api2;
/**
* Root interface for all services available from a connection.
*/
public interface IRemoteConnectionService {
/**
* Return the connection this service applies to.
*
* @return connection
*/
IRemoteConnection getConnection();
}

View file

@ -0,0 +1,85 @@
/*******************************************************************************
* Copyright (c) 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
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.core.api2;
public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
/**
* Returns the original connection this working copy was created from.
*
* @return original connection
*/
public IRemoteConnection getOriginal();
/**
* Returns whether this connection has been modified since it was last saved or created.
*
* @return true if the connection has been modified
*/
public boolean isDirty();
/**
* Saves this working copy to its original connection and returns a handle to the resulting connection. Has no effect if this
* connection does not need saving.
*
* @return saved connection
*/
public IRemoteConnection save();
/**
* Set the address for this connection
*
* @param address
*/
public void setAddress(String address);
/**
* Set an implementation dependent attribute for the connection. Attributes keys supported by the connection can be obtained
* using {@link #getAttributes()}. Attributes are persisted along with connection information.
*
* @param key
* attribute key
* @param value
* attribute value
* @since 5.0
*/
public void setAttribute(String key, String value);
/**
* Set the name for this connection
*
* @param name
*/
public void setName(String name);
/**
* Set the password for this connection
*
* @param password
* @since 5.0
*/
public void setPassword(String password);
/**
* Set the port used for this connection. Only valid if supported by the underlying service provider.
*
* @param port
* port number for the connection
* @since 5.0
*/
public void setPort(int port);
/**
* Set the username for this connection
*
* @param username
*/
public void setUsername(String username);
}

View file

@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 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
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.core.api2;
import java.net.URI;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.IPath;
/**
* Interface for managing resources on a remote system.
*/
public interface IRemoteFileManager {
/**
* Get the resource associated with path. IFileStore can then be used to
* perform operations on the file.
*
* The remote connection does not need to be open to use this method, but
* subsequent operations on the IFileStore that access the underlying remote
* filesystem may require the connection to be open.
*
* @param path
* path to resource
* @return the file store representing the remote path
*/
public IFileStore getResource(String path);
/**
* Gets the directory separator on the target system.
*
* @return String
* @since 4.0
*/
public String getDirectorySeparator();
/**
* Convert URI to a remote path. This path is suitable for direct file
* operations <i>on the remote system</i>.
*
* The remote connection does not need to be open to use this method.
*
* @return IPath representing the remote path
*/
public String toPath(URI uri);
/**
* Convert remote path to equivalent URI. This URI is suitable for EFS
* operations <i>on the local system</i>.
*
* The remote connection does not need to be open to use this method.
*
* @param path
* path on remote system
* @return URI representing path on remote system, or null if the path is
* invalid
*/
public URI toURI(IPath path);
/**
* Convert string representation of a remote path to equivalent URI. This
* URI is suitable for EFS operations <i>on the local system</i>.
*
* The remote connection does not need to be open to use this method.
*
* @param path
* path on remote system
* @return URI representing path on remote system, or null if the path is
* invalid
*/
public URI toURI(String path);
}

View file

@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2014 QNX Software Systems 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
*
* Contributors:
* Doug Schaefer (QNX) - initial
*******************************************************************************/
package org.eclipse.remote.core.api2;
import org.eclipse.debug.core.ILaunchConfigurationType;
/**
* Service that supports setting up launch configurations for
* launching over the remote connection.
*/
public interface IRemoteLaunchConfigService extends IRemoteService {
/**
* Does this remote service support launching on this launch config type.
*
* @param launchConfigType
* @return boolean supports launching on this connection
*/
boolean supportsType(ILaunchConfigurationType launchConfigType);
}

View file

@ -0,0 +1,15 @@
package org.eclipse.remote.core.api2;
/**
* The root interface for a service provided by a remote services provider.
*/
public interface IRemoteService {
/**
* Return the remote services provider object.
*
* @return remote services provider.
*/
IRemoteServices getRemoteServices();
}

View file

@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 2013 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
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.core.api2;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* Abstraction of a remote services provider. Clients obtain this interface using one of the static methods in
* {@link RemoteServices}. The methods on this interface can then be used to access the full range of remote services provided.
*/
public interface IRemoteServices extends IRemoteServicesDescriptor {
public static final int CAPABILITY_ADD_CONNECTIONS = 0x01;
public static final int CAPABILITY_EDIT_CONNECTIONS = 0x02;
public static final int CAPABILITY_REMOVE_CONNECTIONS = 0x04;
public static final int CAPABILITY_SUPPORTS_TCP_PORT_FORWARDING = 0x08;
public static final int CAPABILITY_SUPPORTS_X11_FORWARDING = 0x10;
public static final int CAPABILITY_SUPPORTS_COMMAND_SHELL = 0x20;
/**
* Return one of the remote services that this provider provides.
*
* @param service interface
* @return the service
*/
public <T extends IRemoteService> T getService(Class<T> service);
/**
* Get a connection manager for managing remote connections.
*
* @return connection manager or null if services are not initialized
*/
public IRemoteConnectionManager getConnectionManager();
/**
* Initialize the remote service. Clients should not call this method (it is called internally.)
*
* @return true if the initialization was successful, false otherwise
* @since 7.0
*/
public boolean initialize(IProgressMonitor monitor);
/**
* Gets the capabilities of the remote service.
*
* @return bit-wise or of capability flag constants
*/
public int getCapabilities();
}

View file

@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 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
*
* Contributors:
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.remote.core.api2;
/**
* Interface representing a remote services provider extension. Clients can use this to find out information about the extension
* without loading it.
*/
public interface IRemoteServicesDescriptor extends Comparable<IRemoteServicesDescriptor> {
/**
* Get unique ID of this service. Can be used as a lookup key.
*
* @return unique ID
*/
public String getId();
/**
* Get display name of this service.
*
* @return display name
*/
public String getName();
/**
* Get the EFS scheme provided by this service.
*
* @return display name
*/
public String getScheme();
}

View file

@ -37,6 +37,14 @@
</license> </license>
</licenses> </licenses>
<repositories>
<repository>
<id>eclipse</id>
<url>http://download.eclipse.org/releases/luna</url>
<layout>p2</layout>
</repository>
</repositories>
<modules> <modules>
<module>bundles/org.eclipse.launchbar.core</module> <module>bundles/org.eclipse.launchbar.core</module>
<module>bundles/org.eclipse.launchbar.ui</module> <module>bundles/org.eclipse.launchbar.ui</module>