Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
calIcalComponent Class Reference

#include <calICSService.h>

Inheritance diagram for calIcalComponent:
Inheritance graph
[legend]
Collaboration diagram for calIcalComponent:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 calIcalComponent (icalcomponent *ical, calIIcalComponent *parent, calITimezoneProvider *tzProvider=nsnull)
 calIcalComponent (icaltimezone *icaltz, icalcomponent *ical)
calIIcalComponent getFirstSubcomponent (in AUTF8String componentType)
calIIcalComponent getNextSubcomponent (in AUTF8String componentType)
AUTF8String serializeToICS ()
AUTF8String toString ()
 Return a string representation of this instance.
nsIInputStream serializeToICSStream ()
 Serializes this component (and subcomponents) directly to an input stream.
void addSubcomponent (in calIIcalComponent comp)
calIIcalProperty getFirstProperty (in AUTF8String kind)
calIIcalProperty getNextProperty (in AUTF8String kind)
void addProperty (in calIIcalProperty prop)
void addTimezoneReference (in calITimezone aTimezone)
 Timezones need special handling, as they must be emitted as children of VCALENDAR, but can be referenced by any sub component.
void getReferencedTimezones (out PRUint32 aCount,[array, size_is(aCount), retval] out calITimezone aTimezones)
 Returns an array of VTIMEZONE components.
calIIcalComponent clone ()
 Clones the component.
icalcomponentptr getIcalComponent ()
icaltimezoneptr getIcalTimezone ()

Public Attributes

const PRInt32 INVALID_VALUE = -1
 This is the value that an integer-valued getter will provide if there is no such property on the wrapped ical structure.
readonly attribute AUTF8String componentType
attribute AUTF8String uid
attribute AUTF8String prodid
attribute AUTF8String version
attribute AUTF8String method
 PUBLISH, REQUEST, REPLY, etc.
attribute AUTF8String status
 TENTATIVE, CONFIRMED, CANCELLED, etc.
attribute AUTF8String transp
 OPAQUE, TRANSPARENT, etc.
attribute AUTF8String summary
attribute AUTF8String description
attribute AUTF8String location
attribute AUTF8String categories
attribute AUTF8String URL
attribute PRInt32 priority
attribute AUTF8String icalClass
 PUBLIC, PRIVATE, CONFIDENTIAL, etc.
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
attribute calIDateTime recurrenceId
 The recurrence ID, a.k.a.

Protected Member Functions

virtual ~calIcalComponent ()
calITimezoneProvidergetTzProvider () const
calIcalComponentgetParentVCalendarOrThis ()
nsresult GetDateTimeAttribute (icalproperty_kind kind, calIDateTime **dtp)
nsresult SetDateTimeAttribute (icalproperty_kind kind, calIDateTime *dt)
nsresult SetPropertyValue (icalproperty_kind kind, icalvalue *val)
nsresult SetProperty (icalproperty_kind kind, icalproperty *prop)
nsresult GetStringProperty (icalproperty_kind kind, nsACString &str)
nsresult SetStringProperty (icalproperty_kind kind, const nsACString &str)
nsresult GetIntProperty (icalproperty_kind kind, PRInt32 *valp)
nsresult SetIntProperty (icalproperty_kind kind, PRInt32 i)
void ClearAllProperties (icalproperty_kind kind)
nsresult Serialize (char **icalstr)

Protected Attributes

nsInterfaceHashtable
< nsCStringHashKey,
calITimezone
mReferencedTimezones
icalcomponent * mComponent
icaltimezone * mTimezone
nsCOMPtr< calITimezoneProvider >
const 
mTzProvider
nsCOMPtr< calIIcalComponentmParent

Friends

class calIcalProperty

Detailed Description

Definition at line 88 of file calICSService.h.


Constructor & Destructor Documentation

calIcalComponent::calIcalComponent ( icalcomponent *  ical,
calIIcalComponent parent,
calITimezoneProvider tzProvider = nsnull 
) [inline]

Definition at line 93 of file calICSService.h.

        : mComponent(ical), mTimezone(nsnull), mTzProvider(tzProvider), mParent(parent)
    {
        mReferencedTimezones.Init();
    }

Here is the call graph for this function:

calIcalComponent::calIcalComponent ( icaltimezone *  icaltz,
icalcomponent *  ical 
) [inline]

Definition at line 101 of file calICSService.h.

                                                                  : mComponent(ical), mTimezone(icaltz) {
        mReferencedTimezones.Init();
    }

Here is the call graph for this function:

calIcalComponent::~calIcalComponent ( ) [protected, virtual]

Definition at line 465 of file calICSService.cpp.

{
    if (!mParent) {
        // We free either a plain icalcomponent or a icaltimezone.
        // In the latter case icaltimezone_free frees the VTIMEZONE component.
        if (mTimezone) {
            icaltimezone_free(mTimezone, 1 /* free struct */);
        } else {
            icalcomponent_free(mComponent);
        }
    }
}

Here is the call graph for this function:


Member Function Documentation

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.

Definition at line 938 of file calICSService.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Clones the component.

The cloned component is decoupled from any parent.

Returns:
cloned component

Definition at line 720 of file calICSService.cpp.

{
    NS_ENSURE_ARG_POINTER(dtp);
    icalproperty *prop = icalcomponent_get_first_property(mComponent, kind);
    if (!prop) {
        *dtp = nsnull;  /* invalid date */
        return NS_OK;
    }
    return calIcalProperty::getDatetime_(this, prop, dtp);
}

Here is the call graph for this function:

calIIcalProperty calIIcalComponent::getFirstProperty ( in AUTF8String  kind) [inherited]
Parameters:
kindANY, ATTENDEE, X-WHATEVER, etc.
calIIcalComponent calIIcalComponent::getFirstSubcomponent ( in AUTF8String  componentType) [inherited]
Parameters:
kindANY, XROOT, VCALENDAR, VEVENT, etc.

Definition at line 702 of file calICSService.cpp.

{
    icalproperty *prop = icalcomponent_get_first_property(mComponent, kind);
    if (!prop)
        *valp = calIIcalComponent::INVALID_VALUE;
    else
        *valp = (PRInt32)icalvalue_get_integer(icalproperty_get_value(prop));
    return NS_OK;
}

Here is the call graph for this function:

calIIcalProperty calIIcalComponent::getNextProperty ( in AUTF8String  kind) [inherited]
calIIcalComponent calIIcalComponent::getNextSubcomponent ( in AUTF8String  componentType) [inherited]

Definition at line 125 of file calICSService.h.

                                                  {
        // walk up the parents to find a VCALENDAR:
        calIcalComponent * that = this;
        while (that && icalcomponent_isa(that->mComponent) != ICAL_VCALENDAR_COMPONENT) {
            calIIcalComponent * const p = that->mParent;
            that = static_cast<calIcalComponent *>(p);
        }
        if (!that)
            that = this;
        return that;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void calIIcalComponent::getReferencedTimezones ( out PRUint32  aCount,
[array, size_is(aCount), retval] out calITimezone  aTimezones 
) [inherited]

Returns an array of VTIMEZONE components.

These are the timezones that are in use by this component and its children.

nsresult calIcalComponent::GetStringProperty ( icalproperty_kind  kind,
nsACString &  str 
) [protected]

Definition at line 678 of file calICSService.cpp.

{
    icalproperty *prop = icalcomponent_get_first_property(mComponent, kind);
    if (!prop) {
        str.Truncate();
        str.SetIsVoid(PR_TRUE);
    } else {
        str.Assign(icalvalue_get_string(icalproperty_get_value(prop)));
    }
    return NS_OK;
}

Here is the call graph for this function:

calITimezoneProvider* calIcalComponent::getTzProvider ( ) const [inline, protected]

Definition at line 111 of file calICSService.h.

                                                 {
        // walk up the parents to find a tz provider:
        calIcalComponent const * that = this;
        while (that) {
            calITimezoneProvider * const ret = that->mTzProvider;
            if (ret) {
                return ret;
            }
            calIIcalComponent * const p = that->mParent;
            that = static_cast<calIcalComponent const *>(p);
        }
        return nsnull;
    }

Here is the caller graph for this function:

nsresult calIcalComponent::Serialize ( char **  icalstr) [protected]

Definition at line 1003 of file calICSService.cpp.

{
    NS_ENSURE_ARG_POINTER(icalstr);

    // add the timezone bits
    if (icalcomponent_isa(mComponent) == ICAL_VCALENDAR_COMPONENT && mReferencedTimezones.Count() > 0) {
        mReferencedTimezones.EnumerateRead(AddTimezoneComponentToIcal, mComponent);
    }

    *icalstr = icalcomponent_as_ical_string(mComponent);
    if (!*icalstr) {
        // xxx todo: what about NS_ERROR_OUT_OF_MEMORY?
#ifdef DEBUG
        fprintf(stderr, "Error serializing: %d (%s)\n",
                icalerrno, icalerror_strerror(icalerrno));
#endif
        // The return values in calIError match with libical errnos,
        // so no need for a conversion table or anything.
        return calIErrors::ICS_ERROR_BASE + icalerrno;
    }

    return NS_OK;
}

Here is the call graph for this function:

AUTF8String calIIcalComponent::serializeToICS ( ) [inherited]

Serializes this component (and subcomponents) directly to an input stream.

Typically used for performance to avoid unnecessary conversions and XPConnect traversals.

Returns:
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.

Definition at line 732 of file calICSService.cpp.

{
    ClearAllProperties(kind);
    PRBool isValid;
    if (!dt || NS_FAILED(dt->GetIsValid(&isValid)) || !isValid) {
        return NS_OK;
    }
    icalproperty *prop = icalproperty_new(kind);
    CAL_ENSURE_MEMORY(prop);
    nsresult rc = calIcalProperty::setDatetime_(this, prop, dt);
    if (NS_SUCCEEDED(rc))
        icalcomponent_add_property(mComponent, prop);
    else
        icalproperty_free(prop);
    return rc;
}

Here is the call graph for this function:

Definition at line 712 of file calICSService.cpp.

{
    icalvalue *val = icalvalue_new_integer(i);
    if (!val)
        return NS_ERROR_OUT_OF_MEMORY;
    return SetPropertyValue(kind, val);
}

Here is the call graph for this function:

nsresult calIcalComponent::SetProperty ( icalproperty_kind  kind,
icalproperty *  prop 
) [protected]

Definition at line 543 of file calICSService.cpp.

{
    ClearAllProperties(kind);
    if (!prop)
        return NS_OK;
    icalcomponent_add_property(mComponent, prop);
    return NS_OK;
}

Here is the call graph for this function:

nsresult calIcalComponent::SetPropertyValue ( icalproperty_kind  kind,
icalvalue *  val 
) [protected]

Definition at line 525 of file calICSService.cpp.

{
    ClearAllProperties(kind);
    if (!val)
        return NS_OK;

    icalproperty *prop = icalproperty_new(kind);
    if (!prop) {
        icalvalue_free(val);
        return NS_ERROR_OUT_OF_MEMORY;
    }

    icalproperty_set_value(prop, val);
    icalcomponent_add_property(mComponent, prop);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult calIcalComponent::SetStringProperty ( icalproperty_kind  kind,
const nsACString &  str 
) [protected]

Definition at line 690 of file calICSService.cpp.

{
    icalvalue *val = nsnull;
    if (!str.IsVoid()) {
        val = icalvalue_new_string(PromiseFlatCString(str).get());
        if (!val)
            return NS_ERROR_OUT_OF_MEMORY;
    }
    return SetPropertyValue(kind, val);
}

Here is the call graph for this function:

AUTF8String calIIcalComponent::toString ( ) [inherited]

Return a string representation of this instance.


Friends And Related Function Documentation

friend class calIcalProperty [friend]

Definition at line 91 of file calICSService.h.


Member Data Documentation

attribute AUTF8String calIIcalComponent::categories [inherited]

Definition at line 106 of file calIICSService.idl.

Definition at line 123 of file calIICSService.idl.

readonly attribute AUTF8String calIIcalComponent::componentType [inherited]

Definition at line 82 of file calIICSService.idl.

Definition at line 122 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::description [inherited]

Definition at line 104 of file calIICSService.idl.

Definition at line 119 of file calIICSService.idl.

Definition at line 118 of file calIICSService.idl.

Definition at line 117 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::icalClass [inherited]

PUBLIC, PRIVATE, CONFIDENTIAL, etc.

Definition at line 114 of file calIICSService.idl.

This is the value that an integer-valued getter will provide if there is no such property on the wrapped ical structure.

Definition at line 74 of file calIICSService.idl.

Definition at line 124 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::location [inherited]

Definition at line 105 of file calIICSService.idl.

icalcomponent* calIcalComponent::mComponent [protected]

Definition at line 154 of file calICSService.h.

attribute AUTF8String calIIcalComponent::method [inherited]

PUBLISH, REQUEST, REPLY, etc.

Definition at line 91 of file calIICSService.idl.

Definition at line 157 of file calICSService.h.

Definition at line 153 of file calICSService.h.

icaltimezone* calIcalComponent::mTimezone [protected]

Definition at line 155 of file calICSService.h.

Definition at line 156 of file calICSService.h.

Definition at line 109 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::prodid [inherited]

Definition at line 85 of file calIICSService.idl.

The recurrence ID, a.k.a.

DTSTART-of-calculated-occurrence, or null if this isn't an occurrence.

Definition at line 130 of file calIICSService.idl.

Definition at line 120 of file calIICSService.idl.

Definition at line 116 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::status [inherited]

TENTATIVE, CONFIRMED, CANCELLED, etc.

Definition at line 96 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::summary [inherited]

Definition at line 103 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::transp [inherited]

OPAQUE, TRANSPARENT, etc.

Definition at line 101 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::uid [inherited]

Definition at line 84 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::URL [inherited]

Definition at line 107 of file calIICSService.idl.

attribute AUTF8String calIIcalComponent::version [inherited]

Definition at line 86 of file calIICSService.idl.


The documentation for this class was generated from the following files: