Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions
icalcomponent.h File Reference
#include "icalproperty.h"
#include "icalvalue.h"
#include "icalenums.h"
#include "pvl.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  icalcompiter

Typedefs

typedef struct icalcomponent_impl
typedef struct icalcompiter icalcompiter

Functions

icalcomponent * icalcomponent_new (icalcomponent_kind kind)
 Constructor.
icalcomponent * icalcomponent_new_clone (icalcomponent *component)
 Constructor.
icalcomponent * icalcomponent_new_from_string (char *str)
 Constructor.
icalcomponent * icalcomponent_vanew (icalcomponent_kind kind,...)
 Constructor.
icalcomponent * icalcomponent_new_x (const char *x_name)
 Constructor.
void icalcomponent_free (icalcomponent *component)
char * icalcomponent_as_ical_string (icalcomponent *component)
int icalcomponent_is_valid (icalcomponent *component)
icalcomponent_kind icalcomponent_isa (const icalcomponent *component)
int icalcomponent_isa_component (void *component)
void icalcomponent_add_property (icalcomponent *component, icalproperty *property)
void icalcomponent_remove_property (icalcomponent *component, icalproperty *property)
int icalcomponent_count_properties (icalcomponent *component, icalproperty_kind kind)
icalproperty * icalcomponent_get_current_property (icalcomponent *component)
icalproperty * icalcomponent_get_first_property (icalcomponent *component, icalproperty_kind kind)
icalproperty * icalcomponent_get_next_property (icalcomponent *component, icalproperty_kind kind)
icalproperty * icalcomponent_get_first_x_property (icalcomponent *component, const char *name)
icalproperty * icalcomponent_get_next_x_property (icalcomponent *component, const char *name)
icalcomponent * icalcomponent_get_inner (icalcomponent *comp)
void icalcomponent_add_component (icalcomponent *parent, icalcomponent *child)
void icalcomponent_remove_component (icalcomponent *parent, icalcomponent *child)
int icalcomponent_count_components (icalcomponent *component, icalcomponent_kind kind)
void icalcomponent_merge_component (icalcomponent *comp, icalcomponent *comp_to_merge)
 This takes 2 VCALENDAR components and merges the second one into the first, resolving any problems with conflicting TZIDs.
icalcomponent * icalcomponent_get_current_component (icalcomponent *component)
icalcomponent * icalcomponent_get_first_component (icalcomponent *component, icalcomponent_kind kind)
icalcomponent * icalcomponent_get_next_component (icalcomponent *component, icalcomponent_kind kind)
icalcompiter icalcomponent_begin_component (icalcomponent *component, icalcomponent_kind kind)
icalcompiter icalcomponent_end_component (icalcomponent *component, icalcomponent_kind kind)
icalcomponent * icalcompiter_next (icalcompiter *i)
icalcomponent * icalcompiter_prior (icalcompiter *i)
icalcomponent * icalcompiter_deref (icalcompiter *i)
int icalcomponent_check_restrictions (icalcomponent *comp)
int icalcomponent_count_errors (icalcomponent *component)
 Count embedded errors.
void icalcomponent_strip_errors (icalcomponent *component)
 Remove all X-LIC-ERROR properties.
void icalcomponent_convert_errors (icalcomponent *component)
 Convert some X-LIC-ERROR properties into RETURN-STATUS properties.
icalcomponent * icalcomponent_get_parent (icalcomponent *component)
void icalcomponent_set_parent (icalcomponent *component, icalcomponent *parent)
int icalcomponent_kind_is_valid (const icalcomponent_kind kind)
icalcomponent_kind icalcomponent_string_to_kind (const char *string)
const char * icalcomponent_kind_to_string (icalcomponent_kind kind)
icalcomponent * icalcomponent_get_first_real_component (icalcomponent *c)
 For VCOMPONENT: Return a reference to the first VEVENT, VTODO or VJOURNAL.
struct icaltime_span icalcomponent_get_span (icalcomponent *comp)
 For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end times of an event in UTC.
void icalcomponent_set_dtstart (icalcomponent *comp, struct icaltimetype v)
 Set DTSTART property to given icaltime.
struct icaltimetype icalcomponent_get_dtstart (icalcomponent *comp)
 Get DTSTART property as an icaltime.
struct icaltimetype icalcomponent_get_dtend (icalcomponent *comp)
 Get DTEND property as an icaltime.
void icalcomponent_set_dtend (icalcomponent *comp, struct icaltimetype v)
 Set DTEND property to given icaltime.
struct icaltimetype icalcomponent_get_due (icalcomponent *comp)
 Return the time a TODO task is DUE.
void icalcomponent_set_due (icalcomponent *comp, struct icaltimetype v)
 Set the due date of a VTODO task.
void icalcomponent_set_duration (icalcomponent *comp, struct icaldurationtype v)
 Set DURATION property to given icalduration.
struct icaldurationtype icalcomponent_get_duration (icalcomponent *comp)
 Get DURATION property as an icalduration.
void icalcomponent_set_method (icalcomponent *comp, icalproperty_method method)
 sets the METHOD property to the given method
icalproperty_method icalcomponent_get_method (icalcomponent *comp)
 returns the METHOD property
struct icaltimetype icalcomponent_get_dtstamp (icalcomponent *comp)
void icalcomponent_set_dtstamp (icalcomponent *comp, struct icaltimetype v)
void icalcomponent_set_summary (icalcomponent *comp, const char *v)
const char * icalcomponent_get_summary (icalcomponent *comp)
void icalcomponent_set_comment (icalcomponent *comp, const char *v)
const char * icalcomponent_get_comment (icalcomponent *comp)
void icalcomponent_set_uid (icalcomponent *comp, const char *v)
const char * icalcomponent_get_uid (icalcomponent *comp)
void icalcomponent_set_relcalid (icalcomponent *comp, const char *v)
 set the RELCALID property of a component.
const char * icalcomponent_get_relcalid (icalcomponent *comp)
 get the RELCALID property of a component.
void icalcomponent_set_recurrenceid (icalcomponent *comp, struct icaltimetype v)
struct icaltimetype icalcomponent_get_recurrenceid (icalcomponent *comp)
void icalcomponent_set_description (icalcomponent *comp, const char *v)
const char * icalcomponent_get_description (icalcomponent *comp)
void icalcomponent_set_location (icalcomponent *comp, const char *v)
const char * icalcomponent_get_location (icalcomponent *comp)
void icalcomponent_set_sequence (icalcomponent *comp, int v)
int icalcomponent_get_sequence (icalcomponent *comp)
void icalcomponent_set_status (icalcomponent *comp, enum icalproperty_status v)
enum icalproperty_status icalcomponent_get_status (icalcomponent *comp)
void icalcomponent_foreach_tzid (icalcomponent *comp, void(*callback)(icalparameter *param, void *data), void *callback_data)
 Calls the given function for each TZID parameter found in the component, and any subcomponents.
icaltimezone * icalcomponent_get_timezone (icalcomponent *comp, const char *tzid)
 Returns the icaltimezone in the component corresponding to the TZID, or NULL if it can't be found.
int icalproperty_recurrence_is_excluded (icalcomponent *comp, struct icaltimetype *dtstart, struct icaltimetype *recurtime)
 Decide if this recurrance is acceptable.
void icalcomponent_foreach_recurrence (icalcomponent *comp, struct icaltimetype start, struct icaltimetype end, void(*callback)(icalcomponent *comp, struct icaltime_span *span, void *data), void *callback_data)
 cycle through all recurrances of an event
