gecko/toolkit/components/exthelper/extIApplication.idl

443 lines
12 KiB
Plaintext

/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FUEL.
*
* The Initial Developer of the Original Code is Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joey Minta <jminta@gmail.com> (Original Author)
* Mark Finkle <mfinkle@mozilla.com>
* John Resig <jresig@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIVariant;
interface extIPreference;
interface extISessionStorage;
/**
* Interface that gives simplified access to the console
*/
[scriptable, uuid(ae8482e0-aa5a-11db-abbd-0800200c9a66)]
interface extIConsole : nsISupports
{
/**
* Sends a given string to the console.
* @param aMsg
* The text to send to the console
*/
void log(in AString aMsg);
/**
* Opens the error console window. The console window
* is focused if already open.
*/
void open();
};
/**
* Interface holds information about an event.
*/
[scriptable, function, uuid(05281820-ab62-11db-abbd-0800200c9a66)]
interface extIEventItem : nsISupports
{
/**
* The name of the event
*/
readonly attribute AString type;
/**
* Can hold extra details and data associated with the event. This
* is optional and event specific. If the event does not send extra
* details, this is null.
*/
readonly attribute nsIVariant data;
/**
* Cancels the event if it is cancelable.
*/
void preventDefault();
};
/**
* Interface used as a callback for listening to events.
*/
[scriptable, function, uuid(2dfe3a50-ab2f-11db-abbd-0800200c9a66)]
interface extIEventListener : nsISupports
{
/**
* This method is called whenever an event occurs of the type for which
* the extIEventListener interface was registered.
*
* @param aEvent
* The extIEventItem associated with the event.
*/
void handleEvent(in extIEventItem aEvent);
};
/**
* Interface for supporting custom events.
*/
[scriptable, uuid(3a8ec9d0-ab19-11db-abbd-0800200c9a66)]
interface extIEvents : nsISupports
{
/**
* Adds an event listener to the list. If multiple identical event listeners
* are registered on the same event target with the same parameters the
* duplicate instances are discarded. They do not cause the EventListener
* to be called twice and since they are discarded they do not need to be
* removed with the removeListener method.
*
* @param aEvent
* The name of an event
* @param aListener
* The reference to a listener
*/
void addListener(in AString aEvent, in extIEventListener aListener);
/**
* Removes an event listener from the list. Calling remove
* with arguments which do not identify any currently registered
* event listener has no effect.
* @param aEvent
* The name of an event
* @param aListener
* The reference to a listener
*/
void removeListener(in AString aEvent, in extIEventListener aListener);
};
/**
* Interface for simplified access to preferences. The interface has a
* predefined root preference branch. The root branch is set based on the
* context of the owner. For example, an extension's preferences have a root
* of "extensions.<extensionid>.", while the application level preferences
* have an empty root. All preference "aName" parameters used in this interface
* are relative to the root branch.
*/
[scriptable, uuid(ce697d40-aa5a-11db-abbd-0800200c9a66)]
interface extIPreferenceBranch : nsISupports
{
/**
* The name of the branch root.
*/
readonly attribute AString root;
/**
* Array of extIPreference listing all preferences in this branch.
*/
readonly attribute nsIVariant all;
/**
* The events object for the preferences
* supports: "change"
*/
readonly attribute extIEvents events;
/**
* Check to see if a preference exists.
* @param aName
* The name of preference
* @returns true if the preference exists, false if not
*/
boolean has(in AString aName);
/**
* Gets an object representing a preference
* @param aName
* The name of preference
* @returns a preference object, or null if the preference does not exist
*/
extIPreference get(in AString aName);
/**
* Gets the value of a preference. Returns a default value if
* the preference does not exist.
* @param aName
* The name of preference
* @param aDefaultValue
* The value to return if preference does not exist
* @returns value of the preference or the given default value if preference
* does not exists.
*/
nsIVariant getValue(in AString aName, in nsIVariant aDefaultValue);
/**
* Sets the value of a storage item with the given name.
* @param aName
* The name of an item
* @param aValue
* The value to assign to the item
*/
void setValue(in AString aName, in nsIVariant aValue);
/**
* Resets all preferences in a branch back to their default values.
*/
void reset();
};
/**
* Interface for accessing a single preference. The data is not cached.
* All reads access the current state of the preference.
*/
[scriptable, uuid(2C7462E2-72C2-4473-9007-0E6AE71E23CA)]
interface extIPreference : nsISupports
{
/**
* The name of the preference.
*/
readonly attribute AString name;
/**
* A string representing the type of preference (String, Boolean, or Number).
*/
readonly attribute AString type;
/**
* Get/Set the value of the preference.
*/
attribute nsIVariant value;
/**
* Get the locked state of the preference. Set to a boolean value to (un)lock it.
*/
attribute boolean locked;
/**
* Check if a preference has been modified by the user, or not.
*/
readonly attribute boolean modified;
/**
* The preference branch that contains this preference.
*/
readonly attribute extIPreferenceBranch branch;
/**
* The events object for this preference.
* supports: "change"
*/
readonly attribute extIEvents events;
/**
* Resets a preference back to its default values.
*/
void reset();
};
/**
* Interface representing an extension
*/
[scriptable, uuid(10cee02c-f6e0-4d61-ab27-c16572b18c46)]
interface extIExtension : nsISupports
{
/**
* The id of the extension.
*/
readonly attribute AString id;
/**
* The name of the extension.
*/
readonly attribute AString name;
/**
* Check if the extension is currently enabled, or not.
*/
readonly attribute boolean enabled;
/**
* The version number of the extension.
*/
readonly attribute AString version;
/**
* Indicates whether this is the extension's first run after install
*/
readonly attribute boolean firstRun;
/**
* The preferences object for the extension. Defaults to the
* "extensions.<extensionid>." branch.
*/
readonly attribute extIPreferenceBranch prefs;
/**
* The storage object for the extension.
*/
readonly attribute extISessionStorage storage;
/**
* The events object for the extension.
* supports: "uninstall"
*/
readonly attribute extIEvents events;
};
/**
* Interface representing a list of all installed extensions
*/
[scriptable, uuid(de281930-aa5a-11db-abbd-0800200c9a66)]
interface extIExtensions : nsISupports
{
/**
* Array of extIExtension listing all extensions in the application.
*/
readonly attribute nsIVariant all;
/**
* Determines if an extension exists with the given id.
* @param aId
* The id of an extension
* @returns true if an extension exists with the given id,
* false otherwise.
*/
boolean has(in AString aId);
/**
* Gets a extIExtension object for an extension.
* @param aId
* The id of an extension
* @returns An extension object or null if no extension exists
* with the given id.
*/
extIExtension get(in AString aId);
};
/**
* Interface representing a simple storage system
*/
[scriptable, uuid(0787ac44-29b9-4889-b97f-13573aec6971)]
interface extISessionStorage : nsISupports
{
/**
* The events object for the storage
* supports: "change"
*/
readonly attribute extIEvents events;
/**
* Determines if a storage item exists with the given name.
* @param aName
* The name of an item
* @returns true if an item exists with the given name,
* false otherwise.
*/
boolean has(in AString aName);
/**
* Sets the value of a storage item with the given name.
* @param aName
* The name of an item
* @param aValue
* The value to assign to the item
*/
void set(in AString aName, in nsIVariant aValue);
/**
* Gets the value of a storage item with the given name. Returns a
* default value if the item does not exist.
* @param aName
* The name of an item
* @param aDefaultValue
* The value to return if no item exists with the given name
* @returns value of the item or the given default value if no item
* exists with the given name.
*/
nsIVariant get(in AString aName, in nsIVariant aDefaultValue);
};
[scriptable, uuid(e53d6610-7468-11dd-ad8b-0800200c9a66)]
interface extIApplication : nsISupports
{
/**
* The id of the application.
*/
readonly attribute AString id;
/**
* The name of the application.
*/
readonly attribute AString name;
/**
* The version number of the application.
*/
readonly attribute AString version;
/**
* The console object for the application.
*/
readonly attribute extIConsole console;
/**
* The extensions object for the application. Contains a list
* of all installed extensions.
*/
readonly attribute extIExtensions extensions;
/**
* The preferences object for the application. Defaults to an empty
* root branch.
*/
readonly attribute extIPreferenceBranch prefs;
/**
* The storage object for the application.
*/
readonly attribute extISessionStorage storage;
/**
* The events object for the application.
* supports: "load", "ready", "quit", "unload"
*/
readonly attribute extIEvents events;
/**
* Quits the application (if nobody objects to quit-application-requested).
* @returns whether quitting will proceed
*/
boolean quit();
/**
* Restarts the application (if nobody objects to quit-application-requested).
* @returns whether restarting will proceed
*/
boolean restart();
};