libkcal

icalcomponent.h

Go to the documentation of this file.
00001 /* -*- Mode: C -*- */
00002 /*======================================================================
00003  FILE: icalcomponent.h
00004  CREATOR: eric 20 March 1999
00005 
00006 
00007  (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
00008      http://www.softwarestudio.org
00009 
00010  This program is free software; you can redistribute it and/or modify
00011  it under the terms of either: 
00012 
00013     The LGPL as published by the Free Software Foundation, version
00014     2.1, available at: http://www.fsf.org/copyleft/lesser.html
00015 
00016   Or:
00017 
00018     The Mozilla Public License Version 1.0. You may obtain a copy of
00019     the License at http://www.mozilla.org/MPL/
00020 
00021   The original code is icalcomponent.h
00022 
00023 ======================================================================*/
00024 
00025 #ifndef ICALCOMPONENT_H
00026 #define ICALCOMPONENT_H
00027 
00028 #include "icalproperty.h"
00029 #include "icalvalue.h"
00030 #include "icalenums.h" /* defines icalcomponent_kind */
00031 #include "pvl.h"
00032 
00033 typedef struct icalcomponent_impl icalcomponent;
00034 
00035 #ifndef ICALTIMEZONE_DEFINED
00036 #define ICALTIMEZONE_DEFINED
00037 
00040 typedef struct _icaltimezone        icaltimezone;
00041 #endif
00042 
00043 
00044 /* This is exposed so that callers will not have to allocate and
00045    deallocate iterators. Pretend that you can't see it. */
00046 typedef struct icalcompiter
00047 {
00048     icalcomponent_kind kind;
00049     pvl_elem iter;
00050 
00051 } icalcompiter;
00052 
00053 icalcomponent* icalcomponent_new(icalcomponent_kind kind);
00054 icalcomponent* icalcomponent_new_clone(icalcomponent* component);
00055 icalcomponent* icalcomponent_new_from_string(char* str);
00056 icalcomponent* icalcomponent_vanew(icalcomponent_kind kind, ...);
00057 void icalcomponent_free(icalcomponent* component);
00058 
00059 char* icalcomponent_as_ical_string(icalcomponent* component);
00060 
00061 int icalcomponent_is_valid(icalcomponent* component);
00062 
00063 icalcomponent_kind icalcomponent_isa(const icalcomponent* component);
00064 
00065 int icalcomponent_isa_component (void* component);
00066 
00067 /* 
00068  * Working with properties
00069  */
00070 
00071 void icalcomponent_add_property(icalcomponent* component,
00072                 icalproperty* property);
00073 
00074 void icalcomponent_remove_property(icalcomponent* component,
00075                    icalproperty* property);
00076 
00077 int icalcomponent_count_properties(icalcomponent* component,
00078                    icalproperty_kind kind);
00079 
00080 /* Iterate through the properties */
00081 icalproperty* icalcomponent_get_current_property(icalcomponent* component);
00082 
00083 icalproperty* icalcomponent_get_first_property(icalcomponent* component,
00084                           icalproperty_kind kind);
00085 icalproperty* icalcomponent_get_next_property(icalcomponent* component,
00086                           icalproperty_kind kind);
00087 
00088 
00089 /* 
00090  * Working with components
00091  */ 
00092 
00093 
00094 /* Return the first VEVENT, VTODO or VJOURNAL sub-component of cop, or
00095    comp if it is one of those types */
00096 
00097 icalcomponent* icalcomponent_get_inner(icalcomponent* comp);
00098 
00099 
00100 void icalcomponent_add_component(icalcomponent* parent,
00101                 icalcomponent* child);
00102 
00103 void icalcomponent_remove_component(icalcomponent* parent,
00104                 icalcomponent* child);
00105 
00106 int icalcomponent_count_components(icalcomponent* component,
00107                    icalcomponent_kind kind);
00108 
00113 void icalcomponent_merge_component(icalcomponent* comp,
00114                    icalcomponent* comp_to_merge);
00115 
00116 
00117 /* Iteration Routines. There are two forms of iterators, internal and
00118 external. The internal ones came first, and are almost completely
00119 sufficient, but they fail badly when you want to construct a loop that
00120 removes components from the container.*/
00121 
00122 
00123 /* Iterate through components */
00124 icalcomponent* icalcomponent_get_current_component (icalcomponent* component);
00125 
00126 icalcomponent* icalcomponent_get_first_component(icalcomponent* component,
00127                           icalcomponent_kind kind);
00128 icalcomponent* icalcomponent_get_next_component(icalcomponent* component,
00129                           icalcomponent_kind kind);
00130 
00131 /* Using external iterators */
00132 icalcompiter icalcomponent_begin_component(icalcomponent* component,
00133                        icalcomponent_kind kind);
00134 icalcompiter icalcomponent_end_component(icalcomponent* component,
00135                      icalcomponent_kind kind);
00136 icalcomponent* icalcompiter_next(icalcompiter* i);
00137 icalcomponent* icalcompiter_prior(icalcompiter* i);
00138 icalcomponent* icalcompiter_deref(icalcompiter* i);
00139 
00140 
00141 /* Working with embedded error properties */
00142 
00143 
00144 /* Check the component against itip rules and insert error properties*/
00145 /* Working with embedded error properties */
00146 int icalcomponent_check_restrictions(icalcomponent* comp);
00147 
00149 int icalcomponent_count_errors(icalcomponent* component);
00150 
00152 void icalcomponent_strip_errors(icalcomponent* component);
00153 
00155 void icalcomponent_convert_errors(icalcomponent* component);
00156 
00157 /* Internal operations. They are private, and you should not be using them. */
00158 icalcomponent* icalcomponent_get_parent(icalcomponent* component);
00159 void icalcomponent_set_parent(icalcomponent* component, 
00160                   icalcomponent* parent);
00161 
00162 /* Kind conversion routines */
00163 
00164 int icalcomponent_kind_is_valid(const icalcomponent_kind kind);
00165 
00166 icalcomponent_kind icalcomponent_string_to_kind(const char* string);
00167 
00168 const char* icalcomponent_kind_to_string(icalcomponent_kind kind);
00169 
00170 
00171 /************* Derived class methods.  ****************************
00172 
00173 If the code was in an OO language, the remaining routines would be
00174 members of classes derived from icalcomponent. Don't call them on the
00175 wrong component subtypes. */
00176 
00179 icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c);
00180 
00183 struct icaltime_span icalcomponent_get_span(icalcomponent* comp);
00184 
00185 /******************** Convienience routines **********************/
00186 
00187 void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v);
00188 struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp);
00189 
00190 /* For the icalcomponent routines only, dtend and duration are tied
00191    together. If you call the set routine for one and the other exists,
00192    the routine will calculate the change to the other. That is, if
00193    there is a DTEND and you call set_duration, the routine will modify
00194    DTEND to be the sum of DTSTART and the duration. If you call a get
00195    routine for one and the other exists, the routine will calculate
00196    the return value. If you call a set routine and neither exists, the
00197    routine will create the apcompriate comperty */
00198 
00199 
00200 struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp);
00201 void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v);
00202 
00203 struct icaltimetype icalcomponent_get_due(icalcomponent* comp);
00204 void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v);
00205 
00206 void icalcomponent_set_duration(icalcomponent* comp, 
00207                 struct icaldurationtype v);
00208 struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp);
00209 
00210 void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method);
00211 icalproperty_method icalcomponent_get_method(icalcomponent* comp);
00212 
00213 struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp);
00214 void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v);
00215 
00216 void icalcomponent_set_summary(icalcomponent* comp, const char* v);
00217 const char* icalcomponent_get_summary(icalcomponent* comp);
00218 
00219 void icalcomponent_set_comment(icalcomponent* comp, const char* v);
00220 const char* icalcomponent_get_comment(icalcomponent* comp);
00221 
00222 void icalcomponent_set_uid(icalcomponent* comp, const char* v);
00223 const char* icalcomponent_get_uid(icalcomponent* comp);
00224 
00225 void icalcomponent_set_relcalid(icalcomponent* comp, const char* v);
00226 const char* icalcomponent_get_relcalid(icalcomponent* comp);
00227 
00228 void icalcomponent_set_recurrenceid(icalcomponent* comp, 
00229                     struct icaltimetype v);
00230 struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp);
00231 
00232 void icalcomponent_set_description(icalcomponent* comp, const char* v);
00233 const char* icalcomponent_get_description(icalcomponent* comp);
00234 
00235 void icalcomponent_set_location(icalcomponent* comp, const char* v);
00236 const char* icalcomponent_get_location(icalcomponent* comp);
00237 
00238 void icalcomponent_set_sequence(icalcomponent* comp, int v);
00239 int icalcomponent_get_sequence(icalcomponent* comp);
00240 
00241 void icalcomponent_set_status(icalcomponent* comp, enum icalproperty_status v);
00242 enum icalproperty_status icalcomponent_get_status(icalcomponent* comp);
00243 
00244 
00247 void icalcomponent_foreach_tzid(icalcomponent* comp,
00248                 void (*callback)(icalparameter *param, void *data),
00249                 void *callback_data);
00250 
00253 icaltimezone* icalcomponent_get_timezone(icalcomponent* comp,
00254                      const char *tzid);
00255 
00256 int icalproperty_recurrence_is_excluded(icalcomponent *comp,
00257                                        struct icaltimetype *dtstart,
00258                                        struct icaltimetype *recurtime); 
00259 
00260 void icalcomponent_foreach_recurrence(icalcomponent* comp,
00261                       struct icaltimetype start,
00262                       struct icaltimetype end,
00263             void (*callback)(icalcomponent *comp, 
00264                                          struct icaltime_span *span, 
00265                                          void *data),
00266                   void *callback_data);
00267 
00268 
00269 /*************** Type Specific routines ***************/
00270 
00271 icalcomponent* icalcomponent_new_vcalendar();
00272 icalcomponent* icalcomponent_new_vevent();
00273 icalcomponent* icalcomponent_new_vtodo();
00274 icalcomponent* icalcomponent_new_vjournal();
00275 icalcomponent* icalcomponent_new_valarm();
00276 icalcomponent* icalcomponent_new_vfreebusy();
00277 icalcomponent* icalcomponent_new_vtimezone();
00278 icalcomponent* icalcomponent_new_xstandard();
00279 icalcomponent* icalcomponent_new_xdaylight();
00280 icalcomponent* icalcomponent_new_vagenda();
00281 icalcomponent* icalcomponent_new_vquery();
00282 
00283 #endif /* !ICALCOMPONENT_H */