1822429bd4925e70fa36a2fc93ae9437ca79b484
[platform/core/pim/calendar-service.git] / doc / calendar_doc.h
1 /*
2  * Calendar Service
3  *
4  * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __TIZEN_SOCIAL_CALENDAR_DOC_H__
21 #define __TIZEN_SOCIAL_CALENDAR_DOC_H__
22
23 /**
24  * @ingroup CAPI_SOCIAL_FRAMEWORK
25  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_MODULE Calendar
26  *
27  * @brief The Calendar Service API provides functions for managing calendars(including events, to-dos).
28  * This API allows you not only to store information about calendar but also to query calendar information.
29  *
30  * @section CAPI_SOCIAL_CALENDARS_SVC_MODULE_HEADER Required Header
31  *  \#include <calendar.h>
32  *
33  *
34  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_OVERVIEW Overview
35  * A calendar is a system of organizing days for social purposes and is composed of records like events and todos.
36  * These records are made up of another sub records like alarms, attendees or extended ones.
37  * Events could have recurrence rule, instances would be generated.
38  * @image html calendar_model.png "Figure: Calendar model"
39  *
40  * The Calendar-Service provides an interface to manage the information of records.
41  * <table>
42  * <caption> Table: Calendar service properties. </caption>
43  *      <tr>
44  *              <td>
45  *              * Managing information stored in database. <br>
46  *              * Aggregating information from various accounts. <br>
47  *              * Notifying changes of information. <br>
48  *              * Searching information. <br>
49  *              * Vcalendar  supports ver1.0(vcs) / 2.0(ics).
50  *              </td>
51  *      </tr>
52  * </table>
53  *
54  * Calendar service module works in a way similar to client-service architecture.
55  * In this architecture Tizen application is a client side and has to connect to service before using calendar service APIs.
56  * Connection/disconnection MUST be done with use of calendar_connect() / calendar_disconnect().
57  *
58  * @code
59  * calendar_connect();
60  *
61  * // jobs for records
62  *
63  * calendar_disconnect(); *
64  * @endcode
65  *
66  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Entities Entities
67  * Calendar service manages information related to following entities.
68  * - Calendar books
69  *    - Represents where event and todo should belong to.
70  *    - Created by one of calendars sources below
71  *       -# Local device, which has no account.
72  *       -# Service providers such as Google or Yahoo, with account.
73  *       -# Applications like ChatON, Joyn, Facebook, etc.
74  *    - Have properties like name, account id, color.
75  * - Events
76  *    - Have properties like summary, start_time, description.
77  *    - Single entry can be available on each calendar book.
78  * - Todos
79  *    - Similar with event entry.
80  *
81  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Entities_Relationship_between_entities Relationship between entities
82  * @image html entities.png "Figure: Relationship between entities"
83  *
84  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Entities_Multiple_Address_books_from_Accounts Multiple Address books from Accounts
85  * Each account can create multiple calendar books. Calendar book name does not need to be unique on the device because it is handled with id.
86  * Local device address book has no account and its related account id is zero.
87  *
88  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Views Views
89  * \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE
90  * To access and handle entities, views are provided. <br>
91  * According to data-view declarations, generic access functions are used (calendar_db_insert_record(), calendar_record_get_int(), …). <br>
92  * Data-View is almost same as database "VIEW" which limits access and guarantees the performance by offering various views for the proper purpose.
93  *
94  * _calendar_instance_utime, _calendar_instance_localtime views are not offered but combination with another view are provided.
95  *
96  * <table>
97  * <caption> Table: Calendar views </caption>
98  * <tr>
99  *      <th> Editable view </th>
100  *      <th> Read only view </th>
101  * </tr>
102  * <tr>
103  *      <td>
104  *              _calendar_book <br>
105  *              _calendar_event <br>
106  *              _calendar_todo <br>
107  *              _calendar_timezone <br>
108  *              _calendar_attendee <br>
109  *              _calendar_alarm <br>
110  *              _calendar_extended_property
111  *      </td>
112  *      <td>
113  *              _calendar_updated_info <br>
114  *              _calendar_event_calendar_book <br>
115  *              _calendar_todo_calendar_book <br>
116  *              _calendar_event_calendar_book_attendee <br>
117  *              _calendar_instance_utime_calendar_book <br>
118  *              _calendar_instance_localtime_calendar_book <br>
119  *              _calendar_instance_utime_calendar_book_extended <br>
120  *              _calendar_instance_localtime_calendar_book_extended
121
122  *      </td>
123  * </tr>
124  * </table>
125  *
126  *
127  * _calendar_updated_info is used when identifying record changes depending on version.
128  *
129  * The other read only views are combination of editable views for UI convenience. <br>
130  * _calendar_event + _calendar_book = _calendar_event_calendar_book <br>
131  * _calendar_instance_utime + _calendar_book = _calendar_instance_utime_calendar_book <br>
132  * _calendar_event + _calendar_book + _calendar_attendee = _calendar_event_calendar_book_attendee <br>
133  *
134  *
135  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Views_Properties Properties
136  * Record types which have *_id as their properties, hold identifiers of other records - e.g. attendee and alarm views hold id of their corresponding events or to-dos in event_id or todo_id property respectively (as children of the corresponding events or to-dos record).
137  * Properties of type 'record' are other records. For example, a event record has 'attendee' and 'alarm', which means that records of those types can be children of event type records.
138  *
139  * In calendar_view.h header file, view macros are found and below figure. show what macro means.
140  * @image html view_property.png "Figure: Properties"
141  *
142  * There is an example how to create event with view.
143  *
144  * @code
145  * // create an event with _calendar_event view.
146  * calendar_record_h event = NULL;
147  * calendar_record_create(_calendar_event._uri, &event);
148  *
149  * // set event summary to _calendar_event view.
150  * calendar_record_set_str(event, _calendar_event.summary, "Meeting");
151  * @endcode
152  *
153  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Views_Version Version
154  *
155  * Calendar service uses version system in bellow APIs.
156  *
157  * <table>
158  * <caption> Table: Version related APIs </caption>
159  * <tr>
160  *  <td>
161  * calendar_db_get_current_version(int* calendar_db_version) <br>
162  * calendar_db_get_changes_by_version(const char *view_uri, int calendar_book_id, int calendar_db_version, calendar_list_h *record_list, int *current_calendar_db_version) <br>
163  * calendar_db_get_last_change_version(int* last_change_version) <br>
164  * calendar_db_get_changes_exception_by_version(const char *view_uri, int original_event_id, int calendar_db_version, calendar_list_h *list)
165  *  </td>
166  * </tr>
167  * </table>
168  *
169  * Whenever modifications are in DB, version number is increased every time. <br>
170  * If sync applications like google, facebook sync at version 13 and they try to sync again every 1 minute, they want to get changes from version 14 to current version. <br>
171  * To get current version, calendar_db_get_current_version() is used and calendar_db_get_changes_by_version() is used to get the modified record list. calendar_db_get_changes_exception_by_version() is used to get modified instances in recurring event.
172  * (see exception in Events and instances)
173  *
174  *
175  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records Records
176  * An important concept in Calendar service APIs is a record.
177  * It may be helpful to know that a record represents an actual record in the internal database, but in general, you can think of a record as a structure describing a single (but complex) view, like a calendar event or a time zone.
178  *
179  * A record has many properties, for example, a to-do record has the to-do's description, priority, progress, created, last modified and completed time, plus many others. <br>
180  * A record can also contain an identifier field, which holds an identifier of another record. Setting this field's value establishes a relation between the records, for example, a calendar event contains the identifier of a calendar book to which it belongs.
181  *
182  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records_URI URI
183  *
184  * A record's type is identified by a structure called the view.
185  * For example, the _calendar_event view describes the properties of the calendar event record.
186  * Every view has a special field - _uri - that uniquely identifies the view.
187  * In many cases you will need to provide the _uri value to indicate what type of record you wish to create or operate on.
188  * @code
189  * // create an event and get handle
190  * calendar_record_h event = NULL;
191  * calendar_record_create(_calendar_event._uri, &event);
192  * @endcode
193  *
194  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records_Record_handle Record handle
195  *
196  * To use a record, you must obtain its handle.
197  * There are many ways to obtains it, including creating a new record and referring to child records of a record.
198  * @code
199  * // create an event and get handle
200  * calendar_record_h event = NULL;
201  * calendar_record_create(_calendar_event._uri, &event);
202  *
203  * // get record handle with id
204  * calendar_record_h event2 = NULL
205  * calendar_db_get_record(_calendar_event._uri, event_id, &event2);
206  * @endcode
207  *
208  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records_Basic_types Basic types
209  *
210  * Records contain properties of basic types: integer, lli (long integer, long long int), double,
211  * string and calendar_time_s.<br>
212  * The calendar_time_s type holds either a long long int, or three integers (year, month, day).
213  * There are setter and getter functions for each type:
214  *
215  * <table>
216  * <caption> Table: Setter and getter functions </caption>
217  * <tr>
218  *     <th> Property </th>
219  *     <th> Setter </th>
220  *     <th> Getter </th>
221  * </tr>
222  * <tr>
223  *     <td> integer </td>
224  *     <td> calendar_record_set_int </td>
225  *     <td> calendar_record_get_int </td>
226  * </tr>
227  * <tr>
228  *     <td> long long integer </td>
229  *     <td> calendar_record_set_lli </td>
230  *     <td> calendar_record_get_lli </td>
231  * </tr>
232  * <tr>
233  *     <td> double </td>
234  *     <td> calendar_record_set_double </td>
235  *     <td> calendar_record_get_double </td>
236  * </tr>
237  * <tr>
238  *     <td> string </td>
239  *     <td> calendar_record_set_str </td>
240  *     <td> calendar_record_get_str </td>
241  * </tr>
242  * <tr>
243  *     <td> calendar_time_s </td>
244  *     <td> calendar_record_set_caltime </td>
245  *     <td> calendar_record_get_caltime </td>
246  * </tr>
247  * </table>
248  *
249  * A record's type is identified by a structure called the view. For example,
250  * the _calendar_event view describes the properties of the calendar event record.
251  * Every view has a special field - _uri - that uniquely identifies the view.
252  * In many cases you will need to provide the _uri value to indicate what
253  * type of record you wish to create or operate on.
254  *
255  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records_Child Child
256  *
257  * Records of certain type also hold 'child list' properties.
258  * If a record has property of this type, it can be a parent of other records, called child records.
259  * For example, attendee records can hold an event's identifier in their event_id property.
260  * The event is the parent record of the child attendee records.
261  *
262  * To use a record, you must obtain its handle. There are many ways to obtains it,
263  * including creating a new record and referring to child records of a record.
264  *
265  * Sample code:<br>
266  * the code below creates an event and inserts it into default event book
267  * (see below on calendar books).
268  *
269  * @code
270  * // create an event
271  * calendar_record_h event;
272  * calendar_record_create(_calendar_event._uri, &event);
273  *
274  * // set event summary
275  * calendar_record_set_str(event, _calendar_event.summary, "Meeting");
276  *
277  * // put the event into the default calendar book for events
278  * calendar_record_set_int(event, _calendar_event.calendar_book_id, book_id);
279  *
280  * // add alarm as child
281  * calendar_record_h alarm = NULL;
282  * calendar_record_create(_calendar_alarm._uri, &alarm);
283  * calendar_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_MINUTE);
284  * calendar_record_set_int(alarm, _calendar_alarm.tick, 5);
285  * calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm);
286  *
287  * // insert calendar book into the database
288  * int event_id = 0;
289  * calendar_db_insert_record(event, &event_id);
290  *
291  * // destroy
292  * calendar_record_destroy(event, true);
293  * @endcode
294  *
295  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Calendar_books Calendar Books
296  * A calendar book is a placeholder for other records in Calendar API.
297  * Every event and to-do has to belong to a calendar book.
298  * There are three built-in calendar books.
299  * <table>
300  * <caption> Table: Calendar books </caption>
301  * <tr>
302  *  <td> DEFAULT_EVENT_CALENDAR_BOOK_ID </td>
303  *  <td> Event book </td>
304  * </tr>
305  * <tr>
306  *  <td> DEFAULT_TODO_CALENDAR_BOOK_ID </td>
307  *  <td> Todo book </td>
308  * </tr>
309  * <tr>
310  *  <td> DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID </td>
311  *  <td> Birthday book </td>
312  * </tr>
313  * </table>
314  *
315  * There is an example how calendar book id is set.
316  *
317  * @code
318  * calendar_record_h event = NULL;
319  *
320  * calendar_record_create(_calendar_event._uri, &event);
321  *
322  * // set default calendar book id
323  * calendar_record_set_int(event, _calendar_event.calendar_id, DEFAULT_EVENT_CALENDAR_BOOK_ID);
324  *
325  * // set other fields
326  *
327  * int event_id = 0;
328  * calendar_db_insert_record(event &event_id);
329  *
330  * // destroy
331  * calendar_record_destroy(event, true);
332  * @endcode
333  *
334  * To receive a list of existing calendar books, use the following:
335  *
336  * @code
337  * calendar_list_h calendar_book_list = NULL;
338  * calendar_db_get_all_records(_calendar_calendar_book._uri, 0, 0, &calendar_book_list);
339  * @endcode
340  *
341  *
342  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Events_and_instances Events and Instances
343  * Two important concepts are event and instance. An event record describes
344  * various properties of the event, like description, categories, priority
345  * and many others. It also contains information on when the event takes place,
346  * there can be more than one instance of the event. Each instance has its
347  * corresponding instance record. <br>
348  * If event is inserted with rrule, alarm and attendee, its data is saved to each database.
349  * Generated instances based on rrule are also stored in instance database.
350  * @image html view_db.png "Figure: Views and databases"
351  *
352  * For example, if an event has the following properties:
353  * <table>
354  * <caption> Table: Event and instance example </caption>
355  * <tr>
356  *      <th> event </th>
357  *      <th> instances </th>
358  * </tr>
359  * <tr>
360  *      <td>
361  *              start date on 2012-10-09 (Tuesday) <br>
362  *              frequency set to 'WEEKLY' <br>
363  *              interval set to 1 <br>
364  *              count set to 3
365  * </td>
366  *      <td>
367  *              2012-10-09 Tuesday <br>
368  *              2012-10-16 Tuesday <br>
369  *              2012-10-23 Tuesday
370  *      </td>
371  * </tr>
372  * </table>
373  *
374  * Interval is a multiplier of frequency, which means that if it is set to N,
375  * instances occur every N weeks (or whatever was set in frequency attribute).
376  *
377  * The recurrence model in Calendar API is compliant with iCalendar specification
378  * (<a href="http://www.ietf.org/rfc/rfc2445.txt">www.ietf.org/rfc/rfc2445.txt</a>).
379  * The following event properties have the same functionality as their corresponding
380  * values in iCalendar:
381  *
382  * <table>
383  * <caption> Table: Recurrence rules. </caption>
384  * <tr>
385  *      <th> Recurrence rule property </th>
386  *      <th> comment </th>
387  * </tr>
388  * <tr>
389  *      <td> freq </td>
390  *      <td> Yearly, monthly, weekly, daily </td>
391  * </tr>
392  * <tr>
393  *      <td> count </td>
394  *      <td> Until count. If count is 3, 3 instances are generated </td>
395  * </tr>
396  * <tr>
397  *      <td> interval </td>
398  *      <td> The interval is positive integer representing how often the recurrence rule repeats </td>
399  * </tr>
400  * <tr>
401  *      <td> byday </td>
402  *      <td> MO, TU, WE, TH, FR, SA, SU </td>
403  * </tr>
404  * <tr>
405  *      <td> bymonthday </td>
406  *      <td> Days of month </td>
407  * </tr>
408  * <tr>
409  *      <td> byyearday </td>
410  *      <td> Days of year </td>
411  * </tr>
412  * <tr>
413  *      <td> byweekno </td>
414  *      <td> Ordinals specifying weeks of the year </td>
415  * </tr>
416  * <tr>
417  *      <td> bymonth </td>
418  *      <td> Months of year </td>
419  * </tr>
420  * <tr>
421  *      <td> bysetpos </td>
422  *      <td> Values which corresponds to the nth occurrence within the set of events </td>
423  * </tr>
424  * <tr>
425  *      <td> wkst </td>
426  *      <td> The day on which the workweek starts </td>
427  * </tr>
428  * </table>
429  *
430  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Events_and_instances_Exceptions Exceptions
431  *
432  * If one of instances is modified in summary, date… or deleted, this is called exception.<br>
433  * For example, if 2nd instance date is modified from 16th to 17th, 17th is the exception.
434  * <table>
435  * <caption> Table: Exception example </caption>
436  * <tr>
437  *      <th> event </th>
438  *      <th> instances </th>
439  *      <th> exceptions </th>
440  * </tr>
441  * <tr>
442  *      <td>
443  *              start date on 2012-10-09 (Tuesday) <br>
444  *              frequency set to 'WEEKLY' <br>
445  *              interval set to 1 <br>
446  *              count set to 3
447  * </td>
448  *      <td>
449  *              2012-10-09 Tuesday <br>
450  *              2012-10-23 Tuesday
451  *      </td>
452  *  <td>
453  *              2012-10-17 Tuesday <br>
454  *  </td>
455  * </tr>
456  * </table>
457  *
458  * To get changes in exception, calendar_db_get_changes_exception_by_version() is called. These instances and exceptions are deleted together when original event is deleted.
459  *
460  *
461  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Calendar_time_structure Calendar Time Structure
462  * The calendar time structure, calendar_caltime_s, is defined as follows:
463  *
464  * @code
465  * typedef struct
466  * {
467  *     calendar_time_type_e type;
468  *     union {
469  *         long long int utime;
470  *         struct {
471  *             int year;
472  *             int month;
473  *             int mday;
474  *         } date;
475  *     } time;
476  * } calendar_time_s;
477  * @endcode
478  *
479  * The structure should be used when setting the calendar time type
480  * (_CALENDAR_PROPERTY_CALTIME) properties of records.
481  *
482  * It can hold two types of data: UTC time (long long int) and date,
483  * given as year, month and day of the month (three integers). These types
484  * are identified by values of calendar_time_type_e, which are CALENDAR_TIME_UTIME
485  * and CALENDAR_TIME_LOCALTIME, respectively. The data type determines the usage
486  * of the structure.
487  *
488  * <table>
489  * <caption> Table: Data types </caption>
490  * <tr>
491  *     <th> Identifier </th>
492  *     <th> Type </th>
493  *     <th> Name </th>
494  *     <th> Purpose </th>
495  * </tr>
496  * <tr>
497  *     <td> CALENDAR_TIME_UTIME </td>
498  *     <td> long long int </td>
499  *     <td> utime </td>
500  *     <td> UTC time, used to describe non-all-day events </td>
501  * </tr>
502  * <tr>
503  *     <td> CALENDAR_TIME_LOCALTIME </td>
504  *     <td> struct </td>
505  *     <td> date </td>
506  *     <td> date only (year, month and day of the month), used to describe all day events </td>
507  * </tr>
508  * </table>
509  *
510  *
511  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Calendar_time_structure_UTC_time_usage UTC Time Usage
512  *
513  * Structures with UTC time should be used for non-all-day events.
514  * In such cases, the API user should convert local time to UTC time. The local
515  * time zone identifier should be stored in the record, in the corresponding
516  * property.
517  *
518  * For example, when setting starting time of an event, the local
519  * time zone should be stored in start_tzid.
520  *
521  * When converting local time to UTC time, the function below can be useful.
522  * The function converts the given date and time to the corresponding
523  * UTC time, considering the given time zone (first argument).
524  *
525  * @code
526  * #define ms2sec(ms) (long long int)(ms / 1000.0)
527  *
528  * long long int _time_convert_itol(char *tzid, int y, int mon, int d, int h, int min, int s)
529  * {
530  *     int ret = 0;
531  *     i18n_uchar utf16_timezone[CAL_STR_SHORT_LEN64] = {0};
532  *     i18n_ustring_copy_ua_n(utf16_timezone, tzid, sizeof(utf16_timezone)/sizeof(i18n_uchar));
533  *
534  *     i18n_ucalendar_h ucal = NULL;
535  *     char *loc_default = NULL;
536  *     i18n_ulocale_get_default((const char **)&loc_default);
537  *     ret = i18n_ucalendar_create(utf16_timezone, -1, loc_default, I18N_UCALENDAR_GREGORIAN, &ucal);
538  *     if (I18N_ERROR_NONE != ret) {
539  *                 dlog_print(DLOG_DEBUG, LOG_TAG, "i18n_ucalendar_create() Fail (%d)\n", ret);
540  *         return -1;
541  *     }
542  *
543  *     i18n_ucalendar_set_date_time(ucal, y, mon - 1, d, h, min, s);
544  *
545  *     i18n_udate date;
546  *     ret = i18n_ucalendar_get_millisecond(ucal, &date);
547  *     if (I18N_ERROR_NONE != ret) {
548  *         dlog_print(DLOG_DEBUG, LOG_TAG, "i18n_ucalendar_create() Fail (%d)\n", ret);
549  *         i18n_ucalendar_destroy(ucal);
550  *         return -1;
551  *     }
552  *     i18n_ucalendar_destroy(ucal);
553  *
554  *     return ms2sec(date);
555  * }
556  * @endcode
557  *
558  * Sample code:<br>
559  * @code
560  * // fill calendar time structures (start and end time)
561  * calendar_time_s st = {0};
562  * calendar_time_s et = {0};
563  *
564  * st.type = CALENDAR_TIME_UTIME;
565  * st.time.utime = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 11, 0, 0);
566  *
567  * et.type = CALENDAR_TIME_UTIME;
568  * et.time.utime = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 12, 0, 0);
569  *
570  * // create an event record
571  * // ...
572  *
573  * // set local time zone of start time
574  * calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
575  *
576  * // set start time
577  * calendar_record_set_caltime(event, _calendar_event.start_time, st);
578  *
579  * // set local time zone of end time
580  * calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
581  *
582  * // set end time
583  * calendar_record_set_caltime(event, _calendar_event.end_time, et);
584  * @endcode
585  *
586  *
587  * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Calendar_time_structure_Date_usage Date Usage
588  * Another usage of time structure is an all day event.
589  * In case of such events, the structure's type field MUST be set to CALENDAR_TIME_LOCALTIME.
590  * Only the date (no time) will be stored. Such structures can be used to set start and end time of an event. <br>
591  * Both start and end time of the event MUST be set.
592  * The end date value MUST be later in time than the value of the start date.
593  *
594  * @code
595  * // range is 2days: 2014/02/17 00:00:00 ~ 2014/02/19 00:00:00
596  *
597  * calendar_time_s st = {0};
598  * st.type = CALENDAR_TIME_LOCALTIME;
599  * st.time.date.year = 2014;
600  * st.time.date.month = 2;
601  * st.time.date.mday = 17;
602  *
603  * calendar_time_s et = {0};
604  * et.type = CALENDAR_TIME_LOCALTIME;
605  * et.time.date.year = 2014;
606  * et.time.date.month = 2;
607  * et.time.date.mday = 19;
608  *
609  * // create an event record
610  * // ...
611  * @endcode
612  *
613  *
614  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Creating_a_recurring_event Recurring Events
615  * To create a recurring event in Calendar API, you MUST set frequency.
616  * There is a sample code how to create recurring event. Firstly, set start and end time.
617  *
618  * @code
619  * calendar_time_s st = {0};
620  * st.type = CALENDAR_TIME_UTIME;
621  * st.time.utime = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 11, 0, 0);
622  *
623  * calendar_time_s et = {0};
624  * et.type = CALENDAR_TIME_UTIME;
625  * et.time.utime = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 12, 0, 0);
626  * @endcode
627  *
628  * Then, the remaining properties should be set.
629  * Each frequency needs other proper fields except daily event.
630  * If other values are not inserted, these values are calculated based on start time.
631  *
632  * <table>
633  * <caption> Table: Frequency properties </caption>
634  * <tr>
635  *  <th> Freq </th>
636  *  <th> Property </th>
637  *  <th> Comment </th>
638  * </tr>
639  * <tr>
640  *  <td> CALENDAR_RECURRENCE_YEARLY </td>
641  *  <td> byyearday </td>
642  *  <td> Every 100th day </td>
643  * </tr>
644  * <tr>
645  *  <td> </td>
646  *  <td> byweekno </td>
647  *  <td> Every 34th week </td>
648  * </tr>
649  * <tr>
650  *  <td> </td>
651  *  <td> bymonthday </td>
652  *  <td> Every 1st February (birthday)</td>
653  * </tr>
654  * <tr>
655  *  <td> </td>
656  *  <td> byday </td>
657  *  <td> Every 1st Monday of May (holiday) </td>
658  * </tr>
659  * <tr>
660  *  <td> CALENDAR_RECURRENCE_MONTHLY </td>
661  *  <td> bymonthday </td>
662  *  <td> Every 29th (payday) </td>
663  * </tr>
664  * <tr>
665  *  <td> </td>
666  *  <td> byday </td>
667  *  <td> Every last Friday </td>
668  * </tr>
669  * <tr>
670  *  <td> CALENDAR_RECURRENCE_WEEKLY </td>
671  *  <td> byday </td>
672  *  <td> Every week </td>
673  * </tr>
674  * <tr>
675  *  <td> CALENDAR_RECURRENCE_DAILY </td>
676  *  <td> - </td>
677  *  <td> - </td>
678  * </tr>
679  * </table>
680  *
681  * If byday is not set in weekly event, default byday is followed start day of week.
682  * By the same token, default interval is 1 and default range type is endless.
683  *
684  * <table>
685  * <caption> Table: Range types </caption>
686  * <tr>
687  *  <th> Range type </th>
688  *  <th> Comment </th>
689  * </tr>
690  * <tr>
691  *  <td> CALENDAR_RANGE_NONE </td>
692  *  <td> Endless(max date is 2036/12/31) </td>
693  * </tr>
694  * <tr>
695  *  <td> CALENDAR_RANGE_UNTIL </td>
696  *  <td> Should set until property </td>
697  * </tr>
698  * <tr>
699  *  <td> CALENDAR_RANGE_COUNT </td>
700  *  <td> Should set count property </td>
701  * </tr>
702  * </table>
703  *
704  * @code
705  * calendar_record_h event;
706  * calendar_record_create(_calendar_event._uri, &event);
707  *
708  * calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
709  * calendar_record_set_caltime(event, _calendar_event.start_time, st);
710  * calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
711  * calendar_record_set_caltime(event, _calendar_event.end_time, et);
712  *
713  * calendar_record_set_int(event, _calendar_event.freq, CALENDAR_RECURRENCE_WEEKLY);
714  * calendar_record_set_int(event, _calendar_event.interval, 1)
715  * calendar_record_set_int(event, _calendar_event.count, 3);
716  * @endcode
717  *
718  * The last step is inserting the event into the database.
719  * Records representing instances of the event are created when the event record is inserted.
720  *
721  * @code
722  * int event_id = 0;
723  * calendar_db_insert_record(event, &event_id);
724  *
725  * calendar_record_destroy(event, true);
726  * @endcode
727  *
728  *
729  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Filters_and_queries Filters and Queries
730  * Queries are used to retrieve data which satisfies given criteria, like an integer
731  * property being greater than a given value, or a string property containing a given substring.
732  * The criteria are defined by creating filters and adding conditions to them, joining them
733  * with logical operators. Also, instead of a condition, another filter can be added,
734  * which can be used to create more complex filters.
735  *
736  * Operator precedence in filters determined by the order in which the
737  * conditions and filters are added.
738  *
739  * When a filter is ready, it can be set as a property of a query.
740  * Other query properties allow configuring how the returned results
741  * are grouped and sorted.
742  *
743  * Operator precedence in filters is determined by the order in which the
744  * conditions and filters are added are added.
745  * For example, if the following sequence is added:
746  *
747  * <table>
748  * <caption> Table: Filter and conditions </caption>
749  * <tr>
750  *      <th> Filter with conditions </th>
751  *      <th> Result </th>
752  * </tr>
753  * <tr>
754  *      <td>
755  *              Contidion C1 <br>
756  *              OR <br>
757  *              Contidion C2 <br>
758  *              AND <br>
759  *              Condition C3
760  *      </td>
761  *      <td> (C1 OR C2) AND C3 </td>
762  * </tr>
763  * <tr>
764  *      <td>
765  *              Filter F1: <br>
766  *                      Condition C1 <br>
767  *                      OR <br>
768  *                      Condition C2 <br><br>
769  *              Filter F2: <br>
770  *                      Condition C3 <br>
771  *                      OR <br>
772  *                      Condition C4 <br><br>
773  *              Filter F3: <br>
774  *                      Condition C5 <br>
775  *                      AND <br>
776  *                      F1 <br>
777  *                      AND <br>
778  *                      F2
779  *      </td>
780  *      <td>
781  *              (C5 AND F1) AND F2 <br>
782  *              Which is: <br>
783  *              (C5 AND (C1 OR C2)) AND (C3 OR C4)
784  *      </td>
785  * </tr>
786  * </table>
787  *
788  * The following code creates a filter, accepting events with high priority
789  * or those that include the word "meeting" in their description.
790  *
791  * @code
792  * calendar_filter_h filter = NULL;
793  *
794  * // create a filter returning event type records
795  * calendar_filter_create(_calendar_event._uri, &filter);
796  *
797  * // add 'priority equals high' condition
798  * calendar_filter_add_int(filter, _calendar_event.priority, CALENDAR_MATCH_EQUAL, CALENDAR_EVENT_PRIORITY_HIGH);
799  *
800  * // add OR operator
801  * calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
802  *
803  * // add 'description contains "meeting"' condition
804  * calendar_filter_add_str(filter, _calendar_event.description, CALENDAR_MATCH_CONTAINS, "meeting");
805  * @endcode
806  *
807  * The filter should be inserted into a query and the query should be executed:
808  *
809  * @code
810  * calendar_query_h query = NULL;
811  * calendar_list_h list = NULL;
812  *
813  * // create a query returning event type records
814  * calendar_query_create(_calendar_event._uri, &query);
815  *
816  * // add the filter
817  * calendar_query_set_filter(query, filter);
818  *
819  * // execute the query, results are returned in a list
820  * calendar_db_get_records_with_query(query, 0, 0, &list);
821  *
822  * calendar_filter_destroy(filter);
823  * calendar_query_destroy(query);
824  *
825  * // use the list
826  * // ...
827  *
828  * calendar_list_destroy(list, true);
829  * @endcode
830  *
831  *
832  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Projections Projections
833  * Useful concept in Calendar service APIs is projection, related to searching with filters and queries.
834  * Projection allows you to query the Data for just those specific properties of a record that you actually need, at lower latency
835  * and cost than retrieving the entire properties
836  *
837  * Sample code:<br>
838  * create filter which will get event id, summary and start time from the record with its summary has “test” (string filter).
839  * Create a query and add the filter to it. Results are received in a list.
840  *
841  * @code
842  * calendar_query_h query = NULL;
843  * calendar_filter_h filter = NULL;
844  *
845  * // set query with filter
846  * calendar_query_create(_calendar_event_calendar_book_attendee._uri, &query);
847  * calendar_filter_create(_calendar_event_calendar_book_attendee._uri, &filter);
848  * calendar_filter_add_str(filter, _calendar_event.summary, CALENDAR_MATCH_CONTAINS, "test");
849  * calendar_query_set_filter(query, filter);
850  *
851  * // set projection
852  * unsigned int projection[3];
853  * projection[0]=_calendar_event_calendar_book_attendee.event_id;
854  * projection[1]=_calendar_event_calendar_book_attendee.summary;
855  * projection[2]=_calendar_event_calendar_book_attendee.start_time;
856  *
857  * // get list
858  * calendar_query_set_projection(query, projection, 3);
859  * calendar_db_get_records_with_query(query, 0, 0, &list);
860  *
861  * // destroy handle
862  * calendar_filter_destroy(filter);
863  * calendar_query_destroy(query);
864  * calendar_list_destroy(list, true);
865  * @endcode
866  *
867  *
868  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Reminders Reminders
869  * Alarm and reminder is the similar terminology but reminder is used as package name storages in below figure 5.
870  * When alarm alerts, calendar-service sends notification to all packages which is registered in reminder DB table with calendar_reminder_add_receiver().
871  *
872  * This shows how to set alarm and how alarm works.
873  *
874  * @image html alarm_process.png "Figure: Alarm process"
875  * After adding receiver, registered alarm would be alerted on reserved time by inserting alarm as child.
876  *
877  * <table>
878  * <caption> Table: Alarm fields </caption>
879  * <tr>
880  *      <th> tick_unit </th>
881  *      <th> related field </th>
882  *      <th> comment </th>
883  * </tr>
884  * <tr>
885  *      <td> CALENDAR_ALARM_TIME_UNIT_SPECIFIC </td>
886  *      <td> time </td>
887  *      <td> This represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC) </td>
888  * </tr>
889  * <tr>
890  *      <td> CALENDAR_ALARM_TIME_UNIT_WEEK </td>
891  *      <td> tick </td>
892  *      <td> The number of weeks before start time </td>
893  * </tr>
894  * <tr>
895  *      <td> CALENDAR_ALARM_TIME_UNIT_DAY </td>
896  *      <td> tick </td>
897  *      <td> The number of days before start time </td>
898  * </tr>
899  * <tr>
900  *      <td> CALENDAR_ALARM_TIME_UNIT_HOUR </td>
901  *      <td> tick </td>
902  *      <td> The number of hours before start time </td>
903  * </tr>
904  * <tr>
905  *      <td> CALENDAR_ALARM_TIME_UNIT_MINUTE </td>
906  *      <td> tick </td>
907  *      <td> The number of minutes before start time </td>
908  * </tr>
909  * </table>
910  *
911  * Below example shows the alarm which is set 1 minute before start time.
912  *
913  * @code
914  // set alarm with normal unit
915  * calendar_record_h alarm = NULL;
916  * calendar_record_create(_calendar_alarm._uri, &alarm);
917  * calendar_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_MINUTE);
918  * calendar_record_set_int(alarm, _calendar_alarm.tick, 1); // before 1min (60secs)
919  *
920  * // add alarm as child
921  * calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm);
922  * @endcode
923  *
924  * With CALENDAR_ALARM_TIME_UNIT_SPECIFIC, the alarm could be set regardless of the start time.
925  *
926  * @code
927  // set alarm with specific unit
928  * calendar_record_h alarm = NULL;
929  * calendar_record_create(_calendar_alarm._uri, &alarm);
930  * calendar_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
931  * // suppose start time is 1404036000(Sun, 29 Jun 2014 10:00:00 GMT) and alarm is set 60secs after from start time.
932  * calendar_time_s ct;
933  * ct.type = CALENDAR_TIME_UTIME;
934  * ct.time.utime = 1404036000 + 60;
935  * calendar_record_set_caltime(alarm, _calendar_alarm.alarm_time, ct);
936  *
937  * // add alarm as child
938  * calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm);
939  * @endcode
940  *
941  * How to register package as reminder.
942  *
943  * In manifest.xml file, below code must be inserted.
944  * @code
945  * <app-control>
946  *    <operation name="http://tizen.org/appcontrol/operation/view" />
947  *    <mime name="application/x-tizen.calendar.reminder" />
948  * </app-control>
949  * @endcode
950  *
951  * When alarm alerts, calendar-service sends data with key, value pairs.<br>
952  * With "ids" key, id array could be get.<br>
953  * Each detail value could be get with "each id" key.<br>
954  * The detail data is the combination of alarm values. id, time, tick, unit and type is connected with "&" charater.<br>
955  * ex> id=64&time=1415106300&tick=0&unit=60&type=0
956  *
957  * @code
958  * // "ids" string is the key, to get id array
959  * char **ids = NULL;
960  * int len = 0;
961  * app_control_get_extra_data_array(b, "ids", &ids, &len);
962  *
963  * int i = 0;
964  * for (i = 0; i < len; i++) {
965  *      // "id" is the key to get detail value
966  *      char *value = NULL;
967  *      app_control_get_extra_data(b, ids[i], &value);
968  *      if (NULL == value) {
969  *              continue;
970  *      }
971  *      // parse detail data
972  *
973  *      // free
974  *      free(ids[i]);
975  *      ids[i] = NULL;
976  * }
977  *
978  * free(ids);
979  * @endcode
980  *
981  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Db_change_noties Database Change Notifications
982  *
983  * Applications add/remove callback function to detect/ignore the calendar DB changes
984  * with calendar_db_add_changed_cb() / calendar_db_remove_changed_cb(). <br>
985  * Clients wait calendar change notification on client side.
986  * If calendar is changed by another module, server publishes inotify event. Inotify module broadcasts to subscribe modules.
987  * Internal inotify handler is called at client side. User callback function is called with user data.
988  *
989  * @code
990  * // add callback function
991  * void __event_changed_cb(const char *view_uri, void *user_data)
992  * {
993  * }
994  * // add changed noti callback
995  * calendar_db_add_changed_cb(_calendar_event._uri, __event_changed_cb, NULL);
996  * @endcode
997  *
998  *
999  * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Vcalendar Vcalendar
1000  *
1001  * To exchange of personal calendaring and scheduling information, vcalendar is used.
1002  * In order to avoid confusion with this referenced work, this is to be known as the vcalendar specification.
1003  * Vcalendar ver2.0 is known as icalendar.
1004  *
1005  *
1006  * <table>
1007  * <caption> Table: Vcalendar example ( http://www.ietf.org/rfc/rfc2445.txt ) </caption>
1008  * <tr>
1009  *  <td>
1010  *      BEGIN:VCALENDAR<br>
1011  *      VERSION:2.0<br>
1012  *      PRODID:-//hacksw/handcal//NONSGML v1.0//EN<br>
1013  *      BEGIN:VEVENT<br>
1014  *      DTSTART:19970714T170000Z<br>
1015  *      DTEND:19970715T035959Z<br>
1016  *      SUMMARY:Bastille Day Party<br>
1017  *      END:VEVENT<br>
1018  *      END:VCALENDAR<br>
1019  *  </td>
1020  * </tr>
1021  * </table>
1022  *
1023  * Calendar service provides APIs to compose vcalendar stream.
1024  * With stream, file could be made or data could be transmitted with json data.
1025  *
1026  * @code
1027  * calendar_list_h list = NULL;
1028  * // create or get list to make vcalendar stream
1029  *
1030  * char *stream = NULL;
1031  * calendar_vcalendar_make_from_records(list, &stream);
1032  *
1033  * // jobs for stream
1034  *
1035  * // free
1036  * free(stream);
1037  * @endcode
1038  *
1039  * Vcalendar could be parsed with calendar service APIs as well.
1040  *
1041  * @code
1042  * // read  stream from file
1043  *
1044  * calendar_list_h list = NULL;
1045  * calendar_vcalendar_parse_to_calendar(stream, &list);
1046  *
1047  * // jobs for list…
1048  * calendar_list_destroy(list, true);
1049  * @endcode
1050  *
1051  */
1052
1053 /**
1054  * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1055  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE Database
1056  *
1057  * @brief The calendar database API provides the set of the definitions and interfaces that enable you to handle calendar database.
1058  *
1059  * @section CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE_HEADER Required Header
1060  *  \#include <calendar.h>
1061  *
1062  * <BR>
1063  */
1064
1065 /**
1066  * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1067  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE Filter
1068  *
1069  * @brief The calendar filter API provides the set of the definitions and interfaces that enable you to handle filter.
1070  *
1071  * @section CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE_HEADER Required Header
1072  *  \#include <calendar.h>
1073  *
1074  * <BR>
1075  */
1076
1077 /**
1078  * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1079  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_LIST_MODULE List
1080  *
1081  * @brief The calendar list API provides the set of the definitions and interfaces that enable you to handle list.
1082  *
1083  * @section CAPI_SOCIAL_CALENDAR_SVC_LIST_MODULE_HEADER Required Header
1084  *  \#include <calendar.h>
1085  *
1086  * <BR>
1087  */
1088
1089 /**
1090  * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1091  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_QUERY_MODULE Query
1092  *
1093  * @brief The calendar query API provides the set of the definitions and interfaces that enable you to handle query.
1094  *
1095  * @section CAPI_SOCIAL_CALENDAR_SVC_QUERY_MODULE_HEADER Required Header
1096  *  \#include <calendar.h>
1097  *
1098  * <BR>
1099  */
1100
1101 /**
1102  * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1103  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE Record
1104  *
1105  * @brief The calendar record API provides the set of the definitions and interfaces that enable you to get/set data from/to calendar record handle.
1106  *
1107  * @section CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE_HEADER Required Header
1108  *  \#include <calendar.h>
1109  *
1110  * <BR>
1111  */
1112
1113 /**
1114  * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1115  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_REMINDER_MODULE Reminder
1116  *
1117  * @brief The calendar reminder API provides the interface to set/unset reminder callback.
1118  *
1119  * @section CAPI_SOCIAL_CALENDAR_SVC_REMINDER_MODULE_HEADER Required Header
1120  *  \#include <calendar.h>
1121  *
1122  * <BR>
1123  */
1124
1125 /**
1126  * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1127  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_VCALENDAR_MODULE vCalendar
1128  *
1129  * @brief The calendar vcalendar API provides the set of the definitions and interfaces that enable you to get/set data from/to vCalendar.
1130  *
1131  * @section CAPI_SOCIAL_CALENDAR_SVC_VCALENDAR_MODULE_HEADER Required Header
1132  *  \#include <calendar.h>
1133  *
1134  * <BR>
1135  */
1136
1137 /**
1138  * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1139  * @defgroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
1140  *
1141  * @brief This page provides information about views with properties.
1142  *
1143  * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_OVERVIEW Overview
1144  * A view is a structure which describes properties of a record.
1145  * A record can have basic properties of four types: integer, string, long integer. Each property
1146  * of basic type has functions to operate on it:
1147  *
1148  * <table>
1149  * <tr>
1150  *     <th> Property </th>
1151  *     <th> Setter </th>
1152  *     <th> Getter </th>
1153  * </tr>
1154  * <tr>
1155  *     <td> integer </td>
1156  *     <td> calendar_record_set_int </td>
1157  *     <td> calendar_record_get_int </td>
1158  * </tr>
1159  * <tr>
1160  *     <td> long long integer </td>
1161  *     <td> calendar_record_set_lli </td>
1162  *     <td> calendar_record_get_lli </td>
1163  * </tr>
1164  * <tr>
1165  *     <td> double </td>
1166  *     <td> calendar_record_set_double </td>
1167  *     <td> calendar_record_get_double </td>
1168  * </tr>
1169  * <tr>
1170  *     <td> string </td>
1171  *     <td> calendar_record_set_str </td>
1172  *     <td> calendar_record_get_str </td>
1173  * </tr>
1174  * <tr>
1175  *     <td> calendar_time_s </td>
1176  *     <td> calendar_record_set_caltime </td>
1177  *     <td> calendar_record_get_caltime </td>
1178  * </tr>
1179  * </table>
1180  *
1181  * For long long integer functions, "lli" stands for long long int, ususally used to hold UTC time.
1182  *
1183  * Below you can find tables with view properties.
1184  *
1185  * Properties of type 'record' are other records. For example, the @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event
1186  * has a 'calendar_alarm' property of type 'record'. This means that records of type calendar_alarm (@ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_alarm)
1187  * can be children of the event record. If a name record holds the identifier
1188  * of a event record in its 'event_id' property, it is the child record of the corresponding
1189  * event record.
1190  *
1191  * Records can have many children of a given type.
1192  *
1193  * Please refer to the main section of Calendar API for a more detailed explanation and examples.
1194  *
1195  * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_HEADER Required Header
1196  *  \#include <calendar.h>
1197  */
1198
1199 #endif /* __TIZEN_SOCIAL_CALENDAR_DOC_H__ */