2 /*======================================================================
4 CREATOR: eric 20 March 1999
7 (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
8 http://www.softwarestudio.org
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of either:
13 The LGPL as published by the Free Software Foundation, version
14 2.1, available at: http://www.fsf.org/copyleft/lesser.html
18 The Mozilla Public License Version 1.0. You may obtain a copy of
19 the License at http://www.mozilla.org/MPL/
21 The original code is icalcomponent.h
23 ======================================================================*/
25 #ifndef ICALCOMPONENT_H
26 #define ICALCOMPONENT_H
28 #include "icalproperty.h"
29 #include "icalvalue.h"
30 #include "icalenums.h" /* defines icalcomponent_kind */
33 typedef struct icalcomponent_impl icalcomponent;
35 #ifndef ICALTIMEZONE_DEFINED
36 #define ICALTIMEZONE_DEFINED
37 /** @brief An opaque struct representing a timezone.
38 * We declare this here to avoid a circular dependancy.
40 typedef struct _icaltimezone icaltimezone;
44 /* This is exposed so that callers will not have to allocate and
45 deallocate iterators. Pretend that you can't see it. */
46 typedef struct icalcompiter
48 icalcomponent_kind kind;
53 icalcomponent* icalcomponent_new(icalcomponent_kind kind);
54 icalcomponent* icalcomponent_new_clone(icalcomponent* component);
55 icalcomponent* icalcomponent_new_from_string(const char* str);
56 icalcomponent* icalcomponent_vanew(icalcomponent_kind kind, ...);
57 icalcomponent* icalcomponent_new_x(const char* x_name);
58 void icalcomponent_free(icalcomponent* component);
60 char* icalcomponent_as_ical_string(icalcomponent* component);
61 char* icalcomponent_as_ical_string_r(icalcomponent* component);
63 int icalcomponent_is_valid(icalcomponent* component);
65 icalcomponent_kind icalcomponent_isa(const icalcomponent* component);
67 int icalcomponent_isa_component (void* component);
70 * Working with properties
73 void icalcomponent_add_property(icalcomponent* component,
74 icalproperty* property);
76 void icalcomponent_remove_property(icalcomponent* component,
77 icalproperty* property);
79 int icalcomponent_count_properties(icalcomponent* component,
80 icalproperty_kind kind);
82 /* Iterate through the properties */
83 icalproperty* icalcomponent_get_current_property(icalcomponent* component);
85 icalproperty* icalcomponent_get_first_property(icalcomponent* component,
86 icalproperty_kind kind);
87 icalproperty* icalcomponent_get_next_property(icalcomponent* component,
88 icalproperty_kind kind);
92 * Working with components
96 /* Return the first VEVENT, VTODO or VJOURNAL sub-component of cop, or
97 comp if it is one of those types */
99 icalcomponent* icalcomponent_get_inner(icalcomponent* comp);
102 void icalcomponent_add_component(icalcomponent* parent,
103 icalcomponent* child);
105 void icalcomponent_remove_component(icalcomponent* parent,
106 icalcomponent* child);
108 int icalcomponent_count_components(icalcomponent* component,
109 icalcomponent_kind kind);
112 This takes 2 VCALENDAR components and merges the second one into the first,
113 resolving any problems with conflicting TZIDs. comp_to_merge will no
114 longer exist after calling this function. */
115 void icalcomponent_merge_component(icalcomponent* comp,
116 icalcomponent* comp_to_merge);
119 /* Iteration Routines. There are two forms of iterators, internal and
120 external. The internal ones came first, and are almost completely
121 sufficient, but they fail badly when you want to construct a loop that
122 removes components from the container.*/
125 /* Iterate through components */
126 icalcomponent* icalcomponent_get_current_component (icalcomponent* component);
128 icalcomponent* icalcomponent_get_first_component(icalcomponent* component,
129 icalcomponent_kind kind);
130 icalcomponent* icalcomponent_get_next_component(icalcomponent* component,
131 icalcomponent_kind kind);
133 /* Using external iterators */
134 icalcompiter icalcomponent_begin_component(icalcomponent* component,
135 icalcomponent_kind kind);
136 icalcompiter icalcomponent_end_component(icalcomponent* component,
137 icalcomponent_kind kind);
138 icalcomponent* icalcompiter_next(icalcompiter* i);
139 icalcomponent* icalcompiter_prior(icalcompiter* i);
140 icalcomponent* icalcompiter_deref(icalcompiter* i);
143 /* Working with embedded error properties */
146 /* Check the component against itip rules and insert error properties*/
147 /* Working with embedded error properties */
148 int icalcomponent_check_restrictions(icalcomponent* comp);
150 /** Count embedded errors. */
151 int icalcomponent_count_errors(icalcomponent* component);
153 /** Remove all X-LIC-ERROR properties*/
154 void icalcomponent_strip_errors(icalcomponent* component);
156 /** Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/
157 void icalcomponent_convert_errors(icalcomponent* component);
159 /* Internal operations. They are private, and you should not be using them. */
160 icalcomponent* icalcomponent_get_parent(icalcomponent* component);
161 void icalcomponent_set_parent(icalcomponent* component,
162 icalcomponent* parent);
164 /* Kind conversion routines */
166 int icalcomponent_kind_is_valid(const icalcomponent_kind kind);
168 icalcomponent_kind icalcomponent_string_to_kind(const char* string);
170 const char* icalcomponent_kind_to_string(icalcomponent_kind kind);
173 /************* Derived class methods. ****************************
175 If the code was in an OO language, the remaining routines would be
176 members of classes derived from icalcomponent. Don't call them on the
177 wrong component subtypes. */
179 /** For VCOMPONENT: Return a reference to the first VEVENT, VTODO or
181 icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c);
183 /** For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end
184 times of an event in UTC */
185 struct icaltime_span icalcomponent_get_span(icalcomponent* comp);
187 /******************** Convienience routines **********************/
189 void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v);
190 struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp);
192 /* For the icalcomponent routines only, dtend and duration are tied
193 together. If you call the set routine for one and the other exists,
194 the routine will calculate the change to the other. That is, if
195 there is a DTEND and you call set_duration, the routine will modify
196 DTEND to be the sum of DTSTART and the duration. If you call a get
197 routine for one and the other exists, the routine will calculate
198 the return value. If you call a set routine and neither exists, the
199 routine will create the apcompriate comperty */
202 struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp);
203 void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v);
205 struct icaltimetype icalcomponent_get_due(icalcomponent* comp);
206 void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v);
208 void icalcomponent_set_duration(icalcomponent* comp,
209 struct icaldurationtype v);
210 struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp);
212 void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method);
213 icalproperty_method icalcomponent_get_method(icalcomponent* comp);
215 struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp);
216 void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v);
218 void icalcomponent_set_summary(icalcomponent* comp, const char* v);
219 const char* icalcomponent_get_summary(icalcomponent* comp);
221 void icalcomponent_set_comment(icalcomponent* comp, const char* v);
222 const char* icalcomponent_get_comment(icalcomponent* comp);
224 void icalcomponent_set_uid(icalcomponent* comp, const char* v);
225 const char* icalcomponent_get_uid(icalcomponent* comp);
227 void icalcomponent_set_relcalid(icalcomponent* comp, const char* v);
228 const char* icalcomponent_get_relcalid(icalcomponent* comp);
230 void icalcomponent_set_recurrenceid(icalcomponent* comp,
231 struct icaltimetype v);
232 struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp);
234 void icalcomponent_set_description(icalcomponent* comp, const char* v);
235 const char* icalcomponent_get_description(icalcomponent* comp);
237 void icalcomponent_set_location(icalcomponent* comp, const char* v);
238 const char* icalcomponent_get_location(icalcomponent* comp);
240 void icalcomponent_set_sequence(icalcomponent* comp, int v);
241 int icalcomponent_get_sequence(icalcomponent* comp);
243 void icalcomponent_set_status(icalcomponent* comp, enum icalproperty_status v);
244 enum icalproperty_status icalcomponent_get_status(icalcomponent* comp);
247 /** Calls the given function for each TZID parameter found in the
248 component, and any subcomponents. */
249 void icalcomponent_foreach_tzid(icalcomponent* comp,
250 void (*callback)(icalparameter *param, void *data),
251 void *callback_data);
253 /** Returns the icaltimezone in the component corresponding to the
254 TZID, or NULL if it can't be found. */
255 icaltimezone* icalcomponent_get_timezone(icalcomponent* comp,
258 int icalproperty_recurrence_is_excluded(icalcomponent *comp,
259 struct icaltimetype *dtstart,
260 struct icaltimetype *recurtime);
262 void icalcomponent_foreach_recurrence(icalcomponent* comp,
263 struct icaltimetype start,
264 struct icaltimetype end,
265 void (*callback)(icalcomponent *comp,
266 struct icaltime_span *span,
268 void *callback_data);
271 /*************** Type Specific routines ***************/
273 icalcomponent* icalcomponent_new_vcalendar(void);
274 icalcomponent* icalcomponent_new_vevent(void);
275 icalcomponent* icalcomponent_new_vtodo(void);
276 icalcomponent* icalcomponent_new_vjournal(void);
277 icalcomponent* icalcomponent_new_valarm(void);
278 icalcomponent* icalcomponent_new_vfreebusy(void);
279 icalcomponent* icalcomponent_new_vtimezone(void);
280 icalcomponent* icalcomponent_new_xstandard(void);
281 icalcomponent* icalcomponent_new_xdaylight(void);
282 icalcomponent* icalcomponent_new_vagenda(void);
283 icalcomponent* icalcomponent_new_vquery(void);
285 #endif /* !ICALCOMPONENT_H */