icalcomponent * icalcomponent_new_vcalendar ()
icalcomponent * icalcomponent_new_vevent ()
icalcomponent * icalcomponent_new_vtodo ()
icalcomponent * icalcomponent_new_vjournal ()
icalcomponent * icalcomponent_new_valarm ()
icalcomponent * icalcomponent_new_vfreebusy ()
icalcomponent * icalcomponent_new_vtimezone ()
icalcomponent * icalcomponent_new_xstandard ()
icalcomponent * icalcomponent_new_xdaylight ()
icalcomponent * icalcomponent_new_vagenda ()
icalcomponent * icalcomponent_new_vquery ()

Class Documentation

struct icalcompiter

Definition at line 2588 of file ical.h.

Collaboration diagram for icalcompiter:
Class Members
pvl_elem iter
icalcomponent_kind kind

Typedef Documentation

typedef struct icalcompiter icalcompiter
typedef struct icalcomponent_impl

Definition at line 32 of file icalcomponent.h.


Function Documentation

icalcomponent* icalcompiter_deref ( icalcompiter i)

Definition at line 1480 of file icalcomponent.c.

{
    if(i->iter ==0){
       return 0;
    }

    return pvl_data(i->iter);
}

Here is the call graph for this function:

icalcomponent* icalcompiter_next ( icalcompiter i)

Definition at line 1433 of file icalcomponent.c.

{
   if (i->iter == 0){
       return 0;
   }

   icalerror_check_arg_rz( (i!=0),"i");

   for( i->iter = pvl_next(i->iter);
       i->iter != 0;
       i->iter = pvl_next(i->iter)) {
           
       icalcomponent *c =  (icalcomponent*) pvl_data(i->iter);
       
          if (icalcomponent_isa(c) == i->kind 
              || i->kind == ICAL_ANY_COMPONENT) {
              
              return icalcompiter_deref(i);;
          }
   }

   return 0;

}

Here is the call graph for this function:

icalcomponent* icalcompiter_prior ( icalcompiter i)

Definition at line 1458 of file icalcomponent.c.

{
   if (i->iter == 0){
       return 0;
   }

   for( i->iter = pvl_prior(i->iter);
       i->iter != 0;
       i->iter = pvl_prior(i->iter)) {
           
       icalcomponent *c =  (icalcomponent*) pvl_data(i->iter);
       
          if (icalcomponent_isa(c) == i->kind 
              || i->kind == ICAL_ANY_COMPONENT) {
              
              return icalcompiter_deref(i);;
          }
   }

   return 0;

}

Here is the call graph for this function:

void icalcomponent_add_component ( icalcomponent *  parent,
icalcomponent *  child 
)

Definition at line 579 of file icalcomponent.c.

{
    icalerror_check_arg_rv( (parent!=0), "parent");
    icalerror_check_arg_rv( (child!=0), "child");
    
    if (child->parent !=0) {
        icalerror_set_errno(ICAL_USAGE_ERROR);
    }

    child->parent = parent;

    /* Fix for Mozilla - bug 327602 */
    if (child->kind != ICAL_VTIMEZONE_COMPONENT) {
        pvl_push(parent->components, child);
    } else {
        /* VTIMEZONES should be first in the resulting VCALENDAR. */
        pvl_unshift(parent->components, child);

    /* Add the VTIMEZONE to our array. */
       /* FIXME: Currently we are also creating this array when loading in
          a builtin VTIMEZONE, when we don't need it. */
       if (!parent->timezones)
           parent->timezones = icaltimezone_array_new ();

       icaltimezone_array_append_from_vtimezone (parent->timezones, child);

       /* Flag that we need to sort it before doing any binary searches. */
       parent->timezones_sorted = 0;
    }
}

Here is the call graph for this function:

void icalcomponent_add_property ( icalcomponent *  component,
icalproperty *  property 
)

Definition at line 408 of file icalcomponent.c.

{
    icalerror_check_arg_rv( (component!=0), "component");
    icalerror_check_arg_rv( (property!=0), "property");

    icalerror_assert( (!icalproperty_get_parent(property)),"The property has already been added to a component. Remove the property with icalcomponent_remove_property before calling icalcomponent_add_property");

    icalproperty_set_parent(property,component);

    pvl_push(component->properties,property);
}

Here is the call graph for this function:

char* icalcomponent_as_ical_string ( icalcomponent *  component)

Definition at line 288 of file icalcomponent.c.

{
   char* buf, *out_buf;
   const char* tmp_buf;
   size_t buf_size = 1024;
   char* buf_ptr = 0;
    pvl_elem itr;

#ifdef ICAL_UNIX_NEWLINE    
    char newline[] = "\n";
#else
    char newline[] = "\r\n";
#endif
   
   icalcomponent *c;
   icalproperty *p;
   icalcomponent_kind kind = icalcomponent_isa(impl);

   const char* kind_string;

   buf = icalmemory_new_buffer(buf_size);
   buf_ptr = buf; 

   icalerror_check_arg_rz( (impl!=0), "component");
   icalerror_check_arg_rz( (kind!=ICAL_NO_COMPONENT), "component kind is ICAL_NO_COMPONENT");
   
   if (kind != ICAL_X_COMPONENT) {
       kind_string  = icalcomponent_kind_to_string(kind);
   } else {
       kind_string = impl->x_name;
   }

   icalerror_check_arg_rz( (kind_string!=0),"Unknown kind of component");

   icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:");
   icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
   icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
   


   for( itr = pvl_head(impl->properties);
        itr != 0;
        itr = pvl_next(itr))
    {  
       p = (icalproperty*)pvl_data(itr);
       
       icalerror_assert((p!=0),"Got a null property");
       tmp_buf = icalproperty_as_ical_string(p);
       
       icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf);
    }
   
   
   for( itr = pvl_head(impl->components);
       itr != 0;
       itr = pvl_next(itr))
   {   
       c = (icalcomponent*)pvl_data(itr);
       
       tmp_buf = icalcomponent_as_ical_string(c);
       
       icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf);
       
   }
   
   icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:");
   icalmemory_append_string(&buf, &buf_ptr, &buf_size, 
                         icalcomponent_kind_to_string(kind));
   icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);

   out_buf = icalmemory_tmp_copy(buf);
   free(buf);

   return out_buf;
}

Here is the call graph for this function:

icalcompiter icalcomponent_begin_component ( icalcomponent *  component,
icalcomponent_kind  kind 
)

Definition at line 1382 of file icalcomponent.c.

{
    icalcompiter itr;
    pvl_elem i;

    itr.kind = kind;
    itr.iter = NULL;

    icalerror_check_arg_re(component!=0,"component",icalcompiter_null);

    for( i = pvl_head(component->components); i != 0; i = pvl_next(i)) {
       
       icalcomponent *c =  (icalcomponent*) pvl_data(i);
       
       if (icalcomponent_isa(c) == kind || kind == ICAL_ANY_COMPONENT) {
           
           itr.iter = i;

           return itr;
       }
    }

    return icalcompiter_null;
}

Here is the call graph for this function:

int icalcomponent_check_restrictions ( icalcomponent *  comp)

Definition at line 1144 of file icalcomponent.c.

                                                         {
    icalerror_check_arg_rz(comp!=0,"comp");
    return icalrestriction_check(comp);
}

Here is the call graph for this function:

void icalcomponent_convert_errors ( icalcomponent *  component)

Convert some X-LIC-ERROR properties into RETURN-STATUS properties.

Definition at line 1218 of file icalcomponent.c.

Here is the call graph for this function:

int icalcomponent_count_components ( icalcomponent *  component,
icalcomponent_kind  kind 
)

Definition at line 660 of file icalcomponent.c.

{
    int count=0;
    pvl_elem itr;

    icalerror_check_arg_rz( (component!=0), "component");

    for( itr = pvl_head(component->components);
        itr != 0;
        itr = pvl_next(itr))
    {
       if(kind == icalcomponent_isa((icalcomponent*)pvl_data(itr)) ||
           kind == ICAL_ANY_COMPONENT){
           count++;
       }
    }

    return count;
}

