4 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef __TIZEN_SOCIAL_CALENDAR_DOC_H__
21 #define __TIZEN_SOCIAL_CALENDAR_DOC_H__
24 * @ingroup CAPI_SOCIAL_FRAMEWORK
25 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_MODULE Calendar
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.
30 * @section CAPI_SOCIAL_CALENDARS_SVC_MODULE_HEADER Required Header
31 * \#include <calendar.h>
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"
40 * The Calendar-Service provides an interface to manage the information of records.
42 * <caption> Table: Calendar service properties. </caption>
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).
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().
63 * calendar_disconnect(); *
66 * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Entities Entities
67 * Calendar service manages information related to following entities.
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.
76 * - Have properties like summary, start_time, description.
77 * - Single entry can be available on each calendar book.
79 * - Similar with event entry.
81 * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Entities_Relationship_between_entities Relationship between entities
82 * @image html entities.png "Figure: Relationship between entities"
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.
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.
94 * _calendar_instance_utime, _calendar_instance_localtime views are not offered but combination with another view are provided.
97 * <caption> Table: Calendar views </caption>
99 * <th> Editable view </th>
100 * <th> Read only view </th>
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
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
127 * _calendar_updated_info is used when identifying record changes depending on version.
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>
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.
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"
142 * There is an example how to create event with view.
145 * // create an event with _calendar_event view.
146 * calendar_record_h event = NULL;
147 * calendar_record_create(_calendar_event._uri, &event);
149 * // set event summary to _calendar_event view.
150 * calendar_record_set_str(event, _calendar_event.summary, "Meeting");
153 * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Views_Version Version
155 * Calendar service uses version system in bellow APIs.
158 * <caption> Table: Version related APIs </caption>
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)
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)
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.
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.
182 * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records_URI URI
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.
189 * // create an event and get handle
190 * calendar_record_h event = NULL;
191 * calendar_record_create(_calendar_event._uri, &event);
194 * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records_Record_handle Record handle
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.
199 * // create an event and get handle
200 * calendar_record_h event = NULL;
201 * calendar_record_create(_calendar_event._uri, &event);
203 * // get record handle with id
204 * calendar_record_h event2 = NULL
205 * calendar_db_get_record(_calendar_event._uri, event_id, &event2);
208 * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records_Basic_types Basic types
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:
216 * <caption> Table: Setter and getter functions </caption>
218 * <th> Property </th>
224 * <td> calendar_record_set_int </td>
225 * <td> calendar_record_get_int </td>
228 * <td> long long integer </td>
229 * <td> calendar_record_set_lli </td>
230 * <td> calendar_record_get_lli </td>
234 * <td> calendar_record_set_double </td>
235 * <td> calendar_record_get_double </td>
239 * <td> calendar_record_set_str </td>
240 * <td> calendar_record_get_str </td>
243 * <td> calendar_time_s </td>
244 * <td> calendar_record_set_caltime </td>
245 * <td> calendar_record_get_caltime </td>
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.
255 * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records_Child Child
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.
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.
266 * the code below creates an event and inserts it into default event book
267 * (see below on calendar books).
271 * calendar_record_h event;
272 * calendar_record_create(_calendar_event._uri, &event);
274 * // set event summary
275 * calendar_record_set_str(event, _calendar_event.summary, "Meeting");
277 * // put the event into the default calendar book for events
278 * calendar_record_set_int(event, _calendar_event.calendar_book_id, book_id);
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);
287 * // insert calendar book into the database
289 * calendar_db_insert_record(event, &event_id);
292 * calendar_record_destroy(event, true);
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.
300 * <caption> Table: Calendar books </caption>
302 * <td> DEFAULT_EVENT_CALENDAR_BOOK_ID </td>
303 * <td> Event book </td>
306 * <td> DEFAULT_TODO_CALENDAR_BOOK_ID </td>
307 * <td> Todo book </td>
310 * <td> DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID </td>
311 * <td> Birthday book </td>
315 * There is an example how calendar book id is set.
318 * calendar_record_h event = NULL;
320 * calendar_record_create(_calendar_event._uri, &event);
322 * // set default calendar book id
323 * calendar_record_set_int(event, _calendar_event.calendar_id, DEFAULT_EVENT_CALENDAR_BOOK_ID);
325 * // set other fields
328 * calendar_db_insert_record(event &event_id);
331 * calendar_record_destroy(event, true);
334 * To receive a list of existing calendar books, use the following:
337 * calendar_list_h calendar_book_list = NULL;
338 * calendar_db_get_all_records(_calendar_calendar_book._uri, 0, 0, &calendar_book_list);
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"
352 * For example, if an event has the following properties:
354 * <caption> Table: Event and instance example </caption>
357 * <th> instances </th>
361 * start date on 2012-10-09 (Tuesday) <br>
362 * frequency set to 'WEEKLY' <br>
363 * interval set to 1 <br>
367 * 2012-10-09 Tuesday <br>
368 * 2012-10-16 Tuesday <br>
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).
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:
383 * <caption> Table: Recurrence rules. </caption>
385 * <th> Recurrence rule property </th>
390 * <td> Yearly, monthly, weekly, daily </td>
394 * <td> Until count. If count is 3, 3 instances are generated </td>
397 * <td> interval </td>
398 * <td> The interval is positive integer representing how often the recurrence rule repeats </td>
402 * <td> MO, TU, WE, TH, FR, SA, SU </td>
405 * <td> bymonthday </td>
406 * <td> Days of month </td>
409 * <td> byyearday </td>
410 * <td> Days of year </td>
413 * <td> byweekno </td>
414 * <td> Ordinals specifying weeks of the year </td>
418 * <td> Months of year </td>
421 * <td> bysetpos </td>
422 * <td> Values which corresponds to the nth occurrence within the set of events </td>
426 * <td> The day on which the workweek starts </td>
430 * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Events_and_instances_Exceptions Exceptions
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.
435 * <caption> Table: Exception example </caption>
438 * <th> instances </th>
439 * <th> exceptions </th>
443 * start date on 2012-10-09 (Tuesday) <br>
444 * frequency set to 'WEEKLY' <br>
445 * interval set to 1 <br>
449 * 2012-10-09 Tuesday <br>
453 * 2012-10-17 Tuesday <br>
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.
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:
467 * calendar_time_type_e type;
469 * long long int utime;
479 * The structure should be used when setting the calendar time type
480 * (_CALENDAR_PROPERTY_CALTIME) properties of records.
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
489 * <caption> Table: Data types </caption>
491 * <th> Identifier </th>
497 * <td> CALENDAR_TIME_UTIME </td>
498 * <td> long long int </td>
500 * <td> UTC time, used to describe non-all-day events </td>
503 * <td> CALENDAR_TIME_LOCALTIME </td>
506 * <td> date only (year, month and day of the month), used to describe all day events </td>
511 * @subsection CAPI_SOCIAL_CALENDAR_SVC_MODULE_Calendar_time_structure_UTC_time_usage UTC Time Usage
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
518 * For example, when setting starting time of an event, the local
519 * time zone should be stored in start_tzid.
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).
526 * #define ms2sec(ms) (long long int)(ms / 1000.0)
528 * long long int _time_convert_itol(char *tzid, int y, int mon, int d, int h, int min, int s)
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));
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);
543 * i18n_ucalendar_set_date_time(ucal, y, mon - 1, d, h, min, s);
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);
552 * i18n_ucalendar_destroy(ucal);
554 * return ms2sec(date);
560 * // fill calendar time structures (start and end time)
561 * calendar_time_s st = {0};
562 * calendar_time_s et = {0};
564 * st.type = CALENDAR_TIME_UTIME;
565 * st.time.utime = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 11, 0, 0);
567 * et.type = CALENDAR_TIME_UTIME;
568 * et.time.utime = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 12, 0, 0);
570 * // create an event record
573 * // set local time zone of start time
574 * calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
577 * calendar_record_set_caltime(event, _calendar_event.start_time, st);
579 * // set local time zone of end time
580 * calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
583 * calendar_record_set_caltime(event, _calendar_event.end_time, et);
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.
595 * // range is 2days: 2014/02/17 00:00:00 ~ 2014/02/19 00:00:00
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;
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;
609 * // create an event record
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.
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);
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);
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.
633 * <caption> Table: Frequency properties </caption>
636 * <th> Property </th>
640 * <td> CALENDAR_RECURRENCE_YEARLY </td>
641 * <td> byyearday </td>
642 * <td> Every 100th day </td>
646 * <td> byweekno </td>
647 * <td> Every 34th week </td>
651 * <td> bymonthday </td>
652 * <td> Every 1st February (birthday)</td>
657 * <td> Every 1st Monday of May (holiday) </td>
660 * <td> CALENDAR_RECURRENCE_MONTHLY </td>
661 * <td> bymonthday </td>
662 * <td> Every 29th (payday) </td>
667 * <td> Every last Friday </td>
670 * <td> CALENDAR_RECURRENCE_WEEKLY </td>
672 * <td> Every week </td>
675 * <td> CALENDAR_RECURRENCE_DAILY </td>
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.
685 * <caption> Table: Range types </caption>
687 * <th> Range type </th>
691 * <td> CALENDAR_RANGE_NONE </td>
692 * <td> Endless(max date is 2036/12/31) </td>
695 * <td> CALENDAR_RANGE_UNTIL </td>
696 * <td> Should set until property </td>
699 * <td> CALENDAR_RANGE_COUNT </td>
700 * <td> Should set count property </td>
705 * calendar_record_h event;
706 * calendar_record_create(_calendar_event._uri, &event);
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);
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);
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.
723 * calendar_db_insert_record(event, &event_id);
725 * calendar_record_destroy(event, true);
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.
736 * Operator precedence in filters determined by the order in which the
737 * conditions and filters are added.
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.
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:
748 * <caption> Table: Filter and conditions </caption>
750 * <th> Filter with conditions </th>
761 * <td> (C1 OR C2) AND C3 </td>
768 * Condition C2 <br><br>
772 * Condition C4 <br><br>
781 * (C5 AND F1) AND F2 <br>
783 * (C5 AND (C1 OR C2)) AND (C3 OR C4)
788 * The following code creates a filter, accepting events with high priority
789 * or those that include the word "meeting" in their description.
792 * calendar_filter_h filter = NULL;
794 * // create a filter returning event type records
795 * calendar_filter_create(_calendar_event._uri, &filter);
797 * // add 'priority equals high' condition
798 * calendar_filter_add_int(filter, _calendar_event.priority, CALENDAR_MATCH_EQUAL, CALENDAR_EVENT_PRIORITY_HIGH);
801 * calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
803 * // add 'description contains "meeting"' condition
804 * calendar_filter_add_str(filter, _calendar_event.description, CALENDAR_MATCH_CONTAINS, "meeting");
807 * The filter should be inserted into a query and the query should be executed:
810 * calendar_query_h query = NULL;
811 * calendar_list_h list = NULL;
813 * // create a query returning event type records
814 * calendar_query_create(_calendar_event._uri, &query);
817 * calendar_query_set_filter(query, filter);
819 * // execute the query, results are returned in a list
820 * calendar_db_get_records_with_query(query, 0, 0, &list);
822 * calendar_filter_destroy(filter);
823 * calendar_query_destroy(query);
828 * calendar_list_destroy(list, true);
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
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.
842 * calendar_query_h query = NULL;
843 * calendar_filter_h filter = NULL;
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);
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;
858 * calendar_query_set_projection(query, projection, 3);
859 * calendar_db_get_records_with_query(query, 0, 0, &list);
862 * calendar_filter_destroy(filter);
863 * calendar_query_destroy(query);
864 * calendar_list_destroy(list, true);
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().
872 * This shows how to set alarm and how alarm works.
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.
878 * <caption> Table: Alarm fields </caption>
880 * <th> tick_unit </th>
881 * <th> related field </th>
885 * <td> CALENDAR_ALARM_TIME_UNIT_SPECIFIC </td>
887 * <td> This represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC) </td>
890 * <td> CALENDAR_ALARM_TIME_UNIT_WEEK </td>
892 * <td> The number of weeks before start time </td>
895 * <td> CALENDAR_ALARM_TIME_UNIT_DAY </td>
897 * <td> The number of days before start time </td>
900 * <td> CALENDAR_ALARM_TIME_UNIT_HOUR </td>
902 * <td> The number of hours before start time </td>
905 * <td> CALENDAR_ALARM_TIME_UNIT_MINUTE </td>
907 * <td> The number of minutes before start time </td>
911 * Below example shows the alarm which is set 1 minute before start time.
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)
920 * // add alarm as child
921 * calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm);
924 * With CALENDAR_ALARM_TIME_UNIT_SPECIFIC, the alarm could be set regardless of the start time.
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);
937 * // add alarm as child
938 * calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm);
941 * How to register package as reminder.
943 * In manifest.xml file, below code must be inserted.
946 * <operation name="http://tizen.org/appcontrol/operation/view" />
947 * <mime name="application/x-tizen.calendar.reminder" />
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
958 * // "ids" string is the key, to get id array
961 * app_control_get_extra_data_array(b, "ids", &ids, &len);
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) {
971 * // parse detail data
981 * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Db_change_noties Database Change Notifications
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.
990 * // add callback function
991 * void __event_changed_cb(const char *view_uri, void *user_data)
994 * // add changed noti callback
995 * calendar_db_add_changed_cb(_calendar_event._uri, __event_changed_cb, NULL);
999 * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Vcalendar Vcalendar
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.
1007 * <caption> Table: Vcalendar example ( http://www.ietf.org/rfc/rfc2445.txt ) </caption>
1010 * BEGIN:VCALENDAR<br>
1012 * PRODID:-//hacksw/handcal//NONSGML v1.0//EN<br>
1014 * DTSTART:19970714T170000Z<br>
1015 * DTEND:19970715T035959Z<br>
1016 * SUMMARY:Bastille Day Party<br>
1023 * Calendar service provides APIs to compose vcalendar stream.
1024 * With stream, file could be made or data could be transmitted with json data.
1027 * calendar_list_h list = NULL;
1028 * // create or get list to make vcalendar stream
1030 * char *stream = NULL;
1031 * calendar_vcalendar_make_from_records(list, &stream);
1033 * // jobs for stream
1039 * Vcalendar could be parsed with calendar service APIs as well.
1042 * // read stream from file
1044 * calendar_list_h list = NULL;
1045 * calendar_vcalendar_parse_to_calendar(stream, &list);
1048 * calendar_list_destroy(list, true);
1054 * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1055 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE Database
1057 * @brief The calendar database API provides the set of the definitions and interfaces that enable you to handle calendar database.
1059 * @section CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE_HEADER Required Header
1060 * \#include <calendar.h>
1066 * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1067 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE Filter
1069 * @brief The calendar filter API provides the set of the definitions and interfaces that enable you to handle filter.
1071 * @section CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE_HEADER Required Header
1072 * \#include <calendar.h>
1078 * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1079 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_LIST_MODULE List
1081 * @brief The calendar list API provides the set of the definitions and interfaces that enable you to handle list.
1083 * @section CAPI_SOCIAL_CALENDAR_SVC_LIST_MODULE_HEADER Required Header
1084 * \#include <calendar.h>
1090 * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1091 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_QUERY_MODULE Query
1093 * @brief The calendar query API provides the set of the definitions and interfaces that enable you to handle query.
1095 * @section CAPI_SOCIAL_CALENDAR_SVC_QUERY_MODULE_HEADER Required Header
1096 * \#include <calendar.h>
1102 * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1103 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE Record
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.
1107 * @section CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE_HEADER Required Header
1108 * \#include <calendar.h>
1114 * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1115 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_REMINDER_MODULE Reminder
1117 * @brief The calendar reminder API provides the interface to set/unset reminder callback.
1119 * @section CAPI_SOCIAL_CALENDAR_SVC_REMINDER_MODULE_HEADER Required Header
1120 * \#include <calendar.h>
1126 * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1127 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_VCALENDAR_MODULE vCalendar
1129 * @brief The calendar vcalendar API provides the set of the definitions and interfaces that enable you to get/set data from/to vCalendar.
1131 * @section CAPI_SOCIAL_CALENDAR_SVC_VCALENDAR_MODULE_HEADER Required Header
1132 * \#include <calendar.h>
1138 * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
1139 * @defgroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
1141 * @brief This page provides information about views with properties.
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:
1150 * <th> Property </th>
1155 * <td> integer </td>
1156 * <td> calendar_record_set_int </td>
1157 * <td> calendar_record_get_int </td>
1160 * <td> long long integer </td>
1161 * <td> calendar_record_set_lli </td>
1162 * <td> calendar_record_get_lli </td>
1166 * <td> calendar_record_set_double </td>
1167 * <td> calendar_record_get_double </td>
1171 * <td> calendar_record_set_str </td>
1172 * <td> calendar_record_get_str </td>
1175 * <td> calendar_time_s </td>
1176 * <td> calendar_record_set_caltime </td>
1177 * <td> calendar_record_get_caltime </td>
1181 * For long long integer functions, "lli" stands for long long int, ususally used to hold UTC time.
1183 * Below you can find tables with view properties.
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
1191 * Records can have many children of a given type.
1193 * Please refer to the main section of Calendar API for a more detailed explanation and examples.
1195 * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_HEADER Required Header
1196 * \#include <calendar.h>
1199 #endif /* __TIZEN_SOCIAL_CALENDAR_DOC_H__ */