summaryrefslogtreecommitdiff
path: root/include/calendar.h
blob: 74020d04219429636db651c63d379de8fc74f4ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
/*
 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef __TIZEN_SOCIAL_CALENDAR_CALENDAR_H__
#define __TIZEN_SOCIAL_CALENDAR_CALENDAR_H__

#include <tizen.h>
#include <time.h>
#include "calendar_attendee.h"
#include "calendar_types.h"


#ifdef __cplusplus
extern "C" {
#endif

/**
 * @addtogroup CAPI_SOCIAL_CALENDAR_MODULE
 * @{
 */

/**
 * @brief Connects to the calendar service.
 *
 * @details Opening connection is necessary to access the calendar database.
 * All operations like inserting, updating, or deleting calendar require opened connection to work properly.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @see calendar_disconnect()
 *
 */
int calendar_connect(void);

/**
 * @brief Disconnects the calendar service.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @see calendar_connect()
 *
 */
int calendar_disconnect(void);

/**
 * @brief Begins transaction to calendar database
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_rollback_transaction()
 * @see calendar_commit_transaction()
 */
int calendar_begin_transaction(void);

/**
 * @brief Rollbacks transaction to calendar database
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_begin_transaction()
 * @see calendar_commit_transaction()
 */
int calendar_rollback_transaction(void);

/**
 * @brief Commits transaction to calendar database
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_begin_transaction()
 * @see calendar_rollback_transaction()
 */
int calendar_commit_transaction(void);


/**
 * @brief  Registers a callback function to be invoked when any database change occurs.
 *
 * @param[in]   callback    The callback function to invoke
 * @param[in]   type    	The notification type to subscribe
 * @param[in]   user_data    The user data to be passed to the callback function
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 * @post  calendar_db_changed_cb() will be invoked.
 *
 * @see calendar_db_changed_cb()
 * @see calendar_remove_db_changed_cb()
 * @see	calendar_book_insert_to_db()
 * @see	calendar_book_update_to_db()
 * @see	calendar_book_delete_from_db()
 * @see	calendar_event_insert_to_db()
 * @see	calendar_event_update_to_db()
 * @see	calendar_event_delete_from_db()
 * @see	calendar_todo_insert_to_db()
 * @see	calendar_todo_update_to_db()
 * @see	calendar_todo_delete_from_db()
 */
int calendar_add_db_changed_cb(calendar_db_changed_cb callback, calendar_db_changed_cb_type_e type, void *user_data);

/**
 * @brief	Unregisters the callback function.
 *
 * @param[in]	callback	The callback function to unregister
 * @param[in]   type    	The notification type to unregister callback
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 * @see calendar_db_changed_cb()
 * @see calendar_add_db_changed_cb()
 */
int calendar_remove_db_changed_cb(calendar_db_changed_cb callback, calendar_db_changed_cb_type_e type);

/**
 * @brief	Gets the calendar database version.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE	Successful
 * @retval	#CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_DB_FAILED	Database operation failure
 *
 * @see calendar_connect()
 * @see calendar_query_event_by_version()
 * @see calendar_query_todo_by_version()
 */
int calendar_get_db_version(int* calendar_db_version);

/**
 * @}
 */

/**
 * @addtogroup CAPI_SOCIAL_CALENDAR_EVENT_MODULE
 * @{
 */


/**
 * @brief Creates a handle to the calendar event.
 * @remarks The calendar event handle must be released with calendar_event_destroy() by you.
 * @remarks   The created handle is not added to calendar database until calendar_event_insert_to_db() is called
 *
 * @param[out] event A new handle to calendar event
 *
 * @return   0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 *
 * @see calendar_event_destroy()
 *
 */
int calendar_event_create(calendar_event_h *event);

/**
 * @brief Destroys the calendar event handle and releases all its resources.
 *
 * @param[out]  event   The calendar event handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_create()
 *
 */
int calendar_event_destroy(calendar_event_h event);

/**
 * @brief Adds a calendar event to the calendar database.
 *
 * @param[in]	event               The calendar event handle
 * @param[in]   calendar_book_db_id      The calendar book database ID to which the event insert. \n
 *                       #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device
 * @param[out]	event_db_id         The event database ID associated with the calendar event \n
 * If the function fails, it is -1.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_event_update_to_db()
 * @see calendar_event_delete_from_db()
 */
int calendar_event_insert_to_db(calendar_event_h event, int calendar_book_db_id, int *event_db_id);

/**
 * @brief Removes the calendar event from the calendar database.
 *
 * @param[in]   event_db_id  The database event ID to delete
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre	This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see	calendar_event_insert_to_db()
 * @see	calendar_event_update_to_db()
 */
int calendar_event_delete_from_db(int event_db_id);

/**
 * @brief Updates the calendar event in the calendar database.
 * @details calendar_event_get_db_id() is called internally to update in the calendar database to get the event ID in the calendar database.
 *
 * @param[in]   event The calendar event handle
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE					Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #CALENDAR_ERROR_DB_FAILED 			No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 * @pre		The event is supposed to be in the calendar database already.
 *
 * @see calendar_connect()
 * @see calendar_event_insert_to_db()
 * @see calendar_event_delete_from_db()
 * @see calendar_event_get_from_db()
 * @see calendar_event_get_db_id()
 */
int calendar_event_update_to_db(calendar_event_h event);

/**
 * @brief Gets the calendar event from the calendar database.
 * @details This function gets the new calendar event handle with the given event database ID from the calendar database. \n
 * The new calendar event handle will be created.
 *
 * @remarks The created calendar event handle must be released with calendar_event_destroy() by you.
 *
 *
 * @param[in]   event_id	The event ID
 * @param[out]  event	The calendar event handle associated with the event database ID
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE  Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_event_destroy()
 */
int calendar_event_get_from_db(int event_db_id, calendar_event_h *event);

/**
 * @brief   Gets the database ID associated with the given calendar event handle.
 *
 * @param[in]   event	The calendar event handle
 * @param[out]  event_db_id	The event database ID fetched from the calendar event handle (default : 0)  \n
 * 0 means the event is not in calendar database.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_insert_to_db()
 * @see calendar_event_delete_from_db()
 */
int calendar_event_get_db_id(calendar_event_h event, int *event_db_id);

/**
 * @brief   Gets The calendar book database ID associated with the given calendar event handle.
 *
 * @param[in]   event			The calendar event handle
 * @param[out]  calendar_book_db_id	The calendar book database ID fetched from the calendar event handle (default : 0)  \n
 * 0 means the event is not in calendar database.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_insert_to_db()
 */
int calendar_event_get_calendar_book_db_id(calendar_event_h event, int *calendar_book_db_id);

/**
 * @brief Gets the subject of the event from the calendar event handle .
 *
 * @remarks @a subject must be released with free() by you.
 *
 * @param [in] event The calendar event handle
 * @param [out] subject The subject of the event  \n If the subject does not exist, it is NULL
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_set_subject()
 *
*/
int calendar_event_get_subject(calendar_event_h event, char **subject);

/**
 * @brief Sets the subject of the event in the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] subject The subject of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_subject()
 */
int calendar_event_set_subject(calendar_event_h event, const char *subject);

/**
 * @brief Gets the description of the event from the calendar event handle.
 *
 * @remarks @a description must be released with free() by you.
 *
 * @param [in] event The calendar event handle
 * @param [out] description The description of the event \n If the description does not exist, it is NULL
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE					Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER	Invalid parameter
 *
 * @see calendar_event_set_description()
 */
int calendar_event_get_description(calendar_event_h event, char **description);

/**
 * @brief Sets a description of the event in the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] description The description of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_description()
 */
int calendar_event_set_description(calendar_event_h event, const char *description);

/**
 * @brief Gets the start time of the event from the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [out] start_time The start date of the event \n
 *								The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_NO_DATA				Data not found
 *
 * @see calendar_event_set_start_time()
 */
int calendar_event_get_start_time(calendar_event_h event, long long int *start_time);

/**
 * @brief Sets a start time of the event in the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] start_time The start date of the event \n
 *								The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_start_time()
 */
int calendar_event_set_start_time(calendar_event_h event, long long int start_time);

/**
 * @brief Gets the end time of the event from the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [out] end_time The end date of the event\n
 *								The @a end_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_NO_DATA				Data not found
 *
 * @see calendar_event_set_end_time()
 */
int calendar_event_get_end_time(calendar_event_h event, long long int *end_time);

/**
 * @brief Sets the end time of the event in the calendar event handle.
 *
 * @param[in]   event The calendar event handle
 * @param[in]   end_time    The end date of the event\n
 *								The @a end_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_get_end_time()
 */
int calendar_event_set_end_time(calendar_event_h event, long long int end_time);

/**
 * @brief Gets an all-day event property of the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [out] is_all_day_event @c true if the event lasts for an entire day, otherwise @c false \n
 * (default : @c false)
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_set_is_all_day_event()
 */
int calendar_event_get_is_all_day_event(calendar_event_h event, bool *is_all_day_event);

/**
 * @brief Sets an all-day event with date range
 *
 * @param [in] event				The calendar event handle
 * @param [in] start_year			Year of start date
 * @param [in] start_month			Month of start date
 * @param [in] start_day			Day of start date
 * @param [in] end_year				Year of end date
 * @param [in] end_month			Month of end date
 * @param [in] end_day				Day of end date
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_is_all_day_event()
 * @see calendar_event_get_all_day_event()
 */
int calendar_event_set_all_day_event(calendar_event_h event, int start_year, int start_month, int start_day,
							int end_year, int end_month, int end_day);

/**
 * @brief Gets an all-day event date range
 *
 * @param [in] event				The calendar event handle
 * @param [out] start_year			Year of start date
 * @param [out] start_month			Month of start date
 * @param [out] start_day			Day of start date
 * @param [out] end_year			Year of end date
 * @param [out] end_month			Month of end date
 * @param [out] end_day				Day of end date
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_is_all_day_event()
 * @see calendar_event_set_all_day_event()
 */
int calendar_event_get_all_day_event(calendar_event_h event, int *start_year, int *start_month, int *start_day,
							int *end_year, int *end_month, int *end_day);

/**
 * @brief Gets the location of the event from the calendar event handle.
 *
 * @remarks @a location must be released with free() by you.
 *
 * @param [in] event The calendar event handle
 * @param [out] location The location of the event \n If the location does not exist, it is NULL
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_set_location()
 */
int calendar_event_get_location(calendar_event_h event, char **location);

/**
 * @brief Sets a location of the event in the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] location The location of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_location()
 */
int calendar_event_set_location(calendar_event_h event, const char *location);

/**
 * @brief Gets the reminder of the event from the calendar event handle.
 * @details The function returns reminder type and interval of the event.
 *
 *
 * @param [in] event The calendar event handle
 * @param [out] reminder_interval_type  The reminder type
 * @param [out] reminder_interval       The interval
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_reminder()
 */
int calendar_event_get_reminder(calendar_event_h event, calendar_reminder_interval_type_e *reminder_interval_type, int *reminder_interval);

/**
 * @brief Sets a reminder of the event in the calendar event handle.
 *
 * @remarks If reminder is set, the alarm will remind the event with in-house calendar application.
 *
 * @param [in] event The calendar event handle
 * @param [in] reminder_interval_type  The reminder interval type
 * @param [in] reminder_interval  The reminder interval
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE                 Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER    Invalid parameter
 *
 * @see calendar_event_get_reminder()
 */
int calendar_event_set_reminder(calendar_event_h event, calendar_reminder_interval_type_e reminder_interval_type, int reminder_interval);

/**
 * @brief       Gets the sound file path from the event handle.
 *
 * @remarks @a sound_file_path must be released with free() by you.
 *
 * @param[in]   event          		The calendar event handle
 * @param[out]  sound_file_path		The  sound file path \n
 *						   If @a sound_file_path does not exist, it is NULL
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                    Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER       Invalid parameter
 *
 * @see  calendar_event_set_reminder_sound_file_path()
 */
int calendar_event_get_reminder_sound_file_path(calendar_event_h event, char **sound_file_path);

/**
 * @brief       Sets the  sound file path to the event handle.
 *
 * @param[in]   event          		The calendar event handle
 * @param[in]   sound_file_path		The  sound file path to set
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                    Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER       Invalid parameter
 *
 * @see calendar_event_get_reminder_sound_file_path()
 */
int calendar_event_set_reminder_sound_file_path(calendar_event_h event, const char *sound_file_path);

/**
 * @brief   Creates a attendee handle and make adds it to the calendar event.
 *
 * @remarks   The created handle is not added to calendar database until calendar_event_insert_to_db() is called
 *
 * @param[in]   event The calendar event handle
 * @param[out]  attendee A new attendee handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE            Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY   Out of memory
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_remove_attendee()
 * @see calendar_attendee_set_name()
 * @see calendar_attendee_set_email()
 * @see calendar_attendee_set_phone_number()
 * @see calendar_event_get_attendee_iterator()
 */
int calendar_event_add_attendee(calendar_event_h event, calendar_attendee_h* attendee);

/**
 * @brief   Creates a attendee handle with contact ID and adds it to the calendar event.
 *
 * @details Adds an existing contact as an attendee to an event.  A new attendee record is created, and the name, email address and phone number are populated from the values in the contact record.
 * @remarks   The created handle is not added to calendar database until calendar_event_insert_to_db() is called
 *
 *
 * @param[in]   event The calendar event handle
 * @param[in]   contact_db_id The contact DB ID which is related to attendee
 * @param[out]  attendee A new attendee handle from contact ID in the contacts database
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE            Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY   Out of memory
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @pre     This function requires an open connection to Contacts Service by contacts_connect().
 *
 * @see calendar_event_remove_attendee()
 * @see calendar_attendee_set_name()
 * @see calendar_attendee_set_email()
 * @see calendar_attendee_set_phone_number()
 * @see calendar_event_get_attendee_iterator()
 * @see contact_get_db_id()
 * @see contact_get_from_db()
 * @see calendar_attendee_get_phone_number()
 */
int calendar_event_add_attendee_with_contact(calendar_event_h event, int contact_db_id, calendar_attendee_h* attendee);

/**
 * @brief Removes the attendee from the calendar event handle.
 *
 *
 * @param[in]   event The calendar event handle
 * @param[in]   attendee The attendee handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_add_attendee()
 * @see calendar_event_get_attendee_iterator()
 */
int calendar_event_remove_attendee(calendar_event_h event, calendar_attendee_h attendee);

/**
 * @brief Gets the attendee iterator handle from the event handle.
 *
 * @param[in]   event      The calendar event handle
 * @param[out]  iterator    The attendee iterator handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_attendee_iterator_has_next()
 * @see calendar_attendee_iterator_next()
 *
 */
int calendar_event_get_attendee_iterator(calendar_event_h event, calendar_attendee_iterator_h *iterator);

/**
 * @brief	Gets the last modified time of the event handle.
 *
 * @param[in]   event       The calendar event handle
 * @param[out]  modified_time The last modified time of event \n
 *								The @a modified_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE				Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval  #CALENDAR_ERROR_NO_DATA             Data not found
 *
 * @see calendar_event_insert_to_db()
 * @see calendar_event_update_to_db()
 */
int calendar_event_get_last_modified_time(calendar_event_h event, long long int *modified_time);

/**
 * @brief   Gets the visibility for the given calendar event handle.
 *
 * @param[in]   event   		The calendar event handle
 * @param[out]  visibility	The visibility of the event \n (default : #CALENDAR_VISIBILITY_PUBLIC)
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_visibility()
 */
int calendar_event_get_visibility(calendar_event_h event, calendar_visibility_e *visibility);

/**
 * @brief   Sets the visibility for the given calendar event handle.
 *
 * @param[in]   event   		The calendar event handle
 * @param[in]	visibility		The visibility of the event
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_get_visibility()
 */
int calendar_event_set_visibility(calendar_event_h event, calendar_visibility_e visibility);

/**
 * @brief   Gets the category for the given calendar event handle.
 * @remarks @a categories must be released with free() by you.
 *
 * @param[in]   event   		The calendar event handle
 * @param[out]  categories	    The category of the event \n Multiple categories are seperated by ","
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_categories()
 */
int calendar_event_get_categories(calendar_event_h event, char **categories);

/**
 * @brief   Sets the category for the given calendar event handle.
 *
 * @param[in]   event   		The calendar event handle
 * @param[in]	categories		The category of the event \n Multiple categories are seperated by ","
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_get_categories()
 */
int calendar_event_set_categories(calendar_event_h event, const char *categories);

/**
 * @brief   Gets the status for the given calendar event handle.
 *
 * @param[in]   event	   		The calendar event handle
 * @param[out]  status			The status of the event \n (default : #CALENDAR_EVENT_STATUS_NONE)
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_status()
 */
int calendar_event_get_status(calendar_event_h event, calendar_event_status_e *status);

/**
 * @brief   Sets a status for the given calendar event handle.
 *
 * @param[in]  event   		The calendar event handle
 * @param[in]  status		The status of the event
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_get_status()
 */
int calendar_event_set_status(calendar_event_h event, calendar_event_status_e status);

/**
 * @brief   Gets the busy status for the given calendar event handle.
 *
 * @param[in]   event	   		The calendar event handle
 * @param[out]  busy_status		The busy status of the event \n (default : #CALENDAR_EVENT_BUSY_STATUS_FREE)
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_busy_status()
 */
int calendar_event_get_busy_status(calendar_event_h event, calendar_event_busy_status_e *busy_status);

/**
 * @brief   Sets a busy status for the given calendar event handle.
 *
 * @param[in]  event   		The calendar event handle
 * @param[in]  busy_status		The busy status of the event
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_get_busy_status()
 */
int calendar_event_set_busy_status(calendar_event_h event, calendar_event_busy_status_e busy_status);

/**
 * @brief   Gets the priority for the given calendar event handle.
 *
 * @param[in]   event	   		The calendar event handle
 * @param[out]  priority		The priority of the event \n (default : #CALENDAR_EVENT_PRIORITY_LOW)
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_priority()
 */
int calendar_event_get_priority(calendar_event_h event, calendar_event_priority_e *priority);

/**
 * @brief   Sets a priority for the given calendar event handle.
 *
 * @param[in]  todo   		The calendar event handle
 * @param[in]  priority		The priority of the event
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_get_priority()
 */
int calendar_event_set_priority(calendar_event_h event, calendar_event_priority_e priority);

/**
 * @brief Gets the UID of the event from the calendar event handle.
 *
 * @remarks @a uid must be released with free() by you.
 *
 * @param [in] event The calendar event handle
 * @param [out] uid The UID of the event \n If the uid does not exist, it is NULL
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_set_uid()
 */
int calendar_event_get_uid(calendar_event_h event, char **uid);

/**
 * @brief Sets a UID of the event in the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] uid The UID of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_uid()
 */
int calendar_event_set_uid(calendar_event_h event, const char *uid);

/**
 * @brief   Gets the timezone details for the given calendar event handle.
 *
 * @remark @a timezone_name must be released with free() by you.
 *
 * @param[in]   event   					The calendar event handle
 * @param[out]  timezone_name				The time zone name
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_foreach_timezone()
 * @see calendar_event_set_timezone()
 */
int calendar_event_get_timezone(calendar_event_h event, char** timezone_name);

/**
 * @brief   Sets a timezone for the given calendar event handle.
 *
 * @param[in]   event   					The calendar event handle
 * @param[in]  timezone_name			The time zone name
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_foreach_timezone()
 * @see calendar_event_get_timezone()
 */
int calendar_event_set_timezone(calendar_event_h event, const char* timezone_name);

/**
 * @brief   Gets events as array from vCalendar
 *
 * @remarks     @a event_array must be released with calendar_event_free_event_array() by you.
 *
 * @param[in]   vcalendar_stream        The vCalendar stream to convert
 * @param[out]   event_array				The event array
 * @param[out]   length						The length of the event array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 *
 * @see calendar_event_free_event_array()
 * @see calendar_event_get_vcalendar_from_db()
 */
int calendar_event_get_event_array_from_vcalendar(const char *vcalendar_stream, calendar_event_h **event_array, int *length);

/**
 * @brief   Gets vCalendar with event database ID from the calendar database
 *
 * @remarks @a vcalendar_stream must be released with free() by you.
 *
 * @param[in]   event_db_id_array		The event database ID array
 * @param[in]   length     		  		Length of event database ID array
 * @param[out]  vcalendar_stream           The vCalendar stream to convert
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_connect()
 * @see calendar_event_get_event_array_from_vcalendar()
 */
int calendar_event_get_vcalendar_from_db(int *event_db_id_array, int length, char **vcalendar_stream);

/**
 * @brief Gets information whether an event is recurrence or not.
 *
 * @param [in] event The calendar event handle
 * @param [out] is_recurrence @c true if the event is recurrence event, otherwise @c false \n
 * (default : @c false)
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_set_recurrence_frequency()
 */
int calendar_event_get_is_recurrence(calendar_event_h event, bool *is_recurrence);

/**
 * @brief Gets the recurrence frequency of the event from the calendar event handle.
 *
 * @param[in]   event The calendar event handle
 * @param[out]  recurrence_frequency    The recurrence frequency of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_recurrence_frequency()
 * @see calendar_event_set_recurrence_byday()
 * @see calendar_event_get_recurrence_byday()
 */
int calendar_event_get_recurrence_frequency(calendar_event_h event, calendar_recurrence_frequency_e *recurrence_frequency);

/**
 * @brief Sets a recurrence frequency of the event to the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] recurrence_frequency The recurrence frequency of the event \n
 * If you set it to #CALENDAR_RECURRENCE_WEEKLY, you have to set calendar_event_set_recurrence_byday().
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_recurrence_frequency()
 * @see calendar_event_set_recurrence_byday()
 * @see calendar_event_get_recurrence_byday()
 */
int calendar_event_set_recurrence_frequency(calendar_event_h event, calendar_recurrence_frequency_e recurrence_frequency);

/**
 * @brief Gets the recurrence interval of the event from the calendar event handle.
 *
 * @param[in]   event The calendar event handle
 * @param[out]  recurrence_interval    The recurrence interval of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_recurrence_interval()
 * @see calendar_event_get_recurrence_frequency()
 */
int calendar_event_get_recurrence_interval(calendar_event_h event, int *recurrence_interval);

/**
 * @brief Sets a recurrence interval of the event in the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] recurrence_interval The recurrence interval of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_recurrence_interval()
 * @see calendar_event_set_recurrence_frequency()
 */
int calendar_event_set_recurrence_interval(calendar_event_h event, int recurrence_interval);

/**
 * @brief Gets the recurrence count of the event from the calendar event handle.
 *
 * @param[in]   event The calendar event handle
 * @param[out]  recurrence_count    The recurrence type of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_recurrence_count()
 * @see calendar_event_get_recurrence_frequency()
 */
int calendar_event_get_recurrence_count(calendar_event_h event, int *recurrence_count);

/**
 * @brief Sets a recurrence count of the event to the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] recurrence_count The recurrence count of the event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_recurrence_count()
 * @see calendar_event_set_recurrence_frequency()
 */
int calendar_event_set_recurrence_count(calendar_event_h event, int recurrence_count);

/**
 * @brief Gets the recurrence ending time of the event from the calendar event handle.
 * @details  If recurrence frequency of the event is activated, then @a recurrence_until_date indicates recurrence ending time.
 *
 * @param [in] event The calendar event handle
 * @param [out] recurrence_until_date The ending time of the recurrence event \n
 *								The @a recurrence_until_date is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_NO_DATA				Data not found
 *
 * @see calendar_event_set_recurrence_until_date()
 */
int calendar_event_get_recurrence_until_date(calendar_event_h event, long long int *recurrence_until_date);

/**
 * @brief Sets a recurrence end time of the event in the calendar event handle.
 *
 * @param [in] event The calendar event handle
 * @param [in] recurrence_until_date  The end time of the recurrence event \n
 *								The @a recurrence_until_date is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @pre @a event has a recurrence frequency property using calendar_event_set_recurrence_frequency().
 *
 * @see calendar_event_get_recurrence_until_date()
 */
int calendar_event_set_recurrence_until_date(calendar_event_h event, long long int recurrence_until_date);

/**
 * @brief Gets the recurrence ending date for all day event
 * @details  If recurrence frequency of the event is activated, then @a recurrence_until_date indicates recurrence ending time.
 *
 * @param [in] event				The calendar event handle
 * @param [out] until_year			Year of until date
 * @param [out] until_month			Month of until date
 * @param [out] until_day				Day of until date
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_NO_DATA				Data not found
 *
 * @see calendar_event_set_all_day_recurrence_until_date()
 */
int calendar_event_get_all_day_recurrence_until_date(calendar_event_h event, int *until_year, int *until_month, int *until_day);

/**
 * @brief Sets a recurrence end date for all day event
 *
 * @param [in] event				The calendar event handle
 * @param [in] until_year				Year of until date
 * @param [in] until_month			Month of until date
 * @param [in] until_day				Day of until date
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @pre @a event has a recurrence frequency property using calendar_event_set_recurrence_frequency().
 *
 * @see calendar_event_get_all_day_recurrence_until_date()
 */
int calendar_event_set_all_day_recurrence_until_date(calendar_event_h event, int until_year, int until_month, int until_day);

/**
 * @brief Gets the recurrence frequency of the event from the calendar event handle.
 * @details This rule is "BYDAY" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @remarks @a byday must be released with free() by you.
 *
 * @param[in]   event		The calendar event handle
 * @param[out]  byday		The "BYDAY" of the reccurrence event \n combination of [[-]1~5]MO, TU, WE, TH, FR, SA, SU with ","
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_recurrence_byday()
 * @see calendar_event_set_recurrence_frequency()
 * @see calendar_event_get_recurrence_frequency()
 */
int calendar_event_get_recurrence_byday(calendar_event_h event, char **byday);

/**
 * @brief   Sets the days of week flag to the calendar event handle.
 * @details This rule is "BYDAY" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @param[in]   event	 	The calendar event handle
 * @param[in]   byday    	The "BYDAY" of the reccurrence event \n combination of [[-]1~5]MO, TU, WE, TH, FR, SA, SU with ","
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_get_recurrence_byday()
 * @see calendar_event_set_recurrence_frequency()
 * @see calendar_event_get_recurrence_frequency()
 */
int calendar_event_set_recurrence_byday(calendar_event_h event, const char* byday);

/**
 * @brief Gets the recurrence position flag of the event from the calendar event handle.
 * @details This rule is "BYSETPOS" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @remarks @a bysetpos must be released with free() by you.
 *
 * @param[in]   event The calendar event handle
 * @param[out]  bysetpos    The "BYSETPOS" of the reccurrence event \n combination of 1 to 366 or -366 to -1 with ","
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_recurrence_bysetpos()
 */
int calendar_event_get_recurrence_bysetpos(calendar_event_h event, char **bysetpos);

/**
 * @brief Sets a recurrence position flag of the event to the calendar event handle.
 * @details This rule is "BYSETPOS" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @param[in] event The calendar event handle
 * @param[in] bysetpos		The "BYSETPOS" of the reccurrence event \n combination of 1 to 366 or -366 to -1 with ","
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_get_recurrence_bysetpos()
 */
int calendar_event_set_recurrence_bysetpos(calendar_event_h event, const char* bysetpos);

/**
 * @brief Gets a recurrence BYMONTHDAY of the event to the calendar event handle.
 * @details This rule is "BYMONTHDAY" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @remarks @a bymonthday must be released with free() by you.
 *
 * @param[in] event				The calendar event handle
 * @param[out] bymonthday		The BYMONTHDAY of the reccurrence event \n combination of 1 to 31 or -31 to -1 with ","
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 */
int calendar_event_get_recurrence_bymonthday(calendar_event_h event, char **bymonthday);

/**
 * @brief Sets a recurrence BYMONTHDAY of the event to the calendar event handle.
 * @details This rule is "BYMONTHDAY" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @param[in] event				The calendar event handle
 * @param[in] bymonthday		The BYMONTHDAY of the reccurrence event \n combination of 1 to 31 or -31 to -1 with ","
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 */
int calendar_event_set_recurrence_bymonthday(calendar_event_h event, const char* bymonthday);

/**
 * @brief Gets a recurrence BYMONTH of the event to the calendar event handle.
 * @details This rule is "BYMONTH" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @remarks @a bymonth must be released with free() by you.
 *
 * @param[in] event				The calendar event handle
 * @param[out] bymonth			The BYMONTH of the reccurrence event \n combination of 1 to 12 with ","
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 */
int calendar_event_get_recurrence_bymonth(calendar_event_h event, char** bymonth);

/**
 * @brief Sets a recurrence BYMONTH of the event to the calendar event handle.
 * @details This rule is "BYMONTH" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @param[in] event				The calendar event handle
 * @param[in] bymonth			The BYMONTH of the reccurrence event \n combination of 1 to 12 with ","
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 */
int calendar_event_set_recurrence_bymonth(calendar_event_h event, const char* bymonth);

/**
 * @brief Gets the first day of the week.
 *
 * @param[in]   event			The calendar event handle
 * @param[out]  week_start		The first day of the week for the recurrence
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_set_recurrence_week_start()
 */
int calendar_event_get_recurrence_week_start(calendar_event_h event, calendar_week_flag_e *week_start);

/**
 * @brief   Sets the first day of the week
 *
 * @param[in]   event The calendar event handle
 * @param[in]   week_start    The first day of the week for the recurrence
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_get_recurrence_week_start()
 */
int calendar_event_set_recurrence_week_start(calendar_event_h event, calendar_week_flag_e week_start);

/**
 * @brief Removes the recurrence event instance from the calendar database.
 *
 * @param[in]   event_db_id  The event database ID to delete
 * @param[in]   start_time  The recurrence instance start time to delete
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre	This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see	calendar_event_get_recurrence_exdate()
 */
int calendar_event_delete_recurrence_instance_from_db(int event_db_id, long long int start_time);

/**
 * @brief Removes the recurrence all day event instance from the calendar database.
 *
 * @param[in]   event_db_id		The event database ID to delete
 * @param[in]   year			The year of recurrence all instance
 * @param[in]   month			The month of recurrence all instance
 * @param[in]   day				The day of recurrence all instance
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre	This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see	calendar_event_get_recurrence_exdate()
 */
int calendar_event_delete_recurrence_all_day_instance_from_db(int event_db_id, int year, int month, int day);

/**
 * @brief Gets a recurrence EXDATE of the event to the calendar event handle.
 * @details This rule is "EXDATE" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt
 *
 * @remarks @a exdate must be released with free() by you.
 *
 * @param[in] event				The calendar event handle
 * @param[out] exdate			The EXDATE of the reccurrence event
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_event_delete_recurrence_instance_from_db()
 * @see calendar_event_delete_recurrence_all_day_instance_from_db()
 */
int calendar_event_get_recurrence_exdate(calendar_event_h event, char** exdate);

/**
 * @brief        Frees event array
 *
 * @param[out]   event_array		The event array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_search_event_by_calendar_book()
 */
int calendar_event_free_event_array(calendar_event_h *event_array);

/**
 * @brief        Frees modified event array
 *
 * @param[out]   modified_event_array		The modified event array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_event_search_event_by_version()
 */
int calendar_event_free_modified_event_array(pcalendar_modified_event_s *modified_event_array);

/**
 * @brief       Retrieves all events as array from calendar book
 *
 * @remarks     @a event_array must be released with calendar_event_free_event_array() by you.
 *
 * @param[in]   calendar_book_db_id		 The calendar book database ID to filter \n
 *                       #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[out]   event_array				The event array
 * @param[out]   length						The length of the event array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_event_free_event_array()
 */
int calendar_event_search_event_by_calendar_book(int calendar_book_db_id, calendar_event_h **event_array, int *length);

/**
 * @brief   Retrieves extend event instances within specified time range.
 *
 * @remarks     @a event_array must be released with calendar_event_free_event_array() by you.
 *
 * @param[in]   calendar_book_db_id      The calendar book database ID to filter \n
 *                       #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[in]   period_start_time  The start of the time range\n
 *								The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 * @param[in]   period_end_time    The end of the time range\n
 *								The @a end_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 * @param[out]   event_array				The event array
 * @param[out]   length						The length of the event array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_DB_FAILED           No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_event_free_event_array()
 */
int calendar_event_search_extend_instance_by_period(int calendar_book_db_id,
	long long int period_start_time, long long int period_end_time,
	calendar_event_h **event_array, int *length);

/**
 * @brief   Retrieves all day extend event instances within specified time range.
 *
 * @remarks     @a event_array must be released with calendar_event_free_event_array() by you.
 *
 * @param[in]   calendar_book_db_id      The calendar book database ID to filter \n
 *                       #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[in]   period_start_year		The start year of the time range
 * @param[in]   period_start_month		The start month of the time range
 * @param[in]   period_start_day		The start day of the time range
 * @param[in]   period_end_year			The end year of the time range
 * @param[in]   period_end_month		The end month of the time range
 * @param[in]   period_end_day			The end day of the time range
 * @param[out]   event_array				The event array
 * @param[out]   length						The length of the event array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_DB_FAILED           No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_event_free_event_array()
 */
int calendar_event_search_all_day_extend_instance_by_period(int calendar_book_db_id,
	int period_start_year, int period_start_month, int period_start_day,
	int period_end_year, int period_end_month, int period_end_day,
	calendar_event_h **event_array, int *length);

/**
 * @brief       Retrieves all modified events information as array that have been modified since the given version.
 *
 * @remarks     @a modified_event_array must be released with calendar_event_free_modified_event_array() by you.
 *
 * @param[in]   calendar_book_db_id		 The calendar book database ID to filter \n
 *                       #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[in]   calendar_db_version  The calendar database version
 * @param[out]   modified_event_array		The modified event information array
 * @param[out]   length						The length of the event array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_event_free_modified_event_array()
 */
int calendar_event_search_event_by_version(int calendar_book_db_id, int calendar_db_version, pcalendar_modified_event_s **modified_event_array, int *length);

/**
 * @}
 */



/**
 * @addtogroup CAPI_SOCIAL_CALENDAR_TODO_MODULE
 * @{
 */

/**
 * @brief Creates a handle to calendar to-do.
 * @remarks The calendar to-do handle must be released with calendar_todo_destroy() by you.
 * @remarks   The created handle is not added to calendar database until calendar_todo_insert_to_db() is called
 *
 * @param[out] todo		The new calendar to-do handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 *
 * @see calendar_todo_destroy()
 *
 */
int calendar_todo_create(calendar_todo_h *todo);

/**
 * @brief Destroys the calendar to-do handle
 *
 * @param[in]  todo   The calendar to-do handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_create()
 *
 */
int calendar_todo_destroy(calendar_todo_h todo);

/**
 * @brief Adds the given to-do item to the calendar database.
 *
 * @param[in]   todo		The calendar to-do handle
 * @param[in]   calendar_book_db_id      The calendar book database ID to which the to-do insert. \n
 *                       #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device
 * @param[out]  todo_db_id		The to-do ID to be assigned to the to-do item
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 * @see calendar_todo_delete_from_db()
 * @see calendar_todo_update_to_db()
 *
 */
int calendar_todo_insert_to_db(calendar_todo_h todo, int calendar_book_db_id, int *todo_db_id);

/**
 * @brief Removes the to-do item from the calendar database.
 *
 * @param[in]   todo_id  The to-do ID to delete
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 * @see calendar_todo_insert_to_db()
 * @see calendar_todo_update_to_db()
 */
int calendar_todo_delete_from_db(int todo_id);

/**
 * @brief Updates the to-do item on the calendar database.
 * @details calendar_todo_get_db_id() is called internally to update the to-do item in the calendar database.
 *
 * @param[in]   todo		The calendar to-do handle
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_todo_insert_to_db()
 * @see calendar_todo_delete_from_db()
 * @see calendar_todo_get_from_db()
 * @see calendar_todo_get_db_id()
 */
int calendar_todo_update_to_db(calendar_todo_h todo);

/**
 * @brief Gets the to-do item handle associated with the given to-do DB ID.
 * @details This function gets the new to-do handle with the given to-do database ID from the calendar database.
 * A new calendar to-do handle will be created.
 *
 * @remarks The new to-do handle must be released with calendar_todo_destroy() by you.
 *
 * @param[in]   todo_id			The to-do Database ID
 * @param[out]  todo			The calendar to-do handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE    Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_todo_destroy()
 * @see calendar_todo_get_db_id()
 */
int calendar_todo_get_from_db(int todo_id, calendar_todo_h *todo);

/**
 * @brief   Gets the database ID for the given calendar to-do handle.
 *
 * @param[in]   todo			The calendar to-do handle
 * @param[out]  todo_db_id		The database ID of the to-do item (default : 0) \n
 *  0 means the to-do is not in calendar database
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_insert_to_db()
 * @see calendar_todo_delete_from_db()
 */
int calendar_todo_get_db_id(calendar_todo_h todo, int *todo_db_id);

/**
 * @brief   Gets The calendar book database ID associated with the given calendar to-do handle.
 *
 * @param[in]   todo			The calendar to-do handle
 * @param[out]  calendar_book_db_id	The calendar book database ID fetched from the calendar to-do handle (default : 0)  \n
 * 0 means the to-do is not in calendar database.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_insert_to_db()
 */
int calendar_todo_get_calendar_book_db_id(calendar_todo_h todo, int *calendar_book_db_id);

/**
 * @brief Gets the subject of the to-do from the calendar to-do handle.
 *
 * @remarks @a subject must be released with free() by you.
 *
 * @param [in] todo				The calendar to-do handle
 * @param [out] subject			The subject of the to-do \n If the subject does not exist, it is NULL
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_todo_set_subject()
 */
int calendar_todo_get_subject(calendar_todo_h todo, char **subject);

/**
 * @brief Sets a subject of the to-do handle.
 *
 * @param [in] todo		The calendar to-do handle
 * @param [in] subject	The subject of the to-do
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_todo_get_subject()
 */
int calendar_todo_set_subject(calendar_todo_h todo, const char *subject);

/**
 * @brief Gets description of the to-do from the calendar to-do handle.
 *
 * @remarks @a description must be released with free() by you.
 *
 * @param [in] todo				The calendar to-do handle
 * @param [out] description		The description of the to-do \n If the description does not exist, it is NULL
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_todo_set_description()
 */
int calendar_todo_get_description(calendar_todo_h todo, char **description);

/**
 * @brief Sets a description of the to-do in the calendar to-do handle.
 *
 * @param [in] todo				The calendar to-do handle
 * @param [in] description		The description of the to-do
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_todo_get_description()
 *
 */
int calendar_todo_set_description(calendar_todo_h todo, const char *description);

/**
 * @brief   Gets the priority for the given calendar to-do handle.
 *
 * @param[in]   todo	   		The calendar to-do handle
 * @param[out]  priority			The priority of the to-do
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_set_priority()
 */
int calendar_todo_get_priority(calendar_todo_h todo, calendar_todo_priority_e *priority);

/**
 * @brief   Sets a priority for the given calendar to-do handle.
 *
 * @param[in]  todo   		The calendar to-do handle
 * @param[in]  priority		The priority of the to-do
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_get_priority()
 */
int calendar_todo_set_priority(calendar_todo_h todo, calendar_todo_priority_e priority);

/**
 * @brief   Gets the status for the given calendar to-do handle.
 *
 * @param[in]   todo	   		The calendar to-do handle
 * @param[out]  status			The status of the to-do
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_set_status()
 */
int calendar_todo_get_status(calendar_todo_h todo, calendar_todo_status_e *status);

/**
 * @brief   Sets a status for the given calendar to-do handle.
 *
 * @param[in]   todo   		The calendar to-do handle
 * @param[in]  status		The status of the to-do
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_get_status()
 */
int calendar_todo_set_status(calendar_todo_h todo, calendar_todo_status_e status);

/**
 * @brief   Gets the visibility for the given calendar to-do handle.
 *
 * @param[in]   todo	   		The calendar to-do handle
 * @param[out]  visibility		The visibility of the to-do \n (default : #CALENDAR_VISIBILITY_PUBLIC)
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_set_visibility()
 */
int calendar_todo_get_visibility(calendar_todo_h todo, calendar_visibility_e *visibility);

/**
 * @brief   Sets a visibility for the given calendar to-do handle.
 *
 * @param[in]   todo   		The calendar to-do handle
 * @param[in]  visibility	The visibility of the to-do
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_get_visibility()
 */
int calendar_todo_set_visibility(calendar_todo_h todo, calendar_visibility_e visibility);

/**
 * @brief Gets the location of the to-do from the calendar to-do handle.
 *
 * @remarks @a location must be released with free() by you.
 *
 * @param [in] todo The calendar to-do handle
 * @param [out] location The location of the to-do \n If the location does not exist, it is NULL
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_todo_set_location()
 *
 */
int calendar_todo_get_location(calendar_todo_h todo, char **location);

/**
 * @brief Sets a location of the to-do in the calendar to-do handle.
 *
 * @param [in] todo The calendar to-do handle
 * @param [in] location The location of the to-do
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_todo_get_location()
 */
int calendar_todo_set_location(calendar_todo_h todo, const char *location);

/**
 * @brief	Gets the last modified time of the to-do item.
 *
 * @param[in]   todo       The calendar to-do handle
 * @param[out]  modified_time The last modified time\n
 *								The @a modified_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE				Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CALENDAR_ERROR_NO_DATA             Data not found
 *
 * @see calendar_todo_insert_to_db()
 * @see calendar_todo_update_to_db()
 *
 */
int calendar_todo_get_last_modified_time(calendar_todo_h todo, long long int *modified_time);
/**
 * @brief   Gets the timezone details for the given calendar to-do handle.
 * @remarks @a timezone_name must be released with free() by you.
 *
 * @param[in]   todo   					The calendar to-do handle
 * @param[out]  timezone_name			The time zone name eg. Europe/Paris
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_set_timezone()
 * @see calendar_foreach_timezone()
 */
int calendar_todo_get_timezone(calendar_todo_h todo, char** timezone_name);

/**
 * @brief   Sets the timezone for the given calendar to-do handle.
 *
 * @param[in]   todo   					The calendar to-do handle
 * @param[in]  timezone_name			The timezone name eg. Europe/Paris
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_get_timezone()
 * @see calendar_foreach_timezone()
 */
int calendar_todo_set_timezone(calendar_todo_h todo, const char* timezone_name);

/**
 * @brief Gets the start time of the to-do from the calendar to-do handle.
 *
 * @param [in] todo The calendar to-do handle
 * @param [out] start_time The start date of the to-do\n
 *								The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_NO_DATA Data not found
 *
 * @see calendar_todo_set_start_time()
 */
int calendar_todo_get_start_time(calendar_todo_h todo, long long int *start_time);

/**
 * @brief Sets a start time of the to-do in the calendar to-do handle.
 *
 * @param [in] todo The calendar todo handle
 * @param [in] start_time The start date of the todo\n
 *								The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_todo_get_start_time()
 */
int calendar_todo_set_start_time(calendar_todo_h todo, long long int start_time);

/**
 * @brief Unsets a start time of the to-do in the calendar to-do handle.
 *
 * @param [in] todo The calendar todo handle
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_todo_set_start_time()
 */
int calendar_todo_unset_start_time(calendar_todo_h todo);

/**
 * @brief Gets the due time of the to-do from the calendar to-do handle.
 *
 * @param [in] todo The calendar to-do handle
 * @param [out] due_time The due date of the to-do\n
 *								The @a due_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE					Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #CALENDAR_ERROR_NO_DATA				Data not found
 *
 * @see calendar_todo_set_due_time()
 */
int calendar_todo_get_due_time(calendar_todo_h todo, long long int *due_time);

/**
 * @brief Sets a due time of the to-do in the calendar to-do handle.
 *
 * @param[in]   todo The calendar to-do handle
 * @param[in]   due_time    The due date of the to-do\n
 *								The @a due_time is a unix timestamp since 00:00, Jan 1 1970 UTC.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_get_due_time()
 */
int calendar_todo_set_due_time(calendar_todo_h todo, long long int due_time);

/**
 * @brief Unsets a due time of the to-do in the calendar to-do handle.
 *
 * @param[in]   todo The calendar to-do handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_set_due_time()
 */
int calendar_todo_unset_due_time(calendar_todo_h todo);

/**
 * @brief Gets the total number of to-dos from the calendar book.
 *
 * @param[in]   calendar_book_db_id      The calendar book database ID to filter \n
 *                       #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[in]   todo_priority      The to-do priority(#calendar_todo_priority_e) to filter \n
 *                       Supports "OR"ing of #calendar_todo_priority_e
 * @param[in]   todo_status      The to-do status(#calendar_todo_status_e) to filter \n
 *                       Supports "OR"ing of #calendar_todo_status_e
 * @param[out]  count   The total number of to-dos
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 */
int calendar_todo_get_total_count_from_db(int calendar_book_db_id, int todo_priority, int todo_status, int *count);

/**
 * @brief Gets the total number of to-dos within specified time range from the calendar book.
 *
 * @param[in]   calendar_book_db_id      The calendar book database ID to filter \n
 *                       #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[in]   start_duedate_range  The start of the time range\n
 *								The @a start_duedate_range is a unix timestamp since 00:00, Jan 1 1970 UTC.
 * @param[in]   end_duedate_range    The end of the time range\n
 *								The @a end_duedate_range is a unix timestamp since 00:00, Jan 1 1970 UTC.
 * @param[in]   todo_priority      The to-do priority(#calendar_todo_priority_e) to filter \n
 *                       Supports "OR"ing of #calendar_todo_priority_e
 * @param[in]   todo_status      The to-do status(#calendar_todo_status_e) to filter \n
 *                       Supports "OR"ing of #calendar_todo_status_e
 * @param[out]  count   The total number of to-dos
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 */
int calendar_todo_get_total_count_by_duedate_range(int calendar_book_db_id, long long int start_duedate_range, long long int end_duedate_range, int todo_priority, int todo_status, int *count);

/**
 * @brief        Frees to-do array
 *
 * @param[out]   todo_array		The to-do array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_search_todo_by_calendar_book()
 */
int calendar_todo_free_todo_array(calendar_todo_h *todo_array);

/**
 * @brief        Frees modified to-do array
 *
 * @param[out]   modified_todo_array		The modified to-do array
 * @param[out]   length				The length of the array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_todo_search_todo_by_version()
 */
int calendar_todo_free_modified_todo_array(pcalendar_modified_todo_s *modified_todo_array);

/**
 * @brief       Retrieves all to-dos as array from calendar book
 *
 * @remarks     @a todo_array must be released with calendar_todo_free_todo_array() by you.
 *
 * @param[in]   calendar_book_db_id		 The calendar book database ID to filter \n
 *                       #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[in]   todo_priority      The to-do priority(#calendar_todo_priority_e) to filter \n
 *                       Supports "OR"ing of #calendar_todo_priority_e
 * @param[in]   todo_status      The to-do status(#calendar_todo_status_e) to filter \n
 *                       Supports "OR"ing of #calendar_todo_status_e
 * @param[out]   todo_array				The to-do array
 * @param[out]   length						The length of the to-do array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_todo_free_todo_array()
 */
int calendar_todo_search_todo_by_calendar_book(int calendar_book_db_id, int todo_priority, int todo_status, calendar_todo_h **todo_array, int *length);

/**
 * @brief   Retrieves all calendar to-dos as array within specified time range.
 *
 * @remarks     @a todo_array must be released with calendar_todo_free_todo_array() by you.
 *
 * @param[in]   calendar_book_db_id		 The calendar book database ID to filter \n
 *                       #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[in]   start_duedate_range  The start of the time range\n
 *								The @a start_duedate_range is a unix timestamp since 00:00, Jan 1 1970 UTC.
 * @param[in]   end_duedate_range    The end of the time range\n
 *								The @a end_duedate_range is a unix timestamp since 00:00, Jan 1 1970 UTC.
 * @param[in]   todo_priority      The to-do priority(#calendar_todo_priority_e) to filter \n
 *                       Supports "OR"ing of #calendar_todo_priority_e
 * @param[in]   todo_status      The to-do status(#calendar_todo_status_e) to filter \n
 *                       Supports "OR"ing of #calendar_todo_status_e
 * @param[out]   todo_array				The to-do array
 * @param[out]   length						The length of the todo array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_todo_free_todo_array()
 */
int calendar_todo_search_todo_by_duedate_range(int calendar_book_db_id, long long int start_duedate_range, long long int end_duedate_range, int todo_priority, int todo_status, calendar_todo_h **todo_array, int *length);

/**
 * @brief       Retrieves all modified to-dos information as array that have been modified since the given version.
 *
 * @remarks     @a modified_todo_array must be released with calendar_todo_free_modified_todo_array() by you.
 *
 * @param[in]   calendar_book_db_id		 The calendar book database ID to filter \n
 *                       #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n
 *                       #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device
 * @param[in]   calendar_db_version  The calendar database version
 * @param[out]   modified_todo_array		The modified to-do information array
 * @param[out]   length						The length of the to-do array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_DB_FAILED           Database operation failure
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_todo_free_modified_todo_array()
 */
int calendar_todo_search_todo_by_version(int calendar_book_db_id, int calendar_db_version, pcalendar_modified_todo_s **modified_todo_array, int *length);

/**
 * @}
 */

/**
 * @addtogroup CAPI_SOCIAL_CALENDAR_MULTIPLECALENDAR_MODULE
 * @{
 */

/**
 * @brief Creates a handle to the calendar book.
 * @remarks The calendar book handle must be released with calendar_book_destroy() by you.
 * @remarks   The created handle is not added to calendar database until calendar_insert_to_db() is called
 *
 * @param[out] calendar_book A new handle to calendar book
 *
 * @return   0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 *
 * @see calendar_book_destroy()
 *
 */
int calendar_book_create(calendar_book_h *calendar_book);

/**
 * @brief Destroys the calendar book handle and releases all its resources.
 *
 * @param[out]  calendar_book   The calendar book handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_book_get_from_db()
 */
int calendar_book_destroy(calendar_book_h calendar_book);

/**
 * @brief Gets the calendar book from the calendar database.
 * @details This function gets the new calendar book handle with the given calendar book database ID from the calendar database. \n
 * The new calendar book handle will be created.
 *
 * @remarks The created calendar book handle must be released with calendar_book_destroy() by you.
 *
 * @param[in]   calendar_book_db_id		The calendar book database ID
 * @param[out]  calendar_book			The calendar book handle associated with The calendar book database ID
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE  Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_book_destroy()
 */
int calendar_book_get_from_db(int calendar_book_db_id, calendar_book_h *calendar_book);

/**
 * @brief Adds a calendar book to the calendar database.
 *
 * @param[in]	calendar_book               The calendar book handle
 * @param[out]	calendar_book_db_id         The calendar book database ID associated with the calendar book \n
 * If the function fails, it is -1.
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_book_delete_from_db()
 */
int calendar_book_insert_to_db(calendar_book_h calendar_book, int *calendar_book_db_id);

/**
 * @brief Updates a calendar book to the calendar database.
 *
 * @param[in]	calendar_book               The calendar book handle
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_book_connect()
 */
int calendar_book_update_to_db(calendar_book_h calendar_book);

/**
 * @brief Removes the calendar book from the calendar database.
 *
 * @param[in]   calendar_book_db_id  The calendar book database ID to delete
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre	This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 */
int calendar_book_delete_from_db(int calendar_book_db_id);

/**
 * @brief Removes the calendar books, events and to-dos from the calendar database.
 *
 * @param[in]   account_db_id  The account database ID to filter
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_DB_FAILED No access to database
 *
 * @pre	This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 */
int calendar_book_delete_all_by_account(int account_db_id);

/**
 * @brief   Gets the calendar book database ID associated with the given calendar book handle.
 *
 * @param[in]   calendar_book		The calendar book handle
 * @param[out]  calendar_book_db_id	The calendar book database ID fetched from the calendar book handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_book_get_from_db()
 */
int calendar_book_get_db_id(calendar_book_h calendar_book, int *calendar_book_db_id);

/**
 * @brief   Sets the calendar book type associated with the given calendar book handle.
 *
 * @param[in] calendar_book		The calendar book handle
 * @param[in] calendar_book_type	The calendar book type. \n Supports "OR"ing of #calendar_book_type_e
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_book_get_type()
 */
int calendar_book_set_type(calendar_book_h calendar_book, int calendar_book_type);

/**
 * @brief   Gets the calendar book type associated with the given calendar book handle.
 *
 * @param[in]  calendar_book			The calendar book handle
 * @param[out] calendar_book_type	The calendar book type. \n Supports "OR"ing of #calendar_book_type_e
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_book_set_type()
 */
int calendar_book_get_type(calendar_book_h calendar_book, int *calendar_book_type);

/**
 * @brief Gets the status whether the calendar book is default calendar book is or not in the device.
 *
 * @param [in] calendar_book			The calendar book handle
 * @param [out] is_default		@c true if the calendar is the default calendar book in the device @c false \n
 * (default : @c false)
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 */
int calendar_book_get_is_default(calendar_book_h calendar_book, bool *is_default);

/**
 * @brief Sets the name of the calendar from the calendar book handle.
 *
 * @remarks @a calendar_name must be released with free() by you.
 *
 * @param [in] calendar_book			The calendar book handle
 * @param [in] calendar_book_name	The name of the calendar book
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_book_get_name()
 */
int calendar_book_set_name(calendar_book_h calendar_book, const char *calendar_book_name);

/**
 * @brief Gets the name of the calendar book from the calendar book handle.
 *
 * @remarks @a calendar_book_name must be released with free() by you.
 *
 * @param [in] calendar_book			The calendar book handle
 * @param [out] calendar_book_name	The name of the calendar book \n If the name does not exist, it is NULL
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_book_set_name()
 */
int calendar_book_get_name(calendar_book_h calendar_book, char **calendar_book_name);

/**
 * @brief Sets the visible status of the calendar book handle.
 *
 * @param [in] calendar_book The calendar book handle
 * @param [in] is_visible @c true if the calendar book is visible in the device, otherwise @c false \n
 * (default : @c false)
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_book_get_is_visibile()
 */
int calendar_book_set_is_visible(calendar_book_h calendar_book, bool is_visible);

/**
 * @brief Gets the visible status of the calendar book handle.
 *
 * @param [in] calendar_book The calendar book handle
 * @param [out] is_visible @c true if the calendar book is visible in the device, otherwise @c false \n
 * (default : @c false)
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_book_set_is_visibile()
 */
int calendar_book_get_is_visible(calendar_book_h calendar_book, bool *is_visible);

/**
 * @brief Sets the color of the calendar book from the calendar book handle.
 *
 * @param [in] calendar_book The calendar book handle
 * @param [in] red		The calendar book color which represents red among RGB
 * @param [in] green	The calendar book color which represents green among RGB
 * @param [in] blue		The calendar book color which represents blue among RGB
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_book_get_color()
 * @see calendar_book_unset_color()
 */
int calendar_book_set_color(calendar_book_h calendar_book, unsigned char red, unsigned char green, unsigned char blue);

/**
 * @brief Unsets the color of the calendar book from the calendar book handle.
 *
 * @param [in] calendar_book The calendar book handle
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 *
 * @see calendar_book_set_color()
 */
int calendar_book_unset_color(calendar_book_h calendar_book);

/**
 * @brief Gets the color of the calendar book from the calendar book handle.
 *
 * @remarks returns @a CALENDAR_ERROR_NO_DATA means calendar book color is not valid
 *
 * @param [in] calendar_book The calendar book handle
 * @param [out] red		The calendar book color which represents red among RGB
 * @param [out] green	The calendar book color which represents green among RGB
 * @param [out] blue	The calendar book color which represents blue among RGB
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval #CALENDAR_ERROR_NONE Successful
 * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #CALENDAR_ERROR_NO_DATA				Data not found
 *
 * @see calendar_book_set_color()
 */
int calendar_book_get_color(calendar_book_h calendar_book, unsigned char *red, unsigned char *green, unsigned char *blue);

/**
 * @brief   Sets the account database ID associated with the given calendar book handle.
 *
 * @param[in]  calendar_book	The calendar book handle
 * @param[in]  account_db_id	The account database ID(default : 0) \n
 * 0 means the calendar book is not related to any accounts.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_book_get_account_db_id()
 */
int calendar_book_set_account_db_id(calendar_book_h calendar_book, int account_db_id);

/**
 * @brief   Gets the account database ID associated with the given calendar book handle.
 *
 * @param[in]   calendar_book	The calendar book handle
 * @param[out]  account_db_id	The account database ID(default : 0) \n
 * 0 means the calendar book is not related to any accounts.
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_book_set_account_db_id()
 */
int calendar_book_get_account_db_id(calendar_book_h calendar_book, int *account_db_id);

/**
 * @brief        Frees calendar book array
 *
 * @param[out]   calendar_book_array		The calendar book array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see calendar_book_get_all_calendar_book()
 */
int calendar_book_free_calendar_book_array(calendar_book_h *calendar_book_array);

/**
 * @brief  Retrieves all calendar books as array from database.
 *
 * @remarks     @a calendar_book_array must be released with calendar_book_free_calendar_book_array() by you.
 *
 * @param[out]   calendar_book_array		The calendar book array
 * @param[out]   length						The length of the calendar book array
 *
 * @return	0 on success, otherwise a negative error value.
 * @retval	#CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval	#CALENDAR_ERROR_DB_FAILED			No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_book_free_calendar_book_array()
 */
int calendar_book_get_all_calendar_book(calendar_book_h **calendar_book_array, int *length);

/**
 * @brief  Retrieves calendar books as array with account database ID from database.
 *
 * @remarks     @a calendar_book_array must be released with calendar_book_free_calendar_book_array() by you.
 *
 * @param[in]   account_db_id				The account database ID to filter
 * @param[out]   calendar_book_array		The calendar book array
 * @param[out]   length						The length of the calendar book array
 *
 * @return	0 on success, otherwise a negative error value.
 * @retval	#CALENDAR_ERROR_NONE                Successful
 * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval	#CALENDAR_ERROR_DB_FAILED			No access to database
 *
 * @pre     This function requires an open connection to the calendar service by calendar_connect().
 *
 * @see calendar_connect()
 * @see calendar_book_free_calendar_book_array()
 */
int calendar_book_search_calendar_book_by_account(int account_db_id, calendar_book_h **calendar_book_array, int *length);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif


#endif