/* -*- 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 Application Update Service
 *
 * The Initial Developer of the Original Code is Google Inc.
 * Portions created by the Initial Developer are Copyright (C) 2005
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *  Ben Goodger <ben@mozilla.org>
 *
 * 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 nsIRequest;
interface nsIRequestObserver;
interface nsITimerCallback;

[scriptable, uuid(56863a67-bd69-42de-9f40-583e625b457d)]
interface nsIUpdatePatch : nsISupports
{
  /**
   *
   */
  attribute AString type;
  /**
   *
   */
  attribute AString url;
  /**
   *
   */
  attribute AString hashfunction;
  /**
   *
   */
  attribute AString hashvalue;
  
  /**
   *
   */
  attribute unsigned long size;
};

[scriptable, uuid(bd75a4c6-b813-45b2-a96e-41a429c857c4)]
interface nsIUpdate : nsISupports
{
  /**
   *
   */
  attribute AString type;
  /**
   *
   */
  attribute AString version;
  /**
   *
   */
  attribute AString extensionversion;
  /**
   *
   */
  attribute AString detailsurl;

  /**
   *
   */
  readonly attribute unsigned long patchCount;
  /**
   *
   */
  nsIUpdatePatch getPatchAt(in unsigned long index);  
};

[scriptable, uuid(8cbceb6e-8e27-46f2-8808-444c6499f836)]
interface nsIUpdateCheckListener : nsISupports
{
  /**
   *
   */
  void onProgress(in nsIRequest request, 
                  in unsigned long position,
                  in unsigned long totalSize);

  /**
   *
   */
  void onCheckComplete([array, size_is(updateCount)] in nsIUpdate updates,
                       in unsigned long updateCount);

  /**
   *
   */
  void onError();
};

[scriptable, uuid(22b00276-ec23-4034-a764-395da539b4be)]
interface nsIUpdatePrompt : nsISupports
{
  /**
   * Shows a user interface that checks for and then displays the available
   * updates.
   */
  void checkForUpdates();

  /**
   * Show a message advising that an update is available for download and
   * install.
   * @param   update
   *          The update to be downloaded and installed
   */
  void showUpdateAvailable(in nsIUpdate update);
};

[scriptable, uuid(877ace25-8bc5-452a-8586-9c1cf2871994)]
interface nsIUpdateChecker : nsISupports
{
  /**
   * Ends any pending update check.
   */
  void stopChecking();
};

[scriptable, uuid(9849c4bf-5197-4d22-baa8-e3b44a1703d2)]
interface nsIApplicationUpdateService : nsISupports
{
  /**
   *
   */
  nsIUpdateChecker checkForUpdates(in nsIUpdateCheckListener listener);

  /**
   * Adds a listener that receives progress and state information about the 
   * update that is currently being downloaded, e.g. to update a user 
   * interface.
   * @param   listener
   *          An object implementing nsIRequestObserver and optionally
   *          nsIProgressEventSink that is to be notified of state and
   *          progress information as the update is downloaded.
   */
  void addDownloadListener(in nsIRequestObserver listener);

  /**
   * Removes a listener that is receiving progress and state information
   * about the update that is currently being downloaded. 
   * @param   listener
   *          The listener object to remove.
   */
  void removeDownloadListener(in nsIRequestObserver listener);

  /**
   * Selects the best update to install from a list of available updates.
   * @param   updates
   *          An array of updates that are available
   * @param   updateCount
   *          The length of the |updates| array
   */
  nsIUpdate selectUpdate([array, size_is(updateCount)] in nsIUpdate updates,
                         in unsigned long updateCount);

  /**
   * 
   */
  void downloadUpdate(in nsIUpdate update);
};

[scriptable, uuid(0765c92c-6145-4253-9db4-594d8023087e)]
interface nsIUpdateTimerManager : nsISupports
{
    /**
     *
     */
    void registerTimer(in AString id, 
                       in nsITimerCallback callback, 
                       in unsigned long interval,
                       in unsigned long type);
};

[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);
};

