Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ccda16c57972e90d4fe539180b654a0d18710b2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*******************************************************************************
 * Copyright (c) 2010 Intel 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:
 *     Intel - initial API and implementation
 *******************************************************************************/

package org.eclipse.tm.tcf.services;

import java.util.Map;

import org.eclipse.tm.tcf.protocol.IService;
import org.eclipse.tm.tcf.protocol.IToken;

/**
 * ITerminalsService allows to launch a new terminal on the remote target system.
 */
public interface ITerminals extends IService {

    /**
     * This service name, as it appears on the wire - a TCF name of the service.
     */
    static final String NAME = "Terminals";

    /**
     * Retrieve context info for given context ID.
     * A context corresponds to an terminal.
     * Context IDs are valid across TCF services, so it is allowed to issue
     * 'ITerminals.getContext' command with a context that was obtained,
     * for example, from Memory service.
     * However, 'ITerminals.getContext' is supposed to return only terminal specific data,
     * If the ID is not a terminal ID, 'ITerminals.getContext' may not return any
     * useful information
     *
     * @param id – context ID.
     * @param done - call back interface called when operation is completed.
     */
    IToken getContext(String id, DoneGetContext done);

    /**
     * Client call back interface for getContext().
     */
    interface DoneGetContext {
        /**
         * Called when contexts data retrieval is done.
         * @param error – error description if operation failed, null if succeeded.
         * @param context – context data.
         */
        void doneGetContext(IToken token, Exception error, TerminalContext context);
    }

    /**
     * Context property names.
     */
    static final String
        /** The TCF context ID of the terminal */
        PROP_ID = "ID",

        /** The process ID of the login process of the terminal */
        PROP_PROCESS_ID = "ProcessID",

        /** The PTY type */
        PROP_PTY_TYPE = "PtyType",

        /** The terminal streams encoding */
        PROP_ENCODING = "Encoding",

        /** Window width size */
        PROP_WIDTH = "Width",

        /** Window height size */
        PROP_HEIGHT = "Height",

        /** Terminal standard input stream ID */
        PROP_STDIN_ID = "StdInID",

        /** Terminal standard output stream ID */
        PROP_STDOUT_ID = "StdOutID",

        /** Terminal standard error stream ID */
        PROP_STDERR_ID = "StdErrID";

    interface TerminalContext {

        /**
         * Get context ID.
         * Same as getProperties().get(“ID”)
         */
        String getID();

        /**
         * Get process ID of the login process of the terminal.
         * Same as getProperties().get(“ProcessID”)
         */
        String getProcessID();

        /**
         * Get terminal type.
         * Same as getProperties().get(“PtyType”)
         */
        String getPtyType();

        /**
         * Get encoding.
         * Same as getProperties().get(“Encoding”)
         */
        String getEncoding();

        /**
         * Get width.
         * Same as getProperties().get(“Width”)
         */
        int getWidth();

        /**
         * Get height.
         * Same as getProperties().get(“Height”)
         */
        int getHeight();

        /**
         * Get standard input stream ID of the terminal.
         * Same as getProperties().get(“StdInID”)
         */
        String getStdInID();

        /**
         * Get standard output stream ID of the terminal.
         * Same as getProperties().get(“StdOutID”)
         */
        String getStdOutID();

        /**
         * Get standard error stream ID of the terminal.
         * Same as getProperties().get(“StdErrID”)
         */
        String getStdErrID();

        /**
         * Get all available terminal properties.
         * @return Map 'property name' -> 'property value'
         */
        Map<String, Object> getProperties();

        /**
         * Exit the terminal.
         * @param done - call back interface called when operation is completed.
         * @return pending command handle, can be used to cancel the command.
         */
        IToken exit(DoneCommand done);
    }

    interface DoneCommand {
        void doneCommand(IToken token, Exception error);
    }

    /**
     * Launch a new terminal to remote machine.
     * @param type - requested terminal type for the new terminal.
     * @param encoding - requested encoding for the new terminal.
     * @param environment - Array of environment variable strings.
     * if null then default set of environment variables will be used.
     * @param done - call back interface called when operation is completed.
     * @return pending command handle, can be used to cancel the command.
     */
    IToken launch(String type, String encoding, String[] environment, DoneLaunch done);

    /**
     * Call-back interface to be called when "start" command is complete.
     */
    interface DoneLaunch {
        void doneLaunch(IToken token, Exception error, TerminalContext terminal);
    }


    /**
     * Set the terminal widows size
     * @param context_id - context ID.
     * @param signal - signal code.
     * @param done - call back interface called when operation is completed.
     * @return pending command handle, can be used to cancel the command.
     */
    IToken setWinSize(String context_id, int newWidth, int newHeight, DoneCommand done);

    /**
     * Exit a terminal.
     * @param context_id - context ID.
     * @param done - call back interface called when operation is completed.
     * @return pending command handle, can be used to cancel the command.
     */
    IToken exit(String context_id, DoneCommand done);

    /**
     * Add terminals service event listener.
     * @param listener - event listener implementation.
     */
    void addListener(TerminalsListener listener);

    /**
     * Remove terminals service event listener.
     * @param listener - event listener implementation.
     */
    void removeListener(TerminalsListener listener);

    /**
     * Process event listener is notified when a terminal exits.
     * Event are reported only for terminals that were started by 'launch' command.
     */
    interface TerminalsListener {

        /**
         * Called when a terminal exits.
         * @param terminal_id - terminal context ID
         * @param exit_code - terminal exit code
         */
        void exited(String terminal_id, int exit_code);

        /**
         * Called when a terminal exits.
         * @param terminal_id - terminal context ID
         * @param newWidth – new terminal width
         * @param newHeight – new terminal height
         */
        void winSizeChanged (String terminal_id, int newWidth, int newHeight);
    }
}

Back to the top