Here is the call graph for this function:

int icalcomponent_count_errors ( icalcomponent *  component)

Count embedded errors.

Count embedded errors.

This function counts the number times the X-LIC-ERROR occurs in the data structure.

Definition at line 1155 of file icalcomponent.c.

{
    int errors = 0;
    icalproperty *p;
    icalcomponent *c;
    pvl_elem itr;

    for( itr = pvl_head(component->properties);
        itr != 0;
        itr = pvl_next(itr))
    {  
       p = (icalproperty*)pvl_data(itr);
       
       if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY)
       {
           errors++;
       }
    }


    for( itr = pvl_head(component->components);
        itr != 0;
        itr = pvl_next(itr))
    {  
       c = (icalcomponent*)pvl_data(itr);
       
       errors += icalcomponent_count_errors(c);
       
    }

    return errors;
}

Here is the call graph for this function:

int icalcomponent_count_properties ( icalcomponent *  component,
icalproperty_kind  kind 
)

Definition at line 451 of file icalcomponent.c.

{
    int count=0;
    pvl_elem itr;

    icalerror_check_arg_rz( (component!=0), "component");

    for( itr = pvl_head(component->properties);
        itr != 0;
        itr = pvl_next(itr))
    {  
       if(kind == icalproperty_isa((icalproperty*)pvl_data(itr)) ||
           kind == ICAL_ANY_PROPERTY){
           count++;
       }
    }


    return count;

}

Here is the call graph for this function:

icalcompiter icalcomponent_end_component ( icalcomponent *  component,
icalcomponent_kind  kind 
)

Definition at line 1408 of file icalcomponent.c.

{
    icalcompiter itr; 
    pvl_elem i;

    itr.kind = kind;

    icalerror_check_arg_re(component!=0,"component",icalcompiter_null);

    for( i = pvl_tail(component->components); i != 0; i = pvl_prior(i)) {
       
       icalcomponent *c =  (icalcomponent*) pvl_data(i);
       
       if (icalcomponent_isa(c) == kind || kind == ICAL_ANY_COMPONENT) {
           
           itr.iter = pvl_next(i);

           return itr;
       }
    }

    return icalcompiter_null;;
}

Here is the call graph for this function:

void icalcomponent_foreach_recurrence ( icalcomponent *  comp,
struct icaltimetype  start,
struct icaltimetype  end,
void(*)(icalcomponent *comp, struct icaltime_span *span, void *data callback,
void callback_data 
)

cycle through all recurrances of an event

Parameters:
compA valid VEVENT component
startIgnore timespans before this
endIgnore timespans after this
callbackFunction called for each timespan within the range
callback_dataPointer passed back to the callback function

This function will call the specified callback function for once for the base value of DTSTART, and foreach recurring date/time value.

It will filter out events that are specified as an EXDATE or an EXRULE.

Todo:

We do not filter out duplicate RRULES/RDATES

We do not handle RDATEs with explicit periods

Calculate the ceiling and floor values..

call callback action

save the iterator ICK!

call callback action

Now process RDATE entries

RDATES can specify raw datetimes, periods, or dates. we only support raw datetimes for now..

Todo:
Add support for other types

save the iterator ICK!

call callback action

Definition at line 1015 of file icalcomponent.c.

{
  struct icaltimetype dtstart, dtend;
  icaltime_span recurspan, basespan, limit_span;
  time_t limit_start, limit_end;
  int dtduration;
  icalproperty *rrule, *rdate;
  struct icaldurationtype dur;
  pvl_elem property_iterator;      /* for saving the iterator */
  
  if (comp == NULL || callback == NULL)
    return;
  
  dtstart = icalcomponent_get_dtstart(comp);
  
  if (icaltime_is_null_time(dtstart))
    return;                 


  /* The end time could be specified as either a DTEND or a DURATION */
  /* icalcomponent_get_dtend takes care of these cases. */
  dtend = icalcomponent_get_dtend(comp);

  /* Now set up the base span for this item, corresponding to the 
     base DTSTART and DTEND */
  basespan = icaltime_span_new(dtstart, dtend, 1);

  basespan.is_busy = icalcomponent_is_busy(comp);


  limit_start = icaltime_as_timet_with_zone(start, icaltimezone_get_utc_timezone());
  if (!icaltime_is_null_time(end))
    limit_end   = icaltime_as_timet_with_zone(end, icaltimezone_get_utc_timezone());
  else
    limit_end   = INT_MAX;  /* max 32 bit time_t */

  limit_span.start = limit_start;
  limit_span.end   = limit_end;


  /* Do the callback for the initial DTSTART entry */

  if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &dtstart)) {
    if (icaltime_span_overlaps(&basespan, &limit_span))
    (*callback) (comp, &basespan, callback_data);
  }

  recurspan = basespan;
  dtduration = basespan.end - basespan.start;
  
  /* Now cycle through the rrule entries */
  for (rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY);
       rrule != NULL;
       rrule = icalcomponent_get_next_property(comp,ICAL_RRULE_PROPERTY)) {

    struct icalrecurrencetype recur = icalproperty_get_rrule(rrule);
    icalrecur_iterator *rrule_itr  = icalrecur_iterator_new(recur, dtstart);
    struct icaltimetype rrule_time;
    
    while (1) {
      rrule_time = icalrecur_iterator_next(rrule_itr);

      if (icaltime_is_null_time(rrule_time)) 
       break;

      if (!icaltime_compare(rrule_time, dtstart))
       continue;

      dur = icaltime_subtract(rrule_time, dtstart);

      recurspan.start = basespan.start + icaldurationtype_as_int(dur);
      recurspan.end   = recurspan.start + dtduration;

      property_iterator = comp->property_iterator;

      if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &rrule_time)) {
       if (icaltime_span_overlaps(&recurspan, &limit_span))
       (*callback) (comp, &recurspan, callback_data);
      }
      comp->property_iterator = property_iterator;
    } /* end of iteration over a specific RRULE */

    icalrecur_iterator_free(rrule_itr);
  } /* end of RRULE loop */


  for (rdate = icalcomponent_get_first_property(comp,ICAL_RDATE_PROPERTY);
       rdate != NULL;
       rdate = icalcomponent_get_next_property(comp,ICAL_RDATE_PROPERTY)) {

    struct icaldatetimeperiodtype rdate_period = icalproperty_get_rdate(rdate);

    if (icaltime_is_null_time(rdate_period.time)) 
      continue;

    dur = icaltime_subtract(rdate_period.time, dtstart);

    recurspan.start = basespan.start + icaldurationtype_as_int(dur);
    recurspan.end   = recurspan.start + dtduration;

    property_iterator = comp->property_iterator;

    if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &rdate_period.time)) {
      (*callback) (comp, &recurspan, callback_data);
    }
    comp->property_iterator = property_iterator;
  }
}

Here is the call graph for this function:

void icalcomponent_foreach_tzid ( icalcomponent *  comp,
void(*)(icalparameter *param, void *data callback,
void callback_data 
)

Calls the given function for each TZID parameter found in the component, and any subcomponents.

Definition at line 2373 of file icalcomponent.c.

{
    icalproperty *prop;
    icalproperty_kind kind;
    icalparameter *param;
    icalcomponent *subcomp;

    /* First look for any TZID parameters used in this component itself. */
    prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY);
    while (prop) {
      kind = icalproperty_isa (prop);

      /* These are the only properties that can have a TZID. Note that
        COMPLETED, CREATED, DTSTAMP & LASTMODIFIED must be in UTC. */
      if (kind == ICAL_DTSTART_PROPERTY || kind == ICAL_DTEND_PROPERTY
         || kind == ICAL_DUE_PROPERTY || kind == ICAL_EXDATE_PROPERTY
         || kind == ICAL_RDATE_PROPERTY) {
       param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
       if (param)
           (*callback) (param, callback_data);
      }

      prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY);
    }

    /* Now recursively check child components. */
    subcomp = icalcomponent_get_first_component (comp, ICAL_ANY_COMPONENT);
    while (subcomp) {
        icalcomponent_foreach_tzid (subcomp, callback, callback_data);
        subcomp = icalcomponent_get_next_component (comp, ICAL_ANY_COMPONENT);
    }
}

