1 /* -*- Mode: C++ -*- */
5 * @author fnguyen (12/10/01)
6 * @brief C++ classes for the icalcomponent wrapper (VToDo VEvent, etc..).
8 * (C) COPYRIGHT 2001, Critical Path
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/
26 #include "icptrholder.h"
28 typedef char* string; // Will use the string library from STL
34 * @brief A class wrapping the libical icalcomponent functions
36 * @exception icalerrorenum Any errors generated in libical are
37 * propogated via this exception type.
42 VComponent() throw (icalerrorenum);
43 VComponent(const VComponent&) throw (icalerrorenum);
44 VComponent& operator=(const VComponent&) throw (icalerrorenum);
45 virtual ~VComponent();
47 VComponent(icalcomponent* v) throw (icalerrorenum);
48 VComponent(string str) throw (icalerrorenum);
49 VComponent(icalcomponent_kind kind) throw (icalerrorenum);;
51 operator icalcomponent* () { return imp; }
53 void new_from_string(string str);
55 // detach imp to this object. use with caution. it would cause
56 // memory leak if you are not careful.
62 string as_ical_string() throw (icalerrorenum);
64 icalcomponent_kind isa();
65 int isa_component(void* component);
67 /// Working with properties
68 void add_property(ICalProperty* property);
69 void remove_property(ICalProperty* property);
70 int count_properties(icalproperty_kind kind);
72 // Iterate through the properties
73 ICalProperty* get_current_property();
74 ICalProperty* get_first_property(icalproperty_kind kind);
75 ICalProperty* get_next_property(icalproperty_kind kind);
77 // Working with components
80 * Return the first VEVENT, VTODO or VJOURNAL sub-component if
81 * it is one of those types
84 VComponent* get_inner();
86 void add_component(VComponent* child);
87 void remove_component(VComponent* child);
88 int count_components(icalcomponent_kind kind);
91 * Iteration Routines. There are two forms of iterators,
92 * internal and external. The internal ones came first, and
93 * are almost completely sufficient, but they fail badly when
94 * you want to construct a loop that removes components from
98 /// Iterate through components
99 VComponent* get_current_component();
100 VComponent* get_first_component(icalcomponent_kind kind);
101 VComponent* get_next_component(icalcomponent_kind kind);
103 /// Using external iterators
104 icalcompiter begin_component(icalcomponent_kind kind);
105 icalcompiter end_component(icalcomponent_kind kind);
106 VComponent* next(icalcompiter* i);
107 VComponent* prev(icalcompiter* i);
108 VComponent* current(icalcompiter* i);
110 /// Working with embedded error properties
113 /// Remove all X-LIC-ERROR properties
116 /// Convert some X-LIC-ERROR properties into RETURN-STATUS properties
117 void convert_errors();
119 /// Kind conversion routines
120 static icalcomponent_kind string_to_kind(string str);
121 static string kind_to_string(icalcomponent_kind kind);
124 struct icaltimetype get_dtstart();
125 void set_dtstart(struct icaltimetype v);
127 /** For the icalcomponent routines only, dtend and duration
128 * are tied together. If you call the set routine for one and
129 * the other exists, the routine will calculate the change to
130 * the other. That is, if there is a DTEND and you call
131 * set_duration, the routine will modify DTEND to be the sum
132 * of DTSTART and the duration. If you call a get routine for
133 * one and the other exists, the routine will calculate the
134 * return value. If you call a set routine and neither
135 * exists, the routine will create the apropriate property
138 struct icaltimetype get_dtend();
139 void set_dtend(struct icaltimetype v);
141 struct icaltimetype get_due();
142 void set_due(struct icaltimetype v);
144 struct icaldurationtype get_duration();
145 void set_duration(struct icaldurationtype v);
147 icalproperty_method get_method();
148 void set_method(icalproperty_method method);
150 struct icaltimetype get_dtstamp();
151 void set_dtstamp(struct icaltimetype v);
153 string get_summary();
154 void set_summary(string v);
156 string get_location();
157 void set_location(string v);
159 string get_description();
160 void set_description(string v);
162 string get_comment();
163 void set_comment(string v);
166 void set_uid(string v);
168 string get_relcalid();
169 void set_relcalid(string v);
171 struct icaltimetype get_recurrenceid();
172 void set_recurrenceid(struct icaltimetype v);
175 void set_sequence(int v);
178 void set_status(enum icalproperty_status v);
183 * For VCOMPONENT: Return a reference to the first VEVENT,
186 VComponent* get_first_real_component();
189 * For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the
190 * start and end times of an event in UTC
192 virtual struct icaltime_span get_span();
194 int recurrence_is_excluded(struct icaltimetype *dtstart,
195 struct icaltimetype *recurtime);
200 helper functions for adding/removing/updating property and
203 /// Note: the VComponent kind have to be the same
205 bool remove(VComponent&, bool ignoreValue);
206 bool update(VComponent&, bool removeMissing);
207 bool add(VComponent&);
210 /* Internal operations. They are private, and you should not be using them. */
211 VComponent* get_parent();
212 void set_parent(VComponent *parent);
214 char* quote_ical_string(char* str);
220 class VCalendar : public VComponent {
223 VCalendar(const VCalendar&);
224 VCalendar& operator=(const VCalendar&);
227 VCalendar(icalcomponent* v);
228 VCalendar(string str);
232 class VEvent : public VComponent {
235 VEvent(const VEvent&);
236 VEvent& operator=(const VEvent&);
239 VEvent(icalcomponent* v);
243 class VToDo : public VComponent {
247 VToDo& operator=(const VToDo&);
250 VToDo(icalcomponent* v);
254 class VAgenda : public VComponent {
257 VAgenda(const VAgenda&);
258 VAgenda& operator=(const VAgenda&);
261 VAgenda(icalcomponent* v);
265 class VQuery : public VComponent {
268 VQuery(const VQuery&);
269 VQuery& operator=(const VQuery&);
272 VQuery(icalcomponent* v);
276 class VJournal : public VComponent {
279 VJournal(const VJournal&);
280 VJournal& operator=(const VJournal&);
283 VJournal(icalcomponent* v);
284 VJournal(string str);
287 class VAlarm : public VComponent {
290 VAlarm(const VAlarm&);
291 VAlarm& operator=(const VAlarm&);
294 VAlarm(icalcomponent* v);
298 * compute the absolute trigger time for this alarm. trigger
299 * may be related to the containing component c. the result
300 * is populated in tr->time
302 icalrequeststatus getTriggerTime(VComponent &c, struct icaltriggertype *tr);
305 class VFreeBusy : public VComponent {
308 VFreeBusy(const VFreeBusy&);
309 VFreeBusy& operator=(const VFreeBusy&);
312 VFreeBusy(icalcomponent* v);
313 VFreeBusy(string str);
316 class VTimezone : public VComponent {
319 VTimezone(const VTimezone&);
320 VTimezone& operator=(const VTimezone&);
323 VTimezone(icalcomponent* v);
324 VTimezone(string str);
327 class XStandard : public VComponent {
330 XStandard(const XStandard&);
331 XStandard& operator=(const XStandard&);
334 XStandard(icalcomponent* v);
335 XStandard(string str);
338 class XDaylight : public VComponent {
341 XDaylight(const XDaylight&);
342 XDaylight& operator=(const XDaylight&);
345 XDaylight(icalcomponent* v);
346 XDaylight(string str);
349 typedef ICPointerHolder<VComponent> VComponentTmpPtr; /* see icptrholder.h for comments */
351 #endif /* VComponent_H */