From 22ae382e1cea152d42ad506f8d611bf85dc559eb Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Fri, 11 May 2007 09:31:27 +0000 Subject: [PATCH] [178201] Telnet subsystem contribution initial checkin --- .../.classpath | 7 + .../.cvsignore | 1 + .../org.eclipse.rse.services.telnet/.project | 28 +++ .../.settings/org.eclipse.jdt.core.prefs | 70 ++++++ .../META-INF/MANIFEST.MF | 17 ++ .../about.html | 28 +++ .../build.properties | 16 ++ .../plugin.properties | 16 ++ .../internal/services/telnet/Activator.java | 76 +++++++ .../services/telnet/ITelnetService.java | 23 ++ .../telnet/ITelnetSessionProvider.java | 27 +++ .../telnet/TelnetServiceResources.java | 34 +++ .../telnet/TelnetServiceResources.properties | 18 ++ .../telnet/shell/TelnetHostShell.java | 132 ++++++++++++ .../telnet/shell/TelnetShellOutputReader.java | 146 +++++++++++++ .../telnet/shell/TelnetShellService.java | 90 ++++++++ .../telnet/shell/TelnetShellWriterThread.java | 101 +++++++++ .../.classpath | 7 + .../.cvsignore | 1 + .../.project | 28 +++ .../.settings/org.eclipse.jdt.core.prefs | 70 ++++++ .../META-INF/MANIFEST.MF | 22 ++ .../about.html | 28 +++ .../build.properties | 19 ++ .../icons/full/obj16/systemcommands_obj.gif | Bin 0 -> 230 bytes .../full/obj16/systemcommandslive_obj.gif | Bin 0 -> 246 bytes .../plugin.properties | 20 ++ .../plugin.xml | 30 +++ .../subsystems/shells/telnet/Activator.java | 60 ++++++ .../telnet/TelnetServiceCommandShell.java | 204 ++++++++++++++++++ .../TelnetShellSubSystemConfiguration.java | 84 ++++++++ .../rse/subsystems/shells/telnet/package.html | 28 +++ 32 files changed, 1431 insertions(+) create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/.classpath create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/.cvsignore create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/.project create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/.settings/org.eclipse.jdt.core.prefs create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/META-INF/MANIFEST.MF create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/about.html create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/build.properties create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/plugin.properties create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/Activator.java create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetService.java create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetSessionProvider.java create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/TelnetServiceResources.java create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/TelnetServiceResources.properties create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetHostShell.java create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellOutputReader.java create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellService.java create mode 100644 rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellWriterThread.java create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.classpath create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.cvsignore create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.project create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.settings/org.eclipse.jdt.core.prefs create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/META-INF/MANIFEST.MF create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/about.html create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/build.properties create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/icons/full/obj16/systemcommands_obj.gif create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/icons/full/obj16/systemcommandslive_obj.gif create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/plugin.properties create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/plugin.xml create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/internal/subsystems/shells/telnet/Activator.java create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/internal/subsystems/shells/telnet/TelnetServiceCommandShell.java create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/subsystems/shells/telnet/TelnetShellSubSystemConfiguration.java create mode 100644 rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/subsystems/shells/telnet/package.html diff --git a/rse/plugins/org.eclipse.rse.services.telnet/.classpath b/rse/plugins/org.eclipse.rse.services.telnet/.classpath new file mode 100644 index 00000000000..ce73933404a --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/rse/plugins/org.eclipse.rse.services.telnet/.cvsignore b/rse/plugins/org.eclipse.rse.services.telnet/.cvsignore new file mode 100644 index 00000000000..ba077a4031a --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/.cvsignore @@ -0,0 +1 @@ +bin diff --git a/rse/plugins/org.eclipse.rse.services.telnet/.project b/rse/plugins/org.eclipse.rse.services.telnet/.project new file mode 100644 index 00000000000..574be4622de --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/.project @@ -0,0 +1,28 @@ + + + org.eclipse.rse.services.telnet + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/rse/plugins/org.eclipse.rse.services.telnet/.settings/org.eclipse.jdt.core.prefs b/rse/plugins/org.eclipse.rse.services.telnet/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..d141d33956c --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,70 @@ +#Tue Jan 30 22:33:44 CET 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.3 diff --git a/rse/plugins/org.eclipse.rse.services.telnet/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.services.telnet/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..8426d837a94 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.rse.services.telnet +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.rse.internal.services.telnet.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.rse.services, + org.apache.commons.net, + org.eclipse.rse.services.files.ftp +Export-Package: org.eclipse.rse.internal.services.telnet;x-friends:="org.eclipse.rse.connectorservice.telnet,org.eclipse.rse.subsystems.files.telnet,org.eclipse.rse.subsystems.shells.telnet", + org.eclipse.rse.internal.services.telnet.shell;x-friends:="org.eclipse.rse.connectorservice.telnet,org.eclipse.rse.subsystems.shells.telnet" +Eclipse-LazyStart: true +Bundle-Vendor: %providerName +Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/rse/plugins/org.eclipse.rse.services.telnet/about.html b/rse/plugins/org.eclipse.rse.services.telnet/about.html new file mode 100644 index 00000000000..460233046ee --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