Here is the call graph for this function:

void icalcomponent_free ( icalcomponent *  component)

Definition at line 231 of file icalcomponent.c.

{
    icalproperty* prop;
    icalcomponent* comp;

    icalerror_check_arg_rv( (c!=0), "component");

#ifdef ICAL_FREE_ON_LIST_IS_ERROR
    icalerror_assert( (c->parent ==0),"Tried to free a component that is still attached to a parent component");
#else
    if(c->parent != 0){
       return;
    }
#endif

    if(c != 0 ){
       
              if ( c->properties != 0 )
              {
                 while( (prop=pvl_pop(c->properties)) != 0){
                 assert(prop != 0);
                        icalproperty_set_parent(prop,0);
                 icalproperty_free(prop);
                 }
               pvl_free(c->properties);
              }
      

       while( (comp=pvl_data(pvl_head(c->components))) != 0){
          assert(comp!=0);
          icalcomponent_remove_component(c,comp);
          icalcomponent_free(comp);
       }
       
       pvl_free(c->components);

       if (c->x_name != 0) {
           free(c->x_name);
       }

       if (c->timezones)
           icaltimezone_array_free (c->timezones);

       c->kind = ICAL_NO_COMPONENT;
       c->properties = 0;
       c->property_iterator = 0;
       c->components = 0;
       c->component_iterator = 0;
       c->x_name = 0;       
       c->id[0] = 'X';
       c->timezones = NULL;

       free(c);
    }
}

Here is the call graph for this function:

const char* icalcomponent_get_comment ( icalcomponent *  comp)

Definition at line 1843 of file icalcomponent.c.

                                                          {
    icalcomponent *inner;
    icalproperty *prop;
    icalerror_check_arg_rz(comp!=0,"comp");

    inner = icalcomponent_get_inner(comp); 

    if(inner == 0){
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return 0;
    }

    prop= icalcomponent_get_first_property(inner,ICAL_COMMENT_PROPERTY);

    if (prop == 0){
       return 0;
    }
    
    return icalproperty_get_comment(prop);
}

Here is the call graph for this function:

icalcomponent* icalcomponent_get_current_component ( icalcomponent *  component)

Definition at line 682 of file icalcomponent.c.

{
   icalerror_check_arg_rz( (component!=0),"component");

   if (component->component_iterator == 0){
       return 0;
   }

   return (icalcomponent*) pvl_data(component->component_iterator);
}

Here is the call graph for this function:

icalproperty* icalcomponent_get_current_property ( icalcomponent *  component)

Definition at line 474 of file icalcomponent.c.

{
   icalerror_check_arg_rz( (component!=0),"component");

   if ((component->property_iterator==0)){
       return 0;
   }

   return (icalproperty*) pvl_data(component->property_iterator);
}

Here is the call graph for this function:

const char* icalcomponent_get_description ( icalcomponent *  comp)

Definition at line 1944 of file icalcomponent.c.

{
    icalcomponent *inner;
    icalproperty *prop;
    icalerror_check_arg_rz(comp!=0,"comp");

    inner = icalcomponent_get_inner(comp); 

    if(inner == 0){
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return 0;
    }

    prop= icalcomponent_get_first_property(inner,ICAL_DESCRIPTION_PROPERTY);

    if (prop == 0){
        return 0;
    }

    return icalproperty_get_description(prop);
}

Here is the call graph for this function:

struct icaltimetype icalcomponent_get_dtend ( icalcomponent *  comp) [read]

Get DTEND property as an icaltime.

If a DTEND property is not present but a DURATION is, we use that to determine the proper end.

If DTSTART is a DATE-TIME with a timezone parameter and a corresponding VTIMEZONE is present in the component, the returned component will already be in the correct timezone; otherwise the caller is responsible for converting it.

FIXME this is useless until we can flag the failure

Definition at line 1640 of file icalcomponent.c.

{
    icalcomponent *inner = icalcomponent_get_inner(comp); 
    icalproperty *end_prop 
       = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
    icalproperty *dur_prop 
       = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY);
    struct icaltimetype     ret = icaltime_null_time();

    if ( end_prop != 0) {
       ret = icalcomponent_get_datetime(comp, end_prop);
    } else if ( dur_prop != 0) { 

       struct icaltimetype start = 
           icalcomponent_get_dtstart(inner);
       struct icaldurationtype duration = 
           icalproperty_get_duration(dur_prop);

       struct icaltimetype end = icaltime_add(start,duration);

       ret = end;
    }

    return ret;
}

Here is the call graph for this function:

struct icaltimetype icalcomponent_get_dtstamp ( icalcomponent *  comp) [read]

Definition at line 1781 of file icalcomponent.c.

{
    icalcomponent *inner = icalcomponent_get_inner(comp); 
    icalproperty *prop 
       = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY);

    if (prop == 0){
       return icaltime_null_time();
    }
    
    return icalproperty_get_dtstamp(prop);
}

Here is the call graph for this function:

struct icaltimetype icalcomponent_get_dtstart ( icalcomponent *  comp) [read]

Get DTSTART property as an icaltime.

If DTSTART is a DATE-TIME with a timezone parameter and a corresponding VTIMEZONE is present in the component, the returned component will already be in the correct timezone; otherwise the caller is responsible for converting it.

FIXME this is useless until we can flag the failure

Definition at line 1615 of file icalcomponent.c.

{
    icalcomponent *inner = icalcomponent_get_inner(comp); 
    icalproperty *prop;

    prop = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
    if (prop == 0){
       return icaltime_null_time();
    }

    return icalcomponent_get_datetime(comp, prop);
}

Here is the call graph for this function:

struct icaltimetype icalcomponent_get_due ( icalcomponent *  comp) [read]

Return the time a TODO task is DUE.

Parameters:
compValid calendar component.

Uses the DUE: property if it exists, otherwise we calculate the DUE value by adding the task's duration to the DTSTART time

Definition at line 2596 of file icalcomponent.c.

{
    icalcomponent *inner = icalcomponent_get_inner(comp);

    icalproperty *due_prop
        = icalcomponent_get_first_property(inner,ICAL_DUE_PROPERTY);

    icalproperty *dur_prop
        = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY);

    if( due_prop == 0 && dur_prop == 0){
        return icaltime_null_time();
    } else if ( due_prop != 0) {
        return icalproperty_get_due(due_prop);
    } else if ( dur_prop != 0) {

        struct icaltimetype start =
            icalcomponent_get_dtstart(inner);
        struct icaldurationtype duration =
            icalproperty_get_duration(dur_prop);

        struct icaltimetype due = icaltime_add(start,duration);

        return due;

    } else {
        /* Error, both duration and due have been specified */
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return icaltime_null_time();

    }

}

Here is the call graph for this function:

struct icaldurationtype icalcomponent_get_duration ( icalcomponent *  comp) [read]

Get DURATION property as an icalduration.

If a DURATION property is not present but a DTEND is, we use that to determine the proper end.

FIXME We assume DTSTART and DTEND are not in different time zones. Does the standard actually guarantee this?

Definition at line 1732 of file icalcomponent.c.

{
    icalcomponent *inner = icalcomponent_get_inner(comp); 

    icalproperty *end_prop 
       = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);

    icalproperty *dur_prop 
       = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);

    struct icaldurationtype ret = icaldurationtype_null_duration();

    if ( dur_prop != 0 && end_prop == 0) { 
       ret = icalproperty_get_duration(dur_prop);

    } else if ( end_prop != 0 && dur_prop == 0) {
       struct icaltimetype start = 
           icalcomponent_get_dtstart(inner);
       struct icaltimetype end = 
           icalcomponent_get_dtend(inner);

       ret = icaltime_subtract(end, start);
    } else {
       /* Error, both duration and dtend have been specified */
       icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
    }
    return ret;
}

Here is the call graph for this function:

icalcomponent* icalcomponent_get_first_component ( icalcomponent *  component,
icalcomponent_kind  kind 
)

Definition at line 694 of file icalcomponent.c.

{
   icalerror_check_arg_rz( (c!=0),"component");
  
   for( c->component_iterator = pvl_head(c->components);
       c->component_iterator != 0;
       c->component_iterator = pvl_next(c->component_iterator)) {
           
       icalcomponent *p =  (icalcomponent*) pvl_data(c->component_iterator);
       
          if (icalcomponent_isa(p) == kind || kind == ICAL_ANY_COMPONENT) {
              
              return p;
          }
   }

   return 0;
}

Here is the call graph for this function:

icalproperty* icalcomponent_get_first_property ( icalcomponent *  component,
icalproperty_kind  kind 
)

Definition at line 486 of file icalcomponent.c.

{
   icalerror_check_arg_rz( (c!=0),"component");
  
   for( c->property_iterator = pvl_head(c->properties);
       c->property_iterator != 0;
       c->property_iterator = pvl_next(c->property_iterator)) {
           
       icalproperty *p =  (icalproperty*) pvl_data(c->property_iterator);
       
          if (icalproperty_isa(p) == kind || kind == ICAL_ANY_PROPERTY) {
              
              return p;
          }
   }
   return 0;
}

Here is the call graph for this function:

icalcomponent* icalcomponent_get_first_real_component ( icalcomponent *  c)

For VCOMPONENT: Return a reference to the first VEVENT, VTODO or VJOURNAL.

Definition at line 739 of file icalcomponent.c.

{
    icalcomponent *comp;

    for(comp = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT);
       comp != 0;
       comp = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT)){

       icalcomponent_kind kind = icalcomponent_isa(comp);

       if(kind == ICAL_VEVENT_COMPONENT ||
          kind == ICAL_VTODO_COMPONENT ||
          kind == ICAL_VJOURNAL_COMPONENT ||
          kind == ICAL_VFREEBUSY_COMPONENT ||
          kind == ICAL_VQUERY_COMPONENT ||
          kind == ICAL_VREPLY_COMPONENT ||
          kind == ICAL_VAGENDA_COMPONENT){
           return comp;
       }
    }
    return 0;
}

Here is the call graph for this function:

icalproperty* icalcomponent_get_first_x_property ( icalcomponent *  component,
const char *  name 
)

Definition at line 529 of file icalcomponent.c.

{
   icalerror_check_arg_rz( (c!=0),"component");
  
   for( c->property_iterator = pvl_head(c->properties);
       c->property_iterator != 0;
       c->property_iterator = pvl_next(c->property_iterator)) {
           
       icalproperty *p =  (icalproperty*) pvl_data(c->property_iterator);
       
          if (icalproperty_isa(p) == ICAL_X_PROPERTY &&
              !strcmp(icalproperty_get_x_name(p), name)) {
              
              return p;
          }
   }
   return 0;
}

Here is the call graph for this function:

icalcomponent* icalcomponent_get_inner ( icalcomponent *  comp)

Definition at line 1489 of file icalcomponent.c.

{
    if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){
       return icalcomponent_get_first_real_component(comp);
    } else {
       return comp;
    }
}

Here is the call graph for this function:

const char* icalcomponent_get_location ( icalcomponent *  comp)

Definition at line 1977 of file icalcomponent.c.

{
    icalcomponent *inner;
    icalproperty *prop;
    icalerror_check_arg_rz(comp!=0,"comp");

    inner = icalcomponent_get_inner(comp); 

    if(inner == 0){
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return 0;
    }

    prop= icalcomponent_get_first_property(inner,ICAL_LOCATION_PROPERTY);

    if (prop == 0){
        return 0;
    }

    return icalproperty_get_location(prop);
}

Here is the call graph for this function:

icalproperty_method icalcomponent_get_method ( icalcomponent *  comp)

returns the METHOD property

Definition at line 1519 of file icalcomponent.c.

{
    icalproperty *prop 
       = icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY);

    if (prop == 0){
       return ICAL_METHOD_NONE;
    }
    
    return icalproperty_get_method(prop);
}

Here is the call graph for this function:

icalcomponent* icalcomponent_get_next_component ( icalcomponent *  component,
icalcomponent_kind  kind 
)

Definition at line 716 of file icalcomponent.c.

{
   icalerror_check_arg_rz( (c!=0),"component");
  
   if (c->component_iterator == 0){
       return 0;
   }

   for( c->component_iterator = pvl_next(c->component_iterator);
       c->component_iterator != 0;
       c->component_iterator = pvl_next(c->component_iterator)) {
           
       icalcomponent *p =  (icalcomponent*) pvl_data(c->component_iterator);
       
          if (icalcomponent_isa(p) == kind || kind == ICAL_ANY_COMPONENT) {
              
              return p;
          }
   }

   return 0;
}

Here is the call graph for this function:

icalproperty* icalcomponent_get_next_property ( icalcomponent *  component,
icalproperty_kind  kind 
)

Definition at line 505 of file icalcomponent.c.

{
   icalerror_check_arg_rz( (c!=0),"component");

   if (c->property_iterator == 0){
       return 0;
   }

   for( c->property_iterator = pvl_next(c->property_iterator);
       c->property_iterator != 0;
       c->property_iterator = pvl_next(c->property_iterator)) {
           
       icalproperty *p =  (icalproperty*) pvl_data(c->property_iterator);
          
       if (icalproperty_isa(p) == kind || kind == ICAL_ANY_PROPERTY) {
          
          return p;
       }
   }

   return 0;
}

Here is the call graph for this function:

icalproperty* icalcomponent_get_next_x_property ( icalcomponent *  component,
const char *  name 
)

Definition at line 549 of file icalcomponent.c.

{
   icalerror_check_arg_rz( (c!=0),"component");

   if (c->property_iterator == 0){
       return 0;
   }

   for( c->property_iterator = pvl_next(c->property_iterator);
       c->property_iterator != 0;
       c->property_iterator = pvl_next(c->property_iterator)) {
           
       icalproperty *p =  (icalproperty*) pvl_data(c->property_iterator);
          
       if (icalproperty_isa(p) == ICAL_X_PROPERTY &&
              !strcmp(icalproperty_get_x_name(p), name)) {
          
          return p;
       }
   }

   return 0;
}

Here is the call graph for this function:

icalcomponent* icalcomponent_get_parent ( icalcomponent *  component)

Definition at line 1285 of file icalcomponent.c.

{
   return component->parent;
}
struct icaltimetype icalcomponent_get_recurrenceid ( icalcomponent *  comp) [read]

Definition at line 1908 of file icalcomponent.c.

{
    icalcomponent *inner;
    icalproperty *prop;
    if (comp == 0) {
       icalerror_set_errno(ICAL_BADARG_ERROR);
        return icaltime_null_time();
    }

    inner = icalcomponent_get_inner(comp); 

    if(inner == 0){
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return icaltime_null_time();
    }

    prop= icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY);

    if (prop == 0){
        return icaltime_null_time();
    }

    return icalproperty_get_recurrenceid(prop);
}

Here is the call graph for this function:

const char* icalcomponent_get_relcalid ( icalcomponent *  comp)

get the RELCALID property of a component.

Parameters:
compValid calendar component.

