icalcomponent.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*======================================================================
  2. FILE: icalcomponent.h
  3. CREATOR: eric 20 March 1999
  4. (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
  5. http://www.softwarestudio.org
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of either:
  8. The LGPL as published by the Free Software Foundation, version
  9. 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
  10. Or:
  11. The Mozilla Public License Version 1.0. You may obtain a copy of
  12. the License at http://www.mozilla.org/MPL/
  13. ======================================================================*/
  14. #ifndef ICALCOMPONENT_H
  15. #define ICALCOMPONENT_H
  16. #include "libical_ical_export.h"
  17. #include "icalenums.h" /* defines icalcomponent_kind */
  18. #include "icalproperty.h"
  19. #include "pvl.h"
  20. typedef struct icalcomponent_impl icalcomponent;
  21. /* This is exposed so that callers will not have to allocate and
  22. deallocate iterators. Pretend that you can't see it. */
  23. typedef struct icalcompiter
  24. {
  25. icalcomponent_kind kind;
  26. pvl_elem iter;
  27. } icalcompiter;
  28. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new(icalcomponent_kind kind);
  29. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_clone(icalcomponent *component);
  30. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_from_string(const char *str);
  31. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_vanew(icalcomponent_kind kind, ...);
  32. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_x(const char *x_name);
  33. LIBICAL_ICAL_EXPORT void icalcomponent_free(icalcomponent *component);
  34. LIBICAL_ICAL_EXPORT char *icalcomponent_as_ical_string(icalcomponent *component);
  35. LIBICAL_ICAL_EXPORT char *icalcomponent_as_ical_string_r(icalcomponent *component);
  36. LIBICAL_ICAL_EXPORT int icalcomponent_is_valid(icalcomponent *component);
  37. LIBICAL_ICAL_EXPORT icalcomponent_kind icalcomponent_isa(const icalcomponent *component);
  38. LIBICAL_ICAL_EXPORT int icalcomponent_isa_component(void *component);
  39. /*
  40. * Working with properties
  41. */
  42. LIBICAL_ICAL_EXPORT void icalcomponent_add_property(icalcomponent *component,
  43. icalproperty *property);
  44. LIBICAL_ICAL_EXPORT void icalcomponent_remove_property(icalcomponent *component,
  45. icalproperty *property);
  46. LIBICAL_ICAL_EXPORT int icalcomponent_count_properties(icalcomponent *component,
  47. icalproperty_kind kind);
  48. LIBICAL_ICAL_EXPORT icalcomponent *icalproperty_get_parent(const icalproperty *property);
  49. /* Iterate through the properties */
  50. LIBICAL_ICAL_EXPORT icalproperty *icalcomponent_get_current_property(icalcomponent *component);
  51. LIBICAL_ICAL_EXPORT icalproperty *icalcomponent_get_first_property(icalcomponent *component,
  52. icalproperty_kind kind);
  53. LIBICAL_ICAL_EXPORT icalproperty *icalcomponent_get_next_property(icalcomponent *component,
  54. icalproperty_kind kind);
  55. /*
  56. * Working with components
  57. */
  58. /* Return the first VEVENT, VTODO or VJOURNAL sub-component of cop, or
  59. comp if it is one of those types */
  60. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_inner(icalcomponent *comp);
  61. LIBICAL_ICAL_EXPORT void icalcomponent_add_component(icalcomponent *parent, icalcomponent *child);
  62. LIBICAL_ICAL_EXPORT void icalcomponent_remove_component(icalcomponent *parent,
  63. icalcomponent *child);
  64. LIBICAL_ICAL_EXPORT int icalcomponent_count_components(icalcomponent *component,
  65. icalcomponent_kind kind);
  66. /**
  67. This takes 2 VCALENDAR components and merges the second one into the first,
  68. resolving any problems with conflicting TZIDs. comp_to_merge will no
  69. longer exist after calling this function. */
  70. LIBICAL_ICAL_EXPORT void icalcomponent_merge_component(icalcomponent *comp,
  71. icalcomponent *comp_to_merge);
  72. /* Iteration Routines. There are two forms of iterators, internal and
  73. external. The internal ones came first, and are almost completely
  74. sufficient, but they fail badly when you want to construct a loop that
  75. removes components from the container.*/
  76. /* Iterate through components */
  77. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_current_component(icalcomponent *component);
  78. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_first_component(icalcomponent *component,
  79. icalcomponent_kind kind);
  80. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_next_component(icalcomponent *component,
  81. icalcomponent_kind kind);
  82. /* Using external iterators */
  83. LIBICAL_ICAL_EXPORT icalcompiter icalcomponent_begin_component(icalcomponent *component,
  84. icalcomponent_kind kind);
  85. LIBICAL_ICAL_EXPORT icalcompiter icalcomponent_end_component(icalcomponent *component,
  86. icalcomponent_kind kind);
  87. LIBICAL_ICAL_EXPORT icalcomponent *icalcompiter_next(icalcompiter * i);
  88. LIBICAL_ICAL_EXPORT icalcomponent *icalcompiter_prior(icalcompiter * i);
  89. LIBICAL_ICAL_EXPORT icalcomponent *icalcompiter_deref(icalcompiter * i);
  90. /* Working with embedded error properties */
  91. /* Check the component against itip rules and insert error properties*/
  92. /* Working with embedded error properties */
  93. LIBICAL_ICAL_EXPORT int icalcomponent_check_restrictions(icalcomponent *comp);
  94. /** Count embedded errors. */
  95. LIBICAL_ICAL_EXPORT int icalcomponent_count_errors(icalcomponent *component);
  96. /** Remove all X-LIC-ERROR properties*/
  97. LIBICAL_ICAL_EXPORT void icalcomponent_strip_errors(icalcomponent *component);
  98. /** Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/
  99. LIBICAL_ICAL_EXPORT void icalcomponent_convert_errors(icalcomponent *component);
  100. /* Internal operations. They are private, and you should not be using them. */
  101. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_parent(icalcomponent *component);
  102. LIBICAL_ICAL_EXPORT void icalcomponent_set_parent(icalcomponent *component,
  103. icalcomponent *parent);
  104. /* Kind conversion routines */
  105. LIBICAL_ICAL_EXPORT int icalcomponent_kind_is_valid(const icalcomponent_kind kind);
  106. LIBICAL_ICAL_EXPORT icalcomponent_kind icalcomponent_string_to_kind(const char *string);
  107. LIBICAL_ICAL_EXPORT const char *icalcomponent_kind_to_string(icalcomponent_kind kind);
  108. /************* Derived class methods. ****************************
  109. If the code was in an OO language, the remaining routines would be
  110. members of classes derived from icalcomponent. Don't call them on the
  111. wrong component subtypes. */
  112. /** For VCOMPONENT: Return a reference to the first VEVENT, VTODO or
  113. VJOURNAL */
  114. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_get_first_real_component(icalcomponent *c);
  115. /** For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end
  116. times of an event in UTC */
  117. LIBICAL_ICAL_EXPORT struct icaltime_span icalcomponent_get_span(icalcomponent *comp);
  118. /******************** Convenience routines **********************/
  119. LIBICAL_ICAL_EXPORT void icalcomponent_set_dtstart(icalcomponent *comp, struct icaltimetype v);
  120. LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_dtstart(icalcomponent *comp);
  121. /* For the icalcomponent routines only, dtend and duration are tied
  122. together. If you call the set routine for one and the other exists,
  123. the routine will calculate the change to the other. That is, if
  124. there is a DTEND and you call set_duration, the routine will modify
  125. DTEND to be the sum of DTSTART and the duration. If you call a get
  126. routine for one and the other exists, the routine will calculate
  127. the return value. If you call a set routine and neither exists, the
  128. routine will create the apcompriate comperty */
  129. LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_dtend(icalcomponent *comp);
  130. LIBICAL_ICAL_EXPORT void icalcomponent_set_dtend(icalcomponent *comp, struct icaltimetype v);
  131. LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_due(icalcomponent *comp);
  132. LIBICAL_ICAL_EXPORT void icalcomponent_set_due(icalcomponent *comp, struct icaltimetype v);
  133. LIBICAL_ICAL_EXPORT void icalcomponent_set_duration(icalcomponent *comp,
  134. struct icaldurationtype v);
  135. LIBICAL_ICAL_EXPORT struct icaldurationtype icalcomponent_get_duration(icalcomponent *comp);
  136. LIBICAL_ICAL_EXPORT void icalcomponent_set_method(icalcomponent *comp, icalproperty_method method);
  137. LIBICAL_ICAL_EXPORT icalproperty_method icalcomponent_get_method(icalcomponent *comp);
  138. LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_dtstamp(icalcomponent *comp);
  139. LIBICAL_ICAL_EXPORT void icalcomponent_set_dtstamp(icalcomponent *comp, struct icaltimetype v);
  140. LIBICAL_ICAL_EXPORT void icalcomponent_set_summary(icalcomponent *comp, const char *v);
  141. LIBICAL_ICAL_EXPORT const char *icalcomponent_get_summary(icalcomponent *comp);
  142. LIBICAL_ICAL_EXPORT void icalcomponent_set_comment(icalcomponent *comp, const char *v);
  143. LIBICAL_ICAL_EXPORT const char *icalcomponent_get_comment(icalcomponent *comp);
  144. LIBICAL_ICAL_EXPORT void icalcomponent_set_uid(icalcomponent *comp, const char *v);
  145. LIBICAL_ICAL_EXPORT const char *icalcomponent_get_uid(icalcomponent *comp);
  146. LIBICAL_ICAL_EXPORT void icalcomponent_set_relcalid(icalcomponent *comp, const char *v);
  147. LIBICAL_ICAL_EXPORT const char *icalcomponent_get_relcalid(icalcomponent *comp);
  148. LIBICAL_ICAL_EXPORT void icalcomponent_set_recurrenceid(icalcomponent *comp,
  149. struct icaltimetype v);
  150. LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent *comp);
  151. LIBICAL_ICAL_EXPORT void icalcomponent_set_description(icalcomponent *comp, const char *v);
  152. LIBICAL_ICAL_EXPORT const char *icalcomponent_get_description(icalcomponent *comp);
  153. LIBICAL_ICAL_EXPORT void icalcomponent_set_location(icalcomponent *comp, const char *v);
  154. LIBICAL_ICAL_EXPORT const char *icalcomponent_get_location(icalcomponent *comp);
  155. LIBICAL_ICAL_EXPORT void icalcomponent_set_sequence(icalcomponent *comp, int v);
  156. LIBICAL_ICAL_EXPORT int icalcomponent_get_sequence(icalcomponent *comp);
  157. LIBICAL_ICAL_EXPORT void icalcomponent_set_status(icalcomponent *comp, enum icalproperty_status v);
  158. LIBICAL_ICAL_EXPORT enum icalproperty_status icalcomponent_get_status(icalcomponent *comp);
  159. /** Calls the given function for each TZID parameter found in the
  160. component, and any subcomponents. */
  161. LIBICAL_ICAL_EXPORT void icalcomponent_foreach_tzid(icalcomponent *comp,
  162. void (*callback) (icalparameter *param,
  163. void *data),
  164. void *callback_data);
  165. /** Returns the icaltimezone in the component corresponding to the
  166. TZID, or NULL if it can't be found. */
  167. LIBICAL_ICAL_EXPORT icaltimezone *icalcomponent_get_timezone(icalcomponent *comp,
  168. const char *tzid);
  169. LIBICAL_ICAL_EXPORT int icalproperty_recurrence_is_excluded(icalcomponent *comp,
  170. struct icaltimetype *dtstart,
  171. struct icaltimetype *recurtime);
  172. LIBICAL_ICAL_EXPORT void icalcomponent_foreach_recurrence(icalcomponent *comp,
  173. struct icaltimetype start,
  174. struct icaltimetype end,
  175. void (*callback) (icalcomponent *comp,
  176. struct icaltime_span *
  177. span, void *data),
  178. void *callback_data);
  179. /*************** Type Specific routines ***************/
  180. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vcalendar(void);
  181. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vevent(void);
  182. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vtodo(void);
  183. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vjournal(void);
  184. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_valarm(void);
  185. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vfreebusy(void);
  186. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vtimezone(void);
  187. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xstandard(void);
  188. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xdaylight(void);
  189. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vagenda(void);
  190. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vquery(void);
  191. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vavailability(void);
  192. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xavailable(void);
  193. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vpoll(void);
  194. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vvoter(void);
  195. LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xvote(void);
  196. #endif /* !ICALCOMPONENT_H */