June 2, 2006

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services.telnet/build.properties b/rse/plugins/org.eclipse.rse.services.telnet/build.properties new file mode 100644 index 00000000000..93256781661 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/build.properties @@ -0,0 +1,16 @@ +############################################################################### +# Copyright (c) 2005, 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 +############################################################################### +bin.includes = .,\ + META-INF/,\ + about.html,\ + plugin.properties +source.. = src/ +output.. = bin/ diff --git a/rse/plugins/org.eclipse.rse.services.telnet/plugin.properties b/rse/plugins/org.eclipse.rse.services.telnet/plugin.properties new file mode 100644 index 00000000000..5fd0cd18ab5 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/plugin.properties @@ -0,0 +1,16 @@ +############################################################################### +# Copyright (c) 2000, 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: +# Sheldon D'souza (Celunite) - created +############################################################################### + +# NLS_MESSAGEFORMAT_NONE +# NLS_ENCODING=UTF-8 + +pluginName = RSE Telnet Service +providerName = Eclipse.org diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/Activator.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/Activator.java new file mode 100644 index 00000000000..7fdb5061d4b --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/Activator.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2006, 2007 Celunite, 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: + * Sheldon D'souza (Celunite) - initial API and implementation + *******************************************************************************/ +package org.eclipse.rse.internal.services.telnet; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.osgi.util.NLS; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.rse.services.telnet"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Logs an throwable to the log for this plugin. + * @param t the Throwable to be logged. + */ + public void logException(Throwable t) { + ILog log = getLog(); + String id = getBundle().getSymbolicName(); + String message = NLS.bind(TelnetServiceResources.TelnetPlugin_Unexpected_Exception, t.getClass().getName(), t.getLocalizedMessage()); + IStatus status = new Status(IStatus.ERROR, id, 0, message, t); + log.log(status); + } + +} diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetService.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetService.java new file mode 100644 index 00000000000..7da05254918 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetService.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2006, 2007 Celunite, 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: + * Sheldon D'souza (Celunite) - initial API and implementation + *******************************************************************************/ +package org.eclipse.rse.internal.services.telnet; + +/** + * Markup Interface for services using the TelnetConnectorService. + * + * By implementing this interface, services can be recognized + * as operating against an TelnetConnectorService. The interface + * is used as the key in a table for looking up the connector + * service when needed. + */ +public interface ITelnetService { + +} diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetSessionProvider.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetSessionProvider.java new file mode 100644 index 00000000000..f3c858ab7e9 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/ITelnetSessionProvider.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Sheldon D'souza (Celunite) - adapted from ISshSessionProvider + *******************************************************************************/ +package org.eclipse.rse.internal.services.telnet; + +import org.apache.commons.net.telnet.TelnetClient; + +public interface ITelnetSessionProvider { + + public TelnetClient getTelnetClient(); + + /* Inform the connectorService that a session has been lost. */ + public void handleSessionLost(); +} diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/TelnetServiceResources.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/TelnetServiceResources.java new file mode 100644 index 00000000000..5572200111a --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/TelnetServiceResources.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2006, 2007 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: + * Martin Oberhuber (Wind River) - initial API and implementation + * Sheldon D'souza (Celunite) - adapted form SshServiceResources + *******************************************************************************/ +package org.eclipse.rse.internal.services.telnet; + +import org.eclipse.osgi.util.NLS; + +public class TelnetServiceResources extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.rse.internal.services.telnet.TelnetServiceResources"; //$NON-NLS-1$ + + public static String TelnetPlugin_Unexpected_Exception; + + public static String TelnetShellService_Description; + + public static String TelnetShellService_Name; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, TelnetServiceResources.class); + } + + private TelnetServiceResources(){ + + } +} diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/TelnetServiceResources.properties b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/TelnetServiceResources.properties new file mode 100644 index 00000000000..a44c0f97396 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/TelnetServiceResources.properties @@ -0,0 +1,18 @@ +################################################################################ +# Copyright (c) 2006, 2007 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: +# Martin Oberhuber (Wind River) - initial API and implementation +# Sheldon D'souza (Celunite) - adapted from SshServiceResources +################################################################################ + +# NLS_MESSAGEFORMAT_VAR +# NLS_ENCODING=UTF-8 + +TelnetPlugin_Unexpected_Exception=Unexpected {0}: {1} +TelnetShellService_Name=Telnet Shell Service +TelnetShellService_Description=Telnet Shell Service Description diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetHostShell.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetHostShell.java new file mode 100644 index 00000000000..3763aedce19 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetHostShell.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Martin Oberhuber (Wind River) - Adapted from LocalHostShell. + * Sheldon D'souza (Celunite) - Adapted from SshHostShell + *******************************************************************************/ +package org.eclipse.rse.internal.services.telnet.shell; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.util.regex.Pattern; + +import org.apache.commons.net.telnet.TelnetClient; +import org.eclipse.rse.internal.services.telnet.ITelnetSessionProvider; +import org.eclipse.rse.services.clientserver.PathUtility; +import org.eclipse.rse.services.shells.AbstractHostShell; +import org.eclipse.rse.services.shells.IHostShell; +import org.eclipse.rse.services.shells.IHostShellOutputReader; + +public class TelnetHostShell extends AbstractHostShell implements IHostShell { + + public static final String SHELL_INVOCATION = ">"; //$NON-NLS-1$ + + private ITelnetSessionProvider fSessionProvider; + private TelnetShellOutputReader fStdoutHandler; + private TelnetShellOutputReader fStderrHandler; + private TelnetShellWriterThread fShellWriter; + + public TelnetHostShell(ITelnetSessionProvider sessionProvider, String initialWorkingDirectory, String commandToRun, String encoding, String[] environment) { + try { + fSessionProvider = sessionProvider; + + + fStdoutHandler = new TelnetShellOutputReader(this, new BufferedReader(new InputStreamReader(sessionProvider.getTelnetClient().getInputStream())), false); + fStderrHandler = new TelnetShellOutputReader(this, null,true); + OutputStream outputStream = sessionProvider.getTelnetClient().getOutputStream(); + //TODO check if encoding or command to execute needs to be considered + //If a command is given, it might be possible to do without a Thread + //Charset cs = Charset.forName(encoding); + //PrintWriter outputWriter = new PrintWriter( + // new BufferedWriter(new OutputStreamWriter(outputStream,cs))); + PrintWriter outputWriter = new PrintWriter(outputStream); + fShellWriter = new TelnetShellWriterThread(outputWriter); + + if (initialWorkingDirectory!=null && initialWorkingDirectory.length()>0 + && !initialWorkingDirectory.equals(".") //$NON-NLS-1$ + && !initialWorkingDirectory.equals("Command Shell") //$NON-NLS-1$ //FIXME workaround for bug 153047 + ) { + writeToShell("cd "+PathUtility.enQuoteUnix(initialWorkingDirectory)); //$NON-NLS-1$ + } else if (SHELL_INVOCATION.equals(commandToRun)) { + writeToShell(getPromptCommand()); + } else if(commandToRun!=null && commandToRun.length()>0) { + writeToShell(commandToRun); + } + } catch(Exception e) { + //TODO Forward exception to RSE properly + e.printStackTrace(); + if (fShellWriter!=null) { + fShellWriter.stopThread(); + fShellWriter = null; + } + } + } + + public String getPromptCommand() { + return "echo $PWD'>'"; //$NON-NLS-1$ + } + + public void exit() { + fShellWriter.stopThread(); + try { + fSessionProvider.getTelnetClient().disconnect(); + } catch (IOException e) { + } + + } + + public IHostShellOutputReader getStandardOutputReader() { + return fStdoutHandler; + } + + public IHostShellOutputReader getStandardErrorReader() { + return fStderrHandler; + } + + public boolean isActive() { + TelnetClient client = fSessionProvider.getTelnetClient(); + if (client!=null ) { + return true; + } + // shell is not active: check for session lost + exit(); + + if (client!=null && !client.isConnected()) { + fSessionProvider.handleSessionLost(); + } + return false; + } + + private static final Pattern cdCommands = Pattern.compile("\\A\\s*(cd|chdir|ls)\\b"); //$NON-NLS-1$ + + public void writeToShell(String command) { + if (isActive()) { + if ("#break".equals(command)) { //$NON-NLS-1$ + command = "\u0003"; //Unicode 3 == Ctrl+C //$NON-NLS-1$ + } else if (cdCommands.matcher(command).find()) { + command += "\r\n" + getPromptCommand(); //$NON-NLS-1$ + } + if (!fShellWriter.sendCommand(command)) { + //exception occurred: terminate writer thread, cancel connection + exit(); + isActive(); + } + } + + } + +} diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellOutputReader.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellOutputReader.java new file mode 100644 index 00000000000..f7967fbabca --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellOutputReader.java @@ -0,0 +1,146 @@ +/******************************************************************************* + * 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Martin Oberhuber (Wind River) - Adapted from LocalShellOutputReader. + * Martin Oberhuber (Wind River) - Added vt100 escape sequence ignoring. + * Sheldon D'souza (Celunite) - Adapted from SshShellOutputReader + *******************************************************************************/ +package org.eclipse.rse.internal.services.telnet.shell; + +import java.io.BufferedReader; +import java.io.IOException; + +import org.eclipse.rse.internal.services.telnet.Activator; +import org.eclipse.rse.services.shells.AbstractHostShellOutputReader; +import org.eclipse.rse.services.shells.IHostOutput; +import org.eclipse.rse.services.shells.IHostShell; +import org.eclipse.rse.services.shells.SimpleHostOutput; + +public class TelnetShellOutputReader extends AbstractHostShellOutputReader { + + + protected BufferedReader fReader; + private String fPromptChars = ">$%#]"; //$NON-NLS-1$ + + public TelnetShellOutputReader(IHostShell hostShell, BufferedReader reader,boolean isErrorReader) { + super(hostShell, isErrorReader); + setName("Telnet ShellOutputReader"+getName()); //$NON-NLS-1$ + fReader = reader; + } + + protected IHostOutput internalReadLine() { + if (fReader == null) { + //Our workaround sets the stderr reader to null, so we never give any stderr output. + //TODO Check if ssh supports some method of having separate stdout and stderr streams + return null; + } + StringBuffer theLine = new StringBuffer(); + StringBuffer theDebugLine = null; + theDebugLine = new StringBuffer(); + int ch; + boolean done = false; + while (!done && !isFinished()) { + try { + ch = fReader.read(); + switch (ch) { + case -1: + case 65535: + if (theLine.length() == 0) // End of Reader + return null; + done = true; + break; + case '\b': //backspace + if(theDebugLine!=null) theDebugLine.append((char)ch); + int len = theLine.length()-1; + if (len>=0) theLine.deleteCharAt(len); + break; + case 13: + if(theDebugLine!=null) theDebugLine.append((char)ch); + break; // Carriage Return: dont append to the buffer + case 10: + if(theDebugLine!=null) theDebugLine.append((char)ch); + done = true; // Newline + break; + case 9: + //Tab: we count tabs at column 8 + //TODO Check: SystemViewRemoteOutputAdapter.translateTabs() also translates + //Therefore this special handling here might be unnecessary + if(theDebugLine!=null) theDebugLine.append((char)ch); + int tabIndex = theLine.length() % 8; + while (tabIndex < 8) { + theLine.append(' '); + tabIndex++; + } + break; + default: + char tch = (char) ch; + if(theDebugLine!=null) theDebugLine.append(tch); + if (!Character.isISOControl(tch)) { + theLine.append(tch); // Any other character + } else if (ch == 27) { + // Escape: ignore next char too + int nch = fReader.read(); + if (theDebugLine!=null) theDebugLine.append((char)nch); + if (nch == 91) { + //vt100 escape sequence: read until end-of-command (skip digits and semicolon) + //e.g. \x1b;13;m --> ignore the entire command, including the trailing m + do { + nch = fReader.read(); + if (theDebugLine!=null) theDebugLine.append((char)nch); + } while (Character.isDigit((char)nch) || nch == ';'); + } + } + } + + // Check to see if the BufferedReader is still ready which means + // there are more characters + // in the Buffer...If not, then we assume it is waiting for + // input. + if (!done && !fReader.ready()) { + // wait to make sure -- max. 500 msec to wait for new chars + // if we are not at a CRLF seems to be appropriate for the + // Pipes and Threads in ssh. + long waitIncrement = 500; + // Check if we think we are at a prompt + int len = theLine.length()-1; + while (len>0 && Character.isSpaceChar(theLine.charAt(len))) { + len--; + } + if (len>=0 && fPromptChars.indexOf(theLine.charAt(len))>=0) { + waitIncrement = 5; //wait only 5 msec if we think it's a prompt + } + try { + Thread.sleep(waitIncrement); + } catch (InterruptedException e) { + } + if (!fReader.ready()) { + done = true; + } + } + } catch (IOException e) { + //FIXME it's dangerous to return null here since this will end + //our reader thread completely... the exception could just be + //temporary, and we should keep running! + Activator.getDefault().logException(e); + return null; + } + } + if (theDebugLine!=null) { + String debugLine = theDebugLine.toString(); + debugLine.compareTo(""); //$NON-NLS-1$ + } + return new SimpleHostOutput(theLine.toString()); + } + +} diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellService.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellService.java new file mode 100644 index 00000000000..8a4ca016ef9 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellService.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Martin Oberhuber (Wind River) - Adapted from LocalShellService. + * Sheldon D'souza (Celunite) - Adapted from SshShellService. + *******************************************************************************/ +package org.eclipse.rse.internal.services.telnet.shell; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.rse.internal.services.telnet.ITelnetService; +import org.eclipse.rse.internal.services.telnet.ITelnetSessionProvider; +import org.eclipse.rse.internal.services.telnet.TelnetServiceResources; +import org.eclipse.rse.services.clientserver.messages.SystemMessage; +import org.eclipse.rse.services.shells.IHostShell; +import org.eclipse.rse.services.shells.IShellService; + +public class TelnetShellService implements ITelnetService, IShellService { + + + private ITelnetSessionProvider fTelnetSessionProvider; + + public TelnetShellService( ITelnetSessionProvider sessionProvider) { + this.fTelnetSessionProvider = sessionProvider; + } + + public String[] getHostEnvironment() { + return new String[0]; + } + + public IHostShell launchShell(String initialWorkingDirectory, + String[] environment, IProgressMonitor monitor) { + String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ + return launchShell(initialWorkingDirectory, defaultEncoding, environment, monitor); + } + + public IHostShell launchShell(String initialWorkingDirectory, + String encoding, String[] environment, + IProgressMonitor monitor) { + TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment); + return hostShell; + } + + public IHostShell runCommand(String initialWorkingDirectory, + String command, String[] environment, IProgressMonitor monitor) { + String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$ + return runCommand(initialWorkingDirectory, command, defaultEncoding, environment, monitor); + } + + public IHostShell runCommand(String initialWorkingDirectory, + String command, String encoding, String[] environment, + IProgressMonitor monitor) { + TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment); + return hostShell; + } + + public String getDescription() { + return TelnetServiceResources.TelnetShellService_Description; + } + + public SystemMessage getMessage(String messageID) { + // TODO Auto-generated method stub + return null; + } + + public String getName() { + return TelnetServiceResources.TelnetShellService_Name; + } + + public void initService(IProgressMonitor monitor) { + // TODO Auto-generated method stub + + } + + public void uninitService(IProgressMonitor monitor) { + // TODO Auto-generated method stub + + } + +} diff --git a/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellWriterThread.java b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellWriterThread.java new file mode 100644 index 00000000000..5e1dd298b8d --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.telnet/src/org/eclipse/rse/internal/services/telnet/shell/TelnetShellWriterThread.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2006, 2007 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: + * Martin Oberhuber (Wind River) - initial API and implementation + * Sheldon D'souza (Celunite) - Adapted from SshShellWriterThread + *******************************************************************************/ +package org.eclipse.rse.internal.services.telnet.shell; + +import java.io.PrintWriter; + +public class TelnetShellWriterThread extends Thread { + + private PrintWriter fOutputWriter; + private String fNextCommand; + private boolean fIsCancelled; + + + /** + * constructor for ssh shell writer thread + * @param outputWriter PrintWriter to write to in separate Thread + */ + public TelnetShellWriterThread(PrintWriter outputWriter) + { + super(); + fOutputWriter = outputWriter; + setName("Telnet ShellWriter"+getName()); //$NON-NLS-1$ + start(); + } + + public synchronized boolean isDone() + { + return fIsCancelled; + } + + public synchronized void stopThread() + { + fIsCancelled = true; + notifyAll(); + } + + /** + * Write command to remote side. Wait until the + * thread takes the command (no queueing). + * @param command to send + * @return boolean true if command was sent ok + */ + public synchronized boolean sendCommand(String command) + { + try { + //In case multiple commands try to send: + //wait until it's our turn + while (!fIsCancelled && fNextCommand!=null) { + wait(); + } + if (!fIsCancelled) { + //Now it's our turn + fNextCommand = command; + notifyAll(); + //Wait until our command is processed + while (!fIsCancelled && fNextCommand!=null) { + wait(); + } + } + } catch(InterruptedException e) { + stopThread(); + } + return !fIsCancelled; + } + + public synchronized void run() + { + try { + while (!fIsCancelled) { + while (fNextCommand==null && !fIsCancelled) { + wait(); + } + if (!fIsCancelled) { + fOutputWriter.println(fNextCommand); + fNextCommand=null; + notifyAll(); + if (fOutputWriter.checkError()) { //flush AND get error + stopThread(); + } + } + } + } catch(InterruptedException e) { + /* no special handling -> close stream */ + } finally { + stopThread(); +// if( fOutputWriter != null ) +// fOutputWriter.close(); + fOutputWriter = null; + } + } + +} diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.classpath b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.classpath new file mode 100644 index 00000000000..ce73933404a --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.cvsignore b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.cvsignore new file mode 100644 index 00000000000..ba077a4031a --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.cvsignore @@ -0,0 +1 @@ +bin diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.project b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.project new file mode 100644 index 00000000000..be4c49f0c5b --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.project @@ -0,0 +1,28 @@ + + + org.eclipse.rse.subsystems.shells.telnet + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.settings/org.eclipse.jdt.core.prefs b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..d141d33956c --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,70 @@ +#Tue Jan 30 22:33:44 CET 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.3 diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..c5d11247257 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.rse.subsystems.shells.telnet;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.rse.internal.subsystems.shells.telnet.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.rse.services, + org.eclipse.rse.connectorservice.telnet, + org.eclipse.rse.services.telnet, + org.eclipse.rse.subsystems.shells.core, + org.eclipse.rse.subsystems.files.core, + org.eclipse.rse.shells.ui, + org.eclipse.rse.core, + org.eclipse.rse.ui +Export-Package: org.eclipse.rse.internal.subsystems.shells.telnet;x-internal:=true, + org.eclipse.rse.subsystems.shells.telnet +Eclipse-LazyStart: true +Bundle-Vendor: %providerName +Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/about.html b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/about.html new file mode 100644 index 00000000000..460233046ee --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

