Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
calICSService.cpp File Reference
#include "nsStringStream.h"
#include "nsComponentManagerUtils.h"
#include "nsIClassInfoImpl.h"
#include "calICSService.h"
#include "calTimezone.h"
#include "calDateTime.h"
#include "calDuration.h"
#include "calIErrors.h"
#include "ical.h"

Go to the source code of this file.

Defines

#define COMP_STRING_TO_GENERAL_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname)
#define COMP_STRING_TO_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname)
#define COMP_GENERAL_STRING_ATTRIBUTE(Attrname, ICALNAME)
#define COMP_STRING_ATTRIBUTE(Attrname, ICALNAME, lcname)
#define COMP_GENERAL_INT_ATTRIBUTE(Attrname, ICALNAME)
#define COMP_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname)
#define COMP_INT_ATTRIBUTE(Attrname, ICALNAME, lcname)
#define RO_COMP_DATE_ATTRIBUTE(Attrname, ICALNAME)
#define COMP_DATE_ATTRIBUTE(Attrname, ICALNAME)
#define RO_COMP_DURATION_ATTRIBUTE(Attrname, ICALNAME)

Functions

static icalparameter * FindXParameter (icalproperty *prop, const nsACString &param)
static nsresult FillParameterName (icalparameter *icalparam, nsACString &name)
 TimezoneHashToTimezoneArray (nsACString const &, calITimezone *tz, void *arg)
 AddTimezoneComponentToIcal (nsACString const &, calITimezone *tz, void *arg)

Define Documentation

#define COMP_DATE_ATTRIBUTE (   Attrname,
  ICALNAME 
)
Value:
RO_COMP_DATE_ATTRIBUTE(Attrname, ICALNAME)                              \
                                                                        \
NS_IMETHODIMP                                                           \
calIcalComponent::Set##Attrname(calIDateTime *dt)                       \
{                                                                       \
    return SetDateTimeAttribute(ICAL_##ICALNAME##_PROPERTY, dt);        \
}

Definition at line 800 of file calICSService.cpp.

#define COMP_ENUM_ATTRIBUTE (   Attrname,
  ICALNAME,
  lcname 
)
Value:
NS_IMETHODIMP                                                   \
calIcalComponent::Get##Attrname(PRInt32 *valp)                  \
{                                                               \
    return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp);    \
}                                                               \
                                                                \
NS_IMETHODIMP                                                   \
calIcalComponent::Set##Attrname(PRInt32 val)                    \
{                                                               \
    icalproperty *prop =                                        \
      icalproperty_new_##lcname((icalproperty_##lcname)val);    \
    return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop);       \
}                                                               \

Definition at line 649 of file calICSService.cpp.

#define COMP_GENERAL_INT_ATTRIBUTE (   Attrname,
  ICALNAME 
)
Value:
NS_IMETHODIMP                                                   \
calIcalComponent::Get##Attrname(PRInt32 *valp)                  \
{                                                               \
    return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp);    \
}                                                               \
                                                                \
NS_IMETHODIMP                                                   \
calIcalComponent::Set##Attrname(PRInt32 val)                    \
{                                                               \
    return SetIntProperty(ICAL_##ICALNAME##_PROPERTY, val);     \
}                                                               \

Definition at line 636 of file calICSService.cpp.

#define COMP_GENERAL_STRING_ATTRIBUTE (   Attrname,
  ICALNAME 
)
Value:
NS_IMETHODIMP                                                   \
calIcalComponent::Get##Attrname(nsACString &str)                \
{                                                               \
    return GetStringProperty(ICAL_##ICALNAME##_PROPERTY, str);  \
}                                                               \
                                                                \
NS_IMETHODIMP                                                   \
calIcalComponent::Set##Attrname(const nsACString &str)          \
{                                                               \
    return SetStringProperty(ICAL_##ICALNAME##_PROPERTY, str);  \
}

Definition at line 608 of file calICSService.cpp.

#define COMP_INT_ATTRIBUTE (   Attrname,
  ICALNAME,
  lcname 
)
Value:
NS_IMETHODIMP                                                   \
calIcalComponent::Get##Attrname(PRInt32 *valp)                  \
{                                                               \
    return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp);    \
}                                                               \
                                                                \
