[Non-ACR][calendar-service][TFIVE-14035]
[platform/core/pim/calendar-service.git] / common / cal_record.c
1 /*
2  * Calendar Service
3  *
4  * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20
21 #include <stdlib.h>
22 #include <stdbool.h>
23 #include <string.h>
24
25 #include "cal_internal.h"
26 #include "cal_typedef.h"
27 #include "cal_view.h"
28 #include "cal_record.h"
29
30 #define __CHECK_READ_ONLY_PROPERTY() \
31         if (CAL_PROPERTY_CHECK_FLAGS(property_id, CAL_PROPERTY_FLAGS_READ_ONLY) == true) { \
32                 ERR("Invalid parameter: Don't try to change read-only property."); \
33                 return CALENDAR_ERROR_NOT_PERMITTED; \
34         }
35
36 extern cal_record_plugin_cb_s cal_record_book_plugin_cb;
37 extern cal_record_plugin_cb_s cal_record_event_plugin_cb;
38 extern cal_record_plugin_cb_s cal_record_todo_plugin_cb;
39 extern cal_record_plugin_cb_s cal_record_alarm_plugin_cb;
40 extern cal_record_plugin_cb_s cal_record_attendee_plugin_cb;
41 extern cal_record_plugin_cb_s cal_record_timezone_plugin_cb;
42 extern cal_record_plugin_cb_s cal_record_updated_info_plugin_cb;
43 extern cal_record_plugin_cb_s cal_record_instance_utime_plugin_cb;
44 extern cal_record_plugin_cb_s cal_record_instance_localtime_plugin_cb;
45 extern cal_record_plugin_cb_s cal_record_instance_utime_extended_plugin_cb;
46 extern cal_record_plugin_cb_s cal_record_instance_localtime_extended_plugin_cb;
47 extern cal_record_plugin_cb_s cal_record_search_plugin_cb;
48 extern cal_record_plugin_cb_s cal_record_extended_plugin_cb;
49
50 cal_record_plugin_cb_s* cal_record_get_plugin_cb(cal_record_type_e type)
51 {
52         switch (type) {
53         case CAL_RECORD_TYPE_BOOK:
54                 return (&cal_record_book_plugin_cb);
55         case CAL_RECORD_TYPE_EVENT:
56                 return (&cal_record_event_plugin_cb);
57         case CAL_RECORD_TYPE_TODO:
58                 return (&cal_record_todo_plugin_cb);
59         case CAL_RECORD_TYPE_ALARM:
60                 return (&cal_record_alarm_plugin_cb);
61         case CAL_RECORD_TYPE_ATTENDEE:
62                 return (&cal_record_attendee_plugin_cb);
63         case CAL_RECORD_TYPE_TIMEZONE:
64                 return (&cal_record_timezone_plugin_cb);
65         case CAL_RECORD_TYPE_INSTANCE_UTIME:
66                 return (&cal_record_instance_utime_plugin_cb);
67         case CAL_RECORD_TYPE_INSTANCE_LOCALTIME:
68                 return (&cal_record_instance_localtime_plugin_cb);
69         case CAL_RECORD_TYPE_INSTANCE_UTIME_EXTENDED:
70                 return (&cal_record_instance_utime_extended_plugin_cb);
71         case CAL_RECORD_TYPE_INSTANCE_LOCALTIME_EXTENDED:
72                 return (&cal_record_instance_localtime_extended_plugin_cb);
73         case CAL_RECORD_TYPE_UPDATED_INFO:
74                 return (&cal_record_updated_info_plugin_cb);
75         case CAL_RECORD_TYPE_SEARCH:
76                 return (&cal_record_search_plugin_cb);
77         case CAL_RECORD_TYPE_EXTENDED:
78                 return (&cal_record_extended_plugin_cb);
79         default:
80                 return NULL;
81         }
82 }
83
84 static inline void _cal_record_set_property_flag(calendar_record_h record, unsigned int property_id, cal_properties_flag_e flag)
85 {
86         int index;
87         cal_record_s *_record = NULL;
88
89         _record = (cal_record_s *)record;
90         index = property_id & 0x00000FFF;
91
92         if (NULL == _record->properties_flags) {
93                 int count = 0;
94                 cal_view_get_property_info(_record->view_uri, &count);
95
96                 if (0 < count) {
97                         _record->properties_flags = calloc(count, sizeof(char));
98                         _record->properties_max_count = count;
99                         if (NULL == _record->properties_flags) {
100                                 /* LCOV_EXCL_START */
101                                 ERR("calloc() Fail");
102                                 return ;
103                                 /* LCOV_EXCL_STOP */
104                         }
105                 } else {
106                         /* LCOV_EXCL_START */
107                         ERR("get property_info_Fail");
108                         return ;
109                         /* LCOV_EXCL_STOP */
110                 }
111         }
112
113         _record->properties_flags[index] |= flag;
114         _record->property_flag |= flag;
115 }
116
117 bool cal_record_check_property_flag(calendar_record_h record, unsigned int property_id, cal_properties_flag_e flag)
118 {
119         int index;
120         cal_record_s *_record = NULL;
121
122         _record = (cal_record_s *)record;
123         index = property_id & 0x00000FFF;
124
125         if (NULL == _record->properties_flags) {
126                 if (flag == CAL_PROPERTY_FLAG_PROJECTION)
127                         return true;
128                 else
129                         return false;
130         }
131
132         if (flag == CAL_PROPERTY_FLAG_PROJECTION) {
133                 if (_record->property_flag & CAL_PROPERTY_FLAG_PROJECTION) {
134                         if (_record->properties_flags[index] & CAL_PROPERTY_FLAG_PROJECTION)
135                                 return true;
136                         else
137                                 return false;
138                 }
139
140                 return true;
141         }
142
143         return (_record->properties_flags[index] & flag) ? true : false;
144
145 }
146
147 int cal_record_set_projection(calendar_record_h record, const unsigned int *projection, const int projection_count, int properties_max_count)
148 {
149         int i;
150
151         cal_record_s *_record = NULL;
152
153         RETV_IF(NULL == record, -1);
154
155         _record = (cal_record_s *)record;
156
157         CAL_FREE(_record->properties_flags);
158         _record->properties_flags  = calloc(properties_max_count, sizeof(char));
159
160         RETVM_IF(NULL == _record->properties_flags, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
161
162         _record->properties_max_count = properties_max_count;
163
164         for (i = 0; i < projection_count; i++)
165                 _cal_record_set_property_flag(record, projection[i], CAL_PROPERTY_FLAG_PROJECTION);
166
167         return CALENDAR_ERROR_NONE;
168 }
169
170 EXPORT_API int calendar_record_create(const char* view_uri, calendar_record_h* out_record)
171 {
172         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
173
174         int ret = CALENDAR_ERROR_NONE;
175         cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
176
177         RETV_IF(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER);
178         RETV_IF(NULL == out_record, CALENDAR_ERROR_INVALID_PARAMETER);
179
180 #ifdef CAL_IPC_CLIENT
181         cal_view_initialize();
182 #endif
183         type = cal_view_get_type(view_uri);
184         RETV_IF(CAL_RECORD_TYPE_INVALID == type, CALENDAR_ERROR_INVALID_PARAMETER);
185
186         cal_record_plugin_cb_s *plugin_cb = cal_record_get_plugin_cb(type);
187         RETV_IF(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
188         RETVM_IF(NULL == plugin_cb->create, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted in [%s]", view_uri);
189
190         ret = plugin_cb->create(out_record);
191         if (CALENDAR_ERROR_NONE == ret)
192                 CAL_RECORD_INIT_COMMON((cal_record_s*)*out_record, type, plugin_cb, cal_view_get_uri(view_uri));
193
194         return ret;
195 }
196
197 EXPORT_API int calendar_record_destroy(calendar_record_h record, bool delete_child)
198 {
199         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
200
201         int ret = CALENDAR_ERROR_NONE;
202
203         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
204
205         cal_record_s *temp = (cal_record_s*)(record);
206
207         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
208         RETVM_IF(NULL == temp->plugin_cb->destroy, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted in [%s]", temp->view_uri);
209
210         CAL_FREE(temp->properties_flags);
211
212 #ifdef CAL_IPC_CLIENT
213         cal_view_finalize();
214 #endif
215         ret = temp->plugin_cb->destroy(record, delete_child);
216
217         return ret;
218 }
219
220 EXPORT_API int calendar_record_clone(calendar_record_h record, calendar_record_h* out_record)
221 {
222         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
223
224         int ret = CALENDAR_ERROR_NONE;
225
226         cal_record_s *temp = (cal_record_s*)(record);
227
228         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
229         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
230         RETV_IF(NULL == out_record, CALENDAR_ERROR_INVALID_PARAMETER);
231         RETVM_IF(NULL == temp->plugin_cb->clone, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted in [%s]", temp->view_uri);
232
233 #ifdef CAL_IPC_CLIENT
234         cal_view_initialize();
235 #endif
236         ret = temp->plugin_cb->clone(record, out_record);
237
238         return ret;
239 }
240
241 EXPORT_API int calendar_record_get_uri_p(calendar_record_h record, char** out_str)
242 {
243         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
244
245         int ret = CALENDAR_ERROR_NONE;
246
247         cal_record_s *temp = (cal_record_s*)(record);
248
249         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
250         RETV_IF(NULL == out_str, CALENDAR_ERROR_INVALID_PARAMETER);
251
252         *out_str = (char*)(temp->view_uri);
253
254         return ret;
255 }
256
257 EXPORT_API int calendar_record_get_str(calendar_record_h record, unsigned int property_id, char** out_str)
258 {
259         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
260
261         int ret = CALENDAR_ERROR_NONE;
262
263         cal_record_s *temp = (cal_record_s*)(record);
264
265         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
266         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
267         RETV_IF(NULL == out_str, CALENDAR_ERROR_INVALID_PARAMETER);
268         RETVM_IF(NULL == temp->plugin_cb->get_str, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
269         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
270
271         ret = temp->plugin_cb->get_str(record, property_id, out_str);
272
273         return ret;
274 }
275
276 EXPORT_API int calendar_record_get_str_p(calendar_record_h record, unsigned int property_id, char** out_str)
277 {
278         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
279
280         int ret = CALENDAR_ERROR_NONE;
281
282         cal_record_s *temp = (cal_record_s*)(record);
283
284         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
285         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
286         RETV_IF(NULL == out_str, CALENDAR_ERROR_INVALID_PARAMETER);
287         RETVM_IF(NULL == temp->plugin_cb->get_str_p, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
288         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
289
290         ret = temp->plugin_cb->get_str_p(record, property_id, out_str);
291
292         return ret;
293 }
294
295 EXPORT_API int calendar_record_get_int(calendar_record_h record, unsigned int property_id, int* out_value)
296 {
297         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
298
299         int ret = CALENDAR_ERROR_NONE;
300
301         cal_record_s *temp = (cal_record_s*)(record);
302
303         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
304         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
305         RETV_IF(NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER);
306         RETVM_IF(NULL == temp->plugin_cb->get_int, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
307         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
308
309         ret = temp->plugin_cb->get_int(record, property_id, out_value);
310
311         return ret;
312 }
313
314 EXPORT_API int calendar_record_get_double(calendar_record_h record, unsigned int property_id, double* out_value)
315 {
316         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
317
318         int ret = CALENDAR_ERROR_NONE;
319
320         cal_record_s *temp = (cal_record_s*)(record);
321
322         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
323         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
324         RETV_IF(NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER);
325         RETVM_IF(NULL == temp->plugin_cb->get_double, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
326         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
327
328         ret = temp->plugin_cb->get_double(record, property_id, out_value);
329
330         return ret;
331 }
332
333 EXPORT_API int calendar_record_get_lli(calendar_record_h record, unsigned int property_id, long long int* out_value)
334 {
335         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
336
337         int ret = CALENDAR_ERROR_NONE;
338
339         cal_record_s *temp = (cal_record_s*)(record);
340
341         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
342         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
343         RETV_IF(NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER);
344         RETVM_IF(NULL == temp->plugin_cb->get_lli, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
345         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
346
347         ret = temp->plugin_cb->get_lli(record, property_id, out_value);
348
349         return ret;
350 }
351
352 //Getters & Setters of local caltime
353 EXPORT_API calendar_time_s *cal_caltime_create(void)
354 {
355         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
356         calendar_time_s *caltime = NULL;
357         caltime = calloc(1, sizeof(calendar_time_s));
358         WARN_IF(NULL == caltime, "calloc() Fail");
359
360         return caltime;
361 }
362
363 EXPORT_API void cal_caltime_destroy(calendar_time_s *caltime)
364 {
365         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
366         free(caltime);
367 }
368
369
370 EXPORT_API calendar_time_type_e cal_caltime_get_local_type(calendar_time_s *caltime)
371 {
372         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
373         return caltime->type;
374 }
375
376
377 EXPORT_API int cal_caltime_set_local_type(calendar_time_s *caltime, calendar_time_type_e type)
378 {
379         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
380         RETV_IF(NULL == caltime, CALENDAR_ERROR_INVALID_PARAMETER);
381         caltime->type = type;
382
383         return CALENDAR_ERROR_NONE;
384 }
385
386 EXPORT_API long long int cal_caltime_get_local_utime(calendar_time_s *caltime)
387 {
388         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
389         RETV_IF(CALENDAR_TIME_UTIME != caltime->type, 0);
390
391         return caltime->time.utime;
392 }
393
394 EXPORT_API int cal_caltime_set_local_utime(calendar_time_s *caltime, long long int utime)
395 {
396         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
397         RETV_IF(NULL == caltime, CALENDAR_ERROR_INVALID_PARAMETER);
398         RETV_IF(CALENDAR_TIME_UTIME != caltime->type, CALENDAR_ERROR_INVALID_PARAMETER);
399
400         caltime->time.utime = utime;
401
402         return CALENDAR_ERROR_NONE;
403 }
404
405 EXPORT_API int cal_caltime_get_local_year(calendar_time_s *caltime)
406 {
407         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
408         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, 0);
409
410         return caltime->time.date.year;
411 }
412
413 EXPORT_API int cal_caltime_set_local_year(calendar_time_s *caltime, int year)
414 {
415         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
416         RETV_IF(NULL == caltime, CALENDAR_ERROR_INVALID_PARAMETER);
417         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, CALENDAR_ERROR_INVALID_PARAMETER);
418
419         caltime->time.date.year = year;
420
421         return CALENDAR_ERROR_NONE;
422 }
423
424
425 EXPORT_API int cal_caltime_get_local_month(calendar_time_s *caltime)
426 {
427         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
428         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, 0);
429
430         return caltime->time.date.month;
431 }
432
433 EXPORT_API int cal_caltime_set_local_month(calendar_time_s *caltime, int month)
434 {
435         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
436         RETV_IF(NULL == caltime, CALENDAR_ERROR_INVALID_PARAMETER);
437         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, CALENDAR_ERROR_INVALID_PARAMETER);
438
439         caltime->time.date.year = month;
440
441         return CALENDAR_ERROR_NONE;
442 }
443
444 EXPORT_API int cal_caltime_get_local_mday(calendar_time_s *caltime)
445 {
446         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
447         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, 0);
448
449         return caltime->time.date.mday;
450 }
451
452 EXPORT_API int cal_caltime_set_local_mday(calendar_time_s *caltime, int mday)
453 {
454         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
455         RETV_IF(NULL == caltime, CALENDAR_ERROR_INVALID_PARAMETER);
456         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, CALENDAR_ERROR_INVALID_PARAMETER);
457
458         caltime->time.date.mday = mday;
459
460         return CALENDAR_ERROR_NONE;
461 }
462
463 EXPORT_API int cal_caltime_get_local_hour(calendar_time_s *caltime)
464 {
465         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
466         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, 0);
467
468         return caltime->time.date.hour;
469 }
470
471 EXPORT_API int cal_caltime_set_local_hour(calendar_time_s *caltime, int hour)
472 {
473         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
474         RETV_IF(NULL == caltime, CALENDAR_ERROR_INVALID_PARAMETER);
475         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, CALENDAR_ERROR_INVALID_PARAMETER);
476
477         caltime->time.date.hour = hour;
478
479         return CALENDAR_ERROR_NONE;
480 }
481 EXPORT_API int cal_caltime_get_local_minute(calendar_time_s *caltime)
482 {
483         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
484         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, 0);
485
486         return caltime->time.date.minute;
487 }
488
489 EXPORT_API int cal_caltime_set_local_minute(calendar_time_s *caltime, int minute)
490 {
491         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
492         RETV_IF(NULL == caltime, CALENDAR_ERROR_INVALID_PARAMETER);
493         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, CALENDAR_ERROR_INVALID_PARAMETER);
494
495         caltime->time.date.minute = minute;
496
497         return CALENDAR_ERROR_NONE;
498 }
499
500 EXPORT_API int cal_caltime_get_local_second(calendar_time_s *caltime)
501 {
502         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
503         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, 0);
504
505         return caltime->time.date.second;
506 }
507
508 EXPORT_API int cal_caltime_set_local_second(calendar_time_s *caltime, int second)
509 {
510         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
511         RETV_IF(NULL == caltime, CALENDAR_ERROR_INVALID_PARAMETER);
512         RETV_IF(CALENDAR_TIME_LOCALTIME != caltime->type, CALENDAR_ERROR_INVALID_PARAMETER);
513
514         caltime->time.date.second = second;
515
516         return CALENDAR_ERROR_NONE;
517 }
518
519 EXPORT_API int cal_caltime_set_caltime(calendar_record_h record, unsigned int property_id, calendar_time_s *value)
520 {
521         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
522
523         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
524         __CHECK_READ_ONLY_PROPERTY();
525
526         int ret = cal_record_set_caltime(record, property_id, *value);
527
528         return ret;
529 }
530
531
532
533 EXPORT_API int cal_caltime_get_caltime(calendar_record_h record, unsigned int property_id, calendar_time_s **out_value)
534 {
535         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
536
537         int ret = CALENDAR_ERROR_NONE;
538
539         cal_record_s *temp = (cal_record_s*)(record);
540
541         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
542         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
543         RETV_IF(NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER);
544         RETVM_IF(NULL == temp->plugin_cb->get_caltime, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
545         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
546
547         *out_value = cal_caltime_create();
548         ret = temp->plugin_cb->get_caltime(record, property_id, *out_value);
549
550         return ret;
551 }
552
553 EXPORT_API int calendar_record_get_caltime(calendar_record_h record, unsigned int property_id, calendar_time_s *out_value)
554 {
555         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
556
557         int ret = CALENDAR_ERROR_NONE;
558
559         cal_record_s *temp = (cal_record_s*)(record);
560
561         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
562         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
563         RETV_IF(NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER);
564         RETVM_IF(NULL == temp->plugin_cb->get_caltime, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
565         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
566
567         ret = temp->plugin_cb->get_caltime(record, property_id, out_value);
568
569         return ret;
570 }
571
572 EXPORT_API int calendar_record_set_str(calendar_record_h record, unsigned int property_id, const char* value)
573 {
574         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
575
576         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
577         __CHECK_READ_ONLY_PROPERTY();
578
579         int ret = cal_record_set_str(record, property_id, value);
580
581         return ret;
582 }
583
584 EXPORT_API int calendar_record_set_int(calendar_record_h record, unsigned int property_id, int value)
585 {
586         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
587
588         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
589         __CHECK_READ_ONLY_PROPERTY();
590
591         int ret = cal_record_set_int(record, property_id, value);
592
593         return ret;
594 }
595
596 EXPORT_API int calendar_record_set_double(calendar_record_h record, unsigned int property_id, double value)
597 {
598         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
599
600         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
601         __CHECK_READ_ONLY_PROPERTY();
602
603         int ret = cal_record_set_double(record, property_id, value);
604
605         return ret;
606 }
607
608 EXPORT_API int calendar_record_set_lli(calendar_record_h record, unsigned int property_id, long long int value)
609 {
610         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
611
612         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
613         __CHECK_READ_ONLY_PROPERTY();
614
615         int ret = cal_record_set_lli(record, property_id, value);
616
617         return ret;
618 }
619
620 EXPORT_API int calendar_record_set_caltime(calendar_record_h record, unsigned int property_id, calendar_time_s value)
621 {
622         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
623
624         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
625         __CHECK_READ_ONLY_PROPERTY();
626
627         int ret = cal_record_set_caltime(record, property_id, value);
628
629         return ret;
630 }
631
632 EXPORT_API int calendar_record_add_child_record(calendar_record_h record, unsigned int property_id, calendar_record_h child_record)
633 {
634         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
635
636         int ret = CALENDAR_ERROR_NONE;
637
638         cal_record_s *temp = (cal_record_s*)(record);
639
640         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
641         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
642         RETV_IF(NULL == child_record, CALENDAR_ERROR_INVALID_PARAMETER);
643         RETVM_IF(NULL == temp->plugin_cb->add_child_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
644         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
645
646         ret = temp->plugin_cb->add_child_record(record, property_id, child_record);
647
648         return ret;
649 }
650
651 EXPORT_API int calendar_record_remove_child_record(calendar_record_h record, unsigned int property_id, calendar_record_h child_record)
652 {
653         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
654
655         int ret = CALENDAR_ERROR_NONE;
656
657         cal_record_s *temp = (cal_record_s*)(record);
658
659         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
660         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
661         RETV_IF(NULL == child_record, CALENDAR_ERROR_INVALID_PARAMETER);
662         RETVM_IF(NULL == temp->plugin_cb->remove_child_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
663         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
664
665         ret = temp->plugin_cb->remove_child_record(record, property_id, child_record);
666
667         return ret;
668 }
669
670 EXPORT_API int calendar_record_get_child_record_count(calendar_record_h record, unsigned int property_id, unsigned int* count)
671 {
672         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
673
674         int ret = CALENDAR_ERROR_NONE;
675
676         cal_record_s *temp = (cal_record_s*)(record);
677
678         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
679         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
680         RETV_IF(NULL == count, CALENDAR_ERROR_INVALID_PARAMETER);
681         RETVM_IF(NULL == temp->plugin_cb->get_child_record_count, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
682         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
683
684         ret = temp->plugin_cb->get_child_record_count(record, property_id, count);
685
686         return ret;
687 }
688
689 EXPORT_API int calendar_record_get_child_record_at_p(calendar_record_h record, unsigned int property_id, int index, calendar_record_h* child_record)
690 {
691         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
692
693         int ret = CALENDAR_ERROR_NONE;
694
695         cal_record_s *temp = (cal_record_s*)(record);
696
697         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
698         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
699         RETV_IF(NULL == child_record, CALENDAR_ERROR_INVALID_PARAMETER);
700         RETVM_IF(NULL == temp->plugin_cb->get_child_record_at_p, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
701         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
702
703         ret = temp->plugin_cb->get_child_record_at_p(record, property_id, index, child_record);
704
705         return ret;
706 }
707
708 EXPORT_API int calendar_record_clone_child_record_list(calendar_record_h record, unsigned int property_id, calendar_list_h* out_list)
709 {
710         CHECK_CALENDAR_SUPPORTED(CALENDAR_FEATURE);
711
712         int ret = CALENDAR_ERROR_NONE;
713
714         cal_record_s *temp = (cal_record_s*)(record);
715
716         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
717         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
718         RETV_IF(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER);
719         RETVM_IF(NULL == temp->plugin_cb->clone_child_record_list, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
720         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
721
722         ret = temp->plugin_cb->clone_child_record_list(record, property_id, out_list);
723
724         return ret;
725 }
726
727 int cal_record_set_str(calendar_record_h record, unsigned int property_id, const char* value)
728 {
729         int ret = CALENDAR_ERROR_NONE;
730
731         cal_record_s *temp = (cal_record_s*)(record);
732
733         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
734         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
735         RETVM_IF(NULL == temp->plugin_cb->set_str, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
736         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
737
738         ret = temp->plugin_cb->set_str(record, property_id, value);
739         if (CALENDAR_ERROR_NONE == ret)
740                 _cal_record_set_property_flag(record, property_id, CAL_PROPERTY_FLAG_DIRTY);
741
742         return ret;
743 }
744
745 int cal_record_set_int(calendar_record_h record, unsigned int property_id, int value)
746 {
747         int ret = CALENDAR_ERROR_NONE;
748
749         cal_record_s *temp = (cal_record_s*)(record);
750
751         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
752         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
753         RETVM_IF(NULL == temp->plugin_cb->set_int, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
754         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
755
756         ret = temp->plugin_cb->set_int(record, property_id, value);
757         if (CALENDAR_ERROR_NONE == ret)
758                 _cal_record_set_property_flag(record, property_id, CAL_PROPERTY_FLAG_DIRTY);
759
760         return ret;
761 }
762
763 int cal_record_set_double(calendar_record_h record, unsigned int property_id, double value)
764 {
765         int ret = CALENDAR_ERROR_NONE;
766
767         cal_record_s *temp = (cal_record_s*)(record);
768
769         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
770         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
771         RETVM_IF(NULL == temp->plugin_cb->set_double, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
772         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
773
774         ret = temp->plugin_cb->set_double(record, property_id, value);
775         if (CALENDAR_ERROR_NONE == ret)
776                 _cal_record_set_property_flag(record, property_id, CAL_PROPERTY_FLAG_DIRTY);
777
778         return ret;
779 }
780
781 int cal_record_set_lli(calendar_record_h record, unsigned int property_id, long long int value)
782 {
783         int ret = CALENDAR_ERROR_NONE;
784
785         cal_record_s *temp = (cal_record_s*)(record);
786
787         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
788         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
789         RETVM_IF(NULL == temp->plugin_cb->set_lli, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
790         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
791
792         ret = temp->plugin_cb->set_lli(record, property_id, value);
793         if (CALENDAR_ERROR_NONE == ret)
794                 _cal_record_set_property_flag(record, property_id, CAL_PROPERTY_FLAG_DIRTY);
795
796         return ret;
797 }
798
799 int cal_record_set_caltime(calendar_record_h record, unsigned int property_id, calendar_time_s value)
800 {
801         int ret = CALENDAR_ERROR_NONE;
802
803         cal_record_s *temp = (cal_record_s*)(record);
804
805         RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
806         RETV_IF(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER);
807         RETVM_IF(NULL == temp->plugin_cb->set_caltime, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
808         RETVM_IF(false == cal_record_check_property_flag(record, property_id, CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
809
810         ret = temp->plugin_cb->set_caltime(record, property_id, value);
811         if (CALENDAR_ERROR_NONE == ret)
812                 _cal_record_set_property_flag(record, property_id, CAL_PROPERTY_FLAG_DIRTY);
813
814         return ret;
815 }