June 2, 2006

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/build.properties b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/build.properties new file mode 100644 index 00000000000..3eb760f0a77 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/build.properties @@ -0,0 +1,19 @@ +############################################################################### +# Copyright (c) 2005, 2006 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 +############################################################################### +bin.includes = .,\ + META-INF/,\ + about.html,\ + plugin.properties,\ + icons/,\ + plugin.xml +source.. = src/ +output.. = bin/ +src.includes = about.html diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/icons/full/obj16/systemcommands_obj.gif b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/icons/full/obj16/systemcommands_obj.gif new file mode 100644 index 0000000000000000000000000000000000000000..061b6e226a9ee80a9797e330ca407774f314dfe7 GIT binary patch literal 230 zcmZ?wbhEHb6krfwIKsfNfBt?3h6a24dVBl$_;?^0ykNl+`}qBCerfjc^X=>RGc+{V z&j*6~{rl(NzrX+g?+^d~|KGoVe@jbCLqh{l4+8@OPy|R~1&Tje7#SGE8FWChAUhdY zlOL$|rD(EctXh;(Fd3;*8D8UCP`X-4hiV FtO3DMPksOZ literal 0 HcmV?d00001 diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/icons/full/obj16/systemcommandslive_obj.gif b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/icons/full/obj16/systemcommandslive_obj.gif new file mode 100644 index 0000000000000000000000000000000000000000..3faca447424a6aa52b08191dbce3246c11d582c2 GIT binary patch literal 246 zcmZ?wbhEHb6krfwIKsfNfBt?3h6a24dVBl$_;?^0ykNl+`}qBCerfjg`xzPe`mP{%#43z5cEU}ts;yp#9 zRBPf4o#<653L1@vgFG817^a+yc2aDZ$RLux + + + + + + + + + diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/internal/subsystems/shells/telnet/Activator.java b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/internal/subsystems/shells/telnet/Activator.java new file mode 100644 index 00000000000..8323ff28b8b --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/internal/subsystems/shells/telnet/Activator.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2006, 2007 Celunite, 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: + * Sheldon D'souza (Celunite) + *******************************************************************************/ +package org.eclipse.rse.internal.subsystems.shells.telnet; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.rse.subsystems.shells.telnet"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/internal/subsystems/shells/telnet/TelnetServiceCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/internal/subsystems/shells/telnet/TelnetServiceCommandShell.java new file mode 100644 index 00000000000..2772dd75939 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/internal/subsystems/shells/telnet/TelnetServiceCommandShell.java @@ -0,0 +1,204 @@ +/******************************************************************************* + * 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Martin Oberhuber (Wind River) - Adapted from LocalServiceCommandShell + * Sheldon D'souza (Celunite) - Adapted from SshServiceCommandShell + *******************************************************************************/ +package org.eclipse.rse.internal.subsystems.shells.telnet; + +import java.util.ArrayList; +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.internal.services.telnet.shell.TelnetHostShell; +import org.eclipse.rse.internal.subsystems.shells.servicesubsystem.OutputRefreshJob; +import org.eclipse.rse.services.shells.IHostOutput; +import org.eclipse.rse.services.shells.IHostShell; +import org.eclipse.rse.services.shells.IHostShellChangeEvent; +import org.eclipse.rse.services.shells.ParsedOutput; +import org.eclipse.rse.services.shells.Patterns; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; +import org.eclipse.rse.subsystems.shells.core.model.ISystemOutputRemoteTypes; +import org.eclipse.rse.subsystems.shells.core.model.RemoteError; +import org.eclipse.rse.subsystems.shells.core.model.RemoteOutput; +import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; +import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput; +import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.ServiceCommandShell; + +public class TelnetServiceCommandShell extends ServiceCommandShell { + + private Patterns _patterns; + private String _curCommand; + private String _workingDir; + private IRemoteFileSubSystem _fs; + + public TelnetServiceCommandShell(IRemoteCmdSubSystem cmdSS, IHostShell hostShell) { + super(cmdSS, hostShell); + _patterns = new Patterns(); + _patterns.update("cmd"); //$NON-NLS-1$ + ISubSystem[] sses = cmdSS.getHost().getSubSystems(); + for (int i = 0; i < sses.length; i++) + { + if (sses[i] instanceof IRemoteFileSubSystem) + { + _fs = (IRemoteFileSubSystem)sses[i]; + } + } + } + + public Object getContext() + { + String workingDir = _workingDir; + if (workingDir != null && workingDir.length() > 0) + { + try + { + return _fs.getRemoteFileObject(workingDir, new NullProgressMonitor()); + } + catch (Exception e) + { + } + } + return null; + + } + + public void shellOutputChanged(IHostShellChangeEvent event) + { + IHostOutput[] lines = event.getLines(); + boolean gotCommand = false; + ArrayList outputs = new ArrayList(lines.length); + for (int i = 0; i < lines.length; i++) + { + String line = lines[i].getString(); + if (line.endsWith(getPromptCommand())) { + continue; //ignore our synthetic prompt command + } + + ParsedOutput parsedMsg = null; + if (!gotCommand && line.equals(_curCommand)) { + gotCommand = true; + continue; //ignore remote command echo + } else { + try { + + // Bug 160202: Remote shell dies. + if ((_curCommand == null) || (!_curCommand.trim().equals("ls"))) { //$NON-NLS-1$ + parsedMsg = _patterns.matchLine(line); + + // Bug 160202: Remote shell dies. + if (_curCommand != null) { + String temp = _curCommand.trim(); + StringTokenizer tokenizer = new StringTokenizer(temp); + + if (tokenizer.countTokens() == 2) { + String token1 = tokenizer.nextToken(); + String token2 = tokenizer.nextToken(); + + if ((token1.equals("ls")) && (token2.indexOf('-') == 0) && (token2.indexOf('l') > 0)) { //$NON-NLS-1$ + if (line.startsWith("total")) { //$NON-NLS-1$ + parsedMsg = null; + } + } + } + } + } + } + catch (Throwable e) { + e.printStackTrace(); + } + } + + RemoteOutput output = null; + + String type = "stdout"; //$NON-NLS-1$ + + if (parsedMsg != null) { + type = parsedMsg.type; + } + + if (event.isError()) { + output = new RemoteError(this, type); + } + else { + output = new RemoteOutput(this, type); + } + + output.setText(line); + if (parsedMsg != null) + { + String file = parsedMsg.file; + if (type.equals(ISystemOutputRemoteTypes.TYPE_PROMPT)) + { + _workingDir = file; + output.setAbsolutePath(_workingDir); + } + else if(_workingDir!=null) + { + IPath p = new Path(_workingDir).append(file); + output.setAbsolutePath(p.toString()); + } + else + { + output.setAbsolutePath(file); + } + } + + addOutput(output); + outputs.add(output); + } + IRemoteOutput[] remoteOutputs = (IRemoteOutput[])outputs.toArray(new IRemoteOutput[outputs.size()]); + //if (_lastRefreshJob == null || _lastRefreshJob.isComplete()) + { + _lastRefreshJob = new OutputRefreshJob(this, remoteOutputs, false); + _lastRefreshJob.schedule(); + } + /* + else + { + _lastRefreshJob.addOutputs(remoteOutputs); + _lastRefreshJob.schedule(); + } + */ + } + + /** + * Return the prompt command, such that lines ending with the + * prompt command can be removed from output. + * Should be overridden in case the IHostShell used for this + * service is not an TelnetHostShell. + * @return String promptCommand + */ + protected String getPromptCommand() { + IHostShell shell = getHostShell(); + //assert shell instanceof TelnetHostShell; + if (shell instanceof TelnetHostShell) { + return ((TelnetHostShell)shell).getPromptCommand(); + } + //return something impossible such that nothing is ever matched + return "\uffff"; //$NON-NLS-1$ + } + + public void writeToShell(String cmd) + { + _curCommand = cmd; + _patterns.update(cmd); + super.writeToShell(cmd); + + } + +} diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/subsystems/shells/telnet/TelnetShellSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/subsystems/shells/telnet/TelnetShellSubSystemConfiguration.java new file mode 100644 index 00000000000..c280a2af28c --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/subsystems/shells/telnet/TelnetShellSubSystemConfiguration.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Martin Oberhuber (Wind River) - Adapted template for ssh service. + * Sheldon D'souza (Celunite) - Adapted template for telnet service + *******************************************************************************/ +package org.eclipse.rse.subsystems.shells.telnet; + +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.subsystems.IConnectorService; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.internal.connectorservice.telnet.TelnetConnectorService; +import org.eclipse.rse.internal.connectorservice.telnet.TelnetConnectorServiceManager; +import org.eclipse.rse.internal.services.telnet.ITelnetService; +import org.eclipse.rse.internal.services.telnet.shell.TelnetShellService; +import org.eclipse.rse.internal.subsystems.shells.telnet.TelnetServiceCommandShell; +import org.eclipse.rse.services.shells.IHostShell; +import org.eclipse.rse.services.shells.IShellService; +import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; +import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IServiceCommandShell; +import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.ShellServiceSubSystem; +import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.ShellServiceSubSystemConfiguration; + +public class TelnetShellSubSystemConfiguration extends + ShellServiceSubSystemConfiguration { + + public TelnetShellSubSystemConfiguration() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#isFactoryFor(java.lang.Class) + */ + public boolean isFactoryFor(Class subSystemType) { + boolean isFor = ShellServiceSubSystem.class.equals(subSystemType); + return isFor; + } + + /** + * Instantiate and return an instance of OUR subystem. + * Do not populate it yet though! + * @see org.eclipse.rse.core.subsystems.SubSystemConfiguration#createSubSystemInternal(IHost) + */ + public ISubSystem createSubSystemInternal(IHost host) + { + TelnetConnectorService connectorService = (TelnetConnectorService)getConnectorService(host); + ISubSystem subsys = new ShellServiceSubSystem(host, connectorService, createShellService(host)); + return subsys; + } + + public IShellService createShellService(IHost host) { + TelnetConnectorService cserv = (TelnetConnectorService)getConnectorService(host); + return new TelnetShellService(cserv); + } + + public IConnectorService getConnectorService(IHost host) { + return TelnetConnectorServiceManager.getInstance().getConnectorService(host, ITelnetService.class); + } + + public void setConnectorService(IHost host, + IConnectorService connectorService) { + TelnetConnectorServiceManager.getInstance().setConnectorService(host, ITelnetService.class, connectorService); + } + + public Class getServiceImplType() { + return ITelnetService.class; + } + + public IServiceCommandShell createRemoteCommandShell(IRemoteCmdSubSystem cmdSS, IHostShell hostShell) { + return new TelnetServiceCommandShell(cmdSS, hostShell); + } + +} diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/subsystems/shells/telnet/package.html b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/subsystems/shells/telnet/package.html new file mode 100644 index 00000000000..9cebd3e541c --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.telnet/src/org/eclipse/rse/subsystems/shells/telnet/package.html @@ -0,0 +1,28 @@ + + + + + + Package-level Javadoc + + +Application programming interface for creating customized telnet shell subsystems. +

+Package Specification

+The package provides support classes for creating customized telnet shell +subsystems. +

The class TelnetSubSystemConfiguration is the main factory +for creating a telnet shell subsystem. By deriving from it, extenders +can create their customized telnet shell subsystem configuration which can +then be registered against their system types. A custom +SubSystemConfigurationAdapter can be registered for UI-specific +customizations. Possible customizations include: +

+

+ +