diff --git a/terminal/org.eclipse.tm.terminal.serial/src/org/eclipse/tm/internal/terminal/serial/SerialConnector.java b/terminal/org.eclipse.tm.terminal.serial/src/org/eclipse/tm/internal/terminal/serial/SerialConnector.java index 948a12a96a8..f4f7ead640f 100644 --- a/terminal/org.eclipse.tm.terminal.serial/src/org/eclipse/tm/internal/terminal/serial/SerialConnector.java +++ b/terminal/org.eclipse.tm.terminal.serial/src/org/eclipse/tm/internal/terminal/serial/SerialConnector.java @@ -11,7 +11,7 @@ * Helmut Haigermoser and Ted Williams. * * 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) - [206892] Don't connect if already connecting * 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 SerialConnectWorker fConnectWorker = null; private volatile boolean fDisconnectGoingOn = false; - + public SerialConnector() { } public SerialConnector(SerialSettings settings) { @@ -53,7 +53,7 @@ public class SerialConnector extends TerminalConnectorImpl { } public void initialize() throws Exception { try { - fSettings=new SerialSettings(); + fSettings=new SerialSettings(); } catch (NoClassDefFoundError e) { // 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)); @@ -63,7 +63,7 @@ public class SerialConnector extends TerminalConnectorImpl { Logger.log("entered."); //$NON-NLS-1$ synchronized(this) { 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; } fConnectWorker = new SerialConnectWorker(this, control); @@ -73,7 +73,7 @@ public class SerialConnector extends TerminalConnectorImpl { fConnectWorker.start(); } /** - * Indicate that the connectWorker is finished. + * Indicate that the connectWorker is finished. */ void doneConnect() { synchronized(this) { @@ -83,7 +83,7 @@ public class SerialConnector extends TerminalConnectorImpl { public void disconnect() { Logger.log("entered."); //$NON-NLS-1$ 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) { fConnectWorker.interrupt(); return; @@ -92,7 +92,7 @@ public class SerialConnector extends TerminalConnectorImpl { } fDisconnectGoingOn = true; } - + // Fix for SPR 112422. When output is being received from the serial port, the // below call to removePortOwnershipListener() attempts to lock the serial port // 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 // removePortOwnershipListener(), thus preventing the display thread from // deadlocking with the other Terminal view thread. - + new Thread("Terminal View Serial Port Disconnect Worker") //$NON-NLS-1$ { public void run() { @@ -118,9 +118,9 @@ public class SerialConnector extends TerminalConnectorImpl { Logger.logException(e); } } - + 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 try { getSerialPort().removeEventListener(); @@ -131,7 +131,7 @@ public class SerialConnector extends TerminalConnectorImpl { Logger.log("Calling close() on serial port ..."); //$NON-NLS-1$ getSerialPort().close(); } - + if (getInputStream() != null) { try { getInputStream().close(); @@ -139,7 +139,7 @@ public class SerialConnector extends TerminalConnectorImpl { Logger.logException(exception); } } - + if (getOutputStream() != null) { try { getOutputStream().close(); @@ -147,7 +147,7 @@ public class SerialConnector extends TerminalConnectorImpl { Logger.logException(exception); } } - + setSerialPortIdentifier(null); cleanSerialPort(); setSerialPortHandler(null); @@ -179,11 +179,11 @@ public class SerialConnector extends TerminalConnectorImpl { public void setTerminalSize(int newWidth, int newHeight) { // TODO } - + protected SerialPort getSerialPort() { return fSerialPort; } - + /** * sets the socket to null */ @@ -192,9 +192,9 @@ public class SerialConnector extends TerminalConnectorImpl { setInputStream(null); setOutputStream(null); } - + protected void setSerialPort(SerialPort serialPort) throws IOException { - cleanSerialPort(); + cleanSerialPort(); if(serialPort!=null) { fSerialPort = serialPort; setOutputStream(serialPort.getOutputStream()); @@ -214,9 +214,13 @@ public class SerialConnector extends TerminalConnectorImpl { SerialPortHandler getSerialPortHandler() { return fTerminalSerialPortHandler; } + /** + * Return the Serial Settings. + * + * @return the settings for a concrete connection. + */ public ISerialSettings getSerialSettings() { return fSettings; - } public ISettingsPage makeSettingsPage() { return new SerialSettingsPage(fSettings); diff --git a/terminal/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnection.java b/terminal/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnection.java index 04c27793f29..78694c513f2 100644 --- a/terminal/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnection.java +++ b/terminal/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnection.java @@ -1,19 +1,20 @@ /******************************************************************************* * Copyright (c) 2006, 2008 Wind River Systems, Inc. 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: + * 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: * Michael Scharf (Wind River) - initial API and implementation * 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) * Martin Oberhuber (Wind River) - [198790] make SSH createSession() protected * Mikhail Kalugin - [201864] Fix Terminal SSH keyboard interactive authentication * Martin Oberhuber (Wind River) - [155026] Add keepalives for SSH connection * 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; @@ -86,12 +87,12 @@ class SshConnection extends Thread { public void run() { try { - int nTimeout = fConn.getTelnetSettings().getTimeout() * 1000; - int nKeepalive = fConn.getTelnetSettings().getKeepalive() * 1000; - String host = fConn.getTelnetSettings().getHost(); - String user = fConn.getTelnetSettings().getUser(); - String password = fConn.getTelnetSettings().getPassword(); - int port=fConn.getTelnetSettings().getPort(); + int nTimeout = fConn.getSshSettings().getTimeout() * 1000; + int nKeepalive = fConn.getSshSettings().getKeepalive() * 1000; + String host = fConn.getSshSettings().getHost(); + String user = fConn.getSshSettings().getUser(); + String password = fConn.getSshSettings().getPassword(); + int port = fConn.getSshSettings().getPort(); ////Giving a connectionId could be the index into a local ////Store where passwords are stored @@ -102,7 +103,7 @@ class SshConnection extends Thread { //UserInfo ui=new MyUserInfo(connectionId, 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()); //java.util.Hashtable config=new java.util.Hashtable(); @@ -137,7 +138,7 @@ class SshConnection extends Thread { } catch (IOException e) { connectFailed(e.getMessage(),e.getMessage()); } finally { - + } } synchronized void setChannel(Channel channel) { @@ -177,7 +178,7 @@ class SshConnection extends Thread { } return display; } - + private static class MyUserInfo implements UserInfo, UIKeyboardInteractive { private final String fConnectionId; private final String fUser; @@ -198,10 +199,10 @@ class SshConnection extends Thread { final boolean[] retval = new boolean[1]; Display.getDefault().syncExec(new Runnable() { 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) { 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[] prompt, final boolean[] echo) { @@ -257,14 +258,14 @@ class SshConnection extends Thread { final String[][] finResult = new String[1][]; getStandardDisplay().syncExec(new Runnable() { public void run() { - KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(null, + KeyboardInteractiveDialog dialog = new KeyboardInteractiveDialog(null, fConnectionId, destination, name, instruction, prompt, echo); dialog.open(); finResult[0]=dialog.getResult(); } }); String[] result=finResult[0]; - if (result == null) + if (result == null) return null; // canceled if (result.length == 1 && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$ fPassword = result[0]; diff --git a/terminal/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnector.java b/terminal/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnector.java index 4a60b660312..9485405c1d8 100644 --- a/terminal/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnector.java +++ b/terminal/org.eclipse.tm.terminal.ssh/src/org/eclipse/tm/internal/terminal/ssh/SshConnector.java @@ -1,13 +1,14 @@ /******************************************************************************* * Copyright (c) 2006, 2008 Wind River Systems, Inc. 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: + * 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: * Michael Scharf (Wind River) - initial API and implementation * 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; @@ -59,7 +60,7 @@ public class SshConnector extends TerminalConnectorImpl { Logger.logException(exception); } } - + if (getOutputStream() != null) { try { getOutputStream().close(); @@ -94,9 +95,15 @@ public class SshConnector extends TerminalConnectorImpl { } public void setState(TerminalState 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; } public ISettingsPage makeSettingsPage() { @@ -107,7 +114,7 @@ public class SshConnector extends TerminalConnectorImpl { } public void load(ISettingsStore store) { fSettings.load(store); - + } public void save(ISettingsStore store) { fSettings.save(store);