calendar/base/public/calIICSService.idl
author seabld
Fri, 16 Sep 2011 17:30:15 -0700
branchSEA_COMM70_20110916_RELBRANCH
changeset 8481 70c91f6afb9ca4e55e12b67bef8bc99c31efa61d
parent 8464 cbfc2237d3f3f43b3e1200763aa32da26677acce
child 12286 84ac3c71109811da751f0ef2d72108075938f094
permissions -rw-r--r--
Added tag SEAMONKEY_2_4b3_RELEASE for changeset b7ed5fe0f2b7. CLOSED TREE a=release

/* -*- Mode: idl; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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 Oracle Corporation code.
 *
 * The Initial Developer of the Original Code is
 *  Oracle Corporation
 * Portions created by the Initial Developer are Copyright (C) 2004
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Mike Shaver <shaver@off.net>
 *   Daniel Boelzle <daniel.boelzle@sun.com>
 *
 * 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 ***** */

// XXX use strings for kind values instead of enumerated constants?


#include "nsISupports.idl"

interface calIItemBase;
interface calIDateTime;
interface calIDuration;
interface calITimezone;
interface calITimezoneProvider;

interface calIIcalProperty;
interface nsIUTF8StringEnumerator;
interface nsIInputStream;

[ptr] native icalpropertyptr(struct icalproperty_impl);
[ptr] native icalcomponentptr(struct icalcomponent_impl);
[ptr] native icaltimezoneptr(struct _icaltimezone);

/**
 * General notes:
 *
 * As with libical, use of getNextFoo(footype) is only valid if there have been
 * no intervening getNextFoo(otherfootype)s, or removeFoo()s, or addFoo()s. In
 * general, you want to do as little manipulation of your FooContainers as
 * possible while iterating over them.
 */
[scriptable,uuid(c4637c40-3c4c-4ecd-b802-8b5b46bdf5a4)]
interface calIIcalComponent : nsISupports
{
    /**
     * This is the value that an integer-valued getter will provide if
     * there is no such property on the wrapped ical structure.
     */
    const PRInt32 INVALID_VALUE = -1;

    /**
     * @param kind ANY, XROOT, VCALENDAR, VEVENT, etc.
     */
    calIIcalComponent getFirstSubcomponent(in AUTF8String componentType);
    calIIcalComponent getNextSubcomponent(in AUTF8String componentType);

    readonly attribute AUTF8String componentType;

    attribute AUTF8String uid;
    attribute AUTF8String prodid;
    attribute AUTF8String version;

    /**
     * PUBLISH, REQUEST, REPLY, etc.
     */
    attribute AUTF8String method;

    /**
     * TENTATIVE, CONFIRMED, CANCELLED, etc.
     */
    attribute AUTF8String status;

    attribute AUTF8String summary;
    attribute AUTF8String description;
    attribute AUTF8String location;
    attribute AUTF8String categories;
    attribute AUTF8String URL;

    attribute PRInt32 priority;

    attribute calIDateTime startTime;
    attribute calIDateTime endTime;
    readonly attribute calIDuration duration;
    attribute calIDateTime dueTime;
    attribute calIDateTime stampTime;

    attribute calIDateTime createdTime;
    attribute calIDateTime completedTime;
    attribute calIDateTime lastModified;

    /**
     * The recurrence ID, a.k.a. DTSTART-of-calculated-occurrence,
     * or null if this isn't an occurrence.
     */
    attribute calIDateTime recurrenceId;

    AUTF8String serializeToICS();

    /**
     * Return a string representation of this instance.
     */
    AUTF8String toString();

    /**
     * Serializes this component (and subcomponents) directly to an
     * input stream.  Typically used for performance to avoid
     * unnecessary conversions and XPConnect traversals.
     *
     * @result     an input stream which can be read to get the serialized
     *             version of this component, encoded in UTF-8.  Implements
     *             nsISeekableStream so that it can be used with
     *             nsIUploadChannel.
     */
    nsIInputStream serializeToICSStream();

    void addSubcomponent(in calIIcalComponent comp);
// If you add then remove a property/component, the referenced
// timezones won't get purged out. There's currently no client code.
//     void removeSubcomponent(in calIIcalComponent comp);

    /**
     * @param kind ANY, ATTENDEE, X-WHATEVER, etc.
     */
    calIIcalProperty getFirstProperty(in AUTF8String kind);
    calIIcalProperty getNextProperty(in AUTF8String kind);
    void addProperty(in calIIcalProperty prop);
// If you add then remove a property/component, the referenced
// timezones won't get purged out. There's currently no client code.
//     void removeProperty(in calIIcalProperty prop);

