Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 771e976d1fb4f4f3d6d18e0a71a0e60838bcd953 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*******************************************************************************
 * Copyright (c) 2014, 2015 Wind River Systems, Inc.
 * 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:
 *    Markus Schorn - initial API and implementation
 *******************************************************************************/
package org.eclipse.tcf.te.tcf.remote.core;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.core.exception.UnableToForwardPortException;

public abstract class TCFConnectionBase implements IRemoteConnection {

	private final TCFRemoteServices fRemoteServices;

	private String fWorkingDirectory = "/"; //$NON-NLS-1$

	public TCFConnectionBase(TCFRemoteServices tcfServices) {
		fRemoteServices = tcfServices;
    }

	@Override
	public final int compareTo(IRemoteConnection o) {
		return getName().compareTo(o.getName());
	}

	@Override
	public final String getProperty(String key) {
		return getAttributes().get(key);
	}

	@Override
	public final String getEnv(String name) {
		return getEnv().get(name);
	}

	@Override
	public final TCFRemoteServices getRemoteServices() {
		return fRemoteServices;
	}

	@Override
	public final String getWorkingDirectory() {
		return fWorkingDirectory;
	}

	@Override
	public final void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
		throw new UnableToForwardPortException(Messages.TCFConnectionBase_errorNoPortForwarding);
	}

	@Override
	public final int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
		throw new UnableToForwardPortException(Messages.TCFConnectionBase_errorNoPortForwarding);
	}

	@Override
	public final void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
		throw new UnableToForwardPortException(Messages.TCFConnectionBase_errorNoPortForwarding);
	}

	@Override
	public final int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
		throw new UnableToForwardPortException(Messages.TCFConnectionBase_errorNoPortForwarding);
	}

	@Override
	public final void removeLocalPortForwarding(int port) {
	}

	@Override
	public final void removeRemotePortForwarding(int port) {
	}

	@Override
	public final void setWorkingDirectory(String path) {
		if (new Path(path).isAbsolute()) {
			fWorkingDirectory = path;
		}
	}
	@Override
	public final boolean supportsTCPPortForwarding() {
		return false;
	}

	@Override
	public final String toString() {
		String str = getName() + " [" + getAddress(); //$NON-NLS-1$
		int port = getPort();
		if (port >= 0 && port != 1756) {
			str += ":" + port; //$NON-NLS-1$
		}
		return str + "]"; //$NON-NLS-1$
	}
}

Back to the top