Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | #include "nsIObserver.idl" |
michael@0 | 8 | #include "nsICommandParams.idl" |
michael@0 | 9 | |
michael@0 | 10 | interface nsIDOMWindow; |
michael@0 | 11 | |
michael@0 | 12 | /* |
michael@0 | 13 | * nsICommandManager is an interface used to executing user-level commands, |
michael@0 | 14 | * and getting the state of available commands. |
michael@0 | 15 | * |
michael@0 | 16 | * Commands are identified by strings, which are documented elsewhere. |
michael@0 | 17 | * In addition, the list of required and optional parameters for |
michael@0 | 18 | * each command, that are passed in via the nsICommandParams, are |
michael@0 | 19 | * also documented elsewhere. (Where? Need a good location for this). |
michael@0 | 20 | */ |
michael@0 | 21 | |
michael@0 | 22 | |
michael@0 | 23 | [scriptable, uuid(080D2001-F91E-11D4-A73C-F9242928207C)] |
michael@0 | 24 | interface nsICommandManager : nsISupports |
michael@0 | 25 | { |
michael@0 | 26 | /* |
michael@0 | 27 | * Register an observer on the specified command. The observer's Observe |
michael@0 | 28 | * method will get called when the state (enabled/disbaled, or toggled etc) |
michael@0 | 29 | * of the command changes. |
michael@0 | 30 | * |
michael@0 | 31 | * You can register the same observer on multiple commmands by calling this |
michael@0 | 32 | * multiple times. |
michael@0 | 33 | */ |
michael@0 | 34 | void addCommandObserver(in nsIObserver aCommandObserver, |
michael@0 | 35 | in string aCommandToObserve); |
michael@0 | 36 | |
michael@0 | 37 | /* |
michael@0 | 38 | * Stop an observer from observering the specified command. If the observer |
michael@0 | 39 | * was also registered on ther commands, they will continue to be observed. |
michael@0 | 40 | * |
michael@0 | 41 | * Passing an empty string in 'aCommandObserved' will remove the observer |
michael@0 | 42 | * from all commands. |
michael@0 | 43 | */ |
michael@0 | 44 | void removeCommandObserver(in nsIObserver aCommandObserver, |
michael@0 | 45 | in string aCommandObserved); |
michael@0 | 46 | |
michael@0 | 47 | /* |
michael@0 | 48 | * Ask the command manager if the specified command is supported. |
michael@0 | 49 | * If aTargetWindow is null, the focused window is used. |
michael@0 | 50 | * |
michael@0 | 51 | */ |
michael@0 | 52 | boolean isCommandSupported(in string aCommandName, |
michael@0 | 53 | in nsIDOMWindow aTargetWindow); |
michael@0 | 54 | |
michael@0 | 55 | /* |
michael@0 | 56 | * Ask the command manager if the specified command is currently. |
michael@0 | 57 | * enabled. |
michael@0 | 58 | * If aTargetWindow is null, the focused window is used. |
michael@0 | 59 | */ |
michael@0 | 60 | boolean isCommandEnabled(in string aCommandName, |
michael@0 | 61 | in nsIDOMWindow aTargetWindow); |
michael@0 | 62 | |
michael@0 | 63 | /* |
michael@0 | 64 | * Get the state of the specified commands. |
michael@0 | 65 | * |
michael@0 | 66 | * On input: aCommandParams filled in with values that the caller cares |
michael@0 | 67 | * about, most of which are command-specific (see the command documentation |
michael@0 | 68 | * for details). One boolean value, "enabled", applies to all commands, |
michael@0 | 69 | * and, in return will be set to indicate whether the command is enabled |
michael@0 | 70 | * (equivalent to calling isCommandEnabled). |
michael@0 | 71 | * |
michael@0 | 72 | * aCommandName is the name of the command that needs the state |
michael@0 | 73 | * aTargetWindow is the source of command controller |
michael@0 | 74 | * (null means use focus controller) |
michael@0 | 75 | * On output: aCommandParams: values set by the caller filled in with |
michael@0 | 76 | * state from the command. |
michael@0 | 77 | */ |
michael@0 | 78 | void getCommandState(in string aCommandName, |
michael@0 | 79 | in nsIDOMWindow aTargetWindow, |
michael@0 | 80 | /* inout */ in nsICommandParams aCommandParams); |
michael@0 | 81 | |
michael@0 | 82 | /* |
michael@0 | 83 | * Execute the specified command. |
michael@0 | 84 | * The command will be executed in aTargetWindow if it is specified. |
michael@0 | 85 | * If aTargetWindow is null, it will go to the focused window. |
michael@0 | 86 | * |
michael@0 | 87 | * param: aCommandParams, a list of name-value pairs of command parameters, |
michael@0 | 88 | * may be null for parameter-less commands. |
michael@0 | 89 | * |
michael@0 | 90 | */ |
michael@0 | 91 | void doCommand(in string aCommandName, |
michael@0 | 92 | in nsICommandParams aCommandParams, |
michael@0 | 93 | in nsIDOMWindow aTargetWindow); |
michael@0 | 94 | |
michael@0 | 95 | }; |
michael@0 | 96 | |
michael@0 | 97 | |
michael@0 | 98 | /* |
michael@0 | 99 | |
michael@0 | 100 | Arguments to observers "Observe" method are as follows: |
michael@0 | 101 | |
michael@0 | 102 | void Observe( in nsISupports aSubject, // The nsICommandManager calling this Observer |
michael@0 | 103 | in string aTopic, // Name of the command |
michael@0 | 104 | in wstring aDummy ); // unused |
michael@0 | 105 | |
michael@0 | 106 | */ |
michael@0 | 107 | |
michael@0 | 108 | // {64edb481-0c04-11d5-a73c-e964b968b0bc} |
michael@0 | 109 | %{C++ |
michael@0 | 110 | #define NS_COMMAND_MANAGER_CID \ |
michael@0 | 111 | { 0x64edb481, 0x0c04, 0x11d5, { 0xa7, 0x3c, 0xe9, 0x64, 0xb9, 0x68, 0xb0, 0xbc } } |
michael@0 | 112 | |
michael@0 | 113 | #define NS_COMMAND_MANAGER_CONTRACTID \ |
michael@0 | 114 | "@mozilla.org/embedcomp/command-manager;1" |
michael@0 | 115 | %} |
michael@0 | 116 | |
michael@0 | 117 | |
michael@0 | 118 |