    /**
     * Timezones need special handling, as they must be
     * emitted as children of VCALENDAR, but can be referenced by
     * any sub component.
     * Adding a second timezone (of the same TZID) will remove the
     * first one.
     */
    void addTimezoneReference(in calITimezone aTimezone);

    /**
     * Returns an array of VTIMEZONE components.
     * These are the timezones that are in use by this
     * component and its children.
     */
    void getReferencedTimezones(out PRUint32 aCount,
                                [array,size_is(aCount),retval] out calITimezone aTimezones);

    /**
     * Clones the component. The cloned component is decoupled from any parent.
     * @return cloned component
     */
    calIIcalComponent clone();

    [noscript,notxpcom] icalcomponentptr getIcalComponent();
    [noscript,notxpcom] icaltimezoneptr getIcalTimezone();
};

[scriptable,uuid(17349a10-5d80-47fa-9bea-f22957357675)]
interface calIIcalProperty : nsISupports
{
    /**
     * The whole property as an ical string.
     * @exception Any libical error will be thrown as an calIError::ICS_ error.
     */
    readonly attribute AUTF8String icalString;

    /**
     * Return a string representation of this instance.
     */
    AUTF8String toString();

    /**
     * The value of the property as string.
     * The exception for properties of TEXT or X- type, those will be unescaped
     * when getting, and also expects an unescaped string when setting.
     * Datetime, numeric and other non-text types are represented as ical string
     */
    attribute AUTF8String value;

    /**
     * The value of the property in (escaped) ical format.
     */
    attribute AUTF8String valueAsIcalString;

    /**
     * The value of the property as date/datetime value, keeping
     * track of the used timezone referenced in the owning component.
     */
    attribute calIDateTime valueAsDatetime;

    // XXX attribute AUTF8String stringValueWithParams; ?
    readonly attribute AUTF8String propertyName;

    AUTF8String getParameter(in AUTF8String paramname);
    void setParameter(in AUTF8String paramname, in AUTF8String paramval);

    AUTF8String getFirstParameterName();
    AUTF8String getNextParameterName();
    /**
     * This does not work with X-PARAMETERS, due to limitations in libical.
     * You have to use clearXParameters() and then rebuild the ones you wanted
     * to preserve.  Sorry about that.
     */
    void removeParameter(in AUTF8String paramname);
    void clearXParameters();

    [noscript,notxpcom] icalpropertyptr getIcalProperty();
    /**
     * Returns the icalcompoment this property belongs to. Please note
     * that the returned object is a raw pointer to the appropriate
     * component and is owned by libical.
     */
    [noscript,notxpcom] icalcomponentptr getIcalComponent();
};

[scriptable,uuid(41fb4cbd-9977-41c7-b179-ab567e4b9395)]
interface calIIcsComponentParsingListener : nsISupports
{
    /**
     * Called when the parsing has completed.
     *
     * @param rc            The result code of parsing
     * @param rootComp      The root ical component that was parsed
     */
    void onParsingComplete(in nsresult rc, in calIIcalComponent rootComp);
};

[scriptable,uuid(ae4ca6c3-981b-4f66-a0ce-2f2c218ad9e3)]
interface calIICSService : nsISupports
{
    /**
     * Parses an ICS string and uses the passed tzProvider instance to
     * resolve timezones not contained withing the VCALENDAR.
     *
     * @param serialized     an ICS string
     * @param tzProvider     timezone provider used to resolve TZIDs
     *                       not contained within the VCALENDAR;
     *                       if null is passed, parsing falls back to
     *                       using the timezone service
     */
    calIIcalComponent parseICS(in AUTF8String serialized,
                               in calITimezoneProvider tzProvider);

    /**
     * Asynchronously parse an ICS string
     *
     * @param serialized     an ICS string
     * @param tzProvider     timezone provider used to resolve TZIDs
     *                       not contained within the VCALENDAR;
     *                       if null is passed, parsing falls back to
     *                       using the timezone service
     * @param listener       The listener that notifies the root component
     */
    void parseICSAsync(in AUTF8String serialized,
                       in calITimezoneProvider tzProvider,
                       in calIIcsComponentParsingListener listener);

    calIIcalComponent createIcalComponent(in AUTF8String kind);
    calIIcalProperty createIcalProperty(in AUTF8String kind);
    /* I wish I could write this function atop libical!
    boolean isLegalParameterValue(in AUTF8String paramKind,
                                  in AUTF8String paramValue);
    */
};