Definition at line 2567 of file icalcomponent.c.

                                                           {
    icalcomponent *inner;
    icalproperty *prop;
    icalerror_check_arg_rz(comp!=0,"comp");

    inner = icalcomponent_get_inner(comp);

    if(inner == 0){
        return 0;
    }

    prop= icalcomponent_get_first_property(inner,ICAL_RELCALID_PROPERTY);

    if (prop == 0){
        return 0;
    }

    return icalproperty_get_relcalid(prop);
}

Here is the call graph for this function:

int icalcomponent_get_sequence ( icalcomponent *  comp)

Definition at line 2011 of file icalcomponent.c.

                                                   {
    icalcomponent *inner;
    icalproperty *prop;
    icalerror_check_arg_rz(comp!=0,"comp");

    inner = icalcomponent_get_inner(comp);

    if(inner == 0){
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return 0;
    }

    prop= icalcomponent_get_first_property(inner,ICAL_SEQUENCE_PROPERTY);

    if (prop == 0){
        return 0;
    }

    return icalproperty_get_sequence(prop);
}

Here is the call graph for this function:

struct icaltime_span icalcomponent_get_span ( icalcomponent *  comp) [read]

For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end times of an event in UTC.

For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end times of an event in UTC.

see icalcomponent_foreach_recurrence() for a better way to extract spans from an component.

This method can be called on either a VCALENDAR or any real component. If the VCALENDAR contains no real component, but contains a VTIMEZONE, we return that span instead. This might not be a desirable behavior; we keep it for now for backward compatibility, but it might be deprecated at a future time.

FIXME this API needs to be clarified. DTEND is defined as the first available time after the end of this event, so the span should actually end 1 second before DTEND.

Definition at line 781 of file icalcomponent.c.

{
    icalcomponent *inner;
    icalcomponent_kind kind;
    icaltime_span span;
    struct icaltimetype start, end;

    span.start = 0;
    span.end = 0;
    span.is_busy= 1;

    /* initial Error checking */
    if (comp == NULL) {
       return span;
    }

    /* FIXME this might go away */
    kind  = icalcomponent_isa(comp);
    if(kind == ICAL_VCALENDAR_COMPONENT){
       inner = icalcomponent_get_first_real_component(comp);

       /* Maybe there is a VTIMEZONE in there */
       if (inner == 0){
           inner = icalcomponent_get_first_component(comp,
                            ICAL_VTIMEZONE_COMPONENT);
       }

    } else {
       inner = comp;
    }

    if (inner == 0){
       icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
       /*icalerror_warn("icalcomponent_get_span: no component specified, or empty VCALENDAR component");*/
       return span; 
    }
    
    kind  = icalcomponent_isa(inner);

    if( !( kind == ICAL_VEVENT_COMPONENT ||
          kind == ICAL_VJOURNAL_COMPONENT ||
          kind == ICAL_VTODO_COMPONENT ||    
          kind == ICAL_VFREEBUSY_COMPONENT )) {
       icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
       /*icalerror_warn("icalcomponent_get_span: no component specified, or empty VCALENDAR component");*/
       return span; 
       
    }

    /* Get to work. starting with DTSTART */
    start = icalcomponent_get_dtstart(comp);
    if (icaltime_is_null_time(start)) {
       return span;
    }
    span.start = icaltime_as_timet_with_zone(start,
       icaltimezone_get_utc_timezone());

    /* The end time could be specified as either a DTEND or a DURATION */
    /* icalcomponent_get_dtend takes care of these cases. */
    end = icalcomponent_get_dtend(comp);
    if (icaltime_is_null_time(end)) {
       if (!icaltime_is_date(start)) {
           /* If dtstart is a DATE-TIME and there is no DTEND nor DURATION
              it takes no time */
           span.start = 0;
           return span;
       } else {
           end = start;
       }
    }

    span.end = icaltime_as_timet_with_zone(end,
       icaltimezone_get_utc_timezone());
    if (icaltime_is_date(start)) {
       /* Until the end of the day*/
       span.end += 60*60*24 - 1;
    }

    return span;

}

Here is the call graph for this function:

enum icalproperty_status icalcomponent_get_status ( icalcomponent *  comp)

Definition at line 2045 of file icalcomponent.c.

                                                                      {
    icalcomponent *inner;
    icalproperty *prop;
    icalerror_check_arg_rz(comp!=0,"comp");

    inner = icalcomponent_get_inner(comp);

    if(inner == 0){
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return 0;
    }

    prop= icalcomponent_get_first_property(inner,ICAL_STATUS_PROPERTY);

    if (prop == 0){
        return 0;
    }

    return icalproperty_get_status(prop);
}

Here is the call graph for this function:

const char* icalcomponent_get_summary ( icalcomponent *  comp)

Definition at line 1808 of file icalcomponent.c.

{
    icalcomponent *inner;
    icalproperty *prop;
    icalerror_check_arg_rz(comp!=0,"comp");

    inner = icalcomponent_get_inner(comp); 

    if(inner == 0){
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return 0;
    }

    prop= icalcomponent_get_first_property(inner,ICAL_SUMMARY_PROPERTY);

    if (prop == 0){
       return 0;
    }
    
    return icalproperty_get_summary(prop);

}

Here is the call graph for this function:

icaltimezone* icalcomponent_get_timezone ( icalcomponent *  comp,
const char *  tzid 
)

Returns the icaltimezone in the component corresponding to the TZID, or NULL if it can't be found.

Definition at line 2414 of file icalcomponent.c.

{
    icaltimezone *zone;
    int lower, upper, middle, cmp;
    char *zone_tzid;

    if (!comp->timezones)
       return NULL;

    /* Sort the array if necessary (by the TZID string). */
    if (!comp->timezones_sorted) {
       icalarray_sort (comp->timezones, icalcomponent_compare_timezone_fn);
       comp->timezones_sorted = 1;
    }

    /* Do a simple binary search. */
    lower = middle = 0;
    upper = comp->timezones->num_elements;

    while (lower < upper) {
       middle = (lower + upper) >> 1;
       zone = icalarray_element_at (comp->timezones, middle);
       zone_tzid = icaltimezone_get_tzid (zone);
       cmp = strcmp (tzid, zone_tzid);
       if (cmp == 0)
           return zone;
       else if (cmp < 0)
           upper = middle;
       else
           lower = middle + 1;
    }

    return NULL;
}

Here is the call graph for this function:

const char* icalcomponent_get_uid ( icalcomponent *  comp)

Definition at line 1876 of file icalcomponent.c.

                                                      {
    icalcomponent *inner;
    icalproperty *prop;
    icalerror_check_arg_rz(comp!=0,"comp");

    inner = icalcomponent_get_inner(comp); 

    if(inner == 0){
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        return 0;
    }

    prop= icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);

    if (prop == 0){
       return 0;
    }
    
    return icalproperty_get_uid(prop);
}

Here is the call graph for this function:

int icalcomponent_is_valid ( icalcomponent *  component)

Definition at line 366 of file icalcomponent.c.

{
    if ( (strcmp(component->id,"comp") == 0) &&
        component->kind != ICAL_NO_COMPONENT){
       return 1;
    } else {
       return 0;
    }

}
icalcomponent_kind icalcomponent_isa ( const icalcomponent *  component)

Definition at line 379 of file icalcomponent.c.

{
   icalerror_check_arg_rx( (component!=0), "component", ICAL_NO_COMPONENT);

   if(component != 0)
   {
       return component->kind;
   }

   return ICAL_NO_COMPONENT;
}

Definition at line 393 of file icalcomponent.c.

{
    icalcomponent *impl = component;

    icalerror_check_arg_rz( (component!=0), "component");

    if (strcmp(impl->id,"comp") == 0) {
       return 1;
    } else {
       return 0;
    }

}

Definition at line 1337 of file icalcomponent.c.

