/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Ben Goodger.
 * Portions created by the Initial Developer are Copyright (C) 2004
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *  Ben Goodger <ben@bengoodger.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 ***** */

// XXXben - document these files

#include "nsISupports.idl"

interface nsIDOMWindowInternal;

/**
 * An item managed by the Extension or Software Update System. Contains
 * metadata that describes the item.
 */
[scriptable, uuid(415edb0a-4f2d-485c-9e10-f262b065ab33)]
interface nsIUpdateItem : nsISupports
{
  /**
   * The GUID of the item.
   */
  readonly attribute AString  id;

  /**
   * The Version of the item, in FVF format.
   */
  readonly attribute AString  version;

  /**
   * The minimum version of the application that this item works with, 
   * in FVF format.
   */
  readonly attribute AString  minAppVersion;

  /**
   * The maximum version of the application that this item works with,
   * in FVF format.
   */
  readonly attribute AString  maxAppVersion;

  /**
   * The name of the Install Location where this item is installed.
   */
  readonly attribute AString  installLocationKey;

  /**
   * The name of this item.
   */
  readonly attribute AString  name;

  /**
   * The URL of the XPI where this item can be downloaded.
   */
  readonly attribute AString  xpiURL;

  /**
   * The URL of the icon that can be shown for this item.
   */
  readonly attribute AString  iconURL;

  /**
   * The URL of the update RDF file for this item.
   */
  readonly attribute AString  updateRDF;
  
  const unsigned long TYPE_APP         = 0x01;
  const unsigned long TYPE_EXTENSION   = 0x02;
  const unsigned long TYPE_THEME       = 0x04;
  const unsigned long TYPE_LOCALE      = 0x08;
  const unsigned long TYPE_PLUGIN      = 0x10;
  const unsigned long TYPE_ADDON       = TYPE_EXTENSION + TYPE_THEME + TYPE_LOCALE + TYPE_PLUGIN;
  const unsigned long TYPE_ANY         = TYPE_APP + TYPE_ADDON;

  /**
   * The type of this item.
   */
  readonly attribute long type;

  /**
   * Initializes this Item object.
   */
  void init(in AString aID, in AString aVersion, 
            in AString aInstallLocationKey, in AString aMinAppVersion, 
            in AString aMaxAppVersion, in AString aName,
            in AString aUpdateURL, in AString aIconURL,
            in AString aUpdateRDF, in long aType);

  /**
   * Returns a JS Object source representing an nsIUpdateItem.
   */
  readonly attribute AString objectSource;
};

[scriptable, uuid(24aee3ca-a274-4247-bd3b-d0acbb5a98aa)]
interface nsIAppUpdateInfoItem : nsISupports
{
  readonly attribute AString internalName;
  readonly attribute AString name;
  readonly attribute AString URL;
  readonly attribute AString infoURL;
  readonly attribute AString description;
};

[scriptable, uuid(2daab124-9bc7-4c35-bb7b-0fecdea03ce8)]
interface nsIAppUpdateInfo : nsISupports
{
  readonly attribute AString updateVersion;
  readonly attribute AString updateDisplayVersion;
  readonly attribute AString updateInfoURL;

  void getCollection(in AString aCollectionName, out unsigned long aItemCount,
                     [retval, array, size_is(aItemCount)] out nsIAppUpdateInfoItem aItems);
};

[scriptable, uuid(c8a2339e-770a-417d-ab9c-efde1f23ba24)]
interface nsIUpdateService : nsISupports
{
  void watchForUpdates();

  const unsigned short SOURCE_EVENT_USER        = 0x01;
  const unsigned short SOURCE_EVENT_BACKGROUND  = 0x02;
  const unsigned short SOURCE_EVENT_MISMATCH    = 0x04;

  void checkForUpdates([array, size_is(aItemCount)] in nsIUpdateItem aItems,
                       in unsigned long aItemCount,
                       in unsigned short aUpdateTypes, 
                       in unsigned short aSourceEvent,
                       in nsIDOMWindowInternal aParentWindow);
  void checkForUpdatesInternal([array, size_is(aItemCount)] in nsIUpdateItem aItems,
                               in unsigned long aItemCount,
                               in unsigned short aUpdateTypes, 
                               in unsigned short aSourceEvent);

  readonly attribute long updateCount;
  readonly attribute unsigned short updateSeverity;

  // these are per-session settings
  attribute boolean appUpdatesAvailable;
  attribute long extensionUpdatesAvailable;

  readonly attribute nsIAppUpdateInfo newestVersion;
  readonly attribute nsIAppUpdateInfo currentVersion;

  const unsigned short SEVERITY_HIGH    = 2;
  const unsigned short SEVERITY_MEDIUM  = 1;
  const unsigned short SEVERITY_LOW     = 0;
};

[scriptable, uuid(22d35700-5765-42e1-914b-a0da7c911a8c)]
interface nsIVersionChecker : nsISupports
{
  // -ve      if B is newer
  // equal    if A == B
  // +ve      if A is newer
  long compare(in AString aVersionA, in AString aVersionB);

  boolean isValidVersion(in AString aVersion);
};

