michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIFile; michael@0: interface nsIObserver; michael@0: michael@0: [scriptable, uuid(609610de-9954-4a63-8a7c-346350a86403)] michael@0: interface nsIProcess : nsISupports michael@0: { michael@0: /** michael@0: * Initialises the process with an executable to be run. Call the run method michael@0: * to run the executable. michael@0: * @param executable The executable to run. michael@0: */ michael@0: void init(in nsIFile executable); michael@0: michael@0: /** michael@0: * Kills the running process. After exiting the process will either have michael@0: * been killed or a failure will have been returned. michael@0: */ michael@0: void kill(); michael@0: michael@0: /** michael@0: * Executes the file this object was initialized with michael@0: * @param blocking Whether to wait until the process terminates before michael@0: returning or not. michael@0: * @param args An array of arguments to pass to the process in the michael@0: * native character set. michael@0: * @param count The length of the args array. michael@0: */ michael@0: void run(in boolean blocking, [array, size_is(count)] in string args, michael@0: in unsigned long count); michael@0: michael@0: /** michael@0: * Executes the file this object was initialized with optionally calling michael@0: * an observer after the process has finished running. michael@0: * @param args An array of arguments to pass to the process in the michael@0: * native character set. michael@0: * @param count The length of the args array. michael@0: * @param observer An observer to notify when the process has completed. It michael@0: * will receive this process instance as the subject and michael@0: * "process-finished" or "process-failed" as the topic. The michael@0: * observer will be notified on the main thread. michael@0: * @param holdWeak Whether to use a weak reference to hold the observer. michael@0: */ michael@0: void runAsync([array, size_is(count)] in string args, in unsigned long count, michael@0: [optional] in nsIObserver observer, [optional] in boolean holdWeak); michael@0: michael@0: /** michael@0: * Executes the file this object was initialized with michael@0: * @param blocking Whether to wait until the process terminates before michael@0: returning or not. michael@0: * @param args An array of arguments to pass to the process in UTF-16 michael@0: * @param count The length of the args array. michael@0: */ michael@0: void runw(in boolean blocking, [array, size_is(count)] in wstring args, michael@0: in unsigned long count); michael@0: michael@0: /** michael@0: * Executes the file this object was initialized with optionally calling michael@0: * an observer after the process has finished running. michael@0: * @param args An array of arguments to pass to the process in UTF-16 michael@0: * @param count The length of the args array. michael@0: * @param observer An observer to notify when the process has completed. It michael@0: * will receive this process instance as the subject and michael@0: * "process-finished" or "process-failed" as the topic. The michael@0: * observer will be notified on the main thread. michael@0: * @param holdWeak Whether to use a weak reference to hold the observer. michael@0: */ michael@0: void runwAsync([array, size_is(count)] in wstring args, michael@0: in unsigned long count, michael@0: [optional] in nsIObserver observer, [optional] in boolean holdWeak); michael@0: michael@0: /** michael@0: * The process identifier of the currently running process. This will only michael@0: * be available after the process has started and may not be available on michael@0: * some platforms. michael@0: */ michael@0: readonly attribute unsigned long pid; michael@0: michael@0: /** michael@0: * The exit value of the process. This is only valid after the process has michael@0: * exited. michael@0: */ michael@0: readonly attribute long exitValue; michael@0: michael@0: /** michael@0: * Returns whether the process is currently running or not. michael@0: */ michael@0: readonly attribute boolean isRunning; michael@0: }; michael@0: michael@0: %{C++ michael@0: michael@0: #define NS_PROCESS_CONTRACTID "@mozilla.org/process/util;1" michael@0: %}