{
    int i = 0;
    do {
      if (component_map[i].kind == kind)
       return 1;
    } while (component_map[i++].kind != ICAL_NO_COMPONENT);

    return 0;
}

Definition at line 1348 of file icalcomponent.c.

{
    int i;

    for (i=0; component_map[i].kind != ICAL_NO_COMPONENT; i++) {
       if (component_map[i].kind == kind) {
           return component_map[i].name;
       }
    }

    return 0;

}
void icalcomponent_merge_component ( icalcomponent *  comp,
icalcomponent *  comp_to_merge 
)

This takes 2 VCALENDAR components and merges the second one into the first, resolving any problems with conflicting TZIDs.

comp_to_merge will no longer exist after calling this function.

Definition at line 2125 of file icalcomponent.c.

{
  icalcomponent *subcomp, *next_subcomp;
  icalarray *tzids_to_rename;
  int i;

  /* Check that both components are VCALENDAR components. */
  assert (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT);
  assert (icalcomponent_isa(comp_to_merge) == ICAL_VCALENDAR_COMPONENT);

  /* Step through each subcomponent of comp_to_merge, looking for VTIMEZONEs.
     For each VTIMEZONE found, check if we need to add it to comp and if we
     need to rename it and all TZID references to it. */
  tzids_to_rename = icalarray_new (sizeof (char*), 16);
  subcomp = icalcomponent_get_first_component (comp_to_merge,
                                          ICAL_VTIMEZONE_COMPONENT);
  while (subcomp) {
    next_subcomp = icalcomponent_get_next_component (comp_to_merge,
                                               ICAL_VTIMEZONE_COMPONENT);
    /* This will add the VTIMEZONE to comp, if necessary, and also update
       the array of TZIDs we need to rename. */
    icalcomponent_merge_vtimezone (comp, subcomp, tzids_to_rename);
    /* FIXME: Handle possible NEWFAILED error. */

    subcomp = next_subcomp;
  }

  /* If we need to do any renaming of TZIDs, do it now. */
  if (tzids_to_rename->num_elements != 0) {
    icalcomponent_rename_tzids (comp_to_merge, tzids_to_rename);
      
    /* Now free the tzids_to_rename array. */
    for (i = 0; i < tzids_to_rename->num_elements; i++) {
      free (icalarray_element_at (tzids_to_rename, i));
    }
    icalarray_free (tzids_to_rename);
  }

  /* Now move all the components from comp_to_merge to comp, excluding
     VTIMEZONE components. */
  subcomp = icalcomponent_get_first_component (comp_to_merge,
                                          ICAL_ANY_COMPONENT);
  while (subcomp) {
    next_subcomp = icalcomponent_get_next_component (comp_to_merge,
                                               ICAL_ANY_COMPONENT);
    if (icalcomponent_isa(subcomp) != ICAL_VTIMEZONE_COMPONENT) {
      icalcomponent_remove_component (comp_to_merge, subcomp);
      icalcomponent_add_component (comp, subcomp);
    }
    subcomp = next_subcomp;
  }

  /* Free comp_to_merge. We have moved most of the subcomponents over to
     comp now. */
  icalcomponent_free (comp_to_merge);
}

Here is the call graph for this function:

icalcomponent* icalcomponent_new ( icalcomponent_kind  kind)

Constructor.

Definition at line 144 of file icalcomponent.c.

{
   return icalcomponent_new_impl(kind);
}

Here is the call graph for this function:

icalcomponent* icalcomponent_new_clone ( icalcomponent *  component)

Constructor.

Definition at line 178 of file icalcomponent.c.

{
    icalcomponent *new;
    icalproperty *p;
    icalcomponent *c;
    pvl_elem itr;

    icalerror_check_arg_rz( (old!=0), "component");

    new = icalcomponent_new_impl(old->kind);

    if (new == 0){
       return 0;
    }

    
    for( itr = pvl_head(old->properties);
        itr != 0;
        itr = pvl_next(itr))
    {  
       p = (icalproperty*)pvl_data(itr);
       icalcomponent_add_property(new,icalproperty_new_clone(p));
    }
   
   
    for( itr = pvl_head(old->components);
        itr != 0;
        itr = pvl_next(itr))
    {  
       c = (icalcomponent*)pvl_data(itr);
       icalcomponent_add_component(new,icalcomponent_new_clone(c));
    }

   return new;

}

Here is the call graph for this function:

icalcomponent* icalcomponent_new_from_string ( char *  str)

Constructor.

Definition at line 171 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_vagenda ( )

Definition at line 2102 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_valarm ( )

Definition at line 2082 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_vcalendar ( )

Definition at line 2066 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_vevent ( )

Definition at line 2070 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_vfreebusy ( )

Definition at line 2086 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_vjournal ( )

Definition at line 2078 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_vquery ( )

Definition at line 2106 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_vtimezone ( )

Definition at line 2090 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_vtodo ( )

Definition at line 2074 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_x ( const char *  x_name)

Constructor.

Definition at line 218 of file icalcomponent.c.

{
    icalcomponent* comp = icalcomponent_new_impl(ICAL_X_COMPONENT);
    if (!comp) {
       return 0;
    }
    comp->x_name = icalmemory_strdup(x_name);
    return comp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

icalcomponent* icalcomponent_new_xdaylight ( )

Definition at line 2098 of file icalcomponent.c.

Here is the call graph for this function:

icalcomponent* icalcomponent_new_xstandard ( )

Definition at line 2094 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_remove_component ( icalcomponent *  parent,
icalcomponent *  child 
)

Definition at line 612 of file icalcomponent.c.

{
   pvl_elem itr, next_itr;

   icalerror_check_arg_rv( (parent!=0), "parent");
   icalerror_check_arg_rv( (child!=0), "child");
   
    /* If the component is a VTIMEZONE, remove it from our array as well. */
    if (child->kind == ICAL_VTIMEZONE_COMPONENT) {
       icaltimezone *zone;
       int i, num_elements;

       num_elements = parent->timezones ? parent->timezones->num_elements : 0;
        for (i = 0; i < num_elements; i++) {
           zone = icalarray_element_at (parent->timezones, i);
           if (icaltimezone_get_component (zone) == child) {
              icaltimezone_free (zone, 0);
               icalarray_remove_element_at (parent->timezones, i);
              break;
           }
       }
    }

   for( itr = pvl_head(parent->components);
       itr != 0;
       itr = next_itr)
   {
       next_itr = pvl_next(itr);
       
       if( pvl_data(itr) == (void*)child ){

          if (parent->component_iterator == itr){
              /* Don't let the current iterator become invalid */

              /* HACK. The semantics for this are troubling. */
              parent->component_iterator = 
                 pvl_next(parent->component_iterator);
                 
          }
          pvl_remove( parent->components, itr); 
          child->parent = 0;
          break;
       }
   }   
}

Here is the call graph for this function:

void icalcomponent_remove_property ( icalcomponent *  component,
icalproperty *  property 
)

Definition at line 422 of file icalcomponent.c.

{
    pvl_elem itr, next_itr;

    icalerror_check_arg_rv( (component!=0), "component");
    icalerror_check_arg_rv( (property!=0), "property");
    
    icalerror_assert( (icalproperty_get_parent(property)),"The property is not a member of a component");

    
    for( itr = pvl_head(component->properties);
        itr != 0;
        itr = next_itr)
    {
       next_itr = pvl_next(itr);
       
       if( pvl_data(itr) == (void*)property ){

          if (component->property_iterator == itr){
              component->property_iterator = pvl_next(itr);
          }

          pvl_remove( component->properties, itr); 
         icalproperty_set_parent(property,0);
       }
    }  
}

Here is the call graph for this function:

void icalcomponent_set_comment ( icalcomponent *  comp,
const char *  v 
)

Definition at line 1831 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_description ( icalcomponent *  comp,
const char *  v 
)

Definition at line 1933 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_dtend ( icalcomponent *  comp,
struct icaltimetype  v 
)

Set DTEND property to given icaltime.

This method respects the icaltime type (DATE vs DATE-TIME) and timezone (or lack thereof).

This also checks that a DURATION property isn't already there, and returns an error if it is. It's the caller's responsibility to remove it.

Definition at line 1675 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_dtstamp ( icalcomponent *  comp,
struct icaltimetype  v 
)

Definition at line 1766 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_dtstart ( icalcomponent *  comp,
struct icaltimetype  v 
)

Set DTSTART property to given icaltime.

This method respects the icaltime type (DATE vs DATE-TIME) and timezone (or lack thereof).

Definition at line 1548 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_due ( icalcomponent *  comp,
struct icaltimetype  v 
)

Set the due date of a VTODO task.

Parameters:
compValid VTODO component.
vValid due date time.
  • If no duration or due properties then set the DUE property.
    • If a DUE property is already set, then reset it to the value v.
    • If a DURATION property is already set, then calculate the new duration based on the supplied value of v.

Definition at line 2641 of file icalcomponent.c.

{
    icalcomponent *inner = icalcomponent_get_inner(comp);

    icalproperty *due_prop
        = icalcomponent_get_first_property(inner,ICAL_DUE_PROPERTY);

    icalproperty *dur_prop
        = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY);


    if( due_prop == 0 && dur_prop == 0){
        due_prop = icalproperty_new_due(v);
        icalcomponent_add_property(inner,due_prop);
    } else if ( due_prop != 0) {
        icalproperty_set_due(due_prop,v);
    } else if ( dur_prop != 0) {
        struct icaltimetype start =
            icalcomponent_get_dtstart(inner);

        struct icaltimetype due =
            icalcomponent_get_due(inner);

        struct icaldurationtype dur
            = icaltime_subtract(due,start);

        icalproperty_set_duration(dur_prop,dur);

    } else {
        /* Error, both duration and due have been specified */
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
    }
}

