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: michael@0: interface nsIVariant; michael@0: interface extIPreference; michael@0: interface extISessionStorage; michael@0: michael@0: michael@0: /** michael@0: * Interface that gives simplified access to the console michael@0: */ michael@0: [scriptable, uuid(ae8482e0-aa5a-11db-abbd-0800200c9a66)] michael@0: interface extIConsole : nsISupports michael@0: { michael@0: /** michael@0: * Sends a given string to the console. michael@0: * @param aMsg michael@0: * The text to send to the console michael@0: */ michael@0: void log(in AString aMsg); michael@0: michael@0: /** michael@0: * Opens the error console window. The console window michael@0: * is focused if already open. michael@0: */ michael@0: void open(); michael@0: }; michael@0: michael@0: michael@0: /** michael@0: * Interface holds information about an event. michael@0: */ michael@0: [scriptable, function, uuid(05281820-ab62-11db-abbd-0800200c9a66)] michael@0: interface extIEventItem : nsISupports michael@0: { michael@0: /** michael@0: * The name of the event michael@0: */ michael@0: readonly attribute AString type; michael@0: michael@0: /** michael@0: * Can hold extra details and data associated with the event. This michael@0: * is optional and event specific. If the event does not send extra michael@0: * details, this is null. michael@0: */ michael@0: readonly attribute nsIVariant data; michael@0: michael@0: /** michael@0: * Cancels the event if it is cancelable. michael@0: */ michael@0: void preventDefault(); michael@0: }; michael@0: michael@0: michael@0: /** michael@0: * Interface used as a callback for listening to events. michael@0: */ michael@0: [scriptable, function, uuid(2dfe3a50-ab2f-11db-abbd-0800200c9a66)] michael@0: interface extIEventListener : nsISupports michael@0: { michael@0: /** michael@0: * This method is called whenever an event occurs of the type for which michael@0: * the extIEventListener interface was registered. michael@0: * michael@0: * @param aEvent michael@0: * The extIEventItem associated with the event. michael@0: */ michael@0: void handleEvent(in extIEventItem aEvent); michael@0: }; michael@0: michael@0: michael@0: /** michael@0: * Interface for supporting custom events. michael@0: */ michael@0: [scriptable, uuid(3a8ec9d0-ab19-11db-abbd-0800200c9a66)] michael@0: interface extIEvents : nsISupports michael@0: { michael@0: /** michael@0: * Adds an event listener to the list. If multiple identical event listeners michael@0: * are registered on the same event target with the same parameters the michael@0: * duplicate instances are discarded. They do not cause the EventListener michael@0: * to be called twice and since they are discarded they do not need to be michael@0: * removed with the removeListener method. michael@0: * michael@0: * @param aEvent michael@0: * The name of an event michael@0: * @param aListener michael@0: * The reference to a listener michael@0: */ michael@0: void addListener(in AString aEvent, in extIEventListener aListener); michael@0: michael@0: /** michael@0: * Removes an event listener from the list. Calling remove michael@0: * with arguments which do not identify any currently registered michael@0: * event listener has no effect. michael@0: * @param aEvent michael@0: * The name of an event michael@0: * @param aListener michael@0: * The reference to a listener michael@0: */ michael@0: void removeListener(in AString aEvent, in extIEventListener aListener); michael@0: }; michael@0: michael@0: michael@0: /** michael@0: * Interface for simplified access to preferences. The interface has a michael@0: * predefined root preference branch. The root branch is set based on the michael@0: * context of the owner. For example, an extension's preferences have a root michael@0: * of "extensions..", while the application level preferences michael@0: * have an empty root. All preference "aName" parameters used in this interface michael@0: * are relative to the root branch. michael@0: */ michael@0: [scriptable, uuid(ce697d40-aa5a-11db-abbd-0800200c9a66)] michael@0: interface extIPreferenceBranch : nsISupports michael@0: { michael@0: /** michael@0: * The name of the branch root. michael@0: */ michael@0: readonly attribute AString root; michael@0: michael@0: /** michael@0: * Array of extIPreference listing all preferences in this branch. michael@0: */ michael@0: readonly attribute nsIVariant all; michael@0: michael@0: /** michael@0: * The events object for the preferences michael@0: * supports: "change" michael@0: */ michael@0: readonly attribute extIEvents events; michael@0: michael@0: /** michael@0: * Check to see if a preference exists. michael@0: * @param aName michael@0: * The name of preference michael@0: * @returns true if the preference exists, false if not michael@0: */ michael@0: boolean has(in AString aName); michael@0: michael@0: /** michael@0: * Gets an object representing a preference michael@0: * @param aName michael@0: * The name of preference michael@0: * @returns a preference object, or null if the preference does not exist michael@0: */ michael@0: extIPreference get(in AString aName); michael@0: michael@0: /** michael@0: * Gets the value of a preference. Returns a default value if michael@0: * the preference does not exist. michael@0: * @param aName michael@0: * The name of preference michael@0: * @param aDefaultValue michael@0: * The value to return if preference does not exist michael@0: * @returns value of the preference or the given default value if preference michael@0: * does not exists. michael@0: */ michael@0: nsIVariant getValue(in AString aName, in nsIVariant aDefaultValue); michael@0: michael@0: /** michael@0: * Sets the value of a storage item with the given name. michael@0: * @param aName michael@0: * The name of an item michael@0: * @param aValue michael@0: * The value to assign to the item michael@0: */ michael@0: void setValue(in AString aName, in nsIVariant aValue); michael@0: michael@0: /** michael@0: * Resets all preferences in a branch back to their default values. michael@0: */ michael@0: void reset(); michael@0: }; michael@0: michael@0: /** michael@0: * Interface for accessing a single preference. The data is not cached. michael@0: * All reads access the current state of the preference. michael@0: */ michael@0: [scriptable, uuid(2C7462E2-72C2-4473-9007-0E6AE71E23CA)] michael@0: interface extIPreference : nsISupports michael@0: { michael@0: /** michael@0: * The name of the preference. michael@0: */ michael@0: readonly attribute AString name; michael@0: michael@0: /** michael@0: * A string representing the type of preference (String, Boolean, or Number). michael@0: */ michael@0: readonly attribute AString type; michael@0: michael@0: /** michael@0: * Get/Set the value of the preference. michael@0: */ michael@0: attribute nsIVariant value; michael@0: michael@0: /** michael@0: * Get the locked state of the preference. Set to a boolean value to (un)lock it. michael@0: */ michael@0: attribute boolean locked; michael@0: michael@0: /** michael@0: * Check if a preference has been modified by the user, or not. michael@0: */ michael@0: readonly attribute boolean modified; michael@0: michael@0: /** michael@0: * The preference branch that contains this preference. michael@0: */ michael@0: readonly attribute extIPreferenceBranch branch; michael@0: michael@0: /** michael@0: * The events object for this preference. michael@0: * supports: "change" michael@0: */ michael@0: readonly attribute extIEvents events; michael@0: michael@0: /** michael@0: * Resets a preference back to its default values. michael@0: */ michael@0: void reset(); michael@0: }; michael@0: michael@0: michael@0: /** michael@0: * Interface representing an extension michael@0: */ michael@0: [scriptable, uuid(10cee02c-f6e0-4d61-ab27-c16572b18c46)] michael@0: interface extIExtension : nsISupports michael@0: { michael@0: /** michael@0: * The id of the extension. michael@0: */ michael@0: readonly attribute AString id; michael@0: michael@0: /** michael@0: * The name of the extension. michael@0: */ michael@0: readonly attribute AString name; michael@0: michael@0: /** michael@0: * Check if the extension is currently enabled, or not. michael@0: */ michael@0: readonly attribute boolean enabled; michael@0: michael@0: /** michael@0: * The version number of the extension. michael@0: */ michael@0: readonly attribute AString version; michael@0: michael@0: /** michael@0: * Indicates whether this is the extension's first run after install michael@0: */ michael@0: readonly attribute boolean firstRun; michael@0: michael@0: /** michael@0: * The preferences object for the extension. Defaults to the michael@0: * "extensions.." branch. michael@0: */ michael@0: readonly attribute extIPreferenceBranch prefs; michael@0: michael@0: /** michael@0: * The storage object for the extension. michael@0: */ michael@0: readonly attribute extISessionStorage storage; michael@0: michael@0: /** michael@0: * The events object for the extension. michael@0: * supports: "uninstall" michael@0: */ michael@0: readonly attribute extIEvents events; michael@0: }; michael@0: michael@0: /** michael@0: * Interface representing a list of all installed extensions michael@0: */ michael@0: [scriptable, uuid(de281930-aa5a-11db-abbd-0800200c9a66)] michael@0: interface extIExtensions : nsISupports michael@0: { michael@0: /** michael@0: * Array of extIExtension listing all extensions in the application. michael@0: */ michael@0: readonly attribute nsIVariant all; michael@0: michael@0: /** michael@0: * Determines if an extension exists with the given id. michael@0: * @param aId michael@0: * The id of an extension michael@0: * @returns true if an extension exists with the given id, michael@0: * false otherwise. michael@0: */ michael@0: boolean has(in AString aId); michael@0: michael@0: /** michael@0: * Gets a extIExtension object for an extension. michael@0: * @param aId michael@0: * The id of an extension michael@0: * @returns An extension object or null if no extension exists michael@0: * with the given id. michael@0: */ michael@0: extIExtension get(in AString aId); michael@0: }; michael@0: michael@0: /** michael@0: * Interface representing a callback that receives an array of extIExtensions michael@0: */ michael@0: [scriptable, function, uuid(2571cbb5-550d-4400-8038-75df9b553f98)] michael@0: interface extIExtensionsCallback : nsISupports michael@0: { michael@0: void callback(in nsIVariant extensions); michael@0: }; michael@0: michael@0: /** michael@0: * Interface representing a simple storage system michael@0: */ michael@0: [scriptable, uuid(0787ac44-29b9-4889-b97f-13573aec6971)] michael@0: interface extISessionStorage : nsISupports michael@0: { michael@0: /** michael@0: * The events object for the storage michael@0: * supports: "change" michael@0: */ michael@0: readonly attribute extIEvents events; michael@0: michael@0: /** michael@0: * Determines if a storage item exists with the given name. michael@0: * @param aName michael@0: * The name of an item michael@0: * @returns true if an item exists with the given name, michael@0: * false otherwise. michael@0: */ michael@0: boolean has(in AString aName); michael@0: michael@0: /** michael@0: * Sets the value of a storage item with the given name. michael@0: * @param aName michael@0: * The name of an item michael@0: * @param aValue michael@0: * The value to assign to the item michael@0: */ michael@0: void set(in AString aName, in nsIVariant aValue); michael@0: michael@0: /** michael@0: * Gets the value of a storage item with the given name. Returns a michael@0: * default value if the item does not exist. michael@0: * @param aName michael@0: * The name of an item michael@0: * @param aDefaultValue michael@0: * The value to return if no item exists with the given name michael@0: * @returns value of the item or the given default value if no item michael@0: * exists with the given name. michael@0: */ michael@0: nsIVariant get(in AString aName, in nsIVariant aDefaultValue); michael@0: }; michael@0: michael@0: [scriptable, uuid(2be87909-0817-4292-acfa-fc39be53be3f)] michael@0: interface extIApplication : nsISupports michael@0: { michael@0: /** michael@0: * The id of the application. michael@0: */ michael@0: readonly attribute AString id; michael@0: michael@0: /** michael@0: * The name of the application. michael@0: */ michael@0: readonly attribute AString name; michael@0: michael@0: /** michael@0: * The version number of the application. michael@0: */ michael@0: readonly attribute AString version; michael@0: michael@0: /** michael@0: * The console object for the application. michael@0: */ michael@0: readonly attribute extIConsole console; michael@0: michael@0: /** michael@0: * The extensions object for the application. Contains a list michael@0: * of all installed extensions. michael@0: */ michael@0: void getExtensions(in extIExtensionsCallback aCallback); michael@0: michael@0: /** michael@0: * The preferences object for the application. Defaults to an empty michael@0: * root branch. michael@0: */ michael@0: readonly attribute extIPreferenceBranch prefs; michael@0: michael@0: /** michael@0: * The storage object for the application. michael@0: */ michael@0: readonly attribute extISessionStorage storage; michael@0: michael@0: /** michael@0: * The events object for the application. michael@0: * supports: "load", "ready", "quit", "unload" michael@0: */ michael@0: readonly attribute extIEvents events; michael@0: michael@0: /** michael@0: * Quits the application (if nobody objects to quit-application-requested). michael@0: * @returns whether quitting will proceed michael@0: */ michael@0: boolean quit(); michael@0: michael@0: /** michael@0: * Restarts the application (if nobody objects to quit-application-requested). michael@0: * @returns whether restarting will proceed michael@0: */ michael@0: boolean restart(); michael@0: };