Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
icalcomponent.h
Go to the documentation of this file.
1/*======================================================================
2 FILE: icalcomponent.h
3 CREATOR: eric 20 March 1999
4
5 SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com>
6 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7======================================================================*/
8
12
13#ifndef ICALCOMPONENT_H
14#define ICALCOMPONENT_H
15
16#include "libical_sentinel.h"
17#include "libical_ical_export.h"
18#include "icalenums.h" /* Defines icalcomponent_kind */
19#include "icalproperty.h"
20#include "icalpvl.h"
21
22typedef struct icalcomponent_impl icalcomponent;
23
24/* This is exposed so that callers will not have to allocate and
25 deallocate iterators. Pretend that you can't see it. */
26typedef struct icalcompiter {
27 icalcomponent_kind kind;
28 icalpvl_elem iter;
30
31typedef struct icalpropiter {
32 icalproperty_kind kind;
33 icalpvl_elem iter;
35
38LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new(icalcomponent_kind kind);
39
45LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_clone(const icalcomponent *old);
46
49LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_from_string(const char *str);
50
55LIBICAL_ICAL_EXPORT LIBICAL_SENTINEL icalcomponent *icalcomponent_vanew(icalcomponent_kind kind, ...);
56
59LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_x(const char *x_name);
60
69LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_iana(const char *iana_name);
70
71/*** @brief Destructor
72 */
73LIBICAL_ICAL_EXPORT void icalcomponent_free(icalcomponent *component);
74
75LIBICAL_ICAL_EXPORT char *icalcomponent_as_ical_string(const icalcomponent *component);
76
77LIBICAL_ICAL_EXPORT char *icalcomponent_as_ical_string_r(const icalcomponent *component);
78
79LIBICAL_ICAL_EXPORT bool icalcomponent_is_valid(const icalcomponent *component);
80
81LIBICAL_ICAL_EXPORT icalcomponent_kind icalcomponent_isa(const icalcomponent *component);
82
83LIBICAL_ICAL_EXPORT bool icalcomponent_isa_component(const void *component);
84
85/* Deal with X components */
86
87LIBICAL_ICAL_EXPORT void icalcomponent_set_x_name(icalcomponent *comp, const char *name);
88LIBICAL_ICAL_EXPORT const char *icalcomponent_get_x_name(const icalcomponent *comp);
89
90/* Deal with IANA components */
91
99LIBICAL_ICAL_EXPORT void icalcomponent_set_iana_name(icalcomponent *comp, const char *name);
100
110LIBICAL_ICAL_EXPORT const char *icalcomponent_get_iana_name(const icalcomponent *comp);
111
115LIBICAL_ICAL_EXPORT const char *icalcomponent_get_component_name(const icalcomponent *comp);
116LIBICAL_ICAL_EXPORT char *icalcomponent_get_component_name_r(const icalcomponent *comp);
117
118/***** Working with Properties *****/
119
120LIBICAL_ICAL_EXPORT void icalcomponent_add_property(icalcomponent *component,
121 icalproperty *property);
122
123LIBICAL_ICAL_EXPORT void icalcomponent_remove_property(icalcomponent *component,
124 icalproperty *property);
125
126LIBICAL_ICAL_EXPORT void icalcomponent_remove_property_by_kind(icalcomponent *component,
127 icalproperty_kind kind);
128
129LIBICAL_ICAL_EXPORT int icalcomponent_count_properties(icalcomponent *component,
130 icalproperty_kind kind);
131
136LIBICAL_ICAL_EXPORT void icalproperty_set_parent(icalproperty *property,
137 icalcomponent *component);
138
142LIBICAL_ICAL_EXPORT icalcomponent *icalproperty_get_parent(const icalproperty *property);
143
144/* Iterate through the properties */
145LIBICAL_ICAL_EXPORT icalproperty *icalcomponent_get_current_property(icalcomponent *component);
146
147LIBICAL_ICAL_EXPORT icalproperty *icalcomponent_get_first_property(icalcomponent *component,
148 icalproperty_kind kind);
149LIBICAL_ICAL_EXPORT icalproperty *icalcomponent_get_next_property(icalcomponent *component,
150 icalproperty_kind kind);
151
152/***** Working with Components *****/
153
156LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_inner(icalcomponent *comp);
157
158LIBICAL_ICAL_EXPORT void icalcomponent_add_component(icalcomponent *parent, icalcomponent *child);
159
160LIBICAL_ICAL_EXPORT void icalcomponent_remove_component(icalcomponent *parent,
161 icalcomponent *child);
162
163LIBICAL_ICAL_EXPORT int icalcomponent_count_components(icalcomponent *component,
164 icalcomponent_kind kind);
165
171LIBICAL_ICAL_EXPORT void icalcomponent_merge_component(icalcomponent *comp,
172 icalcomponent *comp_to_merge);
173
174/* Iteration Routines. There are two forms of iterators, internal and
175external. The internal ones came first, and are almost completely
176sufficient, but they fail badly when you want to construct a loop that
177removes components from the container.*/
178
179/* Iterate through components */
180LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_current_component(icalcomponent *component);
181
182LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_first_component(icalcomponent *component,
183 icalcomponent_kind kind);
184LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_next_component(icalcomponent *component,
185 icalcomponent_kind kind);
186
187/* Using external iterators */
188LIBICAL_ICAL_EXPORT icalcompiter icalcomponent_begin_component(icalcomponent *component,
189 icalcomponent_kind kind);
190
191LIBICAL_ICAL_EXPORT icalcompiter icalcomponent_end_component(icalcomponent *component,
192 icalcomponent_kind kind);
193
194LIBICAL_ICAL_EXPORT icalcomponent *icalcompiter_next(icalcompiter *i);
195
196LIBICAL_ICAL_EXPORT icalcomponent *icalcompiter_prior(icalcompiter *i);
197
198LIBICAL_ICAL_EXPORT icalcomponent *icalcompiter_deref(icalcompiter *i);
199
209LIBICAL_ICAL_EXPORT bool icalcompiter_is_valid(const icalcompiter *i);
210
211LIBICAL_ICAL_EXPORT icalpropiter icalcomponent_begin_property(icalcomponent *component,
212 icalproperty_kind kind);
213
214LIBICAL_ICAL_EXPORT icalproperty *icalpropiter_next(icalpropiter *i);
215
216LIBICAL_ICAL_EXPORT icalproperty *icalpropiter_deref(icalpropiter *i);
217
227LIBICAL_ICAL_EXPORT bool icalpropiter_is_valid(const icalpropiter *i);
228
229/***** Working with embedded error properties *****/
230
231/* Check the component against itip rules and insert error properties */
232/* Working with embedded error properties */
233LIBICAL_ICAL_EXPORT bool icalcomponent_check_restrictions(icalcomponent *comp);
234
240LIBICAL_ICAL_EXPORT int icalcomponent_count_errors(icalcomponent *component);
241
243LIBICAL_ICAL_EXPORT void icalcomponent_strip_errors(icalcomponent *component);
244
246LIBICAL_ICAL_EXPORT void icalcomponent_convert_errors(icalcomponent *component);
247
248/* Internal operations. They are private, and you should not be using them. */
249LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_parent(const icalcomponent *component);
250
251LIBICAL_ICAL_EXPORT void icalcomponent_set_parent(icalcomponent *component,
252 icalcomponent *parent);
253
254/* Kind conversion routines */
255
256LIBICAL_ICAL_EXPORT bool icalcomponent_kind_is_valid(const icalcomponent_kind kind);
257
258LIBICAL_ICAL_EXPORT icalcomponent_kind icalcomponent_string_to_kind(const char *string);
259
260LIBICAL_ICAL_EXPORT const char *icalcomponent_kind_to_string(icalcomponent_kind kind);
261
262/************* Derived class methods. ****************************
263
264If the code was in an OO language, the remaining routines would be
265members of classes derived from icalcomponent. Don't call them on the
266wrong component subtypes. */
267
271LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_first_real_component(const icalcomponent *c);
272
289LIBICAL_ICAL_EXPORT struct icaltime_span icalcomponent_get_span(icalcomponent *comp);
290
291/******************** Convenience routines **********************/
292
298LIBICAL_ICAL_EXPORT void icalcomponent_set_dtstart(icalcomponent *comp, struct icaltimetype v);
299
309LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_dtstart(icalcomponent *comp);
310
311/* For the icalcomponent routines only, dtend and duration are tied
312 together. If you call the get routine for one and the other exists,
313 the routine will calculate the return value. That is, if there is a
314 DTEND and you call get_duration, the routine will return the difference
315 between DTEND and DTSTART. However, if you call a set routine for
316 one and the other exists, no action will be taken and icalerrno will
317 be set to ICAL_MALFORMEDDATA_ERROR. If you call a set routine and
318 neither exists, the routine will create the appropriate property. */
319
345LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_dtend(icalcomponent *comp);
346
362LIBICAL_ICAL_EXPORT void icalcomponent_set_dtend(icalcomponent *comp, struct icaltimetype v);
363
371LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_due(icalcomponent *comp);
372
384LIBICAL_ICAL_EXPORT void icalcomponent_set_due(icalcomponent *comp, struct icaltimetype v);
385
401LIBICAL_ICAL_EXPORT void icalcomponent_set_duration(icalcomponent *comp,
402 struct icaldurationtype v);
403
416LIBICAL_ICAL_EXPORT struct icaldurationtype icalcomponent_get_duration(icalcomponent *comp);
417
420LIBICAL_ICAL_EXPORT void icalcomponent_set_method(icalcomponent *comp, icalproperty_method method);
421
424LIBICAL_ICAL_EXPORT icalproperty_method icalcomponent_get_method(icalcomponent *comp);
425
426LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_dtstamp(icalcomponent *comp);
427
428LIBICAL_ICAL_EXPORT void icalcomponent_set_dtstamp(icalcomponent *comp, struct icaltimetype v);
429
430LIBICAL_ICAL_EXPORT void icalcomponent_set_summary(icalcomponent *comp, const char *v);
431
432LIBICAL_ICAL_EXPORT const char *icalcomponent_get_summary(icalcomponent *comp);
433
434LIBICAL_ICAL_EXPORT void icalcomponent_set_comment(icalcomponent *comp, const char *v);
435
436LIBICAL_ICAL_EXPORT const char *icalcomponent_get_comment(icalcomponent *comp);
437
438LIBICAL_ICAL_EXPORT void icalcomponent_set_uid(icalcomponent *comp, const char *v);
439
440LIBICAL_ICAL_EXPORT const char *icalcomponent_get_uid(icalcomponent *comp);
441
442LIBICAL_ICAL_EXPORT void icalcomponent_set_relcalid(icalcomponent *comp, const char *v);
443
444LIBICAL_ICAL_EXPORT const char *icalcomponent_get_relcalid(icalcomponent *comp);
445
446LIBICAL_ICAL_EXPORT void icalcomponent_set_recurrenceid(icalcomponent *comp,
447 struct icaltimetype v);
448
449LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent *comp);
450
451LIBICAL_ICAL_EXPORT void icalcomponent_set_description(icalcomponent *comp, const char *v);
452
453LIBICAL_ICAL_EXPORT const char *icalcomponent_get_description(icalcomponent *comp);
454
455LIBICAL_ICAL_EXPORT void icalcomponent_set_location(icalcomponent *comp, const char *v);
456
457LIBICAL_ICAL_EXPORT const char *icalcomponent_get_location(icalcomponent *comp);
458
459LIBICAL_ICAL_EXPORT void icalcomponent_set_sequence(icalcomponent *comp, int v);
460
461LIBICAL_ICAL_EXPORT int icalcomponent_get_sequence(icalcomponent *comp);
462
463LIBICAL_ICAL_EXPORT void icalcomponent_set_status(icalcomponent *comp, enum icalproperty_status v);
464
471LIBICAL_ICAL_EXPORT enum icalproperty_status icalcomponent_get_status(icalcomponent *comp);
472
476LIBICAL_ICAL_EXPORT void icalcomponent_foreach_tzid(icalcomponent *comp,
477 void (*callback)(icalparameter *param,
478 void *data),
479 void *callback_data);
480
484LIBICAL_ICAL_EXPORT icaltimezone *icalcomponent_get_timezone(icalcomponent *comp,
485 const char *tzid);
486
509LIBICAL_ICAL_EXPORT bool icalproperty_recurrence_is_excluded(icalcomponent *comp,
510 struct icaltimetype *dtstart,
511 struct icaltimetype *recurtime);
512
528LIBICAL_ICAL_EXPORT void icalcomponent_foreach_recurrence(icalcomponent *comp,
529 struct icaltimetype start,
530 struct icaltimetype end,
531 void (*callback)(icalcomponent *comp,
532 const struct icaltime_span *span,
533 void *data),
534 void *callback_data);
535
540LIBICAL_ICAL_EXPORT void icalcomponent_normalize(icalcomponent *comp);
541
553 icalproperty *prop,
554 icalcomponent *comp);
555/*************** Type Specific routines ***************/
556
557LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vcalendar(void);
558
559LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vevent(void);
560
561LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vtodo(void);
562
563LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vjournal(void);
564
565LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_valarm(void);
566
567LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vfreebusy(void);
568
569LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vtimezone(void);
570
571LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xstandard(void);
572
573LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xdaylight(void);
574
575LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vagenda(void);
576
577LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vquery(void);
578
579LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vreply(void);
580
581LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vavailability(void);
582
583LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xavailable(void);
584
585LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vpoll(void);
586
587LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vvoter(void);
588
589LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xvote(void);
590
591LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vpatch(void);
592
593LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xpatch(void);
594
595LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_participant(void);
596
597LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vlocation(void);
598
599LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vresource(void);
600
601#endif /* !ICALCOMPONENT_H */
void icalcomponent_convert_errors(icalcomponent *component)
Converts some X-LIC-ERROR properties into RETURN-STATUS properties.
Definition icalcomponent.c:1203
void icalcomponent_set_relcalid(icalcomponent *comp, const char *v)
Sets the RELCALID property of a component.
Definition icalcomponent.c:2623
icalproperty_method icalcomponent_get_method(icalcomponent *comp)
Returns the METHOD property.
Definition icalcomponent.c:1563
bool icalcompiter_is_valid(const icalcompiter *i)
Definition icalcomponent.c:1382
icalcomponent * icalproperty_get_parent(const icalproperty *property)
Returns the parent icalcomponent for the specified property.
Definition icalproperty.c:931
void icalcomponent_set_iana_name(icalcomponent *comp, const char *name)
Definition icalcomponent.c:356
void icalcomponent_set_dtstart(icalcomponent *comp, struct icaltimetype v)
Sets the DTSTART property to the given icaltime,.
Definition icalcomponent.c:1585
void icalcomponent_strip_errors(icalcomponent *component)
Removes all X-LIC-ERROR properties.
Definition icalcomponent.c:1180
void icalcomponent_normalize(icalcomponent *comp)
Normalizes (reorders and sorts the properties) the specified icalcomponent comp.
Definition icalcomponent.c:2883
enum icalproperty_status icalcomponent_get_status(icalcomponent *comp)
Definition icalcomponent.c:2054
struct icaltimetype icalproperty_get_datetime_with_component(icalproperty *prop, icalcomponent *comp)
Gets a DATE or DATE-TIME property as an icaltime.
Definition icalproperty.c:1074
icalcomponent * icalcomponent_vanew(icalcomponent_kind kind,...)
Constructor.
Definition icalcomponent.c:105
void icalcomponent_set_method(icalcomponent *comp, icalproperty_method method)
Sets the METHOD property to the given method.
Definition icalcomponent.c:1551
icalcomponent * icalcomponent_new(icalcomponent_kind kind)
Constructor.
Definition icalcomponent.c:100
icalcomponent * icalcomponent_get_inner(icalcomponent *comp)
Definition icalcomponent.c:1542
void icalproperty_set_parent(icalproperty *property, icalcomponent *component)
Sets the parent icalcomponent for the specified icalproperty property.
Definition icalproperty.c:924
const char * icalcomponent_get_relcalid(icalcomponent *comp)
Gets the RELCALID property of a component.
Definition icalcomponent.c:2641
icalcomponent * icalcomponent_get_first_real_component(const icalcomponent *c)
Returns a reference to the first VEVENT, VTODO or VJOURNAL in the component.
Definition icalcomponent.c:682
void icalcomponent_merge_component(icalcomponent *comp, icalcomponent *comp_to_merge)
Definition icalcomponent.c:2191
bool icalpropiter_is_valid(const icalpropiter *i)
Definition icalcomponent.c:1503
bool icalproperty_recurrence_is_excluded(icalcomponent *comp, struct icaltimetype *dtstart, struct icaltimetype *recurtime)
Decides if a recurrence is acceptable.
Definition icalcomponent.c:773
int icalcomponent_count_errors(icalcomponent *component)
Returns the number of errors encountered parsing the data.
Definition icalcomponent.c:1158
icalcomponent * icalcomponent_clone(const icalcomponent *old)
Deeply clones an icalcomponent. Returns a pointer to the memory for the newly cloned icalcomponent.
Definition icalcomponent.c:129
icalcomponent * icalcomponent_new_iana(const char *iana_name)
Definition icalcomponent.c:172
const char * icalcomponent_get_iana_name(const icalcomponent *comp)
Definition icalcomponent.c:370
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 icalcomponent.c:2481
void icalcomponent_set_dtend(icalcomponent *comp, struct icaltimetype v)
Sets the DTEND property to given icaltime.
Definition icalcomponent.c:1674
const char * icalcomponent_get_component_name(const icalcomponent *comp)
Definition icalcomponent.c:378
icalcomponent * icalcomponent_new_x(const char *x_name)
Construct a component with an x-name name.
Definition icalcomponent.c:161
void icalcomponent_set_duration(icalcomponent *comp, struct icaldurationtype v)
Sets the DURATION property to given icalduration.
Definition icalcomponent.c:1699
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.
Definition icalcomponent.c:2445
void icalcomponent_set_due(icalcomponent *comp, struct icaltimetype v)
Sets the due date of a VTODO task.
Definition icalcomponent.c:2684
void icalcomponent_foreach_recurrence(icalcomponent *comp, struct icaltimetype start, struct icaltimetype end, void(*callback)(icalcomponent *comp, const struct icaltime_span *span, void *data), void *callback_data)
Cycles through all recurrences of an event.
Definition icalcomponent.c:962
icalcomponent * icalcomponent_new_from_string(const char *str)
Constructor.
Definition icalcomponent.c:124
struct _icaltimezone icaltimezone
An opaque struct representing a timezone. We declare this here to avoid a circular dependency.
Definition icaltime.h:84
Definition icalcomponent.h:26
A struct representing a duration.
Definition icalduration.h:30
Definition icalcomponent.h:31
Definition icaltime.h:88
Definition icaltime.h:96