8acb4bd3a5a1c1632dea517503b3677afd7de98e
[platform/core/pim/calendar-service.git] / include / calendar_db.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_DB_H__
21 #define __TIZEN_SOCIAL_CALENDAR_DB_H__
22
23 #include <calendar_types.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /**
30  * @file calendar_db.h
31  */
32
33 /**
34  * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE
35  * @{
36  */
37
38 /**
39  * @brief Called when a designated view changes.
40  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
41  *
42  * @param[in]   view_uri   The view URI
43  * @param[in]   user_data  The user data passed from the callback registration function
44  *
45  * @see calendar_db_add_changed_cb()
46  */
47 typedef void (*calendar_db_changed_cb)(const char* view_uri, void* user_data);
48
49 /**
50  * @brief Inserts a record into the calendar database.
51  *
52  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
53  * @privlevel public
54  * @privilege %http://tizen.org/privilege/calendar.write
55  *
56  * @param[in]   record     The record handle
57  * @param[out]  record_id  The record ID
58  *
59  * @return  @c 0 on success,
60  *          otherwise a negative error value
61  * @retval  #CALENDAR_ERROR_NONE                Successful
62  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
63  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
64  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
65  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
66  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
67  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
68  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
69  *
70  * @pre     calendar_connect() should be called to open a connection to the calendar service.
71  *
72  * @see calendar_connect()
73  * @see calendar_db_update_record()
74  * @see calendar_db_delete_record()
75  * @see calendar_db_get_record()
76  */
77 int calendar_db_insert_record(calendar_record_h record, int* record_id);
78
79 /**
80  * @brief Gets a record from the calendar database.
81  *
82  * @details This function creates a new record handle from the calendar database by the given @a record_id. \n
83  *          @a record will be created and filled with record information.
84  *
85  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
86  * @privlevel public
87  * @privilege %http://tizen.org/privilege/calendar.read
88  *
89  * @remarks You must release @a record using calendar_record_destroy().
90  *
91  * @param[in]   view_uri    The view URI of a record
92  * @param[in]   record_id   The record ID
93  * @param[out]  record      The record handle associated with the record ID
94  *
95  * @return  @c 0 on success,
96  *          otherwise a negative error value
97  * @retval  #CALENDAR_ERROR_NONE                Successful
98  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
99  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
100  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
101  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
102  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
103  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
104  * @retval  #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
105  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
106  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
107  *
108  * @pre     calendar_connect() should be called to open a connection to the calendar service.
109  *
110  * @see calendar_connect()
111  * @see calendar_record_destroy()
112  */
113 int calendar_db_get_record(const char* view_uri, int record_id, calendar_record_h* record);
114
115 /**
116  * @brief Updates a record in the calendar database.
117  *
118  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
119  * @privlevel public
120  * @privilege %http://tizen.org/privilege/calendar.write
121  *
122  * @param[in]   record    The record handle
123  *
124  * @return  @c 0 on success,
125  *          otherwise a negative error value
126  * @retval  #CALENDAR_ERROR_NONE                Successful
127  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
128  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
129  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
130  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
131  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
132  * @retval  #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
133  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
134  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
135  *
136  * @pre     calendar_connect() should be called to open a connection to the calendar service.
137  *
138  * @see calendar_connect()
139  * @see calendar_db_insert_record()
140  * @see calendar_db_delete_record()
141  * @see calendar_db_get_record()
142  */
143 int calendar_db_update_record(calendar_record_h record);
144
145 /**
146  * @brief Deletes a record from the calendar database with related child records.
147  *
148  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
149  * @privlevel public
150  * @privilege %http://tizen.org/privilege/calendar.write
151  *
152  * @param[in]   view_uri    The view URI of a record
153  * @param[in]   record_id   The record ID to be deleted
154  *
155  * @return  @c 0 on success,
156  *          otherwise a negative error value
157  * @retval  #CALENDAR_ERROR_NONE                Successful
158  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
159  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
160  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
161  * @retval  #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
162  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
163  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
164  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
165  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
166  *
167  * @pre     calendar_connect() should be called to open a connection to the calendar service.
168  *
169  * @see calendar_connect()
170  * @see calendar_db_insert_record()
171  */
172 int calendar_db_delete_record(const char* view_uri, int record_id);
173
174 /**
175  * @brief Retrieves all records as a list.
176  *
177  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
178  * @privlevel public
179  * @privilege %http://tizen.org/privilege/calendar.read
180  *
181  * @remarks You must release @a record_list using calendar_list_destroy().
182  *
183  * @param[in]   view_uri        The view URI to get records from
184  * @param[in]   offset          The index from which results are received
185  * @param[in]   limit           The maximum number of results(value 0 is used for all records)
186  * @param[out]  record_list     The record list
187  *
188  * @return  @c 0 on success,
189  *          otherwise a negative error value
190  * @retval  #CALENDAR_ERROR_NONE                Successful
191  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
192  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
193  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
194  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
195  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
196  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
197  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
198  *
199  * @pre    calendar_connect() should be called to open a connection to the calendar service.
200  *
201  * @see calendar_connect()
202  * @see calendar_list_destroy()
203  */
204 int calendar_db_get_all_records(const char* view_uri, int offset, int limit, calendar_list_h* record_list);
205
206 /**
207  * @brief Retrieves records using a query handle.
208  *
209  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
210  * @privlevel public
211  * @privilege %http://tizen.org/privilege/calendar.read
212  *
213  * @remarks You must release @a record_list using calendar_list_destroy().
214  *
215  * @param[in]   query           The query handle used to filter results
216  * @param[in]   offset          The index from which results are received
217  * @param[in]   limit           The maximum number of results(value 0 is used for all records)
218  * @param[out]  record_list     The record list
219  *
220  * @return  @c 0 on success,
221  *          otherwise a negative error value
222  * @retval  #CALENDAR_ERROR_NONE                            Successful
223  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
224  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
225  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
226  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
227  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
228  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
229  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
230  *
231  * @pre    calendar_connect() should be called to open a connection to the calendar service.
232  *
233  * @see calendar_connect()
234  * @see calendar_list_destroy()
235  */
236 int calendar_db_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* record_list);
237
238 /**
239  * @brief Gets the record count of a specific view.
240  *
241  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
242  * @privlevel public
243  * @privilege %http://tizen.org/privilege/calendar.read
244  *
245  * @param[in]   view_uri        The view URI to get records from
246  * @param[out]  count           The number of records
247  *
248  * @return  @c 0 on success,
249  *          otherwise a negative error value
250  * @retval  #CALENDAR_ERROR_NONE                Successful
251  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
252  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
253  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
254  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
255  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
256  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
257  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
258  *
259  * @pre     This function requires an open connection to the calendar service using calendar_connect2().
260  *
261  * @see calendar_connect()
262  */
263 int calendar_db_get_count(const char* view_uri, int *count);
264
265 /**
266  * @brief Gets the record count with a query handle.
267  *
268  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
269  * @privlevel public
270  * @privilege %http://tizen.org/privilege/calendar.read
271  *
272  * @param[in]   query    The query handle used for filtering the results
273  * @param[out]  count    The number of records
274  *
275  * @return  @c 0 on success,
276  *          otherwise a negative error value
277  * @retval  #CALENDAR_ERROR_NONE                Successful
278  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
279  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
280  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
281  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
282  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
283  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
284  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
285  *
286  * @pre    This function requires an open connection to the calendar service using calendar_connect2().
287  *
288  * @see calendar_connect2()
289  */
290 int calendar_db_get_count_with_query(calendar_query_h query, int *count);
291
292 /**
293  * @brief Inserts multiple records into the calendar database as a batch operation.
294  *
295  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
296  * @privlevel public
297  * @privilege %http://tizen.org/privilege/calendar.write
298  *
299  * @param[in]   record_list         The record list handle
300  * @param[out]  record_id_array     The array of record IDs
301  * @param[out]  count                       The number of record IDs
302  *
303  * @return  @c 0 on success,
304  *          otherwise a negative error value
305  * @retval  #CALENDAR_ERROR_NONE                Successful
306  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
307  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
308  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
309  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
310  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
311  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
312  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
313  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
314  *
315  * @pre     calendar_connect() should be called to open a connection to the calendar service.
316  *
317  * @see calendar_connect()
318  * @see calendar_db_update_records()
319  * @see calendar_db_delete_records()
320  */
321 int calendar_db_insert_records(calendar_list_h record_list, int** record_id_array, int* count);
322
323 /**
324  * @brief Updates multiple records into the calendar database as a batch operation.
325  *
326  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
327  * @privlevel public
328  * @privilege %http://tizen.org/privilege/calendar.write
329  *
330  * @param[in]   record_list       The record list handle
331  *
332  * @return  @c 0 on success,
333  *          otherwise a negative error value
334  * @retval  #CALENDAR_ERROR_NONE                Successful
335  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
336  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
337  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
338  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
339  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
340  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
341  * @retval  #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
342  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
343  *
344  * @pre     calendar_connect() should be called to open a connection to the calendar service.
345  *
346  * @see calendar_connect()
347  * @see calendar_db_insert_records()
348  * @see calendar_db_delete_records()
349  */
350 int calendar_db_update_records(calendar_list_h record_list);
351
352 /**
353  * @brief   Deletes multiple records with related child records from the calendar database as a batch operation.
354  *
355  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
356  * @privlevel public
357  * @privilege %http://tizen.org/privilege/calendar.write
358  *
359  * @param[in]   view_uri            The view URI of the records to delete
360  * @param[in]   record_id_array     The record IDs to delete
361  * @param[in]   count               The number of records
362  *
363  * @return  @c 0 on success,
364  *          otherwise a negative error value
365  * @retval  #CALENDAR_ERROR_NONE                Successful
366  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
367  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
368  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
369  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
370  * @retval  #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
371  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
372  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
373  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
374  *
375  * @pre     calendar_connect() should be called to open a connection to the calendar service.
376  *
377  * @see calendar_connect()
378  * @see calendar_db_insert_records()
379  * @see calendar_db_delete_records()
380  */
381 int calendar_db_delete_records(const char* view_uri, int record_id_array[], int count);
382
383 /**
384  * @brief       Gets the current calendar database version.
385  *
386  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
387  * @privlevel public
388  * @privilege %http://tizen.org/privilege/calendar.read
389  *
390  * @param[out]  calendar_db_version    The calendar database version
391  *
392  * @return  @c 0 on success,
393  *          otherwise a negative error value
394  * @retval  #CALENDAR_ERROR_NONE                 Successful
395  * @retval      #CALENDAR_ERROR_INVALID_PARAMETER    Invalid parameter
396  * @retval  #CALENDAR_ERROR_DB_FAILED            Database operation failure
397  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED    Permission denied. This application does not have the privilege to call this method.
398  * @retval  ##CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
399  * @retval  #CALENDAR_ERROR_IPC                  Unknown IPC error
400  *
401  * @pre     This function requires an open connection to the calendar service using calendar_connect().
402  *
403  * @see calendar_connect()
404  * @see calendar_db_get_changes_by_version()
405  */
406 int calendar_db_get_current_version(int* calendar_db_version);
407
408 /**
409  * @brief Registers a callback function to be invoked when a record changes.
410  *
411  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
412  * @privlevel public
413  * @privilege %http://tizen.org/privilege/calendar.read
414  *
415  * @remarks If successive change notification produced on the view_uri are identical,
416  * then they are coalesced into a single notification if the older notification has not yet been called
417  * because default main loop is doing something.
418  * But, it means that a callback function is not called to reliably count of change.
419  * This API supports only @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_book view, @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event view,
420  * @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo view.
421  *
422  * @param[in]   view_uri    The view URI of the record to subscribe for change notifications
423  * @param[in]   callback    The callback function to register
424  * @param[in]   user_data   The user data to be passed to the callback function
425  *
426  * @return  @c 0 on success,
427  *          otherwise a negative error value
428  * @retval      #CALENDAR_ERROR_NONE                Successful
429  * @retval      #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
430  * @retval  #CALENDAR_ERROR_SYSTEM              Error from another modules
431  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
432  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
433  *
434  * @pre     This function requires an open connection to the calendar service using calendar_connect().
435  * @post    calendar_db_changed_cb() will be invoked when the designated view changes.
436  *
437  * @see calendar_connect()
438  * @see calendar_db_changed_cb()
439  * @see calendar_db_remove_changed_cb()
440  */
441 int calendar_db_add_changed_cb(const char* view_uri, calendar_db_changed_cb callback, void* user_data);
442
443 /**
444  * @brief Unregisters a callback function.
445  *
446  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
447  * @privlevel public
448  * @privilege %http://tizen.org/privilege/calendar.read
449  *
450  * @param[in]   view_uri    The view URI of the record to subscribe for change notifications
451  * @param[in]   callback    The callback function to register
452  * @param[in]   user_data   The user data to be passed to the callback function
453  *
454  * @return  @c 0 on success,
455  *          otherwise a negative error value
456  * @retval      #CALENDAR_ERROR_NONE                Successful
457  * @retval      #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
458  * @retval  #CALENDAR_ERROR_SYSTEM              Error from another modules
459  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
460  *
461  * @pre     This function requires an open connection to the calendar service using calendar_connect().
462  *
463  * @see calendar_connect()
464  * @see calendar_db_changed_cb()
465  * @see calendar_db_add_changed_cb()
466  */
467 int calendar_db_remove_changed_cb(const char* view_uri, calendar_db_changed_cb callback, void* user_data);
468
469 /**
470  * @brief Retrieves records with the given calendar database version.
471  *
472   * @details This function finds all the changed records since the given @a calendar_db_version.
473   *
474  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
475  * @privlevel public
476  * @privilege %http://tizen.org/privilege/calendar.read
477  *
478  * @remarks You must release @a change_record_list using calendar_list_destroy().
479  *
480  * @param[in]   view_uri                    The view URI to get records from
481  * @param[in]   calendar_book_id            The calendar book ID to filter
482  * @param[in]   calendar_db_version         The calendar database version
483  * @param[out]  record_list                 The record list
484  * @param[out]  current_calendar_db_version The current calendar database version
485  *
486  * @return  @c 0 on success,
487  *          otherwise a negative error value
488  * @retval  #CALENDAR_ERROR_NONE                Successful
489  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
490  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
491  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
492  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
493  * @retval  #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
494  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
495  *
496  * @pre    calendar_connect() should be called to open a connection to the calendar service.
497  *
498  * @see calendar_connect()
499  * @see calendar_list_destroy()
500  */
501 int 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);
502
503 /**
504  * @brief Inserts a vcalendar stream into the calendar database.
505  *
506  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
507  * @privlevel public
508  * @privilege %http://tizen.org/privilege/calendar.write
509  *
510  * @param[in]   vcalendar_stream     The vcalendar stream
511  * @param[out]  record_id_array      The record IDs to delete
512  * @param[out]  count                The number of record ID arrays
513  *
514  * @return  @c 0 on success,
515  *          otherwise a negative error value
516  * @retval  #CALENDAR_ERROR_NONE                Successful
517  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
518  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
519  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
520  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
521  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
522  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
523  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
524  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
525  *
526  * @pre     calendar_connect() should be called to open a connection to the calendar service.
527  *
528  * @see calendar_connect()
529  * @see calendar_db_replace_vcalendars()
530  */
531 int calendar_db_insert_vcalendars(const char* vcalendar_stream, int **record_id_array, int *count);
532
533 /**
534  * @brief Replaces a vcalendar stream in the calendar database.
535  *
536  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
537  * @privlevel public
538  * @privilege %http://tizen.org/privilege/calendar.write
539  *
540  * @param[in]   vcalendar_stream     The vcalendar stream
541  * @param[in]   record_id_array      The record IDs to replace
542  * @param[in]   count                The number of record ID arrays
543  *
544  * @return  @c 0 on success,
545  *          otherwise a negative error value
546  * @retval  #CALENDAR_ERROR_NONE                Successful
547  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
548  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
549  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
550  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
551  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
552  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
553  * @retval  #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
554  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
555  *
556  * @pre     This function requires an open connection to the calendar service by calendar_connect().
557  *
558  * @see calendar_connect()
559  * @see calendar_db_replace_vcalendars()
560  */
561 int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record_id_array, int count);
562
563 /**
564  * @brief Replaces a record in the calendar database.
565  *
566  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
567  * @privlevel public
568  * @privilege %http://tizen.org/privilege/calendar.write
569  *
570  * @param[in]   record        The record handle
571  * @param[in]   record_id     The record ID
572  *
573  * @return  @c 0 on success,
574  *          otherwise a negative error value
575  * @retval  #CALENDAR_ERROR_NONE                Successful
576  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
577  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
578  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
579  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
580  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
581  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
582  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
583  *
584  * @pre     calendar_connect() should be called to open a connection to the calendar service.
585  *
586  * @see calendar_connect()
587  * @see calendar_db_update_record()
588  * @see calendar_db_delete_record()
589  * @see calendar_db_get_record()
590  */
591 int calendar_db_replace_record(calendar_record_h record, int record_id);
592
593 /**
594  * @brief Replaces multiple records in the calendar database as a batch operation.
595  *
596  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
597  * @privlevel public
598  * @privilege %http://tizen.org/privilege/calendar.write
599  *
600  * @param[in]   record_list         The record list handle
601  * @param[in]   record_id_array     The record IDs
602  * @param[in]   count               The number of record ID arrays
603  *
604  * @return  @c 0 on success,
605  *          otherwise a negative error value
606  * @retval  #CALENDAR_ERROR_NONE                Successful
607  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
608  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
609  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
610  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
611  * @retval  #CALENDAR_ERROR_NOT_PERMITTED       Operation not permitted
612  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
613  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
614  *
615  * @pre     calendar_connect() should be called to open a connection to the calendar service.
616  *
617  * @see calendar_connect()
618  * @see calendar_db_update_records()
619  * @see calendar_db_delete_records()
620  * @see calendar_db_replace_record()
621  */
622 int calendar_db_replace_records(calendar_list_h record_list, int *record_id_array, int count);
623
624 /**
625  * @brief Gets the last successful change version of the database on the current connection.
626  *
627  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
628  * @privlevel public
629  * @privilege %http://tizen.org/privilege/calendar.read
630  *
631  * @param[out]  last_change_version   The calendar database version on the current connection
632  *
633  * @return  @c 0 on success,
634  *          otherwise a negative error value
635  * @retval  #CALENDAR_ERROR_NONE                Successful
636  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
637  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
638  *
639  * @pre     This function requires an open connection to the calendar service using calendar_connect().
640  *
641  * @see calendar_connect()
642  * @see calendar_db_get_current_version()
643  */
644 int calendar_db_get_last_change_version(int* last_change_version);
645
646 /**
647  * @brief Retrieves changed exception records since the given calendar database version.
648  *        Exceptions are the modified or deleted instances in a recurring event.
649  *
650  * @details This function finds all the changed records since the given @a calendar_db_version.
651  *
652  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
653  * @privlevel public
654  * @privilege %http://tizen.org/privilege/calendar.read
655  *
656  * @remarks You must release @a change_record_list using calendar_list_destroy().
657  *
658  * @param[in]   view_uri               The view URI to get records from
659  * @param[in]   original_event_id      The original event ID
660  * @param[in]   calendar_db_version    The calendar database version starting from which to get records
661  * @param[out]  list                           The record list
662  *
663  * @return  @c 0 on success,
664  *          otherwise a negative error value
665  * @retval  #CALENDAR_ERROR_NONE                Successful
666  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
667  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
668  * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
669  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied. This application does not have the privilege to call this method.
670  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
671  *
672  * @pre     calendar_connect() should be called to open a connection to the calendar service.
673  *
674  * @see calendar_connect()
675  * @see calendar_list_destroy()
676  */
677 int calendar_db_get_changes_exception_by_version(const char* view_uri, int original_event_id, int calendar_db_version, calendar_list_h* list);
678
679 /**
680  * @brief Cleans the data after sync.
681  *
682  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
683  * @privlevel public
684  * @privilege %http://tizen.org/privilege/calendar.write
685
686  * @param[in]   calendar_book_id        The calendar book ID
687  * @param[in]   calendar_db_version         The calendar database version
688  *
689  * @return  @c 0 on success,
690  *          otherwise a negative error value
691  * @retval  #CALENDAR_ERROR_NONE                        Successful
692  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY               Out of memory
693  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
694  * @retval  #CALENDAR_ERROR_DB_FAILED                   Database operation failure
695  * @retval  #CALENDAR_ERROR_PERMISSION_DENIED   Permission denied
696  * @retval  #CALENDAR_ERROR_FILE_NO_SPACE       File system is full
697  * @retval  #CALENDAR_ERROR_IPC                 Unknown IPC error
698  * @retval  #CALENDAR_ERROR_NO_DATA             Data does not exist
699  *
700  * @pre    calendar_connect() should be called to open a connection to the calendar service.
701  *
702  * @see calendar_connect()
703  */
704 int calendar_db_clean_after_sync(int calendar_book_id, int calendar_db_version);
705
706 /**
707  * @}
708  */
709
710 #ifdef __cplusplus
711 }
712 #endif
713
714 #endif /* __TIZEN_SOCIAL_CALENDAR_DB_H__ */
715