1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/embedding/components/commandhandler/public/nsICommandManager.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 +#include "nsIObserver.idl" 1.11 +#include "nsICommandParams.idl" 1.12 + 1.13 +interface nsIDOMWindow; 1.14 + 1.15 +/* 1.16 + * nsICommandManager is an interface used to executing user-level commands, 1.17 + * and getting the state of available commands. 1.18 + * 1.19 + * Commands are identified by strings, which are documented elsewhere. 1.20 + * In addition, the list of required and optional parameters for 1.21 + * each command, that are passed in via the nsICommandParams, are 1.22 + * also documented elsewhere. (Where? Need a good location for this). 1.23 + */ 1.24 + 1.25 + 1.26 +[scriptable, uuid(080D2001-F91E-11D4-A73C-F9242928207C)] 1.27 +interface nsICommandManager : nsISupports 1.28 +{ 1.29 + /* 1.30 + * Register an observer on the specified command. The observer's Observe 1.31 + * method will get called when the state (enabled/disbaled, or toggled etc) 1.32 + * of the command changes. 1.33 + * 1.34 + * You can register the same observer on multiple commmands by calling this 1.35 + * multiple times. 1.36 + */ 1.37 + void addCommandObserver(in nsIObserver aCommandObserver, 1.38 + in string aCommandToObserve); 1.39 + 1.40 + /* 1.41 + * Stop an observer from observering the specified command. If the observer 1.42 + * was also registered on ther commands, they will continue to be observed. 1.43 + * 1.44 + * Passing an empty string in 'aCommandObserved' will remove the observer 1.45 + * from all commands. 1.46 + */ 1.47 + void removeCommandObserver(in nsIObserver aCommandObserver, 1.48 + in string aCommandObserved); 1.49 + 1.50 + /* 1.51 + * Ask the command manager if the specified command is supported. 1.52 + * If aTargetWindow is null, the focused window is used. 1.53 + * 1.54 + */ 1.55 + boolean isCommandSupported(in string aCommandName, 1.56 + in nsIDOMWindow aTargetWindow); 1.57 + 1.58 + /* 1.59 + * Ask the command manager if the specified command is currently. 1.60 + * enabled. 1.61 + * If aTargetWindow is null, the focused window is used. 1.62 + */ 1.63 + boolean isCommandEnabled(in string aCommandName, 1.64 + in nsIDOMWindow aTargetWindow); 1.65 + 1.66 + /* 1.67 + * Get the state of the specified commands. 1.68 + * 1.69 + * On input: aCommandParams filled in with values that the caller cares 1.70 + * about, most of which are command-specific (see the command documentation 1.71 + * for details). One boolean value, "enabled", applies to all commands, 1.72 + * and, in return will be set to indicate whether the command is enabled 1.73 + * (equivalent to calling isCommandEnabled). 1.74 + * 1.75 + * aCommandName is the name of the command that needs the state 1.76 + * aTargetWindow is the source of command controller 1.77 + * (null means use focus controller) 1.78 + * On output: aCommandParams: values set by the caller filled in with 1.79 + * state from the command. 1.80 + */ 1.81 + void getCommandState(in string aCommandName, 1.82 + in nsIDOMWindow aTargetWindow, 1.83 + /* inout */ in nsICommandParams aCommandParams); 1.84 + 1.85 + /* 1.86 + * Execute the specified command. 1.87 + * The command will be executed in aTargetWindow if it is specified. 1.88 + * If aTargetWindow is null, it will go to the focused window. 1.89 + * 1.90 + * param: aCommandParams, a list of name-value pairs of command parameters, 1.91 + * may be null for parameter-less commands. 1.92 + * 1.93 + */ 1.94 + void doCommand(in string aCommandName, 1.95 + in nsICommandParams aCommandParams, 1.96 + in nsIDOMWindow aTargetWindow); 1.97 + 1.98 +}; 1.99 + 1.100 + 1.101 +/* 1.102 + 1.103 +Arguments to observers "Observe" method are as follows: 1.104 + 1.105 + void Observe( in nsISupports aSubject, // The nsICommandManager calling this Observer 1.106 + in string aTopic, // Name of the command 1.107 + in wstring aDummy ); // unused 1.108 + 1.109 +*/ 1.110 + 1.111 +// {64edb481-0c04-11d5-a73c-e964b968b0bc} 1.112 +%{C++ 1.113 +#define NS_COMMAND_MANAGER_CID \ 1.114 +{ 0x64edb481, 0x0c04, 0x11d5, { 0xa7, 0x3c, 0xe9, 0x64, 0xb9, 0x68, 0xb0, 0xbc } } 1.115 + 1.116 +#define NS_COMMAND_MANAGER_CONTRACTID \ 1.117 + "@mozilla.org/embedcomp/command-manager;1" 1.118 +%} 1.119 + 1.120 + 1.121 +