NS_IMETHODIMP                                                   \
calIcalComponent::Set##Attrname(PRInt32 val)                    \
{                                                               \
    icalproperty *prop = icalproperty_new_##lcname(val);        \
    return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop);       \
}                                                               \

Definition at line 664 of file calICSService.cpp.

#define COMP_STRING_ATTRIBUTE (   Attrname,
  ICALNAME,
  lcname 
)
Value:
NS_IMETHODIMP                                                   \
calIcalComponent::Get##Attrname(nsACString &str)                \
{                                                               \
    return GetStringProperty(ICAL_##ICALNAME##_PROPERTY, str);  \
}                                                               \
                                                                \
NS_IMETHODIMP                                                   \
calIcalComponent::Set##Attrname(const nsACString &str)          \
{                                                               \
    icalproperty *prop =                                        \
        icalproperty_new_##lcname(PromiseFlatCString(str).get()); \
    return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop);       \
}

Definition at line 621 of file calICSService.cpp.

#define COMP_STRING_TO_ENUM_ATTRIBUTE (   Attrname,
  ICALNAME,
  lcname 
)
Value:
NS_IMETHODIMP                                                           \
calIcalComponent::Get##Attrname(nsACString &str)                        \
{                                                                       \
    PRInt32 val;                                                        \
    nsresult rv = GetIntProperty(ICAL_##ICALNAME##_PROPERTY, &val);     \
    if (NS_FAILED(rv))                                                  \
        return rv;                                                      \
    if (val == -1) {                                                    \
        str.Truncate();                                                 \
        str.SetIsVoid(PR_TRUE);                                         \
    } else {                                                            \
        str.Assign(icalproperty_##lcname##_to_string((icalproperty_##lcname)val)); \
    }                                                                   \
    return NS_OK;                                                       \
}                                                                       \
                                                                        \
NS_IMETHODIMP                                                           \
calIcalComponent::Set##Attrname(const nsACString &str)                  \
{                                                                       \
    icalproperty *prop = nsnull;                                        \
    if (!str.IsVoid()) {                                                \
        icalproperty_##lcname val =                                     \
            icalproperty_string_to_##lcname(PromiseFlatCString(str).get()); \
        prop = icalproperty_new_##lcname(val);                          \
        if (!prop)                                                      \
            return NS_ERROR_OUT_OF_MEMORY; /* XXX map errno */          \
    }                                                                   \
    return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop);               \
}                                                                       \

Definition at line 577 of file calICSService.cpp.

#define COMP_STRING_TO_GENERAL_ENUM_ATTRIBUTE (   Attrname,
  ICALNAME,
  lcname 
)
Value:
NS_IMETHODIMP                                                           \
calIcalComponent::Get##Attrname(nsACString &str)                        \
{                                                                       \
    PRInt32 val;                                                        \
    nsresult rv = GetIntProperty(ICAL_##ICALNAME##_PROPERTY, &val);     \
    if (NS_FAILED(rv))                                                  \
        return rv;                                                      \
    if (val == -1) {                                                    \
        str.Truncate();                                                 \
        str.SetIsVoid(PR_TRUE);                                         \
    } else {                                                            \
        str.Assign(icalproperty_enum_to_string(val));                   \
    }                                                                   \
    return NS_OK;                                                       \
}                                                                       \
                                                                        \
NS_IMETHODIMP                                                           \
calIcalComponent::Set##Attrname(const nsACString &str)                  \
{                                                                       \
    int val = icalproperty_string_to_enum(PromiseFlatCString(str).get()); \
    icalvalue *ival = icalvalue_new_##lcname((icalproperty_##lcname)val); \
    return SetPropertyValue(ICAL_##ICALNAME##_PROPERTY, ival);          \
}                                                                       \

Definition at line 552 of file calICSService.cpp.

#define RO_COMP_DATE_ATTRIBUTE (   Attrname,
  ICALNAME 
)
Value:
NS_IMETHODIMP                                                           \
calIcalComponent::Get##Attrname(calIDateTime **dtp)                     \
{                                                                       \
    return GetDateTimeAttribute(ICAL_##ICALNAME##_PROPERTY, dtp);       \
}

Definition at line 793 of file calICSService.cpp.

#define RO_COMP_DURATION_ATTRIBUTE (   Attrname,
  ICALNAME 
)
Value:
NS_IMETHODIMP                                                           \
calIcalComponent::Get##Attrname(calIDuration **dtp)                     \
{                                                                       \
    icalproperty *prop =                                                \
        icalcomponent_get_first_property(mComponent,                    \
                                         ICAL_##ICALNAME##_PROPERTY);   \
    if (!prop) {                                                        \
        *dtp = nsnull;  /* invalid duration */                          \
        return NS_OK;                                                   \
    }                                                                   \
    struct icaldurationtype idt =                                       \
        icalvalue_get_duration(icalproperty_get_value(prop));           \
    *dtp = new calDuration(&idt);                                       \
    CAL_ENSURE_MEMORY(*dtp);                                            \
    NS_ADDREF(*dtp);                                                    \
    return NS_OK;                                                       \
}

Definition at line 809 of file calICSService.cpp.


Function Documentation

AddTimezoneComponentToIcal ( nsACString const ,
calITimezone tz,
void arg 
)

Definition at line 950 of file calICSService.cpp.

{
    icalcomponent * const comp = static_cast<icalcomponent *>(arg);
    icaltimezone * icaltz = cal::getIcalTimezone(tz);
    if (icaltz) {
        icalcomponent * const tzcomp = icalcomponent_new_clone(icaltimezone_get_component(icaltz));
        icalcomponent_add_component(comp, tzcomp);
    }
    return PL_DHASH_NEXT;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult FillParameterName ( icalparameter *  icalparam,
nsACString &  name 
) [static]

Definition at line 290 of file calICSService.cpp.

{
    const char *propname = nsnull;
    if (icalparam) {
        icalparameter_kind paramkind = icalparameter_isa(icalparam);
        if (paramkind == ICAL_X_PARAMETER)
            propname = icalparameter_get_xname(icalparam);
        else if (paramkind != ICAL_NO_PARAMETER)
            propname = icalparameter_kind_to_string(paramkind);
    }

    if (propname) {
        name.Assign(propname);
    } else {
        name.Truncate();
        name.SetIsVoid(PR_TRUE);
    }

    return NS_OK;
}

Here is the call graph for this function:

static icalparameter* FindXParameter ( icalproperty *  prop,
const nsACString &  param 
) [static]

Definition at line 201 of file calICSService.cpp.

{
    for (icalparameter *icalparam =
             icalproperty_get_first_parameter(prop, ICAL_X_PARAMETER);
         icalparam;
         icalparam = icalproperty_get_next_parameter(prop, ICAL_X_PARAMETER)) {
        if (param.Equals(icalparameter_get_xname(icalparam)))
            return icalparam;
    }
    return nsnull;
}

Here is the call graph for this function:

TimezoneHashToTimezoneArray ( nsACString const ,
calITimezone tz,
void arg 
)

Definition at line 491 of file calICSService.cpp.

{
    calITimezone *** const arrayPtr = static_cast<calITimezone ***>(arg);
    NS_ADDREF(**arrayPtr = tz);
    ++(*arrayPtr);
    return PL_DHASH_NEXT;
}

Here is the call graph for this function: