/* 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 calICalendar;
interface nsIURI;
interface nsIVariant;

interface calICalendarManagerObserver;

[scriptable, uuid(43a71d40-7807-4e2f-b741-2926ee73f89a)]
interface calICalendarManager : nsISupports
{
  /**
   * Gives the number of registered calendars that require network access.
   */
  readonly attribute PRUint32 networkCalendarCount;

  /***
   * Gives the number of registered readonly calendars.
   */
  readonly attribute PRUint32 readOnlyCalendarCount;

  /**
   * Gives the number of registered calendars
   */
  readonly attribute PRUint32 calendarCount;
  /* 
   * create a new calendar
   * aType is the type ("caldav", "storage", etc)
   */
  calICalendar createCalendar(in AUTF8String aType, in nsIURI aURL);

  /* register a newly created calendar with the calendar service */
  void registerCalendar(in calICalendar aCalendar);

  /* unregister a calendar */
  void unregisterCalendar(in calICalendar aCalendar);

  /* delete a calendar for good */
  void deleteCalendar(in calICalendar aCalendar);

  /* get a calendar by its id */
  calICalendar getCalendarById(in AUTF8String aId);

  /* return a list of all calendars currently registered */
  void getCalendars(out PRUint32 count,
                    [array, size_is(count), retval] out calICalendar aCalendars);


  /* XXX private, don't use:
         will vanish as soon as providers will directly read/write from moz prefs
  */
  nsIVariant getCalendarPref_(in calICalendar aCalendar,
                              in AUTF8String aName);
  void setCalendarPref_(in calICalendar aCalendar,
                        in nsIVariant aName,
                        in nsIVariant aValue);
  void deleteCalendarPref_(in calICalendar aCalendar,
                           in AUTF8String aName);
  
  void addObserver(in calICalendarManagerObserver aObserver);
  void removeObserver(in calICalendarManagerObserver aObserver);
};

[scriptable, uuid(383f36f1-e669-4ca4-be7f-06b43910f44a)]
interface calICalendarManagerObserver : nsISupports
{
  // called after the calendar is registered
  void onCalendarRegistered(in calICalendar aCalendar);

  // called before the unregister actually takes place
  void onCalendarUnregistering(in calICalendar aCalendar);

  // called before the delete actually takes place
  void onCalendarDeleting(in calICalendar aCalendar);
};
