michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: #include "nsIObserver.idl" michael@0: #include "nsICommandParams.idl" michael@0: michael@0: interface nsIDOMWindow; michael@0: michael@0: /* michael@0: * nsICommandManager is an interface used to executing user-level commands, michael@0: * and getting the state of available commands. michael@0: * michael@0: * Commands are identified by strings, which are documented elsewhere. michael@0: * In addition, the list of required and optional parameters for michael@0: * each command, that are passed in via the nsICommandParams, are michael@0: * also documented elsewhere. (Where? Need a good location for this). michael@0: */ michael@0: michael@0: michael@0: [scriptable, uuid(080D2001-F91E-11D4-A73C-F9242928207C)] michael@0: interface nsICommandManager : nsISupports michael@0: { michael@0: /* michael@0: * Register an observer on the specified command. The observer's Observe michael@0: * method will get called when the state (enabled/disbaled, or toggled etc) michael@0: * of the command changes. michael@0: * michael@0: * You can register the same observer on multiple commmands by calling this michael@0: * multiple times. michael@0: */ michael@0: void addCommandObserver(in nsIObserver aCommandObserver, michael@0: in string aCommandToObserve); michael@0: michael@0: /* michael@0: * Stop an observer from observering the specified command. If the observer michael@0: * was also registered on ther commands, they will continue to be observed. michael@0: * michael@0: * Passing an empty string in 'aCommandObserved' will remove the observer michael@0: * from all commands. michael@0: */ michael@0: void removeCommandObserver(in nsIObserver aCommandObserver, michael@0: in string aCommandObserved); michael@0: michael@0: /* michael@0: * Ask the command manager if the specified command is supported. michael@0: * If aTargetWindow is null, the focused window is used. michael@0: * michael@0: */ michael@0: boolean isCommandSupported(in string aCommandName, michael@0: in nsIDOMWindow aTargetWindow); michael@0: michael@0: /* michael@0: * Ask the command manager if the specified command is currently. michael@0: * enabled. michael@0: * If aTargetWindow is null, the focused window is used. michael@0: */ michael@0: boolean isCommandEnabled(in string aCommandName, michael@0: in nsIDOMWindow aTargetWindow); michael@0: michael@0: /* michael@0: * Get the state of the specified commands. michael@0: * michael@0: * On input: aCommandParams filled in with values that the caller cares michael@0: * about, most of which are command-specific (see the command documentation michael@0: * for details). One boolean value, "enabled", applies to all commands, michael@0: * and, in return will be set to indicate whether the command is enabled michael@0: * (equivalent to calling isCommandEnabled). michael@0: * michael@0: * aCommandName is the name of the command that needs the state michael@0: * aTargetWindow is the source of command controller michael@0: * (null means use focus controller) michael@0: * On output: aCommandParams: values set by the caller filled in with michael@0: * state from the command. michael@0: */ michael@0: void getCommandState(in string aCommandName, michael@0: in nsIDOMWindow aTargetWindow, michael@0: /* inout */ in nsICommandParams aCommandParams); michael@0: michael@0: /* michael@0: * Execute the specified command. michael@0: * The command will be executed in aTargetWindow if it is specified. michael@0: * If aTargetWindow is null, it will go to the focused window. michael@0: * michael@0: * param: aCommandParams, a list of name-value pairs of command parameters, michael@0: * may be null for parameter-less commands. michael@0: * michael@0: */ michael@0: void doCommand(in string aCommandName, michael@0: in nsICommandParams aCommandParams, michael@0: in nsIDOMWindow aTargetWindow); michael@0: michael@0: }; michael@0: michael@0: michael@0: /* michael@0: michael@0: Arguments to observers "Observe" method are as follows: michael@0: michael@0: void Observe( in nsISupports aSubject, // The nsICommandManager calling this Observer michael@0: in string aTopic, // Name of the command michael@0: in wstring aDummy ); // unused michael@0: michael@0: */ michael@0: michael@0: // {64edb481-0c04-11d5-a73c-e964b968b0bc} michael@0: %{C++ michael@0: #define NS_COMMAND_MANAGER_CID \ michael@0: { 0x64edb481, 0x0c04, 0x11d5, { 0xa7, 0x3c, 0xe9, 0x64, 0xb9, 0x68, 0xb0, 0xbc } } michael@0: michael@0: #define NS_COMMAND_MANAGER_CONTRACTID \ michael@0: "@mozilla.org/embedcomp/command-manager;1" michael@0: %} michael@0: michael@0: michael@0: