toolkit/components/commandlines/nsICommandLine.idl

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "nsISupports.idl"
michael@0 6
michael@0 7 interface nsIFile;
michael@0 8 interface nsIURI;
michael@0 9 interface nsIDOMWindow;
michael@0 10
michael@0 11 /**
michael@0 12 * Represents the command line used to invoke a XUL application. This may be the
michael@0 13 * original command-line of this instance, or a command line remoted from another
michael@0 14 * instance of the application.
michael@0 15 *
michael@0 16 * DEFINITIONS:
michael@0 17 * "arguments" are any values found on the command line.
michael@0 18 * "flags" are switches. In normalized form they are preceded by a single dash.
michael@0 19 * Some flags may take "parameters", e.g. "-url <param>" or "-install-xpi <param>"
michael@0 20 */
michael@0 21
michael@0 22 [scriptable, uuid(bc3173bd-aa46-46a0-9d25-d9867a9659b6)]
michael@0 23 interface nsICommandLine : nsISupports
michael@0 24 {
michael@0 25 /**
michael@0 26 * Number of arguments in the command line. The application name is not
michael@0 27 * part of the command line.
michael@0 28 */
michael@0 29 readonly attribute long length;
michael@0 30
michael@0 31 /**
michael@0 32 * Get an argument from the array of command-line arguments.
michael@0 33 *
michael@0 34 * On windows, flags of the form /flag are normalized to -flag. /flag:param
michael@0 35 * are normalized to -flag param.
michael@0 36 *
michael@0 37 * On *nix and mac flags of the form --flag are normalized to -flag. --flag=param
michael@0 38 * are normalized to the form -flag param.
michael@0 39 *
michael@0 40 * @param aIndex The argument to retrieve. This index is 0-based, and does
michael@0 41 * not include the application name.
michael@0 42 * @return The indexth argument.
michael@0 43 * @throws NS_ERROR_INVALID_ARG if aIndex is out of bounds.
michael@0 44 */
michael@0 45 AString getArgument(in long aIndex);
michael@0 46
michael@0 47 /**
michael@0 48 * Find a command-line flag.
michael@0 49 *
michael@0 50 * @param aFlag The flag name to locate. Do not include the initial
michael@0 51 * hyphen.
michael@0 52 * @param aCaseSensitive Whether to do case-sensitive comparisons.
michael@0 53 * @return The position of the flag in the command line.
michael@0 54 */
michael@0 55 long findFlag(in AString aFlag, in boolean aCaseSensitive);
michael@0 56
michael@0 57 /**
michael@0 58 * Remove arguments from the command line. This normally occurs after
michael@0 59 * a handler has processed the arguments.
michael@0 60 *
michael@0 61 * @param aStart Index to begin removing.
michael@0 62 * @param aEnd Index to end removing, inclusive.
michael@0 63 */
michael@0 64 void removeArguments(in long aStart, in long aEnd);
michael@0 65
michael@0 66 /**
michael@0 67 * A helper method which will find a flag and remove it in one step.
michael@0 68 *
michael@0 69 * @param aFlag The flag name to find and remove.
michael@0 70 * @param aCaseSensitive Whether to do case-sensitive comparisons.
michael@0 71 * @return Whether the flag was found.
michael@0 72 */
michael@0 73 boolean handleFlag(in AString aFlag, in boolean aCaseSensitive);
michael@0 74
michael@0 75 /**
michael@0 76 * Find a flag with a parameter and remove both. This is a helper
michael@0 77 * method that combines "findFlag" and "removeArguments" in one step.
michael@0 78 *
michael@0 79 * @return null (a void astring) if the flag is not found. The parameter value
michael@0 80 * if found. Note that null and the empty string are not the same.
michael@0 81 * @throws NS_ERROR_INVALID_ARG if the flag exists without a parameter
michael@0 82 *
michael@0 83 * @param aFlag The flag name to find and remove.
michael@0 84 * @param aCaseSensitive Whether to do case-sensitive flag search.
michael@0 85 */
michael@0 86 AString handleFlagWithParam(in AString aFlag, in boolean aCaseSensitive);
michael@0 87
michael@0 88 /**
michael@0 89 * The type of command line being processed.
michael@0 90 *
michael@0 91 * STATE_INITIAL_LAUNCH is the first launch of the application instance.
michael@0 92 * STATE_REMOTE_AUTO is a remote command line automatically redirected to
michael@0 93 * this instance.
michael@0 94 * STATE_REMOTE_EXPLICIT is a remote command line explicitly redirected to
michael@0 95 * this instance using xremote/windde/appleevents.
michael@0 96 */
michael@0 97 readonly attribute unsigned long state;
michael@0 98
michael@0 99 const unsigned long STATE_INITIAL_LAUNCH = 0;
michael@0 100 const unsigned long STATE_REMOTE_AUTO = 1;
michael@0 101 const unsigned long STATE_REMOTE_EXPLICIT = 2;
michael@0 102
michael@0 103 /**
michael@0 104 * There may be a command-line handler which performs a default action if
michael@0 105 * there was no explicit action on the command line (open a default browser
michael@0 106 * window, for example). This flag allows the default action to be prevented.
michael@0 107 */
michael@0 108 attribute boolean preventDefault;
michael@0 109
michael@0 110 /**
michael@0 111 * The working directory for this command line. Use this property instead
michael@0 112 * of the working directory for the current process, since a redirected
michael@0 113 * command line may have had a different working directory.
michael@0 114 */
michael@0 115 readonly attribute nsIFile workingDirectory;
michael@0 116
michael@0 117 /**
michael@0 118 * A window to be targeted by this command line. In most cases, this will
michael@0 119 * be null (xremote will sometimes set this attribute).
michael@0 120 */
michael@0 121 readonly attribute nsIDOMWindow windowContext;
michael@0 122
michael@0 123 /**
michael@0 124 * Resolve a file-path argument into an nsIFile. This method gracefully
michael@0 125 * handles relative or absolute file paths, according to the working
michael@0 126 * directory of this command line.
michael@0 127 *
michael@0 128 * @param aArgument The command-line argument to resolve.
michael@0 129 */
michael@0 130 nsIFile resolveFile(in AString aArgument);
michael@0 131
michael@0 132 /**
michael@0 133 * Resolves a URI argument into a URI. This method has platform-specific
michael@0 134 * logic for converting an absolute URI or a relative file-path into the
michael@0 135 * appropriate URI object; it gracefully handles win32 C:\ paths which would
michael@0 136 * confuse the ioservice if passed directly.
michael@0 137 *
michael@0 138 * @param aArgument The command-line argument to resolve.
michael@0 139 */
michael@0 140 nsIURI resolveURI(in AString aArgument);
michael@0 141 };

mercurial