Here is the call graph for this function:

void icalcomponent_set_duration ( icalcomponent *  comp,
struct icaldurationtype  v 
)

Set DURATION property to given icalduration.

This method respects the icaltime type (DATE vs DATE-TIME) and timezone (or lack thereof).

This also checks that a DTEND property isn't already there, and returns an error if it is. It's the caller's responsibility to remove it.

Definition at line 1709 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_location ( icalcomponent *  comp,
const char *  v 
)

Definition at line 1966 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_method ( icalcomponent *  comp,
icalproperty_method  method 
)

sets the METHOD property to the given method

Definition at line 1501 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_parent ( icalcomponent *  component,
icalcomponent *  parent 
)

Definition at line 1290 of file icalcomponent.c.

{
   component->parent = parent;
}
void icalcomponent_set_recurrenceid ( icalcomponent *  comp,
struct icaltimetype  v 
)

Definition at line 1897 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_relcalid ( icalcomponent *  comp,
const char *  v 
)

set the RELCALID property of a component.

Parameters:
compValid calendar component.
vRelcalid URL value

Definition at line 2547 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_sequence ( icalcomponent *  comp,
int  v 
)

Definition at line 1999 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_status ( icalcomponent *  comp,
enum icalproperty_status  v 
)

Definition at line 2033 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_summary ( icalcomponent *  comp,
const char *  v 
)

Definition at line 1795 of file icalcomponent.c.

Here is the call graph for this function:

void icalcomponent_set_uid ( icalcomponent *  comp,
const char *  v 
)

Definition at line 1864 of file icalcomponent.c.

Here is the call graph for this function:

Definition at line 1362 of file icalcomponent.c.

{
    int i;

    if (string ==0 ) { 
       return ICAL_NO_COMPONENT;
    }

    for (i=0; component_map[i].kind  != ICAL_NO_COMPONENT; i++) {
       if (strncmp(string, component_map[i].name, strlen(component_map[i].name)) == 0) {
           return component_map[i].kind;
       }
    }

    return ICAL_NO_COMPONENT;
}
void icalcomponent_strip_errors ( icalcomponent *  component)

Remove all X-LIC-ERROR properties.

Definition at line 1189 of file icalcomponent.c.

{
    icalproperty *p;
    icalcomponent *c;
    pvl_elem itr, next_itr;

   for( itr = pvl_head(component->properties);
        itr != 0;
        itr = next_itr)
    {  
       p = (icalproperty*)pvl_data(itr);
       next_itr = pvl_next(itr);

       if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY)
       {
           icalcomponent_remove_property(component,p);
       }
    }
    
    for( itr = pvl_head(component->components);
        itr != 0;
        itr = pvl_next(itr))
    {  
       c = (icalcomponent*)pvl_data(itr);
       icalcomponent_strip_errors(c);
    }
}

Here is the call graph for this function:

icalcomponent* icalcomponent_vanew ( icalcomponent_kind  kind,
  ... 
)

Constructor.

Definition at line 152 of file icalcomponent.c.

{
   va_list args;

   icalcomponent *impl = icalcomponent_new_impl(kind);

    if (impl == 0){
       return 0;
    }

   va_start(args,kind);
   icalcomponent_add_children(impl, args);
   va_end(args);

   return impl;
}

Here is the call graph for this function:

int icalproperty_recurrence_is_excluded ( icalcomponent *  comp,
struct icaltimetype dtstart,
struct icaltimetype recurtime 
)

Decide if this recurrance is acceptable.

Parameters:
compA valid icalcomponent.
dtstartThe base dtstart value for this component.
recurtimeThe time to test against.
Returns:
true if the recurrence value is excluded, false otherwise.

This function decides if a specific recurrence value is excluded by EXRULE or EXDATE properties.

It's not the most efficient code. You might get better performance if you assume that recurtime is always increasing for each call. Then you could:

  • sort the EXDATE values
    • save the state of each EXRULE iterator for the next call.

In this case though you don't need to worry how you call this function. It will always return the correct result.

first test against the exdate values

MATCHED

Now test against the EXRULEs

MATCH

exrule_time > recurtime

no matches

Definition at line 886 of file icalcomponent.c.

                                                                   {
  icalproperty *exdate, *exrule;

  if (comp == NULL || 
      dtstart == NULL || 
      recurtime == NULL ||
      icaltime_is_null_time(*recurtime))
    /* BAD DATA */
    return 1; 

  for (exdate = icalcomponent_get_first_property(comp,ICAL_EXDATE_PROPERTY);
       exdate != NULL;
       exdate = icalcomponent_get_next_property(comp,ICAL_EXDATE_PROPERTY)) {
        
    struct icaltimetype exdatetime = icalproperty_get_exdate(exdate);

    if (icaltime_compare(*recurtime, exdatetime) == 0) {
      return 1;
    }
  }

  for (exrule = icalcomponent_get_first_property(comp,ICAL_EXRULE_PROPERTY);
       exdate != NULL;
       exdate = icalcomponent_get_next_property(comp,ICAL_EXRULE_PROPERTY)) {
        
    struct icalrecurrencetype recur = icalproperty_get_exrule(exrule);
    icalrecur_iterator *exrule_itr  = icalrecur_iterator_new(recur, *dtstart);
    struct icaltimetype exrule_time;

    while (1) {
      int result;
      exrule_time = icalrecur_iterator_next(exrule_itr);

      if (icaltime_is_null_time(exrule_time))
       break;

      result = icaltime_compare(*recurtime, exrule_time);
      if (result == 0) {
       icalrecur_iterator_free(exrule_itr);
       return 1; 
      }
      if (result == 1)
       break;    
    }

    icalrecur_iterator_free(exrule_itr);
  }

  return 0;  
}

Here is the call graph for this function: