1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is mozilla.org code.
15 *
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2003
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 * Simon Fraser <sfraser@netscape.com>
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 #include "nsISupports.idl"
39 #include "nsIControllerCommand.idl"
40 #include "nsICommandParams.idl"
41
42 /**
43 * nsIControllerCommandTable
44 *
45 * An interface via which a controller can maintain a series of commands,
46 * and efficiently dispatch commands to their respective handlers.
47 *
48 * Controllers that use an nsIControllerCommandTable should support
49 * nsIInterfaceRequestor, and be able to return an interface to their
50 * controller command table via getInterface().
51 *
52 */
53
54 [scriptable, uuid(d1a47834-6ad4-11d7-bfad-000393636592)]
55 interface nsIControllerCommandTable : nsISupports
56 {
57 /**
58 * Make this command table immutable, so that commands cannot
59 * be registered or unregistered. Some command tables are made
60 * mutable after command registration so that they can be
61 * used as singletons.
62 */
63 void makeImmutable();
64
65 /**
66 * Register and unregister commands with the command table.
67 *
68 * @param aCommandName the name of the command under which to register or
69 * unregister the given command handler.
70 *
71 * @param aCommand the handler for this command.
72 */
73 void registerCommand(in string aCommandName, in nsIControllerCommand aCommand);
74 void unregisterCommand(in string aCommandName, in nsIControllerCommand aCommand);
75
76 /**
77 * Find the command handler which has been registered to handle the named command.
78 *
79 * @param aCommandName the name of the command to find the handler for.
80 */
81 nsIControllerCommand findCommandHandler(in string aCommandName);
82
83 /**
84 * Get whether the named command is enabled.
85 *
86 * @param aCommandName the name of the command to test
87 * @param aCommandRefCon the command context data
88 */
89 boolean isCommandEnabled(in string aCommandName, in nsISupports aCommandRefCon);
90
91 /**
92 * Tell the command to update its state (if it is a state updating command)
93 *
94 * @param aCommandName the name of the command to update
95 * @param aCommandRefCon the command context data
96 */
97 void updateCommandState(in string aCommandName, in nsISupports aCommandRefCon);
98
99 /**
100 * Get whether the named command is supported.
101 *
102 * @param aCommandName the name of the command to test
103 * @param aCommandRefCon the command context data
104 */
105 boolean supportsCommand(in string aCommandName, in nsISupports aCommandRefCon);
106
107 /**
108 * Execute the named command.
109 *
110 * @param aCommandName the name of the command to execute
111 * @param aCommandRefCon the command context data
112 */
113 void doCommand(in string aCommandName, in nsISupports aCommandRefCon);
114
115 void doCommandParams(in string aCommandName, in nsICommandParams aParam, in nsISupports aCommandRefCon);
116
117 void getCommandState(in string aCommandName, in nsICommandParams aParam, in nsISupports aCommandRefCon);
118 };
119
120
121
122 %{C++
123 // {670ee5da-6ad5-11d7-9950-000393636592}
124 #define NS_CONTROLLERCOMMANDTABLE_CID \
125 {0x670ee5da, 0x6ad5, 0x11d7, \
126 { 0x99, 0x50, 0x00, 0x03, 0x93, 0x63, 0x65, 0x92 }}
127
128 #define NS_CONTROLLERCOMMANDTABLE_CONTRACTID \
129 "@mozilla.org/embedcomp/controller-command-table;1"
130 %}