modify terminology:calendar->book,allday->localtime,normal->utime,svc->service
[platform/core/pim/calendar-service.git] / common / cal_typedef.h
1 /*
2  * Calendar Service
3  *
4  * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __CALENDAR_SERVICE_TYPEDEF_H__
21 #define __CALENDAR_SERVICE_TYPEDEF_H__
22
23 #include <glib.h>
24 #include <complex.h>
25 #include <stdbool.h>
26 #include <stdint.h>
27 #include "cal_record.h"
28 #include <tzplatform_config.h>
29
30 #define CAL_STR_SHORT_LEN32 32
31 #define CAL_STR_SHORT_LEN64 64
32 #define CAL_STR_MIDDLE_LEN 1024
33 #define CAL_STR_LONG_LEN 2048
34 #define CAL_STRING_EQUAL 0
35
36 #define CAL_TZID_GMT "Etc/GMT"
37 #define CAL_SOCK_PATH "/run/user/%d"
38 #define CAL_NOTI_FILE_EVENT tzplatform_mkpath(TZ_USER_DATA, "calendar-svc/.CALENDAR_SVC_EVENT_CHANGED")
39 #define CAL_NOTI_FILE_TODO tzplatform_mkpath(TZ_USER_DATA, "calendar-svc/.CALENDAR_SVC_TODO_CHANGED")
40 #define CAL_NOTI_FILE_BOOK tzplatform_mkpath(TZ_USER_DATA, "calendar-svc/.CALENDAR_SVC_CALENDAR_CHANGED")
41 #define CAL_NOTI_REMINDER_CAHNGED "reminder"
42 #define CAL_FORMAT_LOCAL_DATETIME "%04d-%02d-%02dT%02d:%02d:%02d"
43 #define CAL_DATETIME_FORMAT_YYYYMMDD "%04d%02d%02d"
44 #define CAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS "%04d%02d%02dT%02d%02d%02d"
45 #define CAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ "%04d%02d%02dT%02d%02d%02dZ"
46
47 /**
48  * @enum cal_priority_e
49  * This enumeration defines priority for todo data.
50  */
51 typedef enum {
52         CAL_PRIORITY_LOW,       /**< priority low */
53         CAL_PRIORITY_MID,       /**< priority middle */
54         CAL_PRIORITY_HIGH       /**< priority high */
55 } cal_priority_e;
56
57 typedef enum {
58         CAL_PERMISSION_NONE = 0x00,
59         CAL_PERMISSION_READ = 0x01,
60         CAL_PERMISSION_WRITE = 0x02,
61 } cal_permission_e;
62
63 #define LOCAL_ACCOUNT_ID -1
64
65 #define CAL_INVALID_ID (-1)
66
67 typedef enum {
68         CAL_SCH_TYPE_NONE = 0, /**< None type */
69         CAL_SCH_TYPE_EVENT,    /**< schedule event type */
70         CAL_SCH_TYPE_TODO,     /**< task event type */
71         CAL_SCH_TYPE_MAX,      /**< max type */
72 } cal_sch_type_e;
73
74 typedef struct {
75         int count;
76         GList *record;
77         GList *cursor;
78 } cal_list_s;
79
80 /**
81  * This structure defines schedule information.
82  */
83 typedef struct {
84         cal_record_s common;
85         int index;                              /**< Record index */
86         int calendar_id;
87
88         char *summary;                  /**< Summary, appointment, task: subject, birthday:Name */
89         char *description;              /**< Description,appointment, task: description, anniversary,holiday:occasion*/
90         char *location;                 /**< Location */
91         char *categories;
92         char *exdate;
93
94         calendar_event_status_e event_status;           /**< current task status */
95         cal_priority_e priority;                /**< Priority */
96         int timezone;                   /**< timezone of task */
97
98         int contact_id;                 /**< contact id for birthday in contact list */
99
100         int busy_status;                /**< ACS, G : Flag of busy or not */
101         int sensitivity;                /**< ACS, G : The sensitivity (public, private, confidential). #cal_visibility_type_t*/
102         int meeting_status;             /**< ACS, G : The status of the meeting. */
103         char *uid;                              /**< ACS, G : Unique ID of the meeting item */
104         char *organizer_name;           /**< ACS, G : Name of organizer(author) */
105         char *organizer_email;  /**< ACS, G : Email of organizer */
106
107         int original_event_id;        /**< original event id for recurrency exception */
108         double latitude;
109         double longitude;
110         int email_id;
111         long long int created_time;
112         int is_deleted; /**< for sync */
113         long long int last_mod;
114         int freq;
115         int range_type;
116         calendar_time_s until;
117         int count;
118         int interval;
119         char *bysecond;
120         char *byminute;
121         char *byhour;
122         char *byday;
123         char *bymonthday;
124         char *byyearday;
125         char *byweekno;
126         char *bymonth;
127         char *bysetpos;
128         int wkst;
129         char *recurrence_id;
130         char *rdate;
131         int has_attendee;
132         int has_alarm;
133         int system_type;
134         int updated;
135         char *sync_data1;
136         char *sync_data2;
137         char *sync_data3;
138         char *sync_data4;
139
140         calendar_time_s start;
141         char* start_tzid;
142         calendar_time_s end;
143         char* end_tzid;
144         int is_allday;
145         cal_list_s *alarm_list;
146         cal_list_s *attendee_list;
147         cal_list_s *exception_list;
148         cal_list_s *extended_list;
149 } cal_event_s;
150
151 typedef struct {
152         cal_record_s common;
153         int index;
154         int calendar_id;
155         char *summary;
156         char *description;
157         char *location;
158         char *categories;
159         calendar_todo_status_e todo_status;
160         cal_priority_e priority;
161         int sensitivity;
162         char *uid;
163         double latitude;
164         double longitude;
165         long long int created_time;
166         long long int completed_time;
167         int progress;
168         int is_deleted; /**< for sync */
169         long long int last_mod;
170         int freq;
171         int range_type;
172         calendar_time_s until;
173         int count;
174         int interval;
175         char *bysecond;
176         char *byminute;
177         char *byhour;
178         char *byday;
179         char *bymonthday;
180         char *byyearday;
181         char *byweekno;
182         char *bymonth;
183         char *bysetpos;
184         int wkst;
185         int has_alarm;
186         int system_type;
187         int updated;
188         char *sync_data1;
189         char *sync_data2;
190         char *sync_data3;
191         char *sync_data4;
192         calendar_time_s start;
193         char* start_tzid;
194         calendar_time_s due;
195         char* due_tzid;
196         char *organizer_name;
197         char *organizer_email;
198         int has_attendee;
199         int is_allday;
200
201         cal_list_s *alarm_list;
202         cal_list_s *attendee_list;
203         cal_list_s *extended_list;
204 } cal_todo_s;
205
206 typedef struct {
207         int freq;
208         int range_type;
209         calendar_time_s until;
210         int count;
211         int interval;
212         char *bysecond;
213         char *byminute;
214         char *byhour;
215         char *byday;
216         char *bymonthday;
217         char *byyearday;
218         char *byweekno;
219         char *bymonth;
220         char *bysetpos;
221         int wkst;
222 } cal_rrule_s;
223
224 /**
225  * This structure defines participant information of a meetting.
226  * ical: cutype, member, role, partstat, rsvp, delto, delfrom, sentby, cn,  dir, language
227  */
228 typedef struct {
229         cal_record_s common;
230         int id; /* Internal property. Do not add to view_uri property */
231         int parent_id;
232         char *attendee_number;
233         int attendee_cutype;
234         int attendee_ct_index;
235         char *attendee_uid;
236
237         /* ical spec from here */
238         char *attendee_group;   /* cutype */
239         char *attendee_email;   /* member */
240         int attendee_role;              /* role */
241         int attendee_status;    /* partstat: ACCEPTED, DECLINED.. */
242         int attendee_rsvp;              /* rsvp */
243         char *attendee_delegatee_uri;   /* delfrom */
244         char *attendee_delegator_uri;   /* delto */
245         /* sentby */
246         char *attendee_name;    /* cn */
247         char *attendee_member;  /* member */
248
249 } cal_attendee_s;
250
251 /**
252  * This structure defines exception information of alarm.
253  */
254 typedef struct {
255         cal_record_s common;
256         int id; /* Internal property. Do not add to view_uri property */
257         int parent_id;
258         int is_deleted;
259
260         int remind_tick;
261         int remind_tick_unit;
262
263         char *alarm_description;                        /**< Alert description */
264         char *alarm_summary;
265         int alarm_action;
266         char *alarm_attach;
267         calendar_time_s alarm;
268 } cal_alarm_s;
269
270 /* This is the calendar schema */
271 typedef struct {
272         cal_record_s common;
273         int index;
274         int store_type;
275         char *uid;
276         int updated;
277         char *name;
278         char *description;
279         char *color;
280         char *location;
281         int visibility;
282         int sync_event;
283         int is_deleted;
284         int account_id;
285         char *sync_data1;
286         char *sync_data2;
287         char *sync_data3;
288         char *sync_data4;
289         int mode;
290 } cal_book_s;
291
292
293 /* type for timezone information save */
294 typedef struct {
295         cal_record_s common;
296         int index;
297         int tz_offset_from_gmt;
298
299         char *standard_name;
300         int std_start_month;
301         int std_start_position_of_week;
302         int std_start_day;
303         int std_start_hour;
304         int standard_bias;
305
306         char *day_light_name;
307         int day_light_start_month;
308         int day_light_start_position_of_week;
309         int day_light_start_day;
310         int day_light_start_hour;
311         int day_light_bias;
312         int calendar_id;
313 } cal_timezone_s;
314
315 typedef struct {
316         cal_record_s common;
317         int event_id;
318         int calendar_id;
319         calendar_time_s start;
320         calendar_time_s end;
321         char *summary;
322         char *description;
323         char *location;
324         int busy_status;
325         int event_status;
326         int priority;
327         int sensitivity;
328         int has_rrule;  /* rrule_id */
329         double latitude;
330         double longitude;
331         int has_alarm;
332         int original_event_id;
333         long long int last_mod;
334         char *sync_data1;
335 } cal_instance_utime_s;
336
337 typedef struct {
338         cal_record_s common;
339         int event_id;
340         int calendar_id;
341         calendar_time_s start;
342         calendar_time_s end;
343         char *summary;
344         char *description;
345         char *location;
346         int busy_status;
347         int event_status;
348         int priority;
349         int sensitivity;
350         int has_rrule;  /* rrule_id */
351         double latitude;
352         double longitude;
353         int has_alarm;
354         int original_event_id;
355         long long int last_mod;
356         char *sync_data1;
357         int is_allday;
358 } cal_instance_localtime_s;
359
360 typedef struct {
361         cal_record_s common;
362         int event_id;
363         int calendar_id;
364         calendar_time_s start;
365         calendar_time_s end;
366         char *summary;
367         char *description;
368         char *location;
369         int busy_status;
370         int event_status;
371         int priority;
372         int sensitivity;
373         int has_rrule; /*rrule_id */
374         double latitude;
375         double longitude;
376         int has_alarm;
377         int original_event_id;
378         long long int last_mod;
379         char *organizer_name;
380         char *categories;
381         int has_attendee;
382         char *sync_data1;
383         char *sync_data2;
384         char *sync_data3;
385         char *sync_data4;
386 } cal_instance_utime_extended_s;
387
388 typedef struct {
389         cal_record_s common;
390         int event_id;
391         int calendar_id;
392         calendar_time_s start;
393         calendar_time_s end;
394         char *summary;
395         char *description;
396         char *location;
397         int busy_status;
398         int event_status;
399         int priority;
400         int sensitivity;
401         int has_rrule; /* rrule_id */
402         double latitude;
403         double longitude;
404         int has_alarm;
405         int original_event_id;
406         long long int last_mod;
407         char *sync_data1;
408         char *organizer_name;
409         char *categories;
410         int has_attendee;
411         char *sync_data2;
412         char *sync_data3;
413         char *sync_data4;
414         int is_allday;
415 } cal_instance_localtime_extended_s;
416
417 typedef struct {
418         cal_record_s common;
419         int type;
420         int id;
421         int calendar_id;
422         int version;
423 } cal_updated_info_s;
424
425 typedef enum {
426         CAL_NOTI_TYPE_EVENT = 0x0,
427         CAL_NOTI_TYPE_TODO,
428         CAL_NOTI_TYPE_BOOK,
429 } cal_noti_type_e;
430
431 typedef struct {
432         unsigned int property_id;
433         const char* fields; /* DB field */
434 } cal_property_info_s;
435
436 typedef enum {
437         CAL_FILTER_STR,
438         CAL_FILTER_INT,
439         CAL_FILTER_DOUBLE,
440         CAL_FILTER_LLI,
441         CAL_FILTER_CALTIME,
442         CAL_FILTER_COMPOSITE,
443 } cal_filter_type_e;
444
445 typedef struct  {
446         int filter_type; /* composite */
447 } cal_filter_s;
448
449 typedef struct {
450         int filter_type;
451         char *view_uri;
452         GSList *filter_ops; /* calendar_filter_operator_e op */
453         GSList *filters; /* calendar_filter_h l_filter */
454         cal_property_info_s *properties;
455         int property_count;
456 } cal_composite_filter_s;
457
458 typedef struct  {
459         int filter_type; /* cal_filter_type_e */
460         int property_id;
461         int match; /* calendar_match_str_flag_e or calendar_match_int_flag_e */
462         union {
463                 int i;
464                 char *s;
465                 double d;
466                 long long int lli;
467                 calendar_time_s caltime;
468         } value;
469 } cal_attribute_filter_s;
470
471 typedef struct  {
472         char* view_uri;
473         cal_composite_filter_s* filter;
474         int projection_count;
475         unsigned int *projection;
476         int sort_property_id;
477         bool asc;
478         cal_property_info_s *properties;
479         int property_count;
480         bool distinct;
481 } cal_query_s;
482
483 typedef struct {
484         int property_id;
485         union {
486                 int i;
487                 char *s;
488                 double d;
489                 long long int lli;
490                 calendar_time_s caltime;
491         } value;
492 } cal_search_value_s;
493
494 typedef struct {
495         cal_record_s common;
496         GSList *values;
497 } cal_search_s;
498
499 typedef struct {
500         cal_record_s common;
501         int id;
502         int record_id;
503         int record_type;
504         char* key;
505         char* value;
506 } cal_extended_s;
507
508 /**
509  * @}
510  */
511
512 #endif /* __CALENDAR_SERVICE_TYPEDEF_H__ */