Back to index

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

#include <calICSService.h>

Inheritance diagram for calIcalProperty:
Inheritance graph
Collaboration diagram for calIcalProperty:
Collaboration graph

List of all members.

Public Member Functions

 calIcalProperty (icalproperty *prop, calIIcalComponent *parent)
AUTF8String toString ()
 Return a string representation of this instance.
AUTF8String getParameter (in AUTF8String paramname)
void setParameter (in AUTF8String paramname, in AUTF8String paramval)
AUTF8String getFirstParameterName ()
AUTF8String getNextParameterName ()
void removeParameter (in AUTF8String paramname)
 This does not work with X-PARAMETERS, due to limitations in libical.
void clearXParameters ()
icalpropertyptr getIcalProperty ()
icalcomponentptr getIcalComponent ()
 Returns the icalcompoment this property belongs to.

Public Attributes

readonly attribute AUTF8String icalString
 The whole property as an ical string.
attribute AUTF8String value
 The value of the property as string.
attribute AUTF8String valueAsIcalString
 The value of the property in (escaped) ical format.
attribute calIDateTime valueAsDatetime
 The value of the property as date/datetime value, keeping track of the used timezone referenced in the owning component.
readonly attribute AUTF8String propertyName

Protected Member Functions

virtual ~calIcalProperty ()

Static Protected Member Functions

static nsresult getDatetime_ (calIcalComponent *parent, icalproperty *prop, calIDateTime **dtp)
static nsresult setDatetime_ (calIcalComponent *parent, icalproperty *prop, calIDateTime *dt)

Protected Attributes

icalproperty * mProperty
nsCOMPtr< calIIcalComponentmParent


class calIcalComponent

Detailed Description

Definition at line 63 of file calICSService.h.

Constructor & Destructor Documentation

calIcalProperty::calIcalProperty ( icalproperty *  prop,
calIIcalComponent parent 
) [inline]

Definition at line 68 of file calICSService.h.

        : mProperty(prop), mParent(parent) {}
calIcalProperty::~calIcalProperty ( ) [protected, virtual]

Definition at line 54 of file calICSService.cpp.

Here is the call graph for this function:

Member Function Documentation

nsresult calIcalProperty::getDatetime_ ( calIcalComponent parent,
icalproperty *  prop,
calIDateTime **  dtp 
) [static, protected]

