/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIURI;
interface nsIArray;
interface nsICRLInfo;

%{C++
#define NS_CRLMANAGER_CID { /* 5b256c10-22d8-4109-af92-1253035e9fcb */ \
    0x5b256c10, \
    0x22d8, \
    0x4109, \
    {0xaf, 0x92, 0x12, 0x53, 0x03, 0x5e, 0x9f, 0xcb} \
  }

#define NS_CRLMANAGER_CONTRACTID "@mozilla.org/security/crlmanager;1"
%}



[scriptable, uuid(486755db-627a-4678-a21b-f6a63bb9c56a)]
interface nsICRLManager : nsISupports {
  /*
   * importCrl
   *
   * Import a CRL into the certificate database.
   */
  void importCrl([array, size_is(length)] in octet data,
                 in unsigned long length,
                 in nsIURI uri,
                 in unsigned long type,
                 in boolean doSilentDownload,
                 in wstring crlKey);

  
  /*
   * update crl from url
   * update an existing crl from the last fetched url. Needed for the update
   * button in crl manager
   */
  boolean updateCRLFromURL(in wstring url, in wstring key);


  /*
   * getCrls
   *
   * Get a list of Crl entries in the DB.
   */
  nsIArray getCrls();

  /*
   * deleteCrl
   *
   * Delete the crl.
   */
  void deleteCrl(in unsigned long crlIndex);


  /* This would reschedule the autoupdate of crls with auto update enable.
   * Most likely to be called when update prefs are changed, or when a crl
   * is deleted, etc. However, this might not be the most relevant place for
   * this api, but unless we have a separate crl handler object....
   */
  void rescheduleCRLAutoUpdate();


  const unsigned long TYPE_AUTOUPDATE_TIME_BASED     = 1;
  const unsigned long TYPE_AUTOUPDATE_FREQ_BASED     = 2;

  wstring computeNextAutoUpdateTime(in nsICRLInfo info,
                                    in unsigned long autoUpdateType,
                                    in double noOfDays);
};
