/* -*- 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 "calIItemBase.idl"

//
// calITodo
//
// An interface for a todo item (analogous to a VTODO)
//

[scriptable, uuid(0a93fdad-8a5c-44e9-8f90-16a6df819e03)]
interface calITodo : calIItemBase
{
  const long CAL_TODO_STATUS_NEEDSACTION = 4;
  const long CAL_TODO_STATUS_COMPLETED = 5;
  const long CAL_TODO_STATUS_INPROCESS = 6;

  // as per the rather broken RFC2445,

  // entryDate maps to DTSTART, which is the day
  // this todo shows up on, if set. (optional).
  //
  // dueDate maps to DUE, which is the day
  // this todo is due, if set. (optional).
  //
  // If neither DUE nor DTSTART are set, then
  // the todo appears "today" until it is completed.
  //
  // The completeDate is the date the todo was completed,
  // or null if it hasn't been completed yet.

  attribute calIDateTime entryDate;
  attribute calIDateTime dueDate;
  attribute calIDateTime completedDate;
  attribute short percentComplete;

  // A todo isCompleted if any of the following is true:
  // - percentComplete is 100, or
  // - completedDate is non-null, or
  // - status is COMPLETED.
  // Setting isCompleted to true will
  // - set percentComplete to 100, and
  // - set completedDate to the current time, if it is not already set, and
  // - set status to COMPLETED.
  // Setting isCompleted to false will remove percentComplete, completedDate,
  // and status properties.  (This returns the todo to its state at creation,
  // in terms of completion-relevant properties.)
  //
  // If you would like to take advantage of the full, confusing disaster that
  // is the RFC2445 VTODO status state space, you can feel free to set the
  // fields individually, instead of setting isCompleted directly.  (And then
  // hope that whatever else you're talking to has the same set of rules for
  // determining if something is completed or not.)
  //
  // Setting percentComplete, completedDate, or status individually does not
  // affect any of the others at present.  (E.g., setting the percentComplete
  // from 100 to 50 doesn't clear completedDate, or change status to
  // IN-PROCESS.)  It's not clear that we want any more magic than a simple
  // property to control "all complete" vs "not complete in any way".
  attribute boolean isCompleted;

  /**
   * The duration of the todo, which is either set or defined as
   * dueDate - entryDate.
   * Please note that null is returned if there is no duration set and entry
   * Date or dueDate don't exist.
   */
  attribute calIDuration duration;
};