Definition at line 363 of file calICSService.cpp.

    icalvalue * const val = icalproperty_get_value(prop);
    icalvalue_kind const valkind = icalvalue_isa(val);
    if (valkind != ICAL_DATETIME_VALUE && valkind != ICAL_DATE_VALUE) {
        return NS_ERROR_UNEXPECTED;
    icaltimetype itt = icalvalue_get_datetime(val);

    char const* tzid_ = nsnull;
    if (!itt.is_utc) {
        if ( {
            tzid_ = icaltimezone_get_tzid(const_cast<icaltimezone *>(;
        } else {
            // Need to get the tzid param. Unfortunatly, libical tends to return raw
            // ics strings, with quotes and everything. That's not what we want. Need
            // to work around.
            icalparameter * const tzparam = icalproperty_get_first_parameter(prop, ICAL_TZID_PARAMETER);
            if (tzparam) {
                tzid_ = icalparameter_get_xvalue(tzparam);

    nsCOMPtr<calITimezone> tz;
    if (tzid_) {
        nsDependentCString const tzid(tzid_);
        calIcalComponent * comp = nsnull;
        if (parent) {
            comp = parent->getParentVCalendarOrThis();
        // look up parent if timezone is already referenced:
        if (comp) {
            comp->mReferencedTimezones.Get(tzid, getter_AddRefs(tz));
        if (!tz) {
            if (parent) {
                // passed tz provider has precedence over timezone service:
                calITimezoneProvider * const tzProvider = parent->getTzProvider();
                if (tzProvider) {
                    tzProvider->GetTimezone(tzid, getter_AddRefs(tz));
                    NS_ASSERTION(tz, tzid_);
            if (!tz) {
                // look up tz in tz service.
                // this hides errors from incorrect ics files, which could state
                // a TZID that is not present in the ics file.
                // The other way round, it makes this product more error tolerant.
                cal::getTimezoneService()->GetTimezone(tzid, getter_AddRefs(tz));

                if (!tz) {
                    icaltimezone const* zone =;
                    if (!zone && comp) {
                        // look up parent VCALENDAR for VTIMEZONE:
                        zone = icalcomponent_get_timezone(comp->mComponent, tzid_);
                        NS_ASSERTION(zone, tzid_);
                    if (zone) {
                        // We need to decouple this (inner) VTIMEZONE from the parent VCALENDAR to avoid
                        // running into circular references (referenced timezones):
                        icaltimezone * const clonedZone = icaltimezone_new();
                        icalcomponent * const clonedZoneComp =
                            icalcomponent_new_clone(icaltimezone_get_component(const_cast<icaltimezone *>(zone)));
                        if (!clonedZoneComp) {
                            icaltimezone_free(clonedZone, 1 /* free struct */);
                        if (!icaltimezone_set_component(clonedZone, clonedZoneComp)) {
                            icaltimezone_free(clonedZone, 1 /* free struct */);
                            return NS_ERROR_INVALID_ARG;
                        nsCOMPtr<calIIcalComponent> const tzComp(new calIcalComponent(clonedZone, clonedZoneComp));
                        tz = new calTimezone(tzid, tzComp);
            if (comp && tz) {
                // assure timezone is known:
        if (tz) {
            // correct itt which would else appear floating:
   = cal::getIcalTimezone(tz);
            itt.is_utc = 0;
        } else {
    *dtp = new calDateTime(&itt, tz);
    return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

AUTF8String calIIcalProperty::getFirstParameterName ( ) [inherited]

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.

AUTF8String calIIcalProperty::getNextParameterName ( ) [inherited]
AUTF8String calIIcalProperty::getParameter ( in AUTF8String  paramname) [inherited]
void calIIcalProperty::removeParameter ( in AUTF8String  paramname) [inherited]

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.

nsresult calIcalProperty::setDatetime_ ( calIcalComponent parent,
icalproperty *  prop,
calIDateTime dt 
) [static, protected]

Definition at line 757 of file calICSService.cpp.


    icaltimetype itt;

    if (parent) {
        if (!itt.is_utc && {
            nsCOMPtr<calITimezone> tz;
            nsresult rv = dt->GetTimezone(getter_AddRefs(tz));
            NS_ENSURE_SUCCESS(rv, rv);
            rv = parent->getParentVCalendarOrThis()->AddTimezoneReference(tz);
            NS_ENSURE_SUCCESS(rv, rv);
            icalparameter * const param = icalparameter_new_from_value_string(
                ICAL_TZID_PARAMETER, icaltimezone_get_tzid(const_cast<icaltimezone *>(;
            icalproperty_set_parameter(prop, param);
    } else if (!itt.is_date && !itt.is_utc && {
        // no parent to add the CTIMEZONE to: coerce DATETIMEs to UTC, DATEs to floating
                                  const_cast<icaltimezone *>(,
                                  icaltimezone_get_utc_timezone()); = icaltimezone_get_utc_timezone();
        itt.is_utc = 1;

    icalvalue * const val = icalvalue_new_datetime(itt);
    icalproperty_set_value(prop, val);
    return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

void calIIcalProperty::setParameter ( in AUTF8String  paramname,
in AUTF8String  paramval 
) [inherited]
AUTF8String calIIcalProperty::toString ( ) [inherited]

Return a string representation of this instance.

Friends And Related Function Documentation

friend class calIcalComponent [friend]

Definition at line 66 of file calICSService.h.

Member Data Documentation

readonly attribute AUTF8String calIIcalProperty::icalString [inherited]

The whole property as an ical string.

Anylibical error will be thrown as an calIError::ICS_ error.

Definition at line 200 of file calIICSService.idl.

Definition at line 85 of file calICSService.h.

icalproperty* calIcalProperty::mProperty [protected]

Definition at line 84 of file calICSService.h.

readonly attribute AUTF8String calIIcalProperty::propertyName [inherited]

Definition at line 227 of file calIICSService.idl.

attribute AUTF8String calIIcalProperty::value [inherited]

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

Definition at line 213 of file calIICSService.idl.

The value of the property as date/datetime value, keeping track of the used timezone referenced in the owning component.

Definition at line 224 of file calIICSService.idl.

The value of the property in (escaped) ical format.

Definition at line 218 of file calIICSService.idl.

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