/* -*- Mode: idl; 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"

#include "calIRecurrenceItem.idl"

interface calIItemBase;
interface calIDateTime;

// an interface implementing a RRULE

[scriptable, uuid(e965a91a-49fa-41b5-b668-1a824a73bdbf)]
interface calIRecurrenceRule : calIRecurrenceItem
{
  //
  // rule-based recurrence
  //

  // null/"", "SECONDLY", "MINUTELY", "HOURLY", "DAILY", "WEEKLY",
  // "MONTHLY", "YEARLY"
  attribute AUTF8String type;

  // repeat every N of type
  // XXX Please mind an implementation detail:
  // the underlying libical currently only supports C short values for interval,
  // i.e. commonly 16 bits on most platforms, thus please use only 0 <= interval <= 0x7fff.
  // It is open whether we go with IDL short here or tweak libical to support at least 32 bits.
  attribute long interval;

  // These two are mutually exclusive; whichever is set
  // invalidates the other.  It's only valid to read the one
  // that was set; the other will throw NS_ERROR_FAILURE.  Use
  // isByCount to figure out whether count or untilDate is valid.
  // Setting count to -1 or untilDate to null indicates infinite
  // recurrence.
  attribute long count;
  attribute calIDateTime untilDate;

  // if this isn't infinite recurrence, this flag indicates whether
  // it was set by count or not
  readonly attribute boolean isByCount;

  // The week start for this rule, used for certain calculations. This is a
  // value from 0=Sunday to 6=Saturday.
  attribute short weekStart;

  // the components defining the recurrence
  // "BYSECOND", "BYMINUTE", "BYHOUR", "BYDAY",
  // "BYMONTHDAY", "BYYEARDAY", "BYWEEKNO", "BYMONTH",
  // "BYSETPOS"
  void getComponent (in AUTF8String aComponentType,
                     out unsigned long aCount, [array,size_is(aCount),retval] out short aValues);
  void setComponent (in AUTF8String aComponentType,
                     in unsigned long aCount, [array,size_is(aCount)] in short aValues);

};
