/* ***** 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 the Extension Manager.
 *
 * The Initial Developer of the Original Code is
 * the Mozilla Foundation.
 * Portions created by the Initial Developer are Copyright (C) 2010
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Dave Townsend <dtownsend@oxymoronical.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;

/**
 * A callback function that webpages can implement to be notified when triggered
 * installs complete.
 */
[scriptable, function, uuid(bb22f5c0-3ca1-48f6-873c-54e87987700f)]
interface amIInstallCallback : nsISupports
{
  /**
   * Called when an install completes or fails.
   *
   * @param  aUrl
   *         The url of the add-on being installed
   * @param  aStatus
   *         0 if the install was successful or negative if not
   */
  void onInstallEnded(in AString aUrl, in PRInt32 aStatus);
};

/**
 * The interface for the InstallTrigger object available to all websites.
 */
[scriptable, uuid(14b4e84d-001c-4403-a608-52a67ffaab40)]
interface amIInstallTrigger : nsISupports
{
  /**
   * Retained for backwards compatibility.
   */
  const PRUint32 SKIN    = 1;
  const PRUint32 LOCALE  = 2;
  const PRUint32 CONTENT = 4;
  const PRUint32 PACKAGE = 7;

  /**
   * Tests if installation is enabled.
   *
   * @deprecated Use "enabled" in the future.
   */
  [deprecated] boolean updateEnabled();

  /**
   * Tests if installation is enabled.
   */
  boolean enabled();

  /**
   * Starts a new installation of a set of add-ons.
   *
   * @param  aArgs
   *         The add-ons to install. This should be a JS object, each property
   *         is the name of an add-on to be installed. The value of the
   *         property should either be a string URL, or an object with the
   *         following properties:
   *          * URL for the add-on's URL
   *          * IconURL for an icon for the add-on
   *          * Hash for a hash of the add-on
   * @param  aCallback
   *         A callback to call as each installation succeeds or fails
   * @return true if the installations were successfully started
   */
  boolean install(in nsIVariant aArgs, [optional] in amIInstallCallback aCallback);

  /**
   * Starts installing a new add-on. This method is deprecated, please use
   * "install" in the future.
   *
   * @param  aType
   *         Unused, retained for backwards compatibility
   * @param  aUrl
   *         The URL of the add-on
   * @param  aSkin
   *         Unused, retained for backwards compatibility
   * @return true if the installation was successfully started
   */
  boolean installChrome(in PRUint32 aType, in AString aUrl, in AString aSkin);

  /**
   * Starts installing a new add-on.
   *
   * @deprecated use "install" in the future.
   *
   * @param  aUrl
   *         The URL of the add-on
   * @param  aFlags
   *         Unused, retained for backwards compatibility
   * @return true if the installation was successfully started
   */
  [deprecated] boolean startSoftwareUpdate(in AString aUrl, [optional] in PRInt32 aFlags);
};
