1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
/*
* Internal representation of a Calendar object. This is modeled after the
* iCalendar/vCalendar specificiation
*
* Authors: Miguel de Icaza (miguel@gnu.org)
* Federico Mena (quartic@gimp.org).
*/
#ifndef CALOBJ_H
#define CALOBJ_H
#include <libgnome/libgnome.h>
#include "libversit/vcc.h"
BEGIN_GNOME_DECLS
enum AlarmType {
ALARM_MAIL,
ALARM_PROGRAM,
ALARM_DISPLAY,
ALARM_AUDIO
};
enum AlarmUnit {
ALARM_MINUTES,
ALARM_HOURS,
ALARM_DAYS
};
typedef struct {
enum AlarmType type;
int enabled;
int count;
enum AlarmUnit units;
char *data; /* not used for iCalendar alarms */
/* the following pointers are used for iCalendar alarms */
char *attach; /* AUDIO, EMAIL, PROC */
char *desc; /* DISPLAY, EMAIL, PROC */
char *summary; /* EMAIL */
char *attendee; /* EMAIL */
/* Does not get saved, internally used */
time_t offset;
time_t trigger;
int snooze_secs;
int snooze_repeat;
/* Widgets */
void *w_count; /* A GtkEntry */
void *w_enabled; /* A GtkChecButton */
void *w_timesel; /* A GtkMenu */
void *w_entry; /* A GnomeEntryFile/GtkEntry for PROGRAM/MAIL */
void *w_label;
} CalendarAlarm;
/* Calendar object type */
typedef enum {
ICAL_EVENT,
ICAL_TODO,
ICAL_JOURNAL,
ICAL_FBREQUEST,
ICAL_FBREPLY,
ICAL_BUSYTIME,
ICAL_TIMEZONE
} iCalType;
/* For keys that might contain binary or text/binary */
typedef struct {
char *data;
int len;
} iCalValue;
typedef enum {
ICAL_PILOT_SYNC_NONE = 0,
ICAL_PILOT_SYNC_MOD = 1,
ICAL_PILOT_SYNC_DEL = 3
} iCalPilotState;
typedef struct {
int valid; /* true if the Geography was specified */
double latitude;
double longitude;
} iCalGeo;
typedef enum {
ICAL_OPAQUE,
ICAL_TRANSPARENT
} iCalTransp;
typedef struct {
char *uid;
char *reltype;
} iCalRelation;
typedef char NotYet;
enum RecurType {
RECUR_DAILY,
RECUR_WEEKLY,
RECUR_MONTHLY_BY_POS,
RECUR_MONTHLY_BY_DAY,
RECUR_YEARLY_BY_MONTH,
RECUR_YEARLY_BY_DAY,
};
#define DAY_LASTDAY 10000
typedef struct {
enum RecurType type;
int interval;
/* Used for recur computation */
time_t enddate; /* If the value is zero, it is an infinite event
* otherwise, it is either the _enddate value (if
* this is what got specified) or it is our computed
* ending date (computed from the duration item).
*/
int weekday;
union {
int month_pos;
int month_day;
} u;
int duration;
time_t _enddate; /* As found on the vCalendar file */
int __count;
} Recurrence;
/*
NOTE: iCalPerson is used for various property values which specify
people (e.g. ATTENDEE, ORGANIZER, etc. Not all fields are valid
under RFC 2445 for all property values, but iCalPerson can store
them anyway. Enforcing the RFC is a job for the parser.
*/
typedef struct {
char *addr;
char *name;
char *role;
char *partstat;
gboolean rsvp;
char *cutype; /* calendar user type */
GList *member; /* group memberships */
GList *deleg_to;
GList *deleg_from;
char *sent_by;
char *directory;
GList *altrep; /* list of char* URI's */
} iCalPerson;
#define IS_INFINITE(r) (r->duration == 0)
/* Flags to indicate what has changed in an object */
typedef enum {
CHANGE_NEW = 1 << 0, /* new object */
CHANGE_SUMMARY = 1 << 1, /* summary */
CHANGE_DATES = 1 << 2, /* dtstart / dtend */
CHANGE_ALL = CHANGE_SUMMARY | CHANGE_DATES
} CalObjectChange;
/*
* This describes an iCalendar object, note that we never store durations, instead we
* always compute the end time computed from the start + duration.
*/
typedef struct {
iCalType type;
GList *attach; /* type: one or more URIs or binary data */
GList *attendee; /* type: CAL-ADDRESS (list of iCalPerson) */
GList *categories; /* type: one or more TEXT */
char *class;
char *comment; /* we collapse one or more TEXTs into one */
time_t completed;
time_t created;
GList *contact; /* type: one or more TEXT */
char *desc;
time_t dtstamp;
time_t dtstart;
time_t dtend; /* also duedate for todo's */
gboolean date_only; /* set if the start/end times were
specified using dates, not times (internal use, not stored to disk) */
GList *exdate; /* type: one or more time_t's */
GList *exrule; /* type: one or more RECUR */
iCalGeo geo;
time_t last_mod;
char *location;
iCalPerson *organizer;
int percent;
int priority;
char *rstatus; /* request status for freebusy */
GList *related; /* type: one or more TEXT */
GList *resources; /* type: one or more TEXT */
GList *rdate; /* type: one or more recurrence date */
GList *rrule; /* type: one or more recurrence rules */
int seq;
char *status;
char *summary;
iCalTransp transp;
char *uid;
char *url;
time_t recurid;
CalendarAlarm dalarm;
CalendarAlarm aalarm;
CalendarAlarm palarm;
CalendarAlarm malarm;
GList *alarms;
Recurrence *recur;
int new;
void *user_data; /* Generic data pointer */
/* Pilot */
iCalPilotState pilot_status; /* Status information */
guint32 pilot_id; /* Pilot ID */
guint ref_count;
} iCalObject;
/* The callback for the recurrence generator */
typedef int (*calendarfn) (iCalObject *, time_t, time_t, void *);
iCalObject *ical_new (char *comment, char *organizer, char *summary);
iCalObject *ical_object_new (void);
void ical_object_ref (iCalObject *ico);
void ical_object_unref (iCalObject *ico);
iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
VObject *ical_object_to_vobject (iCalObject *ical);
iCalObject *ical_object_duplicate (iCalObject *o);
void ical_foreach (GList *events, calendarfn fn, void *closure);
void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure);
void ical_object_add_exdate (iCalObject *o, time_t t);
/* Computes the enddate field of the recurrence based on the duration */
void ical_object_compute_end (iCalObject *ico);
typedef enum {
CAL_OBJ_FIND_SUCCESS,
CAL_OBJ_FIND_SYNTAX_ERROR,
CAL_OBJ_FIND_NOT_FOUND
} CalObjFindStatus;
CalObjFindStatus ical_object_find_in_string (const char *uid, const char *vcalobj, iCalObject **ico);
char *ical_object_to_string (iCalObject *ico);
/* Returns the first toggled day in a weekday mask -- we do this because we do not support multiple
* days on a monthly-by-pos recurrence. If no days are toggled, it returns -1.
*/
int ical_object_get_first_weekday (int weekday_mask);
/* Returns the number of seconds configured to trigger the alarm in advance to an event */
int alarm_compute_offset (CalendarAlarm *a);
/* Returns TRUE if the dates of both objects match, including any recurrence
rules. */
gboolean ical_object_compare_dates (iCalObject *ico1, iCalObject *ico2);
/* Generates a new uid for a calendar object. Should be g_free'd eventually. */
char *ical_gen_uid (void);
/* This resets any recurrence rules of the iCalObject. */
void ical_object_reset_recurrence (iCalObject *ico);
END_GNOME_DECLS
#endif
|