summaryrefslogtreecommitdiffstats
path: root/tcf/terminals_plugin.patch
diff options
context:
space:
mode:
Diffstat (limited to 'tcf/terminals_plugin.patch')
-rw-r--r--tcf/terminals_plugin.patch618
1 files changed, 618 insertions, 0 deletions
diff --git a/tcf/terminals_plugin.patch b/tcf/terminals_plugin.patch
new file mode 100644
index 0000000..352e151
--- /dev/null
+++ b/tcf/terminals_plugin.patch
@@ -0,0 +1,618 @@
1Index: plugins/org.eclipse.tm.tcf.terminals/META-INF/MANIFEST.MF
2===================================================================
3--- plugins/org.eclipse.tm.tcf.terminals/META-INF/MANIFEST.MF (revision 0)
4+++ plugins/org.eclipse.tm.tcf.terminals/META-INF/MANIFEST.MF (revision 0)
5@@ -0,0 +1,14 @@
6+Manifest-Version: 1.0
7+Bundle-ManifestVersion: 2
8+Bundle-Name: %pluginName
9+Bundle-SymbolicName: org.eclipse.tm.tcf.terminals;singleton:=true
10+Bundle-Version: 0.3.0.qualifier
11+Bundle-Activator: org.eclipse.tm.internal.tcf.terminals.Activator
12+Bundle-Vendor: %providerName
13+Require-Bundle: org.eclipse.core.runtime,
14+ org.eclipse.tm.tcf
15+Bundle-ActivationPolicy: lazy
16+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
17+Import-Package: org.eclipse.tm.tcf.core;version="0.3.0",
18+ org.eclipse.tm.tcf.protocol;version="0.3.0"
19+Export-Package: org.eclipse.tm.internal.tcf.terminals
20Index: plugins/org.eclipse.tm.tcf.terminals/.classpath
21===================================================================
22--- plugins/org.eclipse.tm.tcf.terminals/.classpath (revision 0)
23+++ plugins/org.eclipse.tm.tcf.terminals/.classpath (revision 0)
24@@ -0,0 +1,7 @@
25+<?xml version="1.0" encoding="UTF-8"?>
26+<classpath>
27+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
28+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
29+ <classpathentry kind="src" path="src"/>
30+ <classpathentry kind="output" path="bin"/>
31+</classpath>
32Index: plugins/org.eclipse.tm.tcf.terminals/.project
33===================================================================
34--- plugins/org.eclipse.tm.tcf.terminals/.project (revision 0)
35+++ plugins/org.eclipse.tm.tcf.terminals/.project (revision 0)
36@@ -0,0 +1,28 @@
37+<?xml version="1.0" encoding="UTF-8"?>
38+<projectDescription>
39+ <name>org.eclipse.tm.tcf.terminals</name>
40+ <comment></comment>
41+ <projects>
42+ </projects>
43+ <buildSpec>
44+ <buildCommand>
45+ <name>org.eclipse.jdt.core.javabuilder</name>
46+ <arguments>
47+ </arguments>
48+ </buildCommand>
49+ <buildCommand>
50+ <name>org.eclipse.pde.ManifestBuilder</name>
51+ <arguments>
52+ </arguments>
53+ </buildCommand>
54+ <buildCommand>
55+ <name>org.eclipse.pde.SchemaBuilder</name>
56+ <arguments>
57+ </arguments>
58+ </buildCommand>
59+ </buildSpec>
60+ <natures>
61+ <nature>org.eclipse.pde.PluginNature</nature>
62+ <nature>org.eclipse.jdt.core.javanature</nature>
63+ </natures>
64+</projectDescription>
65Index: plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/TerminalsServiceProxy.java
66===================================================================
67--- plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/TerminalsServiceProxy.java (revision 0)
68+++ plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/TerminalsServiceProxy.java (revision 0)
69@@ -0,0 +1,191 @@
70+/*******************************************************************************
71+ * Copyright (c) 2010 Intel Corporation. and others.
72+ * All rights reserved. This program and the accompanying materials
73+ * are made available under the terms of the Eclipse Public License v1.0
74+ * which accompanies this distribution, and is available at
75+ * http://www.eclipse.org/legal/epl-v10.html
76+ *
77+ * Contributors:
78+ * Intel - initial API and implementation
79+ *******************************************************************************/
80+
81+package org.eclipse.tm.internal.tcf.terminals;
82+
83+import java.io.IOException;
84+import java.util.HashMap;
85+import java.util.Map;
86+
87+import org.eclipse.tm.internal.tcf.terminals.ITerminalsService;
88+import org.eclipse.tm.tcf.core.Command;
89+import org.eclipse.tm.tcf.protocol.IChannel;
90+import org.eclipse.tm.tcf.protocol.IToken;
91+import org.eclipse.tm.tcf.protocol.JSON;
92+import org.eclipse.tm.tcf.protocol.Protocol;
93+
94+public class TerminalsServiceProxy implements ITerminalsService {
95+
96+ private final IChannel channel;
97+ private final Map<TerminalsListener,IChannel.IEventListener> listeners =
98+ new HashMap<TerminalsListener,IChannel.IEventListener>();
99+
100+ private class TerminalContext implements ITerminalsService.TerminalContext {
101+
102+ private final Map<String,Object> props;
103+
104+ TerminalContext(Map<String,Object> props) {
105+ this.props = props;
106+ }
107+
108+ public String getID() {
109+ return (String)props.get(PROP_ID);
110+ }
111+
112+ public String getPtyType() {
113+ return (String)props.get(PROP_PTY_TYPE);
114+ }
115+
116+ public String getEncoding() {
117+ return (String)props.get(PROP_ENCODING);
118+ }
119+
120+ public int getWidth() {
121+ return ((Integer)props.get(PROP_WIDTH)).intValue();
122+ }
123+
124+ public int getHeight() {
125+ return ((Integer)props.get(PROP_HEIGHT)).intValue();
126+ }
127+
128+ public IToken exit(final DoneCommand done) {
129+ return new Command(channel, TerminalsServiceProxy.this,
130+ "exit", new Object[]{ getID() }) {
131+ @Override
132+ public void done(Exception error, Object[] args) {
133+ if (error == null) {
134+ assert args.length == 1;
135+ error = toError(args[0]);
136+ }
137+ done.doneCommand(token, error);
138+ }
139+ }.token;
140+ }
141+
142+ public Map<String, Object> getProperties() {
143+ return props;
144+ }
145+
146+ public String toString() {
147+ return "[Terminals Context " + props.toString() + "]";
148+ }
149+ }
150+
151+ TerminalsServiceProxy(IChannel channel) {
152+ this.channel = channel;
153+ }
154+
155+ /**
156+ * Return service name, as it appears on the wire - a TCF name of the service.
157+ */
158+ public String getName() {
159+ return NAME;
160+ }
161+
162+ public IToken getContext(String id, final DoneGetContext done)
163+ {
164+ return new Command(channel, this,
165+ "getContext", new Object[]{ id }) {
166+ @SuppressWarnings("unchecked")
167+ @Override
168+ public void done(Exception error, Object[] args) {
169+ TerminalContext ctx = null;
170+ if (error == null) {
171+ assert args.length == 2;
172+ error = toError(args[0]);
173+ if (args[1] != null) ctx = new TerminalContext((Map<String, Object>)args[1]);
174+ }
175+ done.doneGetContext(token, error, ctx);
176+ }
177+ }.token;
178+ }
179+
180+ public IToken launch(String type, String encoding, String[] environment, final DoneLaunch done)
181+ {
182+ return new Command(channel, this, "launch",
183+ new Object[]{ type, encoding, environment}) {
184+ @SuppressWarnings("unchecked")
185+ @Override
186+ public void done(Exception error, Object[] args) {
187+ TerminalContext ctx=null;
188+ if (error == null) {
189+ assert args.length == 2;
190+ error = toError(args[0]);
191+ if (args[1] != null) ctx = new TerminalContext((Map<String, Object>)args[1]);
192+ }
193+ done.doneLaunch(token, error, ctx);
194+ }
195+ }.token;
196+ }
197+
198+ public IToken setWinSize(String context_id, int newWidth, int newHeight, final DoneCommand done)
199+ {
200+ return new Command(channel, this, "setWinSize",
201+ new Object[]{ context_id, newWidth, newHeight}) {
202+ @Override
203+ public void done(Exception error, Object[] args) {
204+ if (error == null) {
205+ assert args.length == 1;
206+ error = toError(args[0]);
207+ }
208+ done.doneCommand(token, error);
209+ }
210+ }.token;
211+ }
212+
213+ public void addListener(final TerminalsListener listener)
214+ {
215+ IChannel.IEventListener l = new IChannel.IEventListener() {
216+ public void event(String name, byte[] data) {
217+ try {
218+ Object[] args = JSON.parseSequence(data);
219+ if (name.equals("exited")) {
220+ assert args.length == 2;
221+ listener.exited((String)args[0], ((Number)args[1]).intValue());
222+ }else if(name.equals("winSizeChanged")) {
223+ assert args.length == 3;
224+ listener.winSizeChanged((String)args[0], ((Number)args[1]).intValue(), ((Number)args[2]).intValue());
225+ }else {
226+ throw new IOException("Terminals service: unknown event: " + name);
227+ }
228+ }catch (Throwable x) {
229+ channel.terminate(x);
230+ }
231+ }
232+ };
233+ channel.addEventListener(this, l);
234+ listeners.put(listener, l);
235+ }
236+
237+ public void removeListener(TerminalsListener listener) {
238+ IChannel.IEventListener l = listeners.remove(listener);
239+ if (l != null) channel.removeEventListener(this, l);
240+ }
241+
242+ static {
243+ /*
244+ * Make Terminal Service proxy available to all potential clients by creating
245+ * the proxy object every time a TCF communication channel is opened.
246+ * Note: extension point "org.eclipse.tm.tcf.startup" is used to load this class
247+ * at TCF startup time, so proxy factory is properly activated even if nobody
248+ * import directly from this plugin.
249+ */
250+ Protocol.addChannelOpenListener(new Protocol.ChannelOpenListener() {
251+
252+ public void onChannelOpen(IChannel channel) {
253+ // Check if remote server provides Daytime service
254+ if (channel.getRemoteService(ITerminalsService.NAME) == null) return;
255+ // Create service proxy
256+ channel.setServiceProxy(ITerminalsService.class, new TerminalsServiceProxy(channel));
257+ }
258+ });
259+ }
260+}
261Index: plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/ITerminalsService.java
262===================================================================
263--- plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/ITerminalsService.java (revision 0)
264+++ plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/ITerminalsService.java (revision 0)
265@@ -0,0 +1,193 @@
266+/*******************************************************************************
267+ * Copyright (c) 2010 Intel Corporation. and others.
268+ * All rights reserved. This program and the accompanying materials
269+ * are made available under the terms of the Eclipse Public License v1.0
270+ * which accompanies this distribution, and is available at
271+ * http://www.eclipse.org/legal/epl-v10.html
272+ *
273+ * Contributors:
274+ * Intel - initial API and implementation
275+ *******************************************************************************/
276+
277+package org.eclipse.tm.internal.tcf.terminals;
278+
279+import java.util.Map;
280+
281+import org.eclipse.tm.tcf.protocol.IService;
282+import org.eclipse.tm.tcf.protocol.IToken;
283+
284+/**
285+ * ITerminalsService allows to launch a new terminal on the remote target system.
286+ */
287+public interface ITerminalsService extends IService {
288+
289+ /**
290+ * This service name, as it appears on the wire - a TCF name of the service.
291+ */
292+ static final String NAME = "Terminals";
293+ /**
294+ * Retrieve context info for given context ID.
295+ * A context corresponds to an terminal.
296+ * Context IDs are valid across TCF services, so it is allowed to issue
297+ * 'ITerminals.getContext' command with a context that was obtained,
298+ * for example, from Memory service.
299+ * However, 'ITerminals.getContext' is supposed to return only terminal specific data,
300+ * If the ID is not a terminal ID, 'ITerminals.getContext' may not return any
301+ * useful information
302+ *
303+ * @param id – context ID.
304+ * @param done - call back interface called when operation is completed.
305+ */
306+ IToken getContext(String id, DoneGetContext done);
307+
308+ /**
309+ * Client call back interface for getContext().
310+ */
311+ interface DoneGetContext {
312+ /**
313+ * Called when contexts data retrieval is done.
314+ * @param error – error description if operation failed, null if succeeded.
315+ * @param context – context data.
316+ */
317+ void doneGetContext(IToken token, Exception error, TerminalContext context);
318+ }
319+ /**
320+ * Context property names.
321+ */
322+ static final String
323+ /** The TCF context ID */
324+ PROP_ID = "ID",
325+
326+ /** The pty type */
327+ PROP_PTY_TYPE = "PtyType",
328+
329+ /** terminal encoding */
330+ PROP_ENCODING = "Encoding",
331+
332+ /** window width size */
333+ PROP_WIDTH = "Width",
334+
335+ /** window height size */
336+ PROP_HEIGHT = "Height",
337+
338+ /** Process standard input stream ID */
339+ PROP_STDIN_ID = "StdInID",
340+
341+ /** Process standard output stream ID */
342+ PROP_STDOUT_ID = "StdOutID",
343+
344+ /** Process standard error stream ID */
345+ PROP_STDERR_ID = "StdErrID";
346+
347+ interface TerminalContext {
348+
349+ /**
350+ * Get context ID.
351+ * Same as getProperties().get(“ID”)
352+ */
353+ String getID();
354+
355+ /**
356+ * Get terminal type.
357+ * Same as getProperties().get(“PtyType”)
358+ */
359+ String getPtyType();
360+
361+ /**
362+ * Get encoding.
363+ * Same as getProperties().get(“Encoding”)
364+ */
365+ String getEncoding();
366+
367+ /**
368+ * Get width.
369+ * Same as getProperties().get(“Width”)
370+ */
371+ int getWidth();
372+
373+ /**
374+ * Get height.
375+ * Same as getProperties().get(“Height”)
376+ */
377+ int getHeight();
378+
379+ /**
380+ * Get all available context properties.
381+ * @return Map 'property name' -> 'property value'
382+ */
383+ Map<String, Object> getProperties();
384+
385+ /**
386+ * Exit the terminal.
387+ * @param done - call back interface called when operation is completed.
388+ * @return pending command handle, can be used to cancel the command.
389+ */
390+ IToken exit(DoneCommand done);
391+ }
392+
393+ interface DoneCommand {
394+ void doneCommand(IToken token, Exception error);
395+ }
396+ /**
397+ * Launch a new terminal toremote machine.
398+ * @param type - requested terminal type for the new terminal.
399+ * @param encoding - requested encoding for the new terminal.
400+ * @param environment - Array of environment variable strings.
401+ * if null then default set of environment variables will be used.
402+ * @param done - call back interface called when operation is completed.
403+ * @return pending command handle, can be used to cancel the command.
404+ */
405+ IToken launch(String type, String encoding, String[] environment,
406+ DoneLaunch done);
407+
408+ /**
409+ * Call-back interface to be called when "start" command is complete.
410+ */
411+ interface DoneLaunch {
412+ void doneLaunch(IToken token, Exception error, TerminalContext terminal);
413+ }
414+
415+
416+ /**
417+ * Set the terminal widows size
418+ * @param context_id - context ID.
419+ * @param signal - signal code.
420+ * @param done - call back interface called when operation is completed.
421+ * @return pending command handle, can be used to cancel the command.
422+ */
423+ IToken setWinSize(String context_id, int newWidth, int newHeight, DoneCommand done);
424+
425+ /**
426+ * Add terminals service event listener.
427+ * @param listener - event listener implementation.
428+ */
429+ void addListener(TerminalsListener listener);
430+
431+ /**
432+ * Remove terminals service event listener.
433+ * @param listener - event listener implementation.
434+ */
435+ void removeListener(TerminalsListener listener);
436+
437+ /**
438+ * Process event listener is notified when a terminal exits.
439+ * Event are reported only for terminals that were started by 'launch' command.
440+ */
441+ interface TerminalsListener {
442+
443+ /**
444+ * Called when a terminal exits.
445+ * @param terminal_id - terminal context ID
446+ * @param exit_code - terminal exit code
447+ */
448+ void exited(String terminal_id, int exit_code);
449+
450+ /**
451+ * Called when a terminal exits.
452+ * @param terminal_id - terminal context ID
453+ * @param newWidth – new terminal width
454+ * @param newHeight – new terminal height
455+ */
456+ void winSizeChanged (String terminal_id, int newWidth, int newHeight);
457+ }
458+}
459Index: plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/Activator.java
460===================================================================
461--- plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/Activator.java (revision 0)
462+++ plugins/org.eclipse.tm.tcf.terminals/src/org/eclipse/tm/internal/tcf/terminals/Activator.java (revision 0)
463@@ -0,0 +1,61 @@
464+/*******************************************************************************
465+ * Copyright (c) 2010 Intel Corporation. and others.
466+ * All rights reserved. This program and the accompanying materials
467+ * are made available under the terms of the Eclipse Public License v1.0
468+ * which accompanies this distribution, and is available at
469+ * http://www.eclipse.org/legal/epl-v10.html
470+ *
471+ * Contributors:
472+ * Intel - initial API and implementation
473+ *******************************************************************************/
474+
475+package org.eclipse.tm.internal.tcf.terminals;
476+
477+import org.eclipse.core.runtime.Plugin;
478+import org.osgi.framework.BundleContext;
479+
480+/**
481+ * The activator class controls the plug-in life cycle
482+ */
483+public class Activator extends Plugin {
484+
485+ // The plug-in ID
486+ public static final String PLUGIN_ID = "org.eclipse.tm.tcf.terminals";
487+
488+ // The shared instance
489+ private static Activator plugin;
490+
491+ /**
492+ * The constructor
493+ */
494+ public Activator() {
495+ }
496+
497+ /*
498+ * (non-Javadoc)
499+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
500+ */
501+ public void start(BundleContext context) throws Exception {
502+ super.start(context);
503+ plugin = this;
504+ }
505+
506+ /*
507+ * (non-Javadoc)
508+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
509+ */
510+ public void stop(BundleContext context) throws Exception {
511+ plugin = null;
512+ super.stop(context);
513+ }
514+
515+ /**
516+ * Returns the shared instance
517+ *
518+ * @return the shared instance
519+ */
520+ public static Activator getDefault() {
521+ return plugin;
522+ }
523+
524+}
525Index: plugins/org.eclipse.tm.tcf.terminals/plugin.properties
526===================================================================
527--- plugins/org.eclipse.tm.tcf.terminals/plugin.properties (revision 0)
528+++ plugins/org.eclipse.tm.tcf.terminals/plugin.properties (revision 0)
529@@ -0,0 +1,13 @@
530+###############################################################################
531+# Copyright (c) 2010 Intel, Inc. and others.
532+# All rights reserved. This program and the accompanying materials
533+# are made available under the terms of the Eclipse Public License v1.0
534+# which accompanies this distribution, and is available at
535+# http://www.eclipse.org/legal/epl-v10.html
536+#
537+# Contributors:
538+# Intel - initial implementation
539+###############################################################################
540+pluginName = TCF Terminals service (Incubation)
541+providerName = Eclipse.org
542+
543Index: plugins/org.eclipse.tm.tcf.terminals/build.properties
544===================================================================
545--- plugins/org.eclipse.tm.tcf.terminals/build.properties (revision 0)
546+++ plugins/org.eclipse.tm.tcf.terminals/build.properties (revision 0)
547@@ -0,0 +1,8 @@
548+source.. = src/
549+output.. = bin/
550+bin.includes = META-INF/,\
551+ .,\
552+ plugin.xml,\
553+ about.html,\
554+ plugin.properties
555+src.includes = about.html
556Index: plugins/org.eclipse.tm.tcf.terminals/plugin.xml
557===================================================================
558--- plugins/org.eclipse.tm.tcf.terminals/plugin.xml (revision 0)
559+++ plugins/org.eclipse.tm.tcf.terminals/plugin.xml (revision 0)
560@@ -0,0 +1,11 @@
561+<?xml version="1.0" encoding="UTF-8"?>
562+<?eclipse version="3.4"?>
563+<plugin>
564+ <extension
565+ point="org.eclipse.tm.tcf.startup">
566+ <class
567+ name="org.eclipse.tm.internal.tcf.terminals.TerminalsServiceProxy">
568+ </class>
569+ </extension>
570+
571+</plugin>
572Index: plugins/org.eclipse.tm.tcf.terminals/about.html
573===================================================================
574--- plugins/org.eclipse.tm.tcf.terminals/about.html (revision 0)
575+++ plugins/org.eclipse.tm.tcf.terminals/about.html (revision 0)
576@@ -0,0 +1,28 @@
577+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
578+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
579+<html xmlns="http://www.w3.org/1999/xhtml">
580+<head>
581+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
582+<title>About</title>
583+</head>
584+<body lang="EN-US">
585+<h2>About This Content</h2>
586+
587+<p>January 10, 2008</p>
588+<h3>License</h3>
589+
590+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
591+indicated below, the Content is provided to you under the terms and conditions of the
592+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
593+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
594+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
595+
596+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
597+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
598+apply to your use of any object code in the Content. Check the Redistributor's license that was
599+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
600+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
601+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
602+
603+</body>
604+</html>
605\ No newline at end of file
606Index: plugins/org.eclipse.tm.tcf.terminals/.settings/org.eclipse.jdt.core.prefs
607===================================================================
608--- plugins/org.eclipse.tm.tcf.terminals/.settings/org.eclipse.jdt.core.prefs (revision 0)
609+++ plugins/org.eclipse.tm.tcf.terminals/.settings/org.eclipse.jdt.core.prefs (revision 0)
610@@ -0,0 +1,8 @@
611+#Mon Jun 07 11:42:38 CST 2010
612+eclipse.preferences.version=1
613+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
614+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
615+org.eclipse.jdt.core.compiler.compliance=1.6
616+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
617+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
618+org.eclipse.jdt.core.compiler.source=1.6