19
21
* Patrick Brunschwig <patrick@mozilla-enigmail.org>
21
* Alternatively, the contents of this file may be used under the
22
* terms of the GNU General Public License (the "GPL"), in which case
23
* the provisions of the GPL are applicable instead of
24
* those above. If you wish to allow use of your version of this
25
* file only under the terms of the GPL and not to allow
26
* others to use your version of this file under the MPL, indicate
27
* your decision by deleting the provisions above and replace them
28
* with the notice and other provisions required by the GPL.
29
* If you do not delete the provisions above, a recipient
30
* may use your version of this file under either the MPL or the
34
#include "nsISupports.idl"
35
#include "nsIPipe.idl"
36
#include "nsIFile.idl"
37
#include "nsIRequest.idl"
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
34
* ***** END LICENSE BLOCK ***** */
38
37
#include "nsIPipeListener.idl"
38
#include "nsIProcess.idl"
40
40
interface nsIRequest;
44
44
interface nsIStreamListener;
45
45
interface nsIPipeTransportHeaders;
46
46
interface nsIPipeTransportListener;
50
51
#include "IPCProcess.h"
52
53
#define NS_PIPETRANSPORT_CLASSNAME "Pipe Transport"
53
#define NS_PIPETRANSPORT_CONTRACTID "@mozilla.org/process/pipe-transport;1"
54
#define NS_PIPETRANSPORT_CONTRACTID "@mozilla.org/ipc/pipe-transport;1"
55
56
#define NS_PIPETRANSPORT_CID \
56
{ /* 8431e101-7ab1-11d4-8f02-006008948af5 */ \
57
{ /* 8431e101-7ab1-11d4-8f02-a06008948af5 */ \
57
58
0x8431e101, 0x7ab1, 0x11d4, \
58
{0x8f, 0x02, 0x00, 0x60, 0x08, 0x94, 0x8a, 0xf5} }
59
{0x8f, 0x02, 0xa0, 0x60, 0x08, 0x94, 0x8a, 0xf5} }
88
89
* that the listener/owner is already aware of the shutdown.)
91
[scriptable, uuid(8431e100-7ab1-11d4-8f02-006008948af5)]
92
interface nsIPipeTransport : nsIRequest
92
[scriptable, uuid(8431e100-7ab1-11d4-8f02-a06008948af5)]
93
interface nsIPipeTransport : nsIProcess
95
* Old, oboslete version of init, kept for compatibility reasons
96
* For parameters please refer to init above and open
98
void init(in nsIFile executable,
99
[array, size_is(argCount)] in string args,
100
in unsigned long argCount,
101
[array, size_is(envCount)] in string env,
102
in unsigned long envCount,
103
in unsigned long timeoutMS,
104
in string killString,
106
in boolean mergeStderr,
107
in nsIPipeListener console);
110
97
* Initializes PipeTransport by executing the specified file using the
118
105
* @param startupFlags flags defining how the process should be created
121
void initialize(in nsIFile executable,
123
in unsigned long startupFlags);
108
void initWithWorkDir(in nsIFile executable,
110
in unsigned long startupFlags);
126
113
* Opens a PipeTransport by executing the specified file using the
129
116
* full-featured channel, which will also act as an async stream
130
117
* observer/listener and forward calls to the actual observer/listener.
132
* @param args arguments string array
133
* (excluding the executable path itself)
134
* @param env environment (variable=value) string array
135
* @param timeoutMS timeout (in milliseconds) after which the process
136
* at the other end of the pipe can be assumed to be
138
* (if == 0, a default value, usually an hour, is used)
139
* @param killString string to be transmitted to process before it is
140
* killed (specify null string, if none)
141
* @param noProxy do not use proxy for async callback
142
* (must use join to terminate process, in this case)
143
* @param mergeStderr merge STDERR with STDOUT
144
* @param console nsIPipeListener object to capture STDERR
119
* @param args arguments string array
120
* (excluding the executable path itself)
121
* @param env environment (variable=value) string array
122
* @param timeoutMS timeout (in milliseconds) after which the process
123
* at the other end of the pipe can be assumed to be
125
* (if == 0, a default value, usually an hour, is used)
126
* @param killString string to be transmitted to process before it is
127
* killed (specify null string, if none)
128
* @param noProxy do not use proxy for async callback
129
* (must use join to terminate process, in this case)
130
* @param mergeStderr merge STDERR with STDOUT
131
* @param stderrConsole nsIPipeListener object to capture STDERR (required
132
* if mergeStderr is false)
146
void open([array, size_is(argCount)] in string args,
147
in unsigned long argCount,
148
[array, size_is(envCount)] in string env,
149
in unsigned long envCount,
150
in unsigned long timeoutMS,
151
in string killString,
153
in boolean mergeStderr,
154
in nsIPipeListener console);
134
void openPipe([array, size_is(argCount)] in wstring args,
135
in unsigned long argCount,
136
[array, size_is(envCount)] in wstring env,
137
in unsigned long envCount,
138
in unsigned long timeoutMS,
139
in string killString,
141
in boolean mergeStderr,
142
in nsIPipeListener stderrConsole);
157
145
* detach process after start
233
* Terminates process, if active.
217
* Terminates process, if active, by closing stdin/stdout/stderr.
235
219
void terminate();
238
* Returns exit code of process which has exited;
239
* fails with an exception if process is still attached.
244
222
* Writes string to process STDIN (synchronously)
245
223
* (Note: child process may exit for valid reasons even before
246
224
* the first call to writeSync, causing an an exception to be
262
240
in boolean closeAfterWrite);
265
* Transmits command string to process, blocks for output and returns the
266
* STDOUT response as a string up to maxChars (=-1 for unlimited) long,
267
* delimited by an optional prompt.
268
* If prompt begins with newline, that newline character is returned,
269
* but the rest of the prompt string is not returned.
270
* If clear is true, any prior data in STDOUT is cleared.
273
string execPrompt(in string command, in string prompt,
274
in long maxOutputLen, in boolean clearPrev);
278
243
* Blocks for output and returns the first line from STDOUT
279
244
* as a string, up to maxChars (=-1 for unlimited) long.
280
245
* NOTE: This method is intended for short output; for longer
321
[noscript, uuid(8431e130-7ab1-11d4-8f02-006008948af5)]
322
interface nsIPipeTransportPoller : nsISupports
325
* Starts polling of STDOUT
327
void asyncStart(in nsIOutputStream aOutputStream,
328
in nsIPipeTransportListener aProxyPipeObserver,
330
in unsigned long aMimeHeadersMaxSize);
333
* Interrupts polling thread.
338
* Returns true if polling thread has been interrupted/
340
boolean isInterrupted();
343
* Joins polling thread, if joinable (blocking until it terminates)
348
* Controls console logging of STDOUT from process
350
attribute boolean loggingEnabled;
354
[noscript, uuid(8431e190-7ab1-11d4-8f02-006008948af5)]
355
interface nsIPipeTransportWriter : nsISupports
358
* writes count bytes from input stream to STDIN pipe (asynchronously) and
359
* then closes the STDIN pipe
361
void writeFromStream(in nsIInputStream aFromStream,
362
in unsigned long aCount,
363
in IPCFileDescStar pipe,
364
in boolean closeAfterWrite);
367
* Joins writer thread, if joinable (blocking until it terminates)
373
294
///////////////////////////////////////////////////////////////////////////////