mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
[225792][api][breaking] Rename SshConnector.getTelnetSettings() to getSshSettings()
This commit is contained in:
parent
5b0837cf7f
commit
4fd8ea2b77
3 changed files with 61 additions and 49 deletions
|
@ -11,7 +11,7 @@
|
||||||
* Helmut Haigermoser and Ted Williams.
|
* Helmut Haigermoser and Ted Williams.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - extracted from TerminalControl
|
* Michael Scharf (Wind River) - extracted from TerminalControl
|
||||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||||
* Martin Oberhuber (Wind River) - [206892] Don't connect if already connecting
|
* Martin Oberhuber (Wind River) - [206892] Don't connect if already connecting
|
||||||
* Martin Oberhuber (Wind River) - [208029] COM port not released after quick disconnect/reconnect
|
* Martin Oberhuber (Wind River) - [208029] COM port not released after quick disconnect/reconnect
|
||||||
|
@ -45,7 +45,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
private SerialSettings fSettings;
|
private SerialSettings fSettings;
|
||||||
private SerialConnectWorker fConnectWorker = null;
|
private SerialConnectWorker fConnectWorker = null;
|
||||||
private volatile boolean fDisconnectGoingOn = false;
|
private volatile boolean fDisconnectGoingOn = false;
|
||||||
|
|
||||||
public SerialConnector() {
|
public SerialConnector() {
|
||||||
}
|
}
|
||||||
public SerialConnector(SerialSettings settings) {
|
public SerialConnector(SerialSettings settings) {
|
||||||
|
@ -53,7 +53,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
}
|
}
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
try {
|
try {
|
||||||
fSettings=new SerialSettings();
|
fSettings=new SerialSettings();
|
||||||
} catch (NoClassDefFoundError e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
// tell the user how to install the library
|
// tell the user how to install the library
|
||||||
throw new CoreException(new Status(IStatus.WARNING,Activator.PLUGIN_ID,0, SerialMessages.ERROR_LIBRARY_NOT_INSTALLED,e));
|
throw new CoreException(new Status(IStatus.WARNING,Activator.PLUGIN_ID,0, SerialMessages.ERROR_LIBRARY_NOT_INSTALLED,e));
|
||||||
|
@ -63,7 +63,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
Logger.log("entered."); //$NON-NLS-1$
|
Logger.log("entered."); //$NON-NLS-1$
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (fConnectWorker!=null || fDisconnectGoingOn) {
|
if (fConnectWorker!=null || fDisconnectGoingOn) {
|
||||||
//avoid multiple background connect/disconnect threads at the same time
|
//avoid multiple background connect/disconnect threads at the same time
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fConnectWorker = new SerialConnectWorker(this, control);
|
fConnectWorker = new SerialConnectWorker(this, control);
|
||||||
|
@ -73,7 +73,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
fConnectWorker.start();
|
fConnectWorker.start();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Indicate that the connectWorker is finished.
|
* Indicate that the connectWorker is finished.
|
||||||
*/
|
*/
|
||||||
void doneConnect() {
|
void doneConnect() {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
|
@ -83,7 +83,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
Logger.log("entered."); //$NON-NLS-1$
|
Logger.log("entered."); //$NON-NLS-1$
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
//avoid multiple background connect/disconnect threads at the same time
|
//avoid multiple background connect/disconnect threads at the same time
|
||||||
if (fConnectWorker!=null) {
|
if (fConnectWorker!=null) {
|
||||||
fConnectWorker.interrupt();
|
fConnectWorker.interrupt();
|
||||||
return;
|
return;
|
||||||
|
@ -92,7 +92,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
}
|
}
|
||||||
fDisconnectGoingOn = true;
|
fDisconnectGoingOn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for SPR 112422. When output is being received from the serial port, the
|
// Fix for SPR 112422. When output is being received from the serial port, the
|
||||||
// below call to removePortOwnershipListener() attempts to lock the serial port
|
// below call to removePortOwnershipListener() attempts to lock the serial port
|
||||||
// object, but that object is already locked by another Terminal view thread
|
// object, but that object is already locked by another Terminal view thread
|
||||||
|
@ -105,7 +105,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
// The solution is to spawn a short-lived worker thread that calls
|
// The solution is to spawn a short-lived worker thread that calls
|
||||||
// removePortOwnershipListener(), thus preventing the display thread from
|
// removePortOwnershipListener(), thus preventing the display thread from
|
||||||
// deadlocking with the other Terminal view thread.
|
// deadlocking with the other Terminal view thread.
|
||||||
|
|
||||||
new Thread("Terminal View Serial Port Disconnect Worker") //$NON-NLS-1$
|
new Thread("Terminal View Serial Port Disconnect Worker") //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -118,9 +118,9 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
Logger.logException(e);
|
Logger.logException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSerialPort() != null) {
|
if (getSerialPort() != null) {
|
||||||
//Event listener is removed as part of close(),
|
//Event listener is removed as part of close(),
|
||||||
//but exceptions need to be caught to ensure that close() really succeeds
|
//but exceptions need to be caught to ensure that close() really succeeds
|
||||||
try {
|
try {
|
||||||
getSerialPort().removeEventListener();
|
getSerialPort().removeEventListener();
|
||||||
|
@ -131,7 +131,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
Logger.log("Calling close() on serial port ..."); //$NON-NLS-1$
|
Logger.log("Calling close() on serial port ..."); //$NON-NLS-1$
|
||||||
getSerialPort().close();
|
getSerialPort().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getInputStream() != null) {
|
if (getInputStream() != null) {
|
||||||
try {
|
try {
|
||||||
getInputStream().close();
|
getInputStream().close();
|
||||||
|
@ -139,7 +139,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
Logger.logException(exception);
|
Logger.logException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getOutputStream() != null) {
|
if (getOutputStream() != null) {
|
||||||
try {
|
try {
|
||||||
getOutputStream().close();
|
getOutputStream().close();
|
||||||
|
@ -147,7 +147,7 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
Logger.logException(exception);
|
Logger.logException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSerialPortIdentifier(null);
|
setSerialPortIdentifier(null);
|
||||||
cleanSerialPort();
|
cleanSerialPort();
|
||||||
setSerialPortHandler(null);
|
setSerialPortHandler(null);
|
||||||
|
@ -179,11 +179,11 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
public void setTerminalSize(int newWidth, int newHeight) {
|
public void setTerminalSize(int newWidth, int newHeight) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SerialPort getSerialPort() {
|
protected SerialPort getSerialPort() {
|
||||||
return fSerialPort;
|
return fSerialPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the socket to null
|
* sets the socket to null
|
||||||
*/
|
*/
|
||||||
|
@ -192,9 +192,9 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
setInputStream(null);
|
setInputStream(null);
|
||||||
setOutputStream(null);
|
setOutputStream(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setSerialPort(SerialPort serialPort) throws IOException {
|
protected void setSerialPort(SerialPort serialPort) throws IOException {
|
||||||
cleanSerialPort();
|
cleanSerialPort();
|
||||||
if(serialPort!=null) {
|
if(serialPort!=null) {
|
||||||
fSerialPort = serialPort;
|
fSerialPort = serialPort;
|
||||||
setOutputStream(serialPort.getOutputStream());
|
setOutputStream(serialPort.getOutputStream());
|
||||||
|
@ -214,9 +214,13 @@ public class SerialConnector extends TerminalConnectorImpl {
|
||||||
SerialPortHandler getSerialPortHandler() {
|
SerialPortHandler getSerialPortHandler() {
|
||||||
return fTerminalSerialPortHandler;
|
return fTerminalSerialPortHandler;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Return the Serial Settings.
|
||||||
|
*
|
||||||
|
* @return the settings for a concrete connection.
|
||||||
|
*/
|
||||||
public ISerialSettings getSerialSettings() {
|
public ISerialSettings getSerialSettings() {
|
||||||
return fSettings;
|
return fSettings;
|
||||||
|
|
||||||
}
|
}
|
||||||
public ISettingsPage makeSettingsPage() {
|
public ISettingsPage makeSettingsPage() {
|
||||||
return new SerialSettingsPage(fSettings);
|
return new SerialSettingsPage(fSettings);
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - initial API and implementation
|
* Michael Scharf (Wind River) - initial API and implementation
|
||||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||||
* Martin Oberhuber (Wind River) - [175686] Adapted to new IJSchService API
|
* Martin Oberhuber (Wind River) - [175686] Adapted to new IJSchService API
|
||||||
* - copied code from org.eclipse.team.cvs.ssh2/JSchSession (Copyright IBM)
|
* - copied code from org.eclipse.team.cvs.ssh2/JSchSession (Copyright IBM)
|
||||||
* Martin Oberhuber (Wind River) - [198790] make SSH createSession() protected
|
* Martin Oberhuber (Wind River) - [198790] make SSH createSession() protected
|
||||||
* Mikhail Kalugin <fourdman@xored.com> - [201864] Fix Terminal SSH keyboard interactive authentication
|
* Mikhail Kalugin <fourdman@xored.com> - [201864] Fix Terminal SSH keyboard interactive authentication
|
||||||
* Martin Oberhuber (Wind River) - [155026] Add keepalives for SSH connection
|
* Martin Oberhuber (Wind River) - [155026] Add keepalives for SSH connection
|
||||||
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
|
* Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives
|
||||||
|
* Martin Oberhuber (Wind River) - [225792] Rename SshConnector.getTelnetSettings() to getSshSettings()
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.ssh;
|
package org.eclipse.tm.internal.terminal.ssh;
|
||||||
|
|
||||||
|
@ -86,12 +87,12 @@ class SshConnection extends Thread {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
int nTimeout = fConn.getTelnetSettings().getTimeout() * 1000;
|
int nTimeout = fConn.getSshSettings().getTimeout() * 1000;
|
||||||
int nKeepalive = fConn.getTelnetSettings().getKeepalive() * 1000;
|
int nKeepalive = fConn.getSshSettings().getKeepalive() * 1000;
|
||||||
String host = fConn.getTelnetSettings().getHost();
|
String host = fConn.getSshSettings().getHost();
|
||||||
String user = fConn.getTelnetSettings().getUser();
|
String user = fConn.getSshSettings().getUser();
|
||||||
String password = fConn.getTelnetSettings().getPassword();
|
String password = fConn.getSshSettings().getPassword();
|
||||||
int port=fConn.getTelnetSettings().getPort();
|
int port = fConn.getSshSettings().getPort();
|
||||||
|
|
||||||
////Giving a connectionId could be the index into a local
|
////Giving a connectionId could be the index into a local
|
||||||
////Store where passwords are stored
|
////Store where passwords are stored
|
||||||
|
@ -102,7 +103,7 @@ class SshConnection extends Thread {
|
||||||
//UserInfo ui=new MyUserInfo(connectionId, user, password);
|
//UserInfo ui=new MyUserInfo(connectionId, user, password);
|
||||||
UserInfo ui=new MyUserInfo(null, user, password);
|
UserInfo ui=new MyUserInfo(null, user, password);
|
||||||
|
|
||||||
Session session = createSession(user, password, host, port,
|
Session session = createSession(user, password, host, port,
|
||||||
ui, new NullProgressMonitor());
|
ui, new NullProgressMonitor());
|
||||||
|
|
||||||
//java.util.Hashtable config=new java.util.Hashtable();
|
//java.util.Hashtable config=new java.util.Hashtable();
|
||||||
|
@ -137,7 +138,7 @@ class SshConnection extends Thread {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
connectFailed(e.getMessage(),e.getMessage());
|
connectFailed(e.getMessage(),e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
synchronized void setChannel(Channel channel) {
|
synchronized void setChannel(Channel channel) {
|
||||||
|
@ -177,7 +178,7 @@ class SshConnection extends Thread {
|
||||||
}
|
}
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MyUserInfo implements UserInfo, UIKeyboardInteractive {
|
private static class MyUserInfo implements UserInfo, UIKeyboardInteractive {
|
||||||
private final String fConnectionId;
|
private final String fConnectionId;
|
||||||
private final String fUser;
|
private final String fUser;
|
||||||
|
@ -198,10 +199,10 @@ class SshConnection extends Thread {
|
||||||
final boolean[] retval = new boolean[1];
|
final boolean[] retval = new boolean[1];
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
retval[0] = MessageDialog.openQuestion(null, SshMessages.WARNING, str);
|
retval[0] = MessageDialog.openQuestion(null, SshMessages.WARNING, str);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return retval[0];
|
return retval[0];
|
||||||
}
|
}
|
||||||
private String promptSecret(final String message) {
|
private String promptSecret(final String message) {
|
||||||
final String[] retval = new String[1];
|
final String[] retval = new String[1];
|
||||||
|
@ -240,7 +241,7 @@ class SshConnection extends Thread {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public String[] promptKeyboardInteractive(final String destination,
|
public String[] promptKeyboardInteractive(final String destination,
|
||||||
final String name, final String instruction,
|
final String name, final String instruction,
|
||||||
final String[] prompt, final boolean[] echo)
|
final String[] prompt, final boolean[] echo)
|
||||||
{
|
{
|
||||||
|
@ -257,14 +258,14 @@ class SshConnection extends Thread {
|
||||||
final String[][] finResult = new String[1][];
|
final String[][] finResult = new String[1][];
|
||||||
getStandardDisplay().syncExec(new Runnable() {
|
getStandardDisplay().syncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(null,
|
KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(null,
|
||||||
fConnectionId, destination, name, instruction, prompt, echo);
|
fConnectionId, destination, name, instruction, prompt, echo);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
finResult[0]=dialog.getResult();
|
finResult[0]=dialog.getResult();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
String[] result=finResult[0];
|
String[] result=finResult[0];
|
||||||
if (result == null)
|
if (result == null)
|
||||||
return null; // canceled
|
return null; // canceled
|
||||||
if (result.length == 1 && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
|
if (result.length == 1 && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
|
||||||
fPassword = result[0];
|
fPassword = result[0];
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Scharf (Wind River) - initial API and implementation
|
* Michael Scharf (Wind River) - initial API and implementation
|
||||||
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified
|
||||||
|
* Martin Oberhuber (Wind River) - [225792] Rename SshConnector.getTelnetSettings() to getSshSettings()
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.tm.internal.terminal.ssh;
|
package org.eclipse.tm.internal.terminal.ssh;
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ public class SshConnector extends TerminalConnectorImpl {
|
||||||
Logger.logException(exception);
|
Logger.logException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getOutputStream() != null) {
|
if (getOutputStream() != null) {
|
||||||
try {
|
try {
|
||||||
getOutputStream().close();
|
getOutputStream().close();
|
||||||
|
@ -94,9 +95,15 @@ public class SshConnector extends TerminalConnectorImpl {
|
||||||
}
|
}
|
||||||
public void setState(TerminalState state) {
|
public void setState(TerminalState state) {
|
||||||
fControl.setState(state);
|
fControl.setState(state);
|
||||||
|
|
||||||
}
|
}
|
||||||
public ISshSettings getTelnetSettings() {
|
/**
|
||||||
|
* Return the SSH Settings.
|
||||||
|
*
|
||||||
|
* @return the settings for a concrete connection.
|
||||||
|
* @since org.eclipse.tm.terminal.ssh 2.0 renamed from getTelnetSettings()
|
||||||
|
*/
|
||||||
|
public ISshSettings getSshSettings() {
|
||||||
return fSettings;
|
return fSettings;
|
||||||
}
|
}
|
||||||
public ISettingsPage makeSettingsPage() {
|
public ISettingsPage makeSettingsPage() {
|
||||||
|
@ -107,7 +114,7 @@ public class SshConnector extends TerminalConnectorImpl {
|
||||||
}
|
}
|
||||||
public void load(ISettingsStore store) {
|
public void load(ISettingsStore store) {
|
||||||
fSettings.load(store);
|
fSettings.load(store);
|
||||||
|
|
||||||
}
|
}
|
||||||
public void save(ISettingsStore store) {
|
public void save(ISettingsStore store) {
|
||||||
fSettings.save(store);
|
fSettings.save(store);
|
||||||
|
|
Loading…
Add table
Reference in a new issue