tizen_2.0_build
[framework/pim/calendar-service.git] / include / calendar-svc-provider.h
1 /*
2  * Calendar Service
3  *
4  * Copyright (c) 2000 - 2012 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 #ifndef __CALENDAR_SVC_H__
20 #define __CALENDAR_SVC_H__
21
22 #ifndef DEPRECATED
23 #define DEPRECATED __attribute__ ((deprecated))
24 #endif
25
26
27 /**
28  * @defgroup CALENDAR_SVC  Calendar Service
29  */
30
31 /**
32  * @defgroup common     common
33  * @ingroup CALENDAR_SVC
34  * @brief
35  *              common struct for calendar service
36  */
37
38
39 /**
40  * cal_struct is an opaque type, it must be
41  * used via accessor functions.
42  * @addtogroup common
43  * @see calendar_svc_struct_new(), calendar_svc_struct_free()
44  * @see calendar_svc_struct_get_value(), calendar_svc_struct_get_list(),
45  * @see calendar_svc_struct_store_value(), calendar_svc_struct_store_list()
46  */
47
48 #include <glib.h>
49 #include <stdbool.h>
50 #include <stdint.h>
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 #include <calendar-svc-errors.h>
57 #include <calendar-svc-struct.h>
58 #include <alarm.h>
59
60 /**
61  * @addtogroup common
62  * @{
63  */
64
65 /**
66  * This enumeration date type, sun or lunar.
67  */
68 typedef enum
69 {
70         CAL_DATE_SUN = 0,          /**< date is sun type*/
71         CAL_DATE_LUNAR,         /**< date is lunar type */
72 } cal_date_type_t;
73
74 /**
75  * This enumeration defines Remind Tick Unit for schedule.
76  * Ex. remindTick = 1, remindTickUnit = CAL_SCH_TIME_UNIT_MIN, Organizer alarms
77  * 1 minute before schedule starting time.
78  */
79 typedef enum /* use with *60 */
80 {
81         CAL_SCH_TIME_UNIT_OFF = -1, /**< off */
82         CAL_SCH_TIME_UNIT_MIN = 1, /**< Minute */
83         CAL_SCH_TIME_UNIT_HOUR = 60, /**< Hour 60 * 60 */
84         CAL_SCH_TIME_UNIT_DAY = 1440, /**< Day 60 * 60 *24 */
85         CAL_SCH_TIME_UNIT_WEEK = 10080, /**< Week DAY * 7 */
86         CAL_SCH_TIME_UNIT_MONTH,        /**< Month - will be removed*/
87         CAL_SCH_TIME_UNIT_SPECIFIC  /**< using alarm time */
88 } cal_sch_remind_tick_unit_t;
89
90 /**
91  * This enumeration defines Repeat term.
92  */
93 typedef enum
94 {
95         CAL_REPEAT_NONE = 0,             /**< never Repeat */
96         CAL_REPEAT_EVERY_DAY,         /**< Repeats every day */
97         CAL_REPEAT_EVERY_WEEK,        /**< Repeats every week */
98         CAL_REPEAT_EVERY_MONTH,       /**< Repeats every month */
99         CAL_REPEAT_EVERY_YEAR,        /**< Repeats every year */
100         CAL_REPEAT_EVERY_WEEKDAYS,    /**< Repeats every weekdays *//* same with CAL_REPEAT_EVERY_WEEK, but week_flag="0111110", day_date=1, sun_moon=0, week_start=0 */
101         CAL_REPEAT_EVERY_MONTH_DAY,   /**< Repeats every month's week days *//* same with CAL_REPEAT_EVERY_MONTH, but week_flag="1000000"~"0000001", day_date=0, sun_moon=0, week_start=0 */
102         CAL_REPEAT_EVERY_YEAR_DAY,    /**< Repeats every year's month week days *//* same with CAL_REPEAT_EVERY_YEAR, but week_flag="1000000"~"0000001", day_date=0, sun_moon=0, week_start=0 */
103 } cal_repeat_term_t;
104
105 /**
106  * This enumeration defines Repeat term.
107  */
108 typedef enum
109 {
110         CALS_REPEAT_UNTIL_TYPE_NONE = 0,  /**< Repeat endlessly */
111         CALS_REPEAT_UNTIL_TYPE_COUNT,     /**< Repeat number of times, which the CAL_VALUE_INT_REPEAT_OCCURRENCES indicates */
112         CALS_REPEAT_UNTIL_TYPE_DATETIME,  /**< Repeat until the date-time which the CAL_VALUE_GMT_REPEAT_END_DATE indicates */
113 } cal_repeat_until_type_t;
114
115 /**
116  * This enumeration defines sync status.
117  */
118 typedef enum
119 {
120         CAL_SYNC_STATUS_NEW = 0,        /**< newly added. */
121         CAL_SYNC_STATUS_UPDATED,        /**< updated. */
122         CAL_SYNC_STATUS_DELETED,        /**< deleted. */
123         CAL_SYNC_STATUS_SYNCED,         /**< synced */
124 } cal_sync_status_t;
125
126 /**
127  * This enumeration defines Expiration for schedule data.
128  */
129 typedef enum
130 {
131         CAL_SCH_EXPIRATION_NONE = 0,                      /**< never expirate */
132         CAL_SCH_EXPIRATION_AFTER_1_MONTH,               /**< After 1 month */
133         CAL_SCH_EXPIRATION_AFTER_1_YEAR,                  /**< After 1 year */
134         CAL_SCH_EXPIRATION_AFTER_2_YEARS,               /**< After 2 years */
135         CAL_SCH_EXPIRATION_AFTER_3_YEARS                  /**< After 3 years */
136 } cal_expiration_t;
137
138 /**
139  * This enumeration defines lart type.
140  */
141 typedef enum
142 {
143         CAL_ALERT_MELODY = 0,                             /**< alarm type is melody */
144         CAL_ALERT_MUTE,                                           /**< alarm type is mute */
145         CAL_ALERT_INCREASING_MELODY,              /**< alarm type is increasing melody */
146         CAL_ALERT_VIBRATION,                               /**< alarm type is vibrate */
147         CAL_ALERT_VIBRATION_THEN_MELODY,          /**< alarm type is vibrate then melody */
148         CAL_ALERT_VIBMELODY,                               /**< alarm type is melody with vibrate */
149         CAL_ALERT_VIB_INCREASING_MELODY         /**< alarm type is increasing melody */
150 } cal_alert_type_t;
151
152 /**
153  * This enumeration defines alarm volume .
154  */
155 typedef enum
156 {
157         CAL_SNOOZE_OFF = 0,     /**< snoooze is off */
158         CAL_SNOOZE_1MIN,          /**< snoooze time is 1 min */
159         CAL_SNOOZE_3MINS,         /**< snoooze time is 3 mins */
160         CAL_SNOOZE_5MINS,         /**< snoooze time is 5 mins */
161         CAL_SNOOZE_10MINS,      /**< snoooze time is 10 mins */
162         CAL_SNOOZE_15MINS         /**< snoooze time is 15 mins */
163
164 } cal_snooze_type_t;
165
166 /**
167  * This enumeration defines alarm snooze count .
168  */
169 typedef enum
170 {
171         CAL_SNOOZE_0TIME = 0,           /**< snoooze count is 0 time */
172         CAL_SNOOZE_1TIME = 1,     /**< snoooze count is 1 time */
173         CAL_SNOOZE_2TIMES = 2,    /**< snoooze count is 2 times */
174         CAL_SNOOZE_5TIMES = 5,    /**< snoooze count is 5 times */
175         CAL_SNOOZE_10TIMES = 10   /**< snoooze count is 10 times */
176 } cal_snooze_count_t;
177
178 /**
179  * This enumeration defines attendee's status .
180  */
181 typedef enum
182 {
183         CAL_TZ_FLAG_GMT = 0,    /**< gmt time */
184         CAL_TZ_FLAG_LOCAL = 1,   /**< calendar local time */
185 } cal_timezone_flag;
186
187 /**
188  * This enumeration defines calendar's visibility .
189  */
190 typedef enum
191 {
192         PUBLIC_VISIBILITY = 0,
193         PRIVATE_VISIBILITY,
194         CONFIDENTIAL_VISIBILITY
195 } cal_visibility_type_t;
196
197 /**
198  * This enumeration defines event attendee's availability .
199  */
200 typedef enum
201 {
202         EVENT_BUSY_FB=0,
203         EVENT_BUSY_UNAVAILABLE_FB,
204         EVENT_FREE_FB,
205         EVENT_BUSY_TENTATIVE_FB,
206 } cal_event_availability_type_t;
207
208
209 /**
210  * This enumeration defines event attendee's role .
211  */
212 typedef enum
213 {
214         EVENT_ATTENDEE_REQ_PARTICIPANT_ROLE=0,
215         EVENT_ATTENDEE_OPT_PARTICIPANT_ROLE,
216         EVENT_ATTENDEE_NON_PARTICIPANT_ROLE,
217         EVENT_ATTENDEE_CHAIR_ROLE,
218 } cal_event_attendee_role_type_t;
219
220 /**
221  * This enumeration defines event attendee's status.
222  */
223 typedef enum
224 {
225         EVENT_ATTENDEE_NEEDS_ACTION_AT_STATUS=0,
226         EVENT_ATTENDEE_ACCEPTED_AT_STATUS,
227         EVENT_ATTENDEE_DECLINED_AT_STATUS,
228         EVENT_ATTENDEE_TENTATIVE_AT_STATUS,
229         EVENT_ATTENDEE_DELEGATED_AT_STATUS,
230         EVENT_ATTENDEE_COMPLETED_AT_STATUS,
231         EVENT_ATTENDEE_IN_PROCESS_AT_STATUS
232 } cal_event_attendee_status_type_t;
233
234
235 /**
236  * Deprecated.
237  */
238 #define EVENT_ATTENDEE_PENDING_AT_STATUS EVENT_ATTENDEE_NEEDS_ACTION_AT_STATUS
239
240 /**
241  * This enumeration defines event attendee's type .
242  */
243 typedef enum
244 {
245         EVENT_ATTENDEE_INDIVIDUAL_TYPE=0,
246         EVENT_ATTENDEE_GROUP_TYPE,
247         EVENT_ATTENDEE_RESOURCE_TYPE,
248         EVENT_ATTENDEE_ROOM_TYPE,
249         EVENT_ATTENDEE_UNKNOWN_TYPE
250 } cal_event_attendee_type_t;
251
252
253 /**
254  * This enumeration defines CAL_VALUE_INT_PRIORITY .
255  */
256 typedef enum
257 {
258         EVENT_PRIORITY_LOW = 0,
259         EVENT_PRIORITY_NORMAL,
260         EVENT_PRIORITY_HIGH,
261 } cal_priority_type_t;
262
263 enum {
264         CALS_TODO_PRIORITY_NONE = 0x01,
265         CALS_TODO_PRIORITY_HIGH = 0x02,
266         CALS_TODO_PRIORITY_MID = 0x04,
267         CALS_TODO_PRIORITY_LOW = 0x08,
268 };
269
270 /**
271  * This enumeration defines status.
272  * (related with CAL_VALUE_INT_TASK_STATUS)
273  */
274
275 #define CALS_STATUS_NONE CALS_EVENT_STATUS_NONE
276 typedef enum
277 {
278         CALS_EVENT_STATUS_NONE = 0x0001,
279         CALS_EVENT_STATUS_TENTATIVE = 0x0002,
280         CALS_EVENT_STATUS_CONFIRMED = 0x0004,
281         CALS_EVENT_STATUS_CANCELLED = 0x0008,
282         CALS_TODO_STATUS_NONE = 0x0100,
283         CALS_TODO_STATUS_NEEDS_ACTION = 0x0200,
284         CALS_TODO_STATUS_IN_PROCESS = 0x0400,
285         CALS_TODO_STATUS_CANCELLED = 0x0800,
286         CALS_TODO_STATUS_COMPLETED = 0x1000,
287 } cals_status_t;
288
289 /**
290  * This enumeration defines calendar type.
291  * (related with CAL_TABLE_INT_STORE_TYPE)
292  */
293 typedef enum
294 {
295         CALS_CALENDAR_TYPE_NONE = 0,
296         CALS_CALENDAR_TYPE_EVENT = 1<<0,
297         CALS_CALENDAR_TYPE_TODO = 1<<1,
298 } cals_calendar_store_type;
299
300 /**
301  * This enumeration defines todo list ordering type.
302  */
303 typedef enum
304 {
305         CALS_TODO_LIST_ORDER_END_DATE = 0,
306         CALS_TODO_LIST_ORDER_PRIORITY,
307         CALS_TODO_LIST_ORDER_STATUS,
308 } cals_todo_list_order_t;
309
310 /**
311  * This enumeration defines calendar sensitivity.
312  * (related with CAL_VALUE_INT_SENSITIVITY)
313  */
314 typedef enum
315 {
316         CALS_SENSITIVITY_PUBLIC = 0x0,
317         CALS_SENSITIVITY_PRIVATE,
318         CALS_SENSITIVITY_CONFIDENTIAL,
319 } cals_sensitivity_t;
320
321 /**
322  * This enumeration defines updated type
323  * (related with CALS_STRUCT_UPDATED_INT_TYPE)
324  */
325 enum cals_updated_type {
326         CALS_UPDATED_TYPE_INSERTED = 0x0,
327         CALS_UPDATED_TYPE_MODIFIED,
328         CALS_UPDATED_TYPE_DELETED,
329 };
330
331 /**
332  * Flags to specify what fields will be searched by search API
333  */
334 enum SEARCHFIELD {
335         CALS_SEARCH_FIELD_NONE = 0,
336         CALS_SEARCH_FIELD_SUMMARY = 1<<0,
337         CALS_SEARCH_FIELD_DESCRIPTION = 1<<2,
338         CALS_SEARCH_FIELD_LOCATION = 1<<3,
339         CALS_SEARCH_FIELD_ATTENDEE = 1<<4,
340 };
341
342 /**
343  * @}
344  */
345
346 /**
347  * @addtogroup common
348  * @{
349  * brief
350  *              calendar_svc_struct_new's argument
351  */
352 #define CAL_STRUCT_TYPE                                   /**< CAL_STRUCT_TYPE */
353 #define CAL_STRUCT_CALENDAR "calendar"          /**< CAL_STRUCT_CALENDAR */
354 #define CAL_STRUCT_SCHEDULE "schedule"          /**< CAL_STRUCT_SCHEDULE */
355 #define CAL_STRUCT_TODO         "todo"                  /**< CAL_STRUCT_TASK */
356 #define CAL_STRUCT_TIMEZONE     "timezone"              /**< CAL_STRUCT_TIMEZONE */
357 #define CAL_STRUCT_UPDATED "updated"     /**< CAL_STRUCT_UPDATED */
358 #define CALS_STRUCT_PERIOD_NORMAL_ONOFF "period_normal_onoff"
359 #define CALS_STRUCT_PERIOD_ALLDAY_ONOFF "period_allday_onoff"
360 #define CALS_STRUCT_PERIOD_NORMAL_BASIC "period_normal_basic"
361 #define CALS_STRUCT_PERIOD_ALLDAY_BASIC "period_allday_basic"
362 #define CALS_STRUCT_PERIOD_NORMAL_OSP "period_normal_osp"
363 #define CALS_STRUCT_PERIOD_ALLDAY_OSP "period_allday_osp"
364 #define CALS_STRUCT_PERIOD_NORMAL_LOCATION "period_normal_location"
365 #define CALS_STRUCT_PERIOD_ALLDAY_LOCATION "period_allday_location"
366 #define CALS_STRUCT_PERIOD_NORMAL_ALARM "period_normal_alarm"
367
368 // id for all data read
369 #define ALL_ACCOUNT_ID 0
370 #define ALL_CALENDAR_ID 0
371
372 // id for all data without visibility false
373 #define ALL_VISIBILITY_ACCOUNT -2
374
375 // id for local data read
376 #define LOCAL_ACCOUNT_ID -1
377 #define LOCAL_ALL_CALENDAR -1
378
379 /* start deprecated */
380 #define DEFAULT_CALENDAR_ID 1
381 /* end deprecated, replace DEFAULT_EVENT_CALENDAR_ID */
382
383 #define DEFAULT_EVENT_CALENDAR_ID 1
384 #define DEFAULT_TODO_CALENDAR_ID 2
385
386 // added val 2012.07.30
387 #define CALS_TODO_NO_DUE_DATE INT64_MAX
388
389 /**
390  * @}
391  */
392
393 /**
394  * @addtogroup common
395  * @{
396  * brief
397  *              calendar_svc_struct_xxx()'s argument
398  */
399 #define CAL_TABLE_INT_INDEX "index"
400 #define CAL_TABLE_TXT_CALENDAR_ID "calendar_id"
401 #define CAL_TABLE_TXT_UID "uid"
402 #define CAL_TABLE_TXT_LINK "link"
403 #define CAL_TABLE_INT_UPDATED "updated"
404 #define CAL_TABLE_TXT_NAME "name"
405 #define CAL_TABLE_TXT_DESCRIPTION "description"
406 #define CAL_TABLE_TXT_AUTHOR "author"
407 #define CAL_TABLE_TXT_COLOR "color"
408 #define CAL_TABLE_INT_HIDDEN "hidden"
409 #define CAL_TABLE_INT_SELECTED "selected"
410 #define CAL_TABLE_TXT_LOCATION "location"
411 #define CAL_TABLE_INT_LOCALE "locale"
412 #define CAL_TABLE_INT_COUNTRY "country"
413 #define CAL_TABLE_INT_TIME_ZONE "time_zone"
414 #define CAL_TABLE_TXT_TIME_ZONE_LABEL "timezone_label"
415 #define CAL_TABLE_INT_DISPLAY_ALL_TIMEZONES "display_all_timezones"
416 #define CAL_TABLE_INT_DATE_FIELD_ORDER "date_field_order"
417 #define CAL_TABLE_INT_FROMAT_24HOUR_TIME "format_24hour_time"
418 #define CAL_TABLE_INT_WEEK_START "week_start"
419 #define CAL_TABLE_INT_DEFAULT_CAL_MODE "default_cal_mode"
420 #define CAL_TABLE_INT_CUSTOM_CAL_MODE "custom_cal_mode"
421 #define CAL_TABLE_TXT_USER_LOCATION "user_location"
422 #define CAL_TABLE_TXT_WEATHER "weather"
423 #define CAL_TABLE_INT_SHOW_DECLINED_EVENTS "show_declined_events"
424 #define CAL_TABLE_INT_HIDE_INVITATIONS "hide_invitations"
425 #define CAL_TABLE_INT_ALTERNATE_CALENDAR "alternate_calendar"
426 #define CAL_TABLE_INT_VISIBILITY "visibility"
427 #define CAL_TABLE_INT_PROJECTION "projection"
428 #define CAL_TABLE_INT_SEQUENCE "sequence"
429 #define CAL_TABLE_INT_SUPRESS_REPLY_NOTIFICATIONS "suppress_reply_notifications"
430 #define CAL_TABLE_INT_SYNC_EVENT "sync_event"
431 #define CAL_TABLE_INT_TIMES_CLEANED "times_cleaned"
432 #define CAL_TABLE_INT_GUESTS_CAN_MODIFY "guests_can_modify"
433 #define CAL_TABLE_INT_GUESTS_CAN_INVITE_OTHERS "guests_can_invite_others"
434 #define CAL_TABLE_INT_GUESTS_CAN_SEE_GUESTS "guests_can_see_guests"
435 #define CAL_TABLE_INT_ACCESS_LEVEL "access_level"
436 #define CAL_TABLE_INT_SYNC_STATUS "sync_status"
437 #define CAL_TABLE_INT_IS_DELETED "is_deleted"
438 #define CAL_TABLE_INT_ACCOUNT_ID "account_id"
439 #define CAL_TABLE_INT_SENSITIVITY "sensitivity"
440 #define CAL_TABLE_INT_STORE_TYPE "store_type" /**< #cals_calendar_store_type */
441
442 /**
443  * @}
444  */
445
446 /**
447  * @addtogroup common
448  * @{
449  * brief
450  *              calendar_svc_struct_xxx()'s argument
451  */
452 #define CALS_STRUCT_UPDATED_INT_VERSION "version"                /**< Version of schedule */
453 #define CALS_STRUCT_UPDATED_INT_TYPE "updated_type"      /**< Type of schedule update #cals_updated_type */
454 #define CALS_STRUCT_UPDATED_INT_ID "updated_id"      /**< id of updated schedule */
455 /**
456  * @}
457  */
458
459
460
461 /**
462  * @addtogroup common
463  * @{
464  * brief
465  *              calendar_svc_struct_xxx()'s argument
466  */
467 #define CAL_VALUE_INT_INDEX                               "id"                                  /**< Record index */
468 #define CAL_VALUE_INT_ACCOUNT_ID                          "account_id"                  /**< account id */
469 #define CAL_VALUE_INT_TYPE                                "type"                                /**< Calendar component type */
470 #define CAL_VALUE_TXT_CATEGORIES "categories" /**< Category of schedule */
471 #define CAL_VALUE_TXT_EXDATE "exdate" /**< Exdate */
472 #define CAL_VALUE_TXT_SUMMARY                             "summary"                             /**< Summary, appointment, task: subject, birthday:Name */
473 #define CAL_VALUE_TXT_DESCRIPTION                         "description"                 /**< Description,appointment, task: description, anniversary,holiday:occasion*/
474 #define CAL_VALUE_TXT_LOCATION                            "location"                            /**< Location */
475 #define CAL_VALUE_INT_MISSED                              "missed"                                /**< Miss alarm flag */
476 #define CAL_VALUE_INT_TASK_STATUS                         "task_status"                 /**< current task status #cals_status_t */
477 #define CAL_VALUE_INT_PRIORITY                            "priority"                            /**< Priority */
478 #define CAL_VALUE_INT_TIMEZONE                            "timezone"                            /**< deprecated - timezone of task */
479 #define CAL_VALUE_INT_FILE_ID                             "file_id"                             /**< file id for attach or alarm tone*/
480 #define CAL_VALUE_INT_CONTACT_ID                          "contact_id"                  /**< contact id for birthday in contact list */
481 #define CAL_VALUE_INT_BUSY_STATUS                         "busy_status"                 /**< ACS, G : Flag of busy or not */
482 #define CAL_VALUE_INT_SENSITIVITY                         "sensitivity"                 /**< iCal:CLASS #cals_sensitivity_t */
483 #define CAL_VALUE_TXT_UID                                         "uid"                                   /**< ACS, G : Unique ID of the meeting item */
484 #define CAL_VALUE_INT_CALENDAR_TYPE                       "calendar_type"               /**< ACS, G : Type(all,phone,google) of calendar */
485 #define CAL_VALUE_TXT_ORGANIZER_NAME              "organizer_name"              /**< ACS, G : Name of organizer(author) */
486 #define CAL_VALUE_TXT_ORGANIZER_EMAIL             "organizer_email"             /**< ACS, G : Email of organizer */
487 #define CAL_VALUE_INT_MEETING_STATUS              "meeting_status"              /**< ACS, G : The status of the meeting. */
488 #define CAL_VALUE_TXT_GCAL_ID                             "gcal_id"                             /**< G : Server id of calendar */
489 #define CAL_VALUE_INT_DELETED                             "deleted"                             /**< G : Flag for deleted */
490 #define CAL_VALUE_TXT_UPDATED                             "updated"                             /**< G : Updated time stamp */
491 #define CAL_VALUE_INT_LOCATION_TYPE                       "location_type"               /**< G : Location type */
492 #define CAL_VALUE_TXT_LOCATION_SUMMARY            "location_summary"    /**< G : A simple string value that can be used as a representation of this location */
493 #define CAL_VALUE_TXT_ETAG                                        "etag"                                        /**< G : ETAG of this event */
494 #define CAL_VALUE_INT_CALENDAR_ID                         "calendar_id"                 /**< G : id to map from calendar table */
495 #define CAL_VALUE_INT_SYNC_STATUS                         "sync_status"                 /**< G : Indication for event entry whether added/ modified/ deleted */
496 #define CAL_VALUE_TXT_EDIT_URL                            "edit_uri"    /**< G : EditUri for google calendar */
497 #define CAL_VALUE_TXT_GEDERID                             "gevent_id"                           /**< G : Server id of an event */
498 #define CAL_VALUE_INT_DST                                         "dst"                                   /**< dst of event */
499 #define CAL_VALUE_INT_ORIGINAL_EVENT_ID           "original_event_id" /**< original event id for recurrency exception */
500 #define CAL_VALUE_INT_CALENDAR_INDEX      "calendar_index"   /**< specific calendar id - will be remove */
501 #define CAL_VALUE_DBL_LATITUDE         "latitude"      /**< latitude */
502 #define CAL_VALUE_DBL_LONGITUDE        "longitude"     /**< longitude */
503 #define CAL_VALUE_INT_EMAIL_ID                            "email_id"                    /**< email id */
504 #define CAL_VALUE_INT_AVAILABILITY                        "availability"
505 #define CAL_VALUE_LLI_CREATED_TIME "created_time"
506 #define CAL_VALUE_LLI_COMPLETED_TIME "completed_time"
507 #define CAL_VALUE_INT_PROGRESS "progress"
508 #define CAL_VALUE_INT_IS_DELETED "is_deleted"/**< In deleting action, this is set 1 and will be deleted after sync */
509
510 #define CAL_VALUE_INT_CAL_TYPE                            "cal_type" /**< deprecated */
511
512 /**
513  * @}
514  */
515
516
517 /**
518  * @addtogroup common
519  * @{
520  * brief
521  *              attendee cal_value's detail field
522  */
523 #define CAL_VALUE_LST_ATTENDEE_LIST         "attendee_list"     /**< attendee's detail information set */
524 #define CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME                      "attendee_name"                 /**< attendee_name */
525 #define CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL               "attendee_email"                      /**< attendee_email */
526 #define CAL_VALUE_TXT_ATTENDEE_DETAIL_NUMBER            "attendee_number"                       /**< attendee_email */
527 #define CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS            "attendee_status"                       /**< #cal_event_attendee_status_type_t */
528 #define CAL_VALUE_INT_ATTENDEE_DETAIL_TYPE                      "attendee_type"                 /**< #cal_event_attendee_type_t */
529 #define CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX          "attendee_ct_index"             /**< contact db index for reference */
530 #define CAL_VALUE_INT_ATTENDEE_ROLE                                     "attendee_role" /**< #cal_event_attendee_role_type_t */
531 #define CAL_VALUE_INT_ATTENDEE_RSVP                                     "attendee_rsvp"
532 #define CAL_VALUE_TXT_ATTENDEE_GROUP                            "attendee_group"
533 #define CAL_VALUE_TXT_ATTENDEE_DELEGATOR_URI            "attendee_delegator_uri"
534 #define CAL_VALUE_TXT_ATTENDEE_DELEGATE_URI                     "attendee_delegate_uri"
535 #define CAL_VALUE_TXT_ATTENDEE_UID                                      "attendee_uid"
536
537 /**
538  * @}
539  */
540
541 #define CAL_VALUE_LST_ALARM                             "alarm"    /**< exception's detail information set */
542 #define CAL_VALUE_LLI_ALARMS_TIME                                       "alarm_time"                    /**< alarm time */
543 #define CAL_VALUE_INT_ALARMS_TICK                                       "remind_tick"                   /**< Alarms before remindTick */
544 #define CAL_VALUE_INT_ALARMS_TICK_UNIT                          "remind_tick_unit"      /**< Remind tick unit */
545 #define CAL_VALUE_TXT_ALARMS_TONE                                       "alarm_tone"                    /**< Alert Sound File Name */
546 #define CAL_VALUE_TXT_ALARMS_DESCRIPTION "alarm_description"                    /**< Alert description */
547 #define CAL_VALUE_INT_ALARMS_TYPE                                       "alarm_type"                    /**< Alert type(see 'cal_alert_type_t') */
548 #define CAL_VALUE_INT_ALARMS_ID                                         "alarm_id"                              /**< Alarm id */
549
550 /**
551  * @}
552  */
553
554
555
556 /**
557  * @addtogroup common
558  * @{
559  * brief
560  *              delete flag in detail list
561  */
562
563 #define CAL_VALUE_INT_DETAIL_DELETE     "is_deleted" /**< delete setting in detail list*/
564
565 /**
566  * @}
567  */
568
569
570
571 /**
572  * @addtogroup common
573  * @{
574  * brief
575  *              calendar_svc_value_xxx()'s argument for timezone
576  */
577 /* type for timezone information save */
578
579 #define CAL_TZ_VALUE_INT_INDEX                                                  "index"
580 #define CAL_TZ_VALUE_INT_TZ_OFFSET                                              "tz_offset_from_gmt"
581
582 #define CAL_TZ_VALUE_TXT_STD_NAME                                               "standard_name"
583 #define CAL_TZ_VALUE_INT_STD_START_MONTH                                "std_start_month"
584 #define CAL_TZ_VALUE_INT_STD_START_POSITION_OF_WEEK             "std_start_position_of_week"
585 #define CAL_TZ_VALUE_INT_STD_START_DAY                                  "std_start_day"
586 #define CAL_TZ_VALUE_INT_STD_START_HOUR                                 "std_start_hour"
587 #define CAL_TZ_VALUE_INT_STD_BIAS                                               "standard_bias"
588
589 #define CAL_TZ_VALUE_TXT_DST_NAME                                               "day_light_name"
590 #define CAL_TZ_VALUE_INT_DST_START_MONTH                                "day_light_start_month"
591 #define CAL_TZ_VALUE_INT_DST_START_POSITION_OF_WEEK             "day_light_start_position_of_week"
592 #define CAL_TZ_VALUE_INT_DST_START_DAY                                  "day_light_start_day"
593 #define CAL_TZ_VALUE_INT_DST_START_HOUR                                 "day_light_start_hour"
594 #define CAL_TZ_VALUE_INT_DST_BIAS                                               "day_light_bias"
595
596 /**
597  * @}
598  */
599
600
601
602 /**
603  * @ingroup CALENDAR_SVC
604  * @defgroup service_management service_management
605  * @brief
606  *              calendar service module management
607  */
608
609 /**
610  * @fn int calendar_svc_connect(void);
611  *   This function opens database,it is must be called before other data operaion.
612  *
613  * @ingroup service_management
614  * @return This function returns CAL_SUCCESS or error code on failure.
615  * @exception None.
616  * @remarks None.
617  * @pre none
618  * @post calendar_svc_close() should be called when leave.
619  * @code
620     #include <calendar-svc-provider.h>
621     void sample_code()
622     {
623         //connect to database
624         calendar_svc_connect();
625
626         //..do some operation to database
627
628         //close database
629         calendar_svc_close();
630     }
631  * @endcode
632  * @see calendar_svc_close().
633  */
634 int calendar_svc_connect(void);
635
636 /**
637  * @fn int calendar_svc_close(void);
638  *   This function closes database,it is must be called when leave.
639  *
640  * @ingroup service_management
641  * @return This function returns CAL_SUCCESS or error code on failure.
642  * @exception None.
643  * @remarks None.
644  * @pre the database connected
645  * @post none
646  * @code
647    #include <calendar-svc-provider.h>
648    void sample_code()
649    {
650                 //connect to database
651         calendar_svc_connect();
652
653         //..do some operation to database
654
655         //close database
656         calendar_svc_close();
657    }
658  * @endcode
659  * @see calendar_svc_connect().
660  */
661 int calendar_svc_close(void);
662
663 /**
664  * @fn int calendar_svc_begin_trans(void);
665  * This function start db transaction,it is coninient for user do many operaion once.
666  *
667  * @ingroup service_management
668  * @return This function returns CAL_SUCCESS or error code on failure.
669  * @exception None.
670  * @remarks None.
671  * @pre database connected
672  * @post calendar_svc_end_trans() should be called when leave
673  * @code
674    #include <calendar-svc-provider.h>
675    void sample_code()
676    {
677                 //connect to database
678         calendar_svc_connect();
679
680                 // begin transaction
681                 calendar_svc_begin_trans();
682
683         //..do some operation to database
684
685         // end transaction
686                 calendar_svc_end_trans();
687
688         //close database
689         calendar_svc_close();
690
691    }
692  * @endcode
693  * @see calendar_svc_end_trans().
694  */
695 int calendar_svc_begin_trans(void);
696
697 /**
698  * @fn int calendar_svc_end_trans(bool is_success);
699  * This function finishes database transaction of calendar service.
700  * If it returns error, the transaction has been rollbacked.
701  * When transction is success, it returns the last contacts version.
702  *
703  * @ingroup service_management
704  * @param[in] is_success Commit changes if #true. Otherwise, no changes will be made on the database.
705  * @return CAL_SUCCESS or the last calendar version(when success) on success,
706  *         Negative value(#cal_error) on error
707  * @exception None.
708  * @remarks None.
709  * @pre database connected and calendar_svc_begin_trans() is called.
710  * @post none
711  * @code
712    #include <calendar-svc-provider.h>
713    void sample_code()
714    {
715                 //connect to database
716         calendar_svc_connect();
717
718                 // begin transaction
719                 calendar_svc_begin_trans();
720
721         //..do some operation to database
722
723         // end transaction
724                 calendar_svc_end_trans(true);
725
726         //close database
727         calendar_svc_close();
728
729    }
730  * @endcode
731  * @see calendar_svc_begin_trans().
732  */
733 int calendar_svc_end_trans(bool is_success);
734
735
736 /**
737  * @fn int calendar_svc_subscribe_db_change (const char *data_type,void(*cb)(void *), void *user_data);
738  * This function registers callback function in receiver,it is convenient for user receive noti from database.
739  *
740  * @ingroup service_management
741  * @param[in]   datatype for subscribe detail db change
742  * @param[in]   cb Fuction pointer of calendar notification callback
743  * @param[in]   user_data when cb function is called, user_data will be passed.
744  * @return   This function returns CAL_SUCCESS or error code on failure.
745  * @exception None.
746  * @remarks None.
747  * @pre database connected
748  * @post none
749  * @code
750    #include <calendar-svc-provider.h>
751    #include <glib.h>
752
753    int received_cb (void *user_data)
754    {
755           if(NULL != user_data)
756           {
757                 printf("enter received_cb:%s\n",(char*)user_data);
758           }
759    }
760
761    void sample_code()
762    {
763       //connect database
764       calendar_svc_connect();
765
766       char* user_data = "Get a noti!\n";
767         calendar_svc_subscribe_db_change (CAL_STRUCT_SCHEDULE,received_cb, user_data);
768
769           GMainLoop* loop = g_main_loop_new(NULL,TRUE);
770
771           //close database
772           calendar_svc_close();
773    }
774  * @endcode
775  * @see calendar_svc_unsubscribe_db_change().
776  */
777 int calendar_svc_subscribe_db_change (const char *data_type,void(*cb)(void *), void *user_data);
778
779
780 int calendar_svc_subscribe_change (void(*cb)(void *), void *user_data);
781
782
783 /**
784  * @fn int calendar_svc_unsubscribe_db_change (const char *data_type,void(*cb)(void *));
785  * This function deregisters callback function in receiver,it is convenient for user unscribe some receive noti from database.
786  *
787  * @ingroup service_management
788  * @param[in]   datatype for subscribe detail db change
789  * @param[in]   cb Fuction pointer of calendar notification callback
790  * @return   This function returns CAL_SUCCESS or error code on failure.
791  * @exception None.
792  * @remarks None.
793  * @pre calendar_svc_subscribe_change called
794  * @post none
795  * @code
796    #include <calendar-svc-provider.h>
797
798    int received_cb (void *user_data)
799    {
800           if(NULL != user_data)
801           {
802                 printf("enter received_cb:%s\n",(char*)user_data);
803           }
804    }
805
806    void sample_code()
807    {
808        //connect database
809            calendar_svc_connect();
810
811            char* user_data = "Get a noti!\n";
812            calendar_svc_unsubscribe_db_change (CAL_STRUCT_SCHEDULE,received_cb, user_data);
813
814            cal_struct * event = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
815            calendar_svc_insert(event);
816
817            GMainLoop* loop = g_main_loop_new(NULL,TRUE);
818            g_main_loop_run(loop);
819
820            //...
821
822            //close database
823            calendar_svc_close();
824            calendar_svc_unsubscribe_db_change (CAL_STRUCT_SCHEDULE,received_cb);
825    }
826  * @endcode
827  * @see calendar_svc_subscribe_change().
828  */
829 int calendar_svc_unsubscribe_db_change (const char *data_type,void(*cb)(void *));
830
831
832 int calendar_svc_unsubscribe_change (void(*cb)(void *));
833
834
835
836 /**
837  * @defgroup event_management event_management
838  * @ingroup CALENDAR_SVC
839  * @brief
840  *              major data access api
841  */
842
843
844 /**
845  * @fn int calendar_svc_insert(cal_struct *record);
846  * This function insert records to database,user can save event through calling it.
847  *
848  * @ingroup event_management
849  * @param[in] record calendar data for add
850  * @return This function returns CAL_SUCCESS or error code on failure.
851  * @exception None.
852  * @remarks event should .
853  * @pre database connected
854  * @post none
855  * @code
856    #include <calendar-svc-provider.h>
857    void sample_code()
858    {
859           //connect to database
860           calendar_svc_connect();
861
862           //create the variable
863           cal_struct* event = calendar_svc_struct_new("schedule");
864
865           //insert the event
866           calendar_svc_insert(event);
867
868           //close database
869           calendar_svc_close();
870    }
871  * @endcode
872  * @see detail_management module
873  */
874 int calendar_svc_insert(cal_struct *record);
875
876
877
878 /**
879  * @fn int calendar_svc_update(cal_struct *record);
880  * This function updates record to database,it is convenient for user to update some record.
881  *
882  * @ingroup event_management
883  * @return This function returns CAL_SUCCESS or error code on failure.
884  * @param[in] record calendar data for update
885  * @return This function returns CAL_SUCCESS or error code on failure.
886  * @exception None.
887  * @remarks None.
888  * @pre database connected
889  * @post none
890  * @code
891    #include <calendar-svc-provider.h>
892    void sample_code()
893    {
894           cal_struct* event = NULL;
895           int index = 1;
896
897           //connect to database
898           calendar_svc_connect();
899
900           //get the record whose index is 1
901           calendar_svc_get("schedule",index,NULL,&event);
902
903           //modify the summary
904           calendar_svc_struct_set_str(event,"summary","weekend");
905
906           //update
907           calendar_svc_update(event);
908
909           //free
910           calendar_svc_free(&evnet);
911
912           //close database
913           calendar_svc_close();
914    }
915  * @endcode
916  * @see detail_management module
917  */
918 int calendar_svc_update(cal_struct *record);
919
920 /**
921  * @fn int calendar_svc_delete(const char *data_type,int index);
922  * This function delete records from database,it is convenient for user to delete some record.
923  *
924  * @ingroup event_management
925  * @return This function returns CAL_SUCCESS or error code on failure.
926  * @param[in] data_type sepecific record type
927  * @param[in] index event db index
928  * @return This function returns CAL_SUCCESS or error code on failure.
929  * @exception None.
930  * @remarks None.
931  * @pre database connected
932  * @post none
933  * @code
934    #include <calendar-svc-provider.h>
935    void sample_code()
936    {
937           int index = 1;
938
939           //connect to database
940           calendar_svc_connect();
941
942           //delete the record whose index is 1
943           calendar_svc_delete("schedule",index);
944
945           //free
946           calendar_svc_free(&evnet);
947
948           //close database
949           calendar_svc_close();
950    }
951  * @endcode
952  * @see detail_management module
953  */
954 int calendar_svc_delete(const char *data_type,int index);
955
956 /**
957  * @fn int calendar_svc_delete_all(int account_id,const char *data_type);
958  * This function delete all records from database,it is convenient for user to delete all of records.
959  * local account deletes data immediately but the others set is_deleted parameter 1.
960  *
961  * @ingroup event_management
962  * @return This function returns CAL_SUCCESS or error code on failure.
963  * @param[in] account_id account db index
964  * @param[in] data_type detail data type(eg. CAL_STRUCT_CALENDAR,CAL_STRUCT_SCHEDULE, NULL), if null delete all data by account_id
965  * @return This function returns CAL_SUCCESS or error code on failure.
966  * @exception None.
967  * @remarks None.
968  * @pre database connected
969  * @post none
970  * @code
971    #include <calendar-svc-provider.h>
972    void sample_code()
973    {
974           //connect to database
975           calendar_svc_connect();
976
977           //delete the all records of schudule_table
978           calendar_svc_delete_all(0,"schedule");
979
980           //close database
981           calendar_svc_close();
982    }
983  * @endcode
984  * @see detail_management module
985  */
986 int calendar_svc_delete_all(int account_id,const char *data_type);
987
988 /**
989  * @fn int calendar_svc_delete_account(int account_id);
990  * This function delete all records from database,it is convenient for user to delete all of records according to account.
991  * local account deletes data immediately but the others set is_deleted parameter 1.
992  *
993  * @ingroup event_management
994  * @return This function returns CAL_SUCCESS or error code on failure.
995  * @param[in] account_id account db index
996  * @return This function returns CAL_SUCCESS or error code on failure.
997  * @exception None.
998  * @remarks None.
999  * @pre database connected
1000  * @post none
1001  * @code
1002    #include <calendar-svc-provider.h>
1003    void sample_code()
1004    {
1005           //connect to database
1006           calendar_svc_connect();
1007
1008           //delete the all records of schudule_table
1009           calendar_svc_delete_account(0);
1010
1011           //close database
1012           calendar_svc_close();
1013    }
1014  * @endcode
1015  * @see detail_management module
1016  */
1017
1018 int calendar_svc_delete_account(int account_id);
1019
1020
1021 /**
1022  * @fn int calendar_svc_clean_after_sync(int calendar_id);
1023  * This function clean deleted(marked) all records from database,which is used to remove data from database after sync operation.
1024  *
1025  * @ingroup event_management
1026  * @return This function returns CAL_SUCCESS or error code on failure.
1027  * @param[in] account_id calendar id
1028  * @return This function returns CAL_SUCCESS or error code on failure.
1029  * @exception None.
1030  * @remarks None.
1031  * @pre database connected
1032  * @post none
1033  * @code
1034    #include <calendar-svc-provider.h>
1035    void sample_code()
1036    {
1037           //connect to database
1038           calendar_svc_connect();
1039
1040           //delete the all records from schudule_table
1041           calendar_svc_clean_after_sync(0);
1042
1043           //close database
1044           calendar_svc_close();
1045    }
1046  * @endcode
1047  * @see detail_management module
1048  */
1049
1050 int calendar_svc_clean_after_sync(int calendar_id);
1051
1052 /**
1053  * @fn int calendar_svc_get(const char *data_type,int index,const char *field_list, cal_struct **record);
1054  * This function get records from database,user can get event from database through calling it.
1055  *
1056  * @ingroup event_management
1057  * @return This function returns inserted contact id or error code on failure.
1058  * @param[in] data_type sepecific record type
1059  * @param[in] index db index
1060  * @param[in] field_list specific field list(eg. "summary,description"), if NULL, all field is returned.
1061  * @param[out] record calendar data , it should be free by calendar_svc_struct_free
1062  * @return This function returns CAL_SUCCESS or error code on failure.
1063  * @exception None.
1064  * @remarks event should .
1065  * @pre database connected
1066  * @post none
1067  * @code
1068    #include <calendar-svc-provider.h>
1069    void sample_code()
1070    {
1071           int index = 1;
1072           cal_struct* event = NULL;
1073
1074           //connect to database
1075           calendar_svc_connect();
1076
1077           //get the record whose index is 1
1078           calendar_svc_get("schedule",index,NULL, &event);
1079
1080           //free the space
1081           calendar_svc_struct_free(&event);
1082
1083           //close database
1084           calendar_svc_close();
1085    }
1086  * @endcode
1087  * @see detail_management module
1088  */
1089 int calendar_svc_get(const char *data_type,int index,const char *field_list, cal_struct **record);
1090
1091 /**
1092  * @fn int calendar_svc_get_count(int account_id,int calendar_id,const char *data_type);
1093  * This function get count of records from database,user can get the count through calling it.
1094  *
1095  * @ingroup event_management
1096  * @return Integer value, or 0 if no value is obtained
1097  * @param[in] account_id account db index
1098  * @param[in] calendar_id calendar id(will be support phase 2)
1099  * @param[in] data_type data_type(CAL_STRUCT_CALENDAR or CAL_STRUCT_SCHEDULE)
1100  * @return This function returns CAL_SUCCESS or error code on failure.
1101  * @exception None.
1102  * @remarks event should .
1103  * @pre database connected
1104  * @post none
1105  * @code
1106    #include <calendar-svc-provider.h>
1107    void sample_code()
1108    {
1109           int count = -1;
1110
1111           //connect to database
1112           calendar_svc_connect();
1113
1114           //get the count of all
1115           count = calendar_svc_get_count(0,0,"shchedule");
1116
1117           //close database
1118           calendar_svc_close();
1119    }
1120  * @endcode
1121  * @see detail_management module
1122  */
1123 int calendar_svc_get_count(int account_id,int calendar_id,const char *data_type);
1124
1125 int calendar_svc_calendar_get_count(int account_id);
1126 int calendar_svc_event_get_count(int calendar_id);
1127 int calendar_svc_todo_get_count(int calendar_id);
1128
1129 /**
1130  * @fn int calendar_svc_get_all(int account_id,int calendar_id,const char *data_type, cal_iter **iter);
1131  * This function get all records from database,it is convenient for user to get all of the reocrds once.
1132  *
1133  * @ingroup event_management
1134  * @return This function returns CAL_SUCCESS or error code on failure.
1135  * @param[in] account_id account db index
1136  * @param[in] calendar_id calendar id. If account_id is set, the account_id will be ignore.
1137  * @param[in] data_type data_type(CAL_STRUCT_CALENDAR or CAL_STRUCT_SCHEDULE)
1138  * @param[out] iter calendar data
1139  * @return This function returns CAL_SUCCESS or error code on failure.
1140  * @exception None.
1141  * @remarks event should .
1142  * @pre database connected
1143  * @post call calendar_svc_iter_remove() when leave
1144  * @code
1145    #include <calendar-svc-provider.h>
1146    void sample_code()
1147    {
1148           cal_iter *iter = NULL;
1149
1150           //connect to database
1151           calendar_svc_connect();
1152
1153           //get all records
1154           calendar_svc_get_all(0,0,"schedule", &iter);
1155
1156           //free
1157           calendar_svc_iter_remove(&iter);
1158
1159           //close database
1160           calendar_svc_close();
1161    }
1162  * @endcode
1163  * @see detail_management module
1164  */
1165 int calendar_svc_get_all(int account_id,int calendar_id,const char *data_type, cal_iter **iter);
1166
1167 /**
1168  * @fn int calendar_svc_event_get_changes(int calendar_id, int version, cal_iter **iter);
1169  * This function provides the iterator to get all changes later than the version.
1170  *
1171  * @ingroup event_management
1172  * @return This function returns CAL_SUCCESS or error code on failure.
1173  * @param[in] calendar_id calendar ID
1174  * @param[in] version version number
1175  * @param[out] iter interation struct for list travel
1176  * @return This function returns CAL_SUCCESS or error code on failure.
1177  * @exception None.
1178  * @remarks None.
1179  * @pre database connected
1180  * @post none
1181  * @code
1182    #include <calendar-svc-provider.h>
1183    #include <stdio.h>
1184    void sample_code()
1185    {
1186       int ret;
1187       cal_struct *cs;
1188       cal_iter *it;
1189       int id, type, ver;
1190
1191       calendar_svc_event_get_changes(1, 0, &it);
1192
1193       while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
1194          cs = NULL;
1195          ret = calendar_svc_iter_get_info(it, &cs);
1196          if (ret != CAL_SUCCESS) {
1197             printf("calendar_svc_iter_get_info failed (%d)\n", ret);
1198             return -1;
1199          }
1200          id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID);
1201          type = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE);
1202          ver = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_VERSION);
1203          printf("type = %d id = %d ver = %d\n", id, type, ver);
1204          calendar_svc_struct_free(&cs);
1205       }
1206       calendar_svc_iter_remove(&it);
1207    }
1208  * @endcode
1209  * @see detail_management module
1210  */
1211 int calendar_svc_event_get_changes(int calendar_id, int version, cal_iter **iter);
1212
1213 /**
1214  * @fn int calendar_svc_todo_get_changes(int calendar_id, int version, cal_iter **iter);
1215  * This function provides the iterator to get all changes later than the version.
1216  *
1217  * @ingroup event_management
1218  * @return This function returns CAL_SUCCESS or error code on failure.
1219  * @param[in] calendar_id calendar ID
1220  * @param[in] version version number
1221  * @param[out] iter interation struct for list travel
1222  * @return This function returns CAL_SUCCESS or error code on failure.
1223  * @exception None.
1224  * @remarks None.
1225  * @pre database connected
1226  * @post none
1227  * @code
1228    #include <calendar-svc-provider.h>
1229    #include <stdio.h>
1230    void sample_code()
1231    {
1232       int ret;
1233       cal_struct *cs;
1234       cal_iter *it;
1235       int id, type, ver;
1236
1237       calendar_svc_todo_get_changes(1, 0, &it);
1238
1239       while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
1240          cs = NULL;
1241          ret = calendar_svc_iter_get_info(it, &cs);
1242          if (ret != CAL_SUCCESS) {
1243             printf("calendar_svc_iter_get_info failed (%d)\n", ret);
1244             return -1;
1245          }
1246          id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID);
1247          type = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE);
1248          ver = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_VERSION);
1249          printf("type = %d id = %d ver = %d\n", id, type, ver);
1250          calendar_svc_struct_free(&cs);
1251       }
1252       calendar_svc_iter_remove(&it);
1253    }
1254  * @endcode
1255  * @see detail_management module
1256  */
1257 int calendar_svc_todo_get_changes(int calendar_id, int version, cal_iter **iter);
1258
1259 int calendar_svc_convert_id_to_uid(const char *data_type,int index,char **uid);
1260
1261 /**
1262  * @fn int calendar_svc_iter_get_info(cal_iter *iter, cal_struct **row_record);
1263  * This function get cal_value by cal_iter,it is convenient for user to get event from iter.
1264  *
1265  * @ingroup event_management
1266  * @return This function returns CAL_SUCCESS or error code on failure.
1267  * @param[in] iter interation struct for list travel
1268  * @param[out] row_record detail information
1269  * @exception None.
1270  * @remarks row_record should be free with calendar_svc_struct_free
1271  * @pre database connected
1272  * @post none
1273  * @code
1274    #include <calendar-svc-provider.h>
1275    void sample_code()
1276    {
1277           cal_iter *iter = NULL;
1278           cal_struct* evnet = NULL;
1279
1280           //connect to database
1281           calendar_svc_connect();
1282
1283           //get all records
1284           calendar_svc_get_all(0,0,"schedule", &iter);
1285
1286           //get events
1287           calendar_svc_iter_get_info(iter, &event);
1288
1289           //free
1290           calendar_svc_iter_remove(&iter);
1291
1292           //close database
1293           calendar_svc_close();
1294    }
1295  * @endcode
1296  * @see detail_management module
1297  */
1298 int calendar_svc_iter_get_info(cal_iter *iter, cal_struct **row_record);
1299
1300
1301 /**
1302  * @fn int calendar_svc_iter_next(cal_iter *iter);
1303  * This function get cal_value by cal_iter,it is convenient for user to get record one by one.
1304  *
1305  * @ingroup event_management
1306  * @return This function returns CAL_SUCCESS or error code on failure.
1307  * @param[in] iter interation struct for list travel
1308  * @exception None.
1309  * @remarks None.
1310  * @pre database connected
1311  * @post none
1312  * @code
1313    #include <calendar-svc-provider.h>
1314    void sample_code()
1315    {
1316           cal_iter *iter = NULL;
1317           cal_struct* evnet = NULL;
1318
1319           //connect to database
1320           calendar_svc_connect();
1321
1322           //get all records
1323           calendar_svc_get_all(0,0,"schedule", &iter);
1324
1325           //get events
1326           calendar_svc_iter_get_info(iter, &event);
1327
1328           //get next event
1329           calendar_svc_iter_next(iter);
1330           calendar_svc_iter_get_info(iter, &event);
1331
1332           //free
1333           calendar_svc_iter_remove(&iter);
1334
1335           //close database
1336           calendar_svc_close();
1337    }
1338  * @endcode
1339  * @see detail_management module
1340  */
1341 int calendar_svc_iter_next(cal_iter *iter);
1342
1343
1344 /**
1345  * @fn int calendar_svc_iter_remove(cal_iter **iter);
1346  * This function remove db iteration struct,it is convenient for user to avoid memory leak.
1347  *
1348  * @ingroup event_management
1349  * @return This function returns CAL_SUCCESS or error code on failure.
1350  * @param[in] iter interation struct for list travel
1351  * @exception None.
1352  * @remarks None.
1353  * @pre database connected
1354  * @post none
1355  * @code
1356    #include <calendar-svc-provider.h>
1357    void sample_code()
1358    {
1359           cal_iter *iter = NULL;
1360
1361           //connect to database
1362           calendar_svc_connect();
1363
1364           //get all records
1365           calendar_svc_get_all(0,0,"schedule", &iter);
1366
1367           //free
1368           calendar_svc_iter_remove(&iter);
1369
1370           //close database
1371           calendar_svc_close();
1372    }
1373  * @endcode
1374  * @see detail_management module
1375  */
1376 int calendar_svc_iter_remove(cal_iter **iter);
1377
1378 /**
1379  * @defgroup detail_management detail_management
1380  * @ingroup CALENDAR_SVC
1381  * @brief
1382  *              deatil field access api
1383  */
1384
1385
1386 /**
1387  * @fn cal_struct * calendar_svc_struct_new(const char *data_type);
1388  * This function alloc calendar struct,it is convenient for user to create an event.
1389  *
1390  * @ingroup detail_management
1391  * @return This function returns allocated event struct
1392  * @param[in] data_type (eg.CAL_EVENT_TYPE_SCHEDULE,CAL_EVENT_TYPE_CALENDAR..)
1393  * @exception None.
1394  * @remarks it should be free with calendar_svc_struct_free
1395  * @pre cal_struct variable is defined.
1396  * @post None.
1397  * @remarks None.
1398  * @code
1399    #include <calendar_svc_provider.h>
1400    void sample_code()
1401    {
1402         //connect to database
1403         calendar_svc_connect();
1404
1405         //create variable
1406     cal_struct * event = calendar_svc_struct_new("schedule");
1407
1408     //free the space
1409     calendar_svc_struct_free(&event);
1410
1411         //close the database
1412         calendar_svc_close();
1413    }
1414  * @endcode
1415  * @see calendar_svc_struct_free().
1416  */
1417 cal_struct * calendar_svc_struct_new(const char *data_type);
1418
1419 /**
1420  * @fn int calendar_svc_struct_free(cal_struct **record);
1421  * This function is used to free space malloced to cal_struct variable,it is convenient for user to avoid memory leak when using cal_struct.
1422  *
1423  * @ingroup detail_management
1424  * @param[in] record Point to alloced address
1425  * @return This function returns CAL_SUCCESS or error code on failure.
1426  * @pre cal_struct variable is defined.
1427  * @post None.
1428  * @remarks None.
1429  * @code
1430    #include <calendar_svc_provider.h>
1431    void sample_code()
1432    {
1433         //connect to database
1434         calendar_svc_connect();
1435
1436         //create variable
1437     cal_struct * event = calendar_svc_struct_new("schedule");
1438
1439     //free the space
1440     calendar_svc_struct_free(&event);
1441
1442         //close the database
1443         calendar_svc_close();
1444    }
1445  * @endcode
1446  * @see common, CAL_STRUCT_TYPE , calendar_svc_struct_new.
1447  */
1448 int calendar_svc_struct_free(cal_struct **record);
1449
1450
1451 /**
1452  * @fn int calendar_svc_struct_get_str(cal_struct* record, const char* field);
1453  * This function gets the point of string value of the calendar service value,it is convenient for user get the value needed without knowing the detail of the struct.
1454  *
1455  * @ingroup detail_management
1456  * @param[in] record Point to The calendar struct
1457  * @param[in] field The index of the string value in calendar service value.
1458  * @return string value(should not be freed), or NULL if no value is obtained
1459  * @remarks if parent cal_struct is destroyed, return string is not valid.
1460  * @pre cal_struct varibale is defined.
1461  * @post none
1462  * @code
1463         #include <calendar-svc-provider.h>
1464         void sample_code()
1465         {
1466                 char* summary = NULL;
1467                 index = 1;
1468                 cal_struct* event = NULL;
1469
1470                 //connect to database
1471                 calendar_svc_connect();
1472
1473                 //get the record
1474                 calendar_svc_get("schedule",index,NULL,&event);
1475
1476                 //get the str value
1477                 summary = calendar_svc_struct_get_str(event,CAL_VALUE_TXT_SUMMARY);
1478
1479                 //free space
1480                 calendar_svc_free(&event);
1481
1482                 //close database
1483                 calendar_svc_close();
1484         }
1485  * @endcode
1486  * @see calendar_svc_struct_set_str().
1487  */
1488 char *calendar_svc_struct_get_str(cal_struct* record, const char *field);
1489
1490 /**
1491  * @fn int calendar_svc_struct_get_int(cal_struct* record, const char* field);
1492  * This function gets Integer value of the calendar service value,it is convenient for user get the value needed without knowing the detail of the struct.
1493  *
1494  * @ingroup detail_management
1495  * @param[in] record Point to The calendar struct
1496  * @param[in] field The index of the integer value in calendar service value.
1497  * @return Integer value, or 0 if no value is obtained
1498  * @remarks none
1499  * @pre cal_struct varibale is defined.
1500  * @post none
1501  * @code
1502         #include <calendar-svc-provider.h>
1503         void sample_code()
1504         {
1505                 int account_id = 0;
1506                 index = 1;
1507                 cal_struct* event = NULL;
1508
1509                 //connect to database
1510                 calendar_svc_connect();
1511
1512                 //get the record
1513                 calendar_svc_get("schedule",index,NULL,&event);
1514
1515                 //get the int value
1516                 account_id = calendar_svc_struct_get_int(event,CAL_VALUE_INT_ACCOUNT_ID);
1517
1518                 //free space
1519                 calendar_svc_free(&event);
1520
1521                 //close database
1522                 calendar_svc_close();
1523         }
1524  * @endcode
1525  * @see calendar_svc_struct_set_int().
1526  */
1527 int calendar_svc_struct_get_int(cal_struct* record, const char *field);
1528
1529
1530 /**
1531  * @fn double calendar_svc_struct_get_double(cal_struct* record, const char* field);
1532  * This function gets double value of the calendar service value,it is convenient for user get the value needed without knowing the detail of the struct.
1533  *
1534  * @ingroup detail_management
1535  * @param[in] record Point to The calendar struct
1536  * @param[in] field The index of the integer value in calendar service value.
1537  * @return double value, or 0.0 if no value is obtained
1538  * @remarks none
1539  * @pre cal_struct varibale is defined.
1540  * @post none
1541  * @code
1542         #include <calendar-svc-provider.h>
1543         void sample_code()
1544         {
1545                 double latitude = 0.0;
1546                 index = 1;
1547                 cal_struct* event = NULL;
1548
1549                 //connect to database
1550                 calendar_svc_connect();
1551
1552                 //get the record
1553                 calendar_svc_get("schedule",index,NULL,&event);
1554
1555                 //get the double value
1556                 latitude = calendar_svc_struct_get_double(event,CAL_VALUE_DBL_LATITUDE);
1557
1558                 //free space
1559                 calendar_svc_free(&event);
1560
1561                 //close database
1562                 calendar_svc_close();
1563         }
1564  * @endcode
1565  * @see calendar_svc_struct_set_double().
1566  */
1567 double calendar_svc_struct_get_double(cal_struct* record, const char *field);
1568
1569
1570 /**
1571  * @fn int calendar_svc_struct_set_double(cal_struct* record, const char* field,double value);
1572  * This function sets double value of the calendar service value,it is convenient for user set the value without knowing the detail of the struct.
1573  *
1574  * @ingroup detail_management
1575  * @param[in] record Point to The calendar struct
1576  * @param[in] field The index of the integer value in calendar service value.
1577  * @param[in] value The dobule value to be set.
1578  * @return Integer value, or 0 if no value is obtained
1579  * @remarks none.
1580  * @pre cal_struct variable is defined.
1581  * @post the corresponding value of cal_struct is set.
1582  * @code
1583         #include <calendar-svc-provider.h>
1584         void sample_code()
1585         {
1586                 double latitude = 3.14;
1587                 index = 0;
1588                 cal_struct* event = NULL;
1589
1590                 //connect to database
1591                 calendar_svc_connect();
1592
1593                 //create a cal_struct variable
1594                 event = calendar_svc_struct_new("schedule");
1595
1596                 //set the double value
1597                 calendar_svc_set_double(event,CAL_VALUE_DBL_LATITUDE,latitude);
1598
1599                 //insert the record
1600                 index = calendar_svc_insert(event);
1601
1602                 //free the space
1603                 calendar_svc_struct_free(&event);
1604
1605                 //close database
1606                 calendar_svc_close();
1607         }
1608  * @endcode
1609  * @see calendar_svc_struct_get_double().
1610  */
1611 int calendar_svc_struct_set_double(cal_struct* record, const char *field,double value);
1612
1613
1614 /**
1615  * @fn int calendar_svc_struct_set_int(cal_struct* record, const char* field, int intval);
1616  * This function sets integer value to the calendar service value,it is convenient for user set the value without knowing the detail of the struct.
1617  *
1618  * @ingroup detail_management
1619  * @param[in] record Point to The calendar struct
1620  * @param[in] field The index of the integer value in calendar service value.
1621  * @param[in] intval The integer value to be set.
1622  * @return      This function returns CAL_SUCCESS or error code on failure.
1623  * @remarks none.
1624  * @pre cal_struct variable is defined.
1625  * @post the corresponding value of cal_struct is set.
1626  * @code
1627         #include <calendar-svc-provider.h>
1628         void sample_code()
1629         {
1630                 int account_id = 1;
1631                 index = 0;
1632                 cal_struct* event = NULL;
1633
1634                 //connect to database
1635                 calendar_svc_connect();
1636
1637                 //create a cal_struct variable
1638                 event = calendar_svc_struct_new("schedule");
1639
1640                 //set the int value
1641                 calendar_svc_set_int(event,CAL_VALUE_INT_ACCOUNT_ID,account_id);
1642
1643                 //insert the record
1644                 index = calendar_svc_insert(event);
1645
1646                 //free the space
1647                 calendar_svc_struct_free(&event);
1648
1649                 //close database
1650                 calendar_svc_close();
1651         }
1652  * @endcode
1653  * @see calendar_svc_struct_get_int().
1654  */
1655 int calendar_svc_struct_set_int(cal_struct* record, const char *field, int intval);
1656
1657 /**
1658  * @fn int calendar_svc_struct_set_str(cal_struct* record, const char* field, const char *strval);
1659  * This function sets string value to the calendar service value,it is convenient for user set the value without knowing the detail of the struct.
1660  * If it is in struct, free old string and copy strval to struct.
1661  *
1662  * @ingroup detail_management
1663  * @param[in] record Point to The calendar struct
1664  * @param[in] field The index of the string value in calendar service value.
1665  * @param[in] strval The string value to be set.
1666  * @return      This function returns CAL_SUCCESS or error code on failure.
1667  * @remarks none.
1668  * @pre cal_struct variable is defined.
1669  * @post the corresponding value of cal_struct is set.
1670  * @code
1671         #include <calendar-svc-provider.h>
1672         void sample_code()
1673         {
1674                 char* summary = "party";
1675                 index = 0;
1676                 cal_struct* event = NULL;
1677
1678                 //connect to database
1679                 calendar_svc_connect();
1680
1681                 //create a cal_struct variable
1682                 event = calendar_svc_struct_new("schedule");
1683
1684                 //set the string value
1685                 calendar_svc_set_str(event,CAL_VALUE_TXT_SUMMARY,summary);
1686
1687                 //insert the record
1688                 index = calendar_svc_insert(event);
1689
1690                 //free the space
1691                 calendar_svc_struct_free(&event);
1692
1693                 //close database
1694                 calendar_svc_close();
1695         }
1696  * @endcode
1697  * @see calendar_svc_struct_get_str().
1698  */
1699 int calendar_svc_struct_set_str(cal_struct* record, const char *field, const char *strval);
1700
1701
1702 /**
1703  * @fn int calendar_svc_struct_get_list(cal_struct* record, const char* field, GList** retlist);
1704  * This function gets the point of glib double-linked list in the calendar service struct,it is convenient for user get the value without knowing the detail of the struct.
1705  *
1706  * @ingroup detail_management
1707  * @param[in] record structure A calendar service struct
1708  * @param[in] field The index of the glib singly-linked list in calendar service struct.
1709  * @param[out] retlist the glib singly-linked list requested with field(should not be freed or removed)
1710  * @return      This function returns CAL_SUCCESS or error code on failure.
1711  * @remarks if parent cal_struct is destroyed, retlist is not valid.
1712  * @pre cal_struct variable is defined.
1713  * @post none.
1714  * @code
1715         #include <calendar-svc-provider.h>
1716         void sample_code()
1717         {
1718                 GList* list = NULL;
1719                 index = 1;
1720                 cal_struct* event = NULL;
1721
1722                 //connect to database
1723                 calendar_svc_connect();
1724
1725                 //get the record
1726                 calendar_svc_get("schedule",index,NULL,&event);
1727
1728                 //get the list
1729                 calendar_svc_struct_get_list(event,"attendee_list",&list);
1730
1731                 //free the space
1732                 calendar_svc_struct_free(&event);
1733
1734                 //close database
1735                 calendar_svc_close();
1736         }
1737  * @endcode
1738  * @see calendar_svc_struct_store_list().
1739  */
1740 int calendar_svc_struct_get_list(cal_struct* record,const char *field, GList** retlist);
1741
1742 /**
1743  * @fn int calendar_svc_struct_store_list(cal_struct* record, const char* field, GList* list)
1744  * This function sets the glib double-linked list to the calendar service struct,it is convenient for user set the value.
1745  * \n Values(cal_value) of the list are moved to the calendar service struct. But the list is copied.
1746  *
1747  * @ingroup detail_management
1748  * @param[in] record structure A calendar service struct
1749  * @param[in] field The index of the glib singly-linked list in calendar service struct.
1750  * @param[in] list the glib singly-linked list to be set
1751  * @return      This function returns CAL_SUCCESS or error code on failure.
1752  * @remarks if parent cal_struct is destroyed, GSList is not valid.
1753  * @pre cal_struct variable is defined.
1754  * @post none.
1755  * @code
1756         #include <calendar-svc-provider.h>
1757         void sample_code()
1758         {
1759                 GList* list = NULL;
1760                 index = 1;
1761                 cal_struct* event = NULL;
1762
1763                 //connect to database
1764                 calendar_svc_connect();
1765
1766                 //create the event
1767                 event = calendar_svc_struct_new("schedule");
1768
1769                 //set the list
1770                 calendar_svc_struct_store_list(event,"attendee_list",list);
1771
1772                 //free the space
1773                 calendar_svc_struct_free(&event);
1774
1775                 //close database
1776                 calendar_svc_close();
1777         }
1778  * @endcode
1779  * @see calendar_svc_struct_get_list().
1780  */
1781 int calendar_svc_struct_store_list(cal_struct* record,const char *field, GList* list);
1782
1783 /**
1784  * @fn int calendar_svc_value_new(const char* val_type);
1785  * Allocate, initialize and return a new calendar service value,it is convenient for user to create a calendar service value.
1786  *
1787  * @ingroup detail_management
1788  * @param[in] val_type The type of calendar service value
1789  * @return The pointer of New calendar service value, NULL on error
1790  * @remarks none.
1791  * @pre none.
1792  * @post none.
1793  * @code
1794         #include <calendar-svc-provider.h>
1795         void sample_code()
1796         {
1797                 GList* list = NULL;
1798                 index = 1;
1799                 cal_value* event = NULL;
1800
1801                 //connect to database
1802                 calendar_svc_connect();
1803
1804                 //create the event
1805                 event = calendar_svc_value_new("attendee_list");
1806
1807                 //set the list
1808                 list = g_list_append(list,event);
1809                 calendar_svc_struct_store_list(event,"attendee_list",list);
1810
1811                 //free the space
1812                 calendar_svc_value_free(&event);
1813
1814                 //close database
1815                 calendar_svc_close();
1816         }
1817  * @endcode
1818  * @see calendar_svc_value_free().
1819  */
1820 cal_value* calendar_svc_value_new(const char *val_type);
1821
1822 /**
1823  * @fn int calendar_svc_value_free(cal_value** value);
1824  * A destructor for calendar service value,,it is convenient for user to free the space allocated.
1825  * If it is in struct, return CAL_ERR_ARG_INVALID.
1826  *
1827  * @ingroup detail_management
1828  * @param[in] value A calendar service value
1829  * @return      This function returns CAL_SUCCESS or error code on failure.
1830  * @remarks none.
1831  * @pre cal_value variable is defined.
1832  * @post none.
1833  * @code
1834         #include <calendar-svc-provider.h>
1835         void sample_code()
1836         {
1837                 GList* list = NULL;
1838                 index = 1;
1839                 cal_value* event = NULL;
1840
1841                 //connect to database
1842                 calendar_svc_connect();
1843
1844                 //create the event
1845                 event = calendar_svc_value_new("attendee_list");
1846
1847                 //set the list
1848                 list = g_list_append(list,event);
1849                 calendar_svc_struct_store_list(event,"attendee_list",list);
1850
1851                 //free the space
1852                 calendar_svc_value_free(&event);
1853
1854                 //close database
1855                 calendar_svc_close();
1856         }
1857  * @endcode
1858  * @see calendar_svc_value_new().
1859  */
1860 int calendar_svc_value_free(cal_value** value);
1861
1862 /**
1863  * @fn int calendar_svc_value_set_int(cal_value* value, const char* field, int intval);
1864  * This function sets integer value to the calendar service value,it is convenient for user set value of cal_value varible.
1865  *
1866  * @ingroup detail_management
1867  * @param[in] value The calendar service value
1868  * @param[in] field The index of the integer value in calendar service value.
1869  * @param[in] intval The integer value to be set.
1870  * @return      This function returns CAL_SUCCESS or error code on failure.
1871  * @remarks none.
1872  * @pre cal_value variable is defined.
1873  * @post none.
1874  * @code
1875         #include <calendar-svc-provider.h>
1876         void sample_code()
1877         {
1878                 GList* list = NULL;
1879                 index = 1;
1880                 cal_value* event = NULL;
1881
1882                 //connect to database
1883                 calendar_svc_connect();
1884
1885                 //create the event
1886                 event = calendar_svc_value_new("attendee_list");
1887                 calendar_svc_value_set_int(event,"attendee_status",1);
1888
1889                 //set the list
1890                 list = g_list_append(list,event);
1891                 calendar_svc_struct_store_list(event,"attendee_list",list);
1892
1893                 //free the space
1894                 calendar_svc_value_free(&event);
1895
1896                 //close database
1897                 calendar_svc_close();
1898         }
1899  * @endcode
1900  * @see calendar_svc_value_get_int().
1901  */
1902 int calendar_svc_value_set_int(cal_value* value, const char *field, int intval);
1903
1904 int calendar_svc_value_set_lli (cal_value *value, const char *field, long long int llival);
1905 long long int calendar_svc_value_get_lli (cal_value *value, const char *field);
1906 /**
1907  * @fn int calendar_svc_value_set_str(cal_value* value, const char* field, const char *strval);
1908  * This function sets string value to the calendar service value,it is convenient for user set value of cal_value varible.
1909  * If it is in struct, free old string and copy strval to struct.
1910  *
1911  * @ingroup detail_management
1912  * @param[in] value The calendar service value
1913  * @param[in] field The index of the string value in calendar service value.
1914  * @param[in] strval The string value to be set.
1915  * @return      This function returns CAL_SUCCESS or error code on failure.
1916  * @remarks none.
1917  * @pre cal_value variable is defined.
1918  * @post none.
1919  * @code
1920         #include <calendar-svc-provider.h>
1921         void sample_code()
1922         {
1923                 GList* list = NULL;
1924                 index = 1;
1925                 cal_value* event = NULL;
1926
1927                 //connect to database
1928                 calendar_svc_connect();
1929
1930                 //create the event
1931                 event = calendar_svc_value_new("attendee_list");
1932                 calendar_svc_value_set_str(event,"attendee_name","Max");
1933
1934                 //set the list
1935                 list = g_list_append(list,event);
1936                 calendar_svc_struct_store_list(event,"attendee_list",list);
1937
1938                 //free the space
1939                 calendar_svc_value_free(&event);
1940
1941                 //close database
1942                 calendar_svc_close();
1943         }
1944  * @endcode
1945  * @see calendar_svc_value_get_str().
1946  */
1947 int calendar_svc_value_set_str(cal_value* value, const char *field, const char *strval);
1948
1949
1950 /**
1951  * @fn int calendar_svc_value_get_int(cal_value* value, const char* field);
1952  * This function gets Integer value of the calendar service value,it is convenient for user get value of cal_value varible.
1953  *
1954  * @ingroup detail_management
1955  * @param[in] value The calendar service value
1956  * @param[in] field The index of the integer value in calendar service value.
1957  * @return Integer value, or 0 if no value is obtained
1958  * @remarks none.
1959  * @pre cal_value variable is defined.
1960  * @post none.
1961  * @code
1962         #include <calendar-svc-provider.h>
1963         void sample_code()
1964         {
1965                 int type = 0;
1966                 cal_value* event = NULL;
1967
1968                 //connect to database
1969                 calendar_svc_connect();
1970
1971                 //create the event
1972                 event = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
1973
1974                 //get the type value
1975                 type = calendar_svc_value_get_int(event,
1976                         CAL_VALUE_INT_ATTENDEE_DETAIL_TYPE);
1977
1978                 //free the space
1979                 calendar_svc_value_free(&event);
1980
1981                 //close database
1982                 calendar_svc_close();
1983         }
1984  * @endcode
1985  * @see calendar_svc_value_set_int().
1986  */
1987 int calendar_svc_value_get_int(cal_value* value, const char *field);
1988
1989 /**
1990  * @fn char* calendar_svc_value_get_str(cal_value* value, const char* field);
1991  * This function gets the point of string value of the calendar service value,it is convenient for user get value of cal_value varible.
1992  *
1993  * @ingroup detail_management
1994  * @param[in] value The calendar service value
1995  * @param[in] field The index of the string value in calendar service value.
1996  * @return string value(should not be freed), or NULL if no value is obtained
1997  * @remarks none.
1998  * @pre cal_value variable is defined.
1999  * @post none.
2000  * @code
2001         #include <calendar-svc-provider.h>
2002         void sample_code()
2003         {
2004                 char* name = "money";
2005                 cal_value* event = NULL;
2006
2007                 //connect to database
2008                 calendar_svc_connect();
2009
2010                 //create the event
2011                 event = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
2012
2013                 //get the event_id value
2014                 name = calendar_svc_value_get_str(event,
2015                         CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME);
2016
2017                 //free the space
2018                 calendar_svc_value_free(&event);
2019
2020                 //close database
2021                 calendar_svc_close();
2022         }
2023  * @endcode
2024  * @see calendar_svc_value_set_str().
2025  */
2026 char *calendar_svc_value_get_str(cal_value* value, const char *field);
2027
2028 /**
2029  * @fn int calendar_svc_util_convert_event_to_vcs (cal_struct *record,char **raw_data,int *data_size);
2030  * This function converts data (cal_struct(event) to raw_data(vcal format)),it is convenient for user to convert.
2031  *
2032  * @ingroup utilities
2033  * @param[in] record      original record type
2034  * @param[out]  raw_data            vcalendar event raw data
2035  * @param[out]  data_size          raw_data buf size
2036  * @return       This function returns CAL_SUCCESS or error code on failure.
2037  * @remarks none
2038  * @pre none.
2039  * @post none
2040  * @code
2041         #include <calendar_svc_provider.h>
2042         void sample_code()
2043         {
2044                 char raw_data = NULL;
2045                 int data_size = 0;
2046
2047                 //connect to database
2048                 calendar_svc_connect();
2049
2050                 cal_struct* event = NULL;
2051
2052                 //get the record
2053                 calendar_svc_get("schedule",1,NULL,&event);
2054
2055                 //convert
2056                 calendar_svc_util_convert_event_to_vcs (event,&raw_data,&data_size);
2057
2058                 calendar_svc_struct_free(&event);
2059
2060                 //close to database
2061                 calendar_svc_close();
2062         }
2063  * @endcode
2064  */
2065 DEPRECATED int calendar_svc_util_convert_event_to_vcs (cal_struct *record,char **raw_data,int *data_size);
2066
2067
2068 /**
2069  * @fn int calendar_svc_find_event_list(int account_id,const char* search_type,const void* search_value, cal_iter **iter);
2070  * This function get records from database by search param,it is convenient for user to get records according to some condition.
2071  *
2072  * @ingroup event_management
2073  * @return This function returns CAL_SUCCESS or error code on failure.
2074  * @param[in] account_id account db index
2075  * @param[in] search_type event search type(eg. CAL_VALUE_SUMMARY or CAL_VALUE_DESCRIPTION,..)
2076  * @param[in] search_value event search value(eg. "weekly report", etc.. ), it can be integer value(eg. 1 or 2.. etc)
2077  * @param[out] iter interation struct for list travel
2078  * @return This function returns CAL_SUCCESS or error code on failure.
2079  * @exception None.
2080  * @remarks None.
2081  * @pre database connected
2082  * @post none
2083  * @code
2084   #include <calendar-svc-provider.h>
2085   void sample_code()
2086   {
2087          cal_iter *iter = NULL;
2088
2089          //connect to database
2090          calendar_svc_connect();
2091
2092          //find event whose summary including string like "party"
2093          calendar_svc_find_event_list(0,"summary","party", &iter);
2094
2095          //free
2096          calendar_svc_iter_remove(&iter);
2097
2098          //close database
2099          calendar_svc_close();
2100   }
2101  * @endcode
2102  * @see detail_management module
2103  * @deprecated it will replacement calendar_svc_find_list
2104  */
2105 int calendar_svc_find_event_list(int account_id,const char *search_type,const void* search_value, cal_iter **iter);
2106
2107 /**
2108  * @fn int calendar_svc_event_search(int field, const char *keyword, cal_iter **iter);
2109  * #calendar_svc_event_search searches events including the keyword in given fields.
2110  *
2111  * @ingroup event_management
2112  * @return This function returns CAL_SUCCESS or error code on failure.
2113  * @param[in] field fields where the keyword is searched.  #SEARCHFIELD
2114  * @param[in] keyword keyword to be searched
2115  * @param[out] iter interation struct for list travel
2116  * @return This function returns CAL_SUCCESS or error code on failure.
2117  * @exception None.
2118  * @remarks None.
2119  * @pre database connected
2120  * @post none
2121  * @code
2122   #include <calendar-svc-provider.h>
2123   void sample_code()
2124   {
2125         int ret;
2126         cal_struct *cs;
2127         cal_iter *it;
2128         char *summary;
2129         char *desc;
2130         int id;
2131
2132         calendar_svc_connect();
2133         int search_field;
2134
2135         search_field = CALS_SEARCH_FIELD_NONE;
2136         search_field |= CALS_SEARCH_FIELD_SUMMARY;
2137         search_field |= CALS_SEARCH_FIELD_DESCRIPTION;
2138         search_field |= CALS_SEARCH_FIELD_LOCATION;
2139         search_field |= CALS_SEARCH_FIELD_ATTENDEE;
2140
2141         ret = calendar_svc_event_search(search_field, "Hello", &it);
2142         if (ret < 0)
2143                 return -1;
2144
2145         while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
2146                 cs = NULL;
2147                 ret = calendar_svc_iter_get_info(it, &cs);
2148                 if (ret != CAL_SUCCESS) {
2149                         printf("calendar_svc_iter_get_info failed (%d)\n", ret);
2150                         return -1;
2151                 }
2152
2153                 id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_INDEX);
2154                 summary = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
2155                 desc = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION);
2156                 printf("type = %d id = %s desc = %s\n", id, summary, desc);
2157                 calendar_svc_struct_free(&cs);
2158         }
2159
2160         calendar_svc_iter_remove(&it);
2161
2162         calendar_svc_close();
2163
2164         return 0;
2165   }
2166  * @endcode
2167  * @see detail_management module
2168  */
2169 int calendar_svc_event_search(int field, const char *keyword, cal_iter **iter);
2170
2171 /**
2172  * @fn int calendar_svc_smartsearch_excl(const char *keyword, int offset, int limit, cal_iter **iter)
2173  * Search events by keyword with database offset and limit option.
2174  * This function is provided for Smartsearch application exclusively.
2175  *
2176  * @ingroup event_management
2177  * @return CAL_SUCCESS or negative error code on failure.
2178  * @param[in] field fields where the keyword is searched, #SEARCHFIELD
2179  * @param[in] keyword keyword to be searched
2180  * @param[in] offset offset to omit some searching results
2181  * @param[in] limit limit of the number of results. If negative, no limit is applied.
2182  * @param[out] iter interation struct for list travel
2183  * @return This function returns CAL_SUCCESS or error code on failure.
2184  * @exception None.
2185  * @remarks None.
2186  * @pre database connected
2187  * @post none
2188  * @see detail_management module
2189  */
2190 int calendar_svc_smartsearch_excl(const char *keyword, int offset, int limit, cal_iter **iter);
2191
2192 /**
2193  * @fn int calendar_svc_todo_search(int field, const char *keyword, cal_iter **iter);
2194  * #calendar_svc_event_search searches TO-DOs including the keyword in given fields.
2195  *
2196  * @ingroup event_management
2197  * @return This function returns CAL_SUCCESS or error code on failure.
2198  * @param[in] field fields where the keyword is searched, #SEARCHFIELD
2199  * @param[in] keyword keyword to be searched
2200  * @param[out] iter interation struct for list travel
2201  * @return This function returns CAL_SUCCESS or error code on failure.
2202  * @exception None.
2203  * @remarks None.
2204  * @pre database connected
2205  * @post none
2206  * @code
2207   #include <calendar-svc-provider.h>
2208   void sample_code()
2209   {
2210         int ret;
2211         cal_struct *cs;
2212         cal_iter *it;
2213         char *summary;
2214         char *desc;
2215         int id;
2216
2217         calendar_svc_connect();
2218         int search_field;
2219
2220         search_field = CALS_SEARCH_FIELD_NONE;
2221         search_field |= CALS_SEARCH_FIELD_SUMMARY;
2222         search_field |= CALS_SEARCH_FIELD_DESCRIPTION;
2223         search_field |= CALS_SEARCH_FIELD_LOCATION;
2224         search_field |= CALS_SEARCH_FIELD_ATTENDEE;
2225
2226         ret = calendar_svc_todo_search(search_field, "Hello", &it);
2227         if (ret < 0)
2228                 return -1;
2229
2230         while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
2231                 cs = NULL;
2232                 ret = calendar_svc_iter_get_info(it, &cs);
2233                 if (ret != CAL_SUCCESS) {
2234                         printf("calendar_svc_iter_get_info failed (%d)\n", ret);
2235                         return -1;
2236                 }
2237
2238                 id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_INDEX);
2239                 summary = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
2240                 desc = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION);
2241                 printf("type = %d id = %s desc = %s\n", id, summary, desc);
2242                 calendar_svc_struct_free(&cs);
2243         }
2244
2245         calendar_svc_iter_remove(&it);
2246
2247         calendar_svc_close();
2248
2249         return 0;
2250   }
2251  * @endcode
2252  * @see detail_management module
2253  */
2254 int calendar_svc_todo_search(int field, const char *keyword, cal_iter **iter);
2255
2256 /**
2257  * @fn int calendar_svc_read_schedules(const char *stream, GList **schedules);
2258  * This function reads schedules and provides schedule list.
2259  *
2260  * @ingroup event management
2261  * @param[in] stream vcalendar(ver1.0) icalendar(ver2.0) stream
2262  * @param[out] schedules schedule list which data is cal_struct
2263  * @return This function returns CAL_SUCCESS or error code on failure.
2264  * @remarks none
2265  * @pre none
2266  * @post none
2267  * @code
2268         #include <stdio.h>
2269         #include <stdlib.h>
2270         #include <calendar-svc-provider.h>
2271
2272         void sample_code()
2273         {
2274                 int ret, len = 0;
2275                 char *vals;
2276                 char *stream = NULL;
2277                 char buf[1024];
2278                 time_t tt;
2279                 cal_struct *cs = NULL;
2280                 GList *l, *schedules = NULL;
2281                 buf_size = 1024;
2282                 FILE *file;
2283
2284                 file = fopen(path, "r");
2285                 if (file == NULL) {
2286                         printf("failed to open\n");
2287                         return -1;
2288                 }
2289                 stream = malloc(1024);
2290                 while (fgets(buf, sizeof(buf), file)) {
2291                         if (len + sizeof(buf) < buf_size) {
2292                                 len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
2293
2294                         } else {
2295                                 char *new_stream;
2296                                 buf_size *= 2;
2297                                 new_stream = realloc(stream, buf_size);
2298                                 if (new_stream) {
2299                                         stream = new_stream;
2300                                 } else {
2301                                         free(stream);
2302                                         fclose(file);
2303                                         printf("out of memory\n");
2304                                         return NULL;
2305                                 }
2306                                 len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
2307                         }
2308                 }
2309                 fclose(file);
2310
2311                 ret = calendar_svc_read_schedules(stream, &schedules);
2312                 if (ret < 0) {
2313                         printf("Failed to read schedules(errno:%d)\n", ret);
2314                         return -1;
2315                 }
2316
2317                 if (schedules == NULL) {
2318                         printf("No schedules\n");
2319                         return -1;
2320                 }
2321
2322                 l = schedules;
2323                 while (l) {
2324                         cs = l->data;
2325                         if (cs == NULL) {
2326                                 l = g_list_next(l);
2327                                 continue;
2328                         }
2329                         vals = NULL;
2330                         vals = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
2331                         printf("summary:%s\n", vals);
2332
2333                         l = g_list_next(l);
2334                 }
2335                 if (stream) free(stream);
2336                 return 0;
2337         }
2338  * @endcode
2339  * @see calendar_svc_write_schedules().
2340  */
2341 int calendar_svc_read_schedules(const char *stream, GList **schedules);
2342
2343 /**
2344  * @fn int calendar_svc_calendar_import(const char *path, int calendar_id);
2345  * This function import vcalendar(ver 1.0), icalendar(ver 2.0) to calendar DB.
2346  *
2347  * @ingroup event management
2348  * @param[in] path file path
2349  * @param[out] calendar_id calendar id
2350  * @return This function returns CAL_SUCCESS or error code on failure.
2351  * @remarks none
2352  * @pre none
2353  * @post none
2354  * @code
2355         #include <stdio.h>
2356         #include <stdlib.h>
2357         #include <calendar-svc-provider.h>
2358
2359         int sample_code())
2360         {
2361                 int r;
2362                 int calendar_id = 1;
2363                 char *path = "/opt/media/test.ics";
2364
2365         calendar_svc_connect();
2366                 ret = calendar_svc_calendar_import(path, calendar_id);
2367                 if (ret != CAL_SUCCESS) {
2368                         printf("Failed to import path(%s) to id(%d)\n", path, calendar_id);
2369                         return -1;
2370                 }
2371         calendar_svc_close();
2372                 return 0;
2373         }
2374  * @endcode
2375  * @see calendar_svc_calendar_export().
2376  */
2377 int calendar_svc_calendar_import(const char *path, int calendar_id);
2378
2379 /**
2380  * @fn int calendar_svc_write_schedules(GList *schedules, char **stream);
2381  * This function writes schedules to stream.
2382  *
2383  * @ingroup event management
2384  * @param[in] schedules schedule list which data is cal_struct
2385  * @param[out] stream vcalendar(ver1.0) icalendar(ver2.0) stream
2386  * @return This function returns CAL_SUCCESS or error code on failure.
2387  * @remarks none
2388  * @pre none
2389  * @post none
2390  * @code
2391         #include <stdio.h>
2392         #include <stdlib.h>
2393         #include <calendar-svc-provider.h>
2394
2395         int main(int argc, char **argv)
2396         {
2397                 int ret;
2398                 char *stream;
2399                 GList *schedules = NULL;
2400                 cal_struct *cs = NULL;
2401
2402                 cs = calendar_svc_struct_new(CAL_STRUCT_CALENDAR);
2403                 if (cs == NULL) {
2404                         printf("Failed to calloc\n");
2405                         return-1;
2406                 }
2407                 calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, "title");
2408                 // set data in cs...
2409
2410                 schedules = g_list_append(schedules, cs);
2411
2412                 ret = calendar_svc_write_schedules(schedules, &stream);
2413                 if (ret != CAL_SUCCESS) {
2414                         printf("Failed to read schedules(errno:%d)\n", ret);
2415                         return -1;
2416                 }
2417
2418                 if (stream == NULL) {
2419                         printf("stream is NULL\n");
2420                         return -1;
2421                 }
2422
2423                 if (stream) free(stream);
2424                 return 0;
2425         }
2426  * @endcode
2427  * @see calendar_svc_read_schedules().
2428  */
2429 int calendar_svc_write_schedules(GList *schedules, char **stream);
2430
2431 /**
2432  * @fn int calendar_svc_calendar_export(int calendar_id, const char *path);
2433  * This function export calendar DB to file.
2434  *
2435  * @ingroup event management
2436  * @param[in] calendar_id calendar id
2437  * @param[out] path file path
2438  * @return This function returns CAL_SUCCESS or error code on failure.
2439  * @remarks none
2440  * @pre none
2441  * @post none
2442  * @code
2443         #include <stdio.h>
2444         #include <stdlib.h>
2445         #include <calendar-svc-provider.h>
2446
2447         int sample_code())
2448         {
2449                 int r;
2450                 int calendar_id = 1;
2451                 char *path = "/opt/media/test.ics";
2452
2453         calendar_svc_connect();
2454                 r = calendar_svc_calendar_export(calendar_id, path);
2455                 if (r != CAL_SUCCESS) {
2456                         printf("Failed to export schedules\n");
2457                         return -1;
2458                 }
2459
2460         calendar_svc_close();
2461                 return 0;
2462         }
2463  * @endcode
2464  * @see calendar_svc_calendar_import().
2465  */
2466 int calendar_svc_calendar_export(int calendar_id, const char *path);
2467
2468 #define CALS_VALUE_INT_DTSTART_TYPE "dtstart_type"
2469 #define CALS_VALUE_LLI_DTSTART_UTIME "dtstart_utime"
2470 #define CALS_VALUE_INT_DTSTART_YEAR "dtstart_year"
2471 #define CALS_VALUE_INT_DTSTART_MONTH "dtstart_month"
2472 #define CALS_VALUE_INT_DTSTART_MDAY "dtstart_mday"
2473 #define CALS_VALUE_TXT_DTSTART_TZID "dtstart_tzid"
2474 #define CALS_VALUE_INT_DTEND_TYPE "dtend_type"
2475 #define CALS_VALUE_LLI_DTEND_UTIME "dtend_utime"
2476 #define CALS_VALUE_INT_DTEND_YEAR "dtend_year"
2477 #define CALS_VALUE_INT_DTEND_MONTH "dtend_month"
2478 #define CALS_VALUE_INT_DTEND_MDAY "dtend_mday"
2479 #define CALS_VALUE_TXT_DTEND_TZID "dtend_tzid"
2480 #define CALS_VALUE_LLI_LASTMOD "last_mod"
2481
2482 #define CALS_VALUE_INT_RRULE_FREQ "freq"
2483 #define CALS_VALUE_INT_RRULE_ID "rrule_id"
2484 #define CALS_VALUE_INT_RRULE_RANGE_TYPE "range_type"    //endless, until, count
2485 #define CALS_VALUE_INT_RRULE_UNTIL_TYPE "until_type"    //until by utc, until by local date
2486 #define CALS_VALUE_LLI_RRULE_UNTIL_UTIME "until_utime"  //unix time
2487 #define CALS_VALUE_INT_RRULE_UNTIL_YEAR "until_year"
2488 #define CALS_VALUE_INT_RRULE_UNTIL_MONTH "until_month"
2489 #define CALS_VALUE_INT_RRULE_UNTIL_MDAY "until_mday"
2490 #define CALS_VALUE_INT_RRULE_COUNT "count"
2491 #define CALS_VALUE_INT_RRULE_INTERVAL "interval"
2492 #define CALS_VALUE_TXT_RRULE_BYSECOND "bysecond"
2493 #define CALS_VALUE_TXT_RRULE_BYMINUTE "byminute"
2494 #define CALS_VALUE_TXT_RRULE_BYHOUR "byhour"
2495 #define CALS_VALUE_TXT_RRULE_BYDAY "byday"
2496 #define CALS_VALUE_TXT_RRULE_BYMONTHDAY "bymonthday"
2497 #define CALS_VALUE_TXT_RRULE_BYYEARDAY "byyearday"
2498 #define CALS_VALUE_TXT_RRULE_BYWEEKNO "byweekno"
2499 #define CALS_VALUE_TXT_RRULE_BYMONTH "bymonth"
2500 #define CALS_VALUE_TXT_RRULE_BYSETPOS "bysetpos"
2501 #define CALS_VALUE_INT_RRULE_WKST "wkst"
2502
2503 /* 0x00 ~0x06 used cal_struct_type */
2504 enum {
2505         CALS_LIST_PERIOD_NORMAL_ONOFF = 0x07,
2506         CALS_LIST_PERIOD_ALLDAY_ONOFF,
2507         CALS_LIST_PERIOD_NORMAL_BASIC,
2508         CALS_LIST_PERIOD_ALLDAY_BASIC,
2509         CALS_LIST_PERIOD_NORMAL_OSP = 0x100,
2510         CALS_LIST_PERIOD_ALLDAY_OSP,
2511         CALS_LIST_PERIOD_NORMAL_LOCATION,
2512         CALS_LIST_PERIOD_ALLDAY_LOCATION,
2513         CALS_LIST_PERIOD_NORMAL_ALARM,
2514         CALS_LIST_PERIOD_ALLDAY_ALARM,
2515 };
2516
2517 #define CALS_LIST_PERIOD_NORMAL_ONOFF_INT_EVENTID CAL_VALUE_INT_INDEX
2518 #define CALS_LIST_PERIOD_NORMAL_ONOFF_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2519 #define CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
2520 #define CALS_LIST_PERIOD_NORMAL_ONOFF_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2521 #define CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
2522
2523 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_EVENTID CAL_VALUE_INT_INDEX
2524 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2525 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_YEAR CALS_VALUE_INT_DTSTART_YEAR
2526 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MONTH CALS_VALUE_INT_DTSTART_MONTH
2527 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MDAY CALS_VALUE_INT_DTSTART_MDAY
2528 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2529 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_YEAR CALS_VALUE_INT_DTEND_YEAR
2530 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_MONTH CALS_VALUE_INT_DTEND_MONTH
2531 #define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_MDAY CALS_VALUE_INT_DTEND_MDAY
2532
2533 #define CALS_LIST_PERIOD_NORMAL_BASIC_INT_EVENTID CAL_VALUE_INT_INDEX
2534 #define CALS_LIST_PERIOD_NORMAL_BASIC_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2535 #define CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
2536 #define CALS_LIST_PERIOD_NORMAL_BASIC_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2537 #define CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
2538 #define CALS_LIST_PERIOD_NORMAL_BASIC_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
2539 #define CALS_LIST_PERIOD_NORMAL_BASIC_TXT_LOCATION CAL_VALUE_TXT_LOCATION
2540
2541 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_EVENTID CAL_VALUE_INT_INDEX
2542 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2543 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_YEAR CALS_VALUE_INT_DTSTART_YEAR
2544 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MONTH CALS_VALUE_INT_DTSTART_MONTH
2545 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MDAY CALS_VALUE_INT_DTSTART_MDAY
2546 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2547 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_YEAR CALS_VALUE_INT_DTEND_YEAR
2548 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MONTH CALS_VALUE_INT_DTEND_MONTH
2549 #define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MDAY CALS_VALUE_INT_DTEND_MDAY
2550 #define CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
2551 #define CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_LOCATION CAL_VALUE_TXT_LOCATION
2552
2553 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_EVENTID CAL_VALUE_INT_INDEX
2554 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2555 #define CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
2556 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2557 #define CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
2558 #define CALS_LIST_PERIOD_NORMAL_OSP_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
2559 #define CALS_LIST_PERIOD_NORMAL_OSP_TXT_LOCATION CAL_VALUE_TXT_LOCATION
2560 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
2561 #define CALS_LIST_PERIOD_NORMAL_OSP_TXT_DESCRIPTION CAL_VALUE_TXT_DESCRIPTION
2562 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_BUSY_STATUS CAL_VALUE_INT_BUSY_STATUS
2563 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_STATUS CAL_VALUE_INT_MEETING_STATUS
2564 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_PRIORITY CAL_VALUE_INT_PRIORITY
2565 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_VISIBILITY CAL_VALUE_INT_SENSITIVITY
2566 #define CALS_LIST_PERIOD_NORMAL_OSP_INT_IS_RECURRING CALS_VALUE_INT_RRULE_ID
2567
2568 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_EVENTID CAL_VALUE_INT_INDEX
2569 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2570 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_YEAR CALS_VALUE_INT_DTSTART_YEAR
2571 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MONTH CALS_VALUE_INT_DTSTART_MONTH
2572 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MDAY CALS_VALUE_INT_DTSTART_MDAY
2573 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2574 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_YEAR CALS_VALUE_INT_DTEND_YEAR
2575 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MONTH CALS_VALUE_INT_DTEND_MONTH
2576 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MDAY CALS_VALUE_INT_DTEND_MDAY
2577 #define CALS_LIST_PERIOD_ALLDAY_OSP_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
2578 #define CALS_LIST_PERIOD_ALLDAY_OSP_TXT_LOCATION CAL_VALUE_TXT_LOCATION
2579 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
2580 #define CALS_LIST_PERIOD_ALLDAY_OSP_TXT_DESCRIPTION CAL_VALUE_TXT_DESCRIPTION
2581 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_BUSY_STATUS CAL_VALUE_INT_BUSY_STATUS
2582 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_STATUS CAL_VALUE_INT_MEETING_STATUS
2583 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_PRIORITY CAL_VALUE_INT_PRIORITY
2584 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_VISIBILITY CAL_VALUE_INT_SENSITIVITY
2585 #define CALS_LIST_PERIOD_ALLDAY_OSP_INT_IS_RECURRING CALS_VALUE_INT_RRULE_ID
2586
2587 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_EVENTID CAL_VALUE_INT_INDEX
2588 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2589 #define CALS_LIST_PERIOD_NORMAL_LOCATION_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
2590 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2591 #define CALS_LIST_PERIOD_NORMAL_LOCATION_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
2592 #define CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
2593 #define CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_LOCATION CAL_VALUE_TXT_LOCATION
2594 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
2595 #define CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_DESCRIPTION CAL_VALUE_TXT_DESCRIPTION
2596 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_BUSY_STATUS CAL_VALUE_INT_BUSY_STATUS
2597 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_STATUS CAL_VALUE_INT_MEETING_STATUS
2598 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_PRIORITY CAL_VALUE_INT_PRIORITY
2599 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_VISIBILITY CAL_VALUE_INT_SENSITIVITY
2600 #define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_IS_RECURRING CALS_VALUE_INT_RRULE_ID
2601 #define CALS_LIST_PERIOD_NORMAL_LOCATION_DBL_LATITUDE CAL_VALUE_DBL_LATITUDE
2602 #define CALS_LIST_PERIOD_NORMAL_LOCATION_DBL_LONGITUDE CAL_VALUE_DBL_LONGITUDE
2603
2604 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_EVENTID CAL_VALUE_INT_INDEX
2605 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2606 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_YEAR CALS_VALUE_INT_DTSTART_YEAR
2607 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_MONTH CALS_VALUE_INT_DTSTART_MONTH
2608 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_MDAY CALS_VALUE_INT_DTSTART_MDAY
2609 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2610 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_YEAR CALS_VALUE_INT_DTEND_YEAR
2611 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_MONTH CALS_VALUE_INT_DTEND_MONTH
2612 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_MDAY CALS_VALUE_INT_DTEND_MDAY
2613 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
2614 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_LOCATION CAL_VALUE_TXT_LOCATION
2615 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
2616 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_DESCRIPTION CAL_VALUE_TXT_DESCRIPTION
2617 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_BUSY_STATUS CAL_VALUE_INT_BUSY_STATUS
2618 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_STATUS CAL_VALUE_INT_MEETING_STATUS
2619 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_PRIORITY CAL_VALUE_INT_PRIORITY
2620 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_VISIBILITY CAL_VALUE_INT_SENSITIVITY
2621 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_IS_RECURRING CALS_VALUE_INT_RRULE_ID
2622 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_DBL_LATITUDE CAL_VALUE_DBL_LATITUDE
2623 #define CALS_LIST_PERIOD_ALLDAY_LOCATION_DBL_LONGITUDE CAL_VALUE_DBL_LONGITUDE
2624
2625 #define CALS_LIST_PERIOD_NORMAL_ALARM_INT_EVENTID CAL_VALUE_INT_INDEX
2626 #define CALS_LIST_PERIOD_NORMAL_ALARM_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
2627 #define CALS_LIST_PERIOD_NORMAL_ALARM_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
2628 #define CALS_LIST_PERIOD_NORMAL_ALARM_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
2629 #define CALS_LIST_PERIOD_NORMAL_ALARM_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
2630 #define CALS_LIST_PERIOD_NORMAL_ALARM_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
2631 #define CALS_LIST_PERIOD_NORMAL_ALARM_LLI_ALARM_UTIME CAL_VALUE_LLI_ALARMS_TIME
2632 #define CALS_LIST_PERIOD_NORMAL_ALARM_INT_ALARM_ID CAL_VALUE_INT_ALARMS_ID
2633
2634 enum cals_day {
2635         CALS_SUNDAY,
2636         CALS_MONDAY,
2637         CALS_TUESDAY,
2638         CALS_WEDNESDAY,
2639         CALS_THURSDAY,
2640         CALS_FRIDAY,
2641         CALS_SATURDAY,
2642         CALS_NODAY,
2643 };
2644
2645 enum cals_freq {
2646         CALS_FREQ_ONCE = 0x0,
2647         CALS_FREQ_YEARLY,
2648         CALS_FREQ_MONTHLY,
2649         CALS_FREQ_WEEKLY,
2650         CALS_FREQ_DAILY,
2651         CALS_FREQ_HOURLY,
2652         CALS_FREQ_MINUTELY,
2653         CALS_FREQ_SECONDLY,
2654 };
2655
2656 enum cals_time_type {
2657         CALS_TIME_UTIME,
2658         CALS_TIME_LOCALTIME,
2659 };
2660
2661 enum cals_range {
2662         CALS_RANGE_UNTIL,
2663         CALS_RANGE_COUNT,
2664         CALS_RANGE_NONE,
2665 };
2666
2667 int calendar_svc_event_get_normal_list_by_period(int calendar_id, int op_code,
2668                 long long int start, long long int end, cal_iter **iter);
2669
2670 int calendar_svc_event_get_allday_list_by_period(int calendar_id, int op_code,
2671                 int dtstart_year, int dtstart_mon, int dtstart_day,
2672                 int dtend_year, int dtend_mon, int dtend_day, cal_iter **iter);
2673
2674 int calendar_svc_struct_set_lli(cal_struct *record, const char *field, long long int llival);
2675
2676 long long int calendar_svc_struct_get_lli(cal_struct *record, const char *field);
2677
2678 int calendar_svc_todo_get_list_by_period(int calendar_id,
2679                 long long int due_from, long long int dueto, int priority, int status, cal_iter **iter);
2680 int calendar_svc_todo_get_count_by_period(int calendar_id,
2681                 long long int due_from, long long int dueto, int priority, int status, int *count);
2682 int calendar_svc_event_delete_normal_instance(int event_id, long long int dtstart_utime);
2683 int calendar_svc_event_delete_allday_instance(int event_id, int dtstart_year, int dtstart_month, int dtstart_mday);
2684 #ifdef __cplusplus
2685 }
2686 #endif
2687
2688 /**
2689  * deprecated
2690  */
2691 typedef enum
2692 {
2693         CAL_STATUS_FREE = 0,               /**< deprecated */
2694         CAL_STATUS_TENTATIVE,             /**< deprecated */
2695         CAL_STATUS_BUSY,                     /**< deprecated */
2696         CAL_STATUS_OUROFOFFICE,           /**< deprecated */
2697         CAL_STATUS_CONFIRM,               /**< deprecated */
2698         CAL_STATUS_DENIED,                /**< deprecated */
2699 } cal_status_type_t;
2700
2701 #endif /* __CALENDAR_SVC_H__ */
2702