Extension Manager:API Rewrite:API: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
=AddonManager=
=AddonManager=
The AddonManager is the global API that allows access to all types of add-ons. It hides the differences in implementations presenting a standard interface to developers.


==getInstallForURL==
==getInstallForURL==
Line 75: Line 77:


=Addon=
=Addon=
An Addon represents an instance of an installed add-on. It is a live view of the add-on.
==id (string, readonly)==
The ID of the add-on. No other installed add-on will have the same ID.
==version (string, readonly)==
The version of the add-on.
==type (string, readonly)==
The type of the add-on.
==optionsURL (string, readonly)==
The url of the options dialog to display for this add-on.
==aboutURL (string, readonly)==
The url of the about dialog to display for this add-on.
==iconURL (string, readonly)==
The url of the icon that represents this add-on.
==isCompatible (boolean, readonly)==
True or false depending on whether the add-on is compatible with the current version and platform of the application.
==providesUpdatesSecurely (boolean, readonly)==
True if the add-on has a secure means of updating.
==satisfiesDependencies (boolean, readonly)==
True if all requirements for this add-on are installed and enabled.
'''TODO''' rename this to something better.
==blocklistState (number, readonly)==
The current blocklist state of this add-on.
==appDisabled (boolean, readonly)==
True if this add-on cannot be used in the application based on version compatibility, dependencies and blocklisting.
==userDisabled (boolean)==
True if the user wants this add-on to be disabled.
'''TODO''' Make setting this asynchronous
==isActive (boolean, readonly)==
True if the add-on is currently functional. For some add-ons this will change immediately based on the appDisabled and userDisabled properties, for others it will only change after an application restart.
==name (string, readonly)==
The name of the add-on.
==description (string, readonly)==
The description of the add-on.
==creator (string, readonly)==
The creator of the add-on.
==homepageURL (string, readonly)==
The homepageURL of the add-on.
==developers (string array, readonly)==
The developers of the add-on.
==translators (string array, readonly)==
The translators of the add-on.
==contributors (string array, readonly)==
The contributors of the add-on.
==pendingOperations (number)==
A bitfield holding all of the current operations that are waiting to be performed for this add-on. Operations are generally deferred when a restart is necessary to accomplish them.
==permissions (number)==
A bitfield holding all the the operations that can be performed on this add-on. Operations my be restricted based on system policies (e.g. the system administrator may not allow certain add-ons to be uninstalled), add-on type (e.g. themes may not be disabled) or add-on state (e.g. an incompatible add-on cannot be enabled).
==uninstall==
Uninstalls this add-on. If possible the uninstall will happen immediately otherwise it will wait until the next application restart.
'''TODO''' This should be asynchronous.
==cancelUninstall==
Cancels uninstalling an add-on if it is pending uninstall.
==findUpdates==
Starts an update check for this add-on. This will perform asynchronously and deliver results to the given listener.
;listener :An [[#UpdateListener|UpdateListener]] for the update process
;appVersion :An application version to check for updates for (optional)
;platformVersion :A platform version to check for updates for (optional)


=AddonInstall=
=AddonInstall=


=AddonListener=
=AddonListener=
=UpdateListener=
Notification about events during an update check for an add-on are passed to an update listener. <code>onUpdateFinished</code> will always be called.
==onCompatibilityUpdated==
Called when new compatibility information has been found for the installed version of an add-on.
;addon :The [[#Addon|Addon]] that was being checked for updates
==onUpdateAvailable==
Called when a new version of an add-on has been found for install.
;addon :The [[#Addon|Addon]] that was being checked for updates
;install :An [[#AddonInstall|AddonInstall]] for the updated version
==onUpdateFinished==
Called when the update check is complete.
;addon :The [[#Addon|Addon]] that was being checked for updates


=InstallListener=
=InstallListener=

Revision as of 23:36, 9 October 2009

AddonManager

The AddonManager is the global API that allows access to all types of add-ons. It hides the differences in implementations presenting a standard interface to developers.

getInstallForURL

Creates a new object representing an add-on installation from a url.

TODO This probably needs to be asynchronous to look up the mimetype of the url to determine the add-on type and maybe the signing certificate. Also move name and version arguments into a generic parameters object.

name
A human readable name for the add-on to be displayed during install (optional)
version
The version of the add-on to be installed (optional)
url
The URL to install the add-on from
hash
A hash of the file to be downloaded
returns
An AddonInstall for the installation

getInstallForFile

Creates a new object reperesenting an add-on installation from a local file, properties for the install will be loaded out of the file synchronously.

file
A nsIFile to install the add-on from
returns
An AddonInstall for the installation

getInstalls

Returns the list of known add-on installs optionally restricting to a set of types of add-ons.

types
An array of types of add-ons to return (optional)
returns
An array of AddonInstalls

addInstallListener

Adds a listener that will be notified about any events in any install. The same listener will not be added multiple times.

listener
An InstallListener

removeInstallListener

Removes a previously added install listener.

listener
An InstallListener

getAddon

Gets an installed add-on.

TODO Make this asynchronous.

id
The ID of the add-on to retrieve
returns
An Addon representing the add-on or null if there is no installed add-on with the given ID

getAddons

Gets an array of the installed add-ons optionally restricting to a set of types.

TODO Make this asynchronous.

types
An array of types of add-ons to return (optional)
returns
An array of Addons representing the installed add-ons

addAddonListener

Adds a listener that will be notified about changes to add-on states for all installed add-ons. The same listener will not be added multiple times.

listener
An AddonListener

removeAddonListener

Removes a previously added add-on listener.

listener
An AddonListener

Addon

An Addon represents an instance of an installed add-on. It is a live view of the add-on.

id (string, readonly)

The ID of the add-on. No other installed add-on will have the same ID.

version (string, readonly)

The version of the add-on.

type (string, readonly)

The type of the add-on.

optionsURL (string, readonly)

The url of the options dialog to display for this add-on.

aboutURL (string, readonly)

The url of the about dialog to display for this add-on.

iconURL (string, readonly)

The url of the icon that represents this add-on.

isCompatible (boolean, readonly)

True or false depending on whether the add-on is compatible with the current version and platform of the application.

providesUpdatesSecurely (boolean, readonly)

True if the add-on has a secure means of updating.

satisfiesDependencies (boolean, readonly)

True if all requirements for this add-on are installed and enabled. TODO rename this to something better.

blocklistState (number, readonly)

The current blocklist state of this add-on.

appDisabled (boolean, readonly)

True if this add-on cannot be used in the application based on version compatibility, dependencies and blocklisting.

userDisabled (boolean)

True if the user wants this add-on to be disabled. TODO Make setting this asynchronous

isActive (boolean, readonly)

True if the add-on is currently functional. For some add-ons this will change immediately based on the appDisabled and userDisabled properties, for others it will only change after an application restart.

name (string, readonly)

The name of the add-on.

description (string, readonly)

The description of the add-on.

creator (string, readonly)

The creator of the add-on.

homepageURL (string, readonly)

The homepageURL of the add-on.

developers (string array, readonly)

The developers of the add-on.

translators (string array, readonly)

The translators of the add-on.

contributors (string array, readonly)

The contributors of the add-on.

pendingOperations (number)

A bitfield holding all of the current operations that are waiting to be performed for this add-on. Operations are generally deferred when a restart is necessary to accomplish them.

permissions (number)

A bitfield holding all the the operations that can be performed on this add-on. Operations my be restricted based on system policies (e.g. the system administrator may not allow certain add-ons to be uninstalled), add-on type (e.g. themes may not be disabled) or add-on state (e.g. an incompatible add-on cannot be enabled).

uninstall

Uninstalls this add-on. If possible the uninstall will happen immediately otherwise it will wait until the next application restart. TODO This should be asynchronous.

cancelUninstall

Cancels uninstalling an add-on if it is pending uninstall.

findUpdates

Starts an update check for this add-on. This will perform asynchronously and deliver results to the given listener.

listener
An UpdateListener for the update process
appVersion
An application version to check for updates for (optional)
platformVersion
A platform version to check for updates for (optional)

AddonInstall

AddonListener

UpdateListener

Notification about events during an update check for an add-on are passed to an update listener. onUpdateFinished will always be called.

onCompatibilityUpdated

Called when new compatibility information has been found for the installed version of an add-on.

addon
The Addon that was being checked for updates

onUpdateAvailable

Called when a new version of an add-on has been found for install.

addon
The Addon that was being checked for updates
install
An AddonInstall for the updated version

onUpdateFinished

Called when the update check is complete.

addon
The Addon that was being checked for updates

InstallListener