4 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef __CALENDAR_SERVICE_RECORD_H__
20 #define __CALENDAR_SERVICE_RECORD_H__
22 #include "calendar_record.h"
29 CAL_RECORD_TYPE_INVALID = 0,
31 CAL_RECORD_TYPE_EVENT ,
33 CAL_RECORD_TYPE_TIMEZONE,
34 CAL_RECORD_TYPE_ATTENDEE,
35 CAL_RECORD_TYPE_ALARM,
36 CAL_RECORD_TYPE_INSTANCE_UTIME,
37 CAL_RECORD_TYPE_INSTANCE_LOCALTIME,
38 CAL_RECORD_TYPE_INSTANCE_UTIME_EXTENDED,
39 CAL_RECORD_TYPE_INSTANCE_LOCALTIME_EXTENDED,
40 CAL_RECORD_TYPE_UPDATED_INFO,
41 CAL_RECORD_TYPE_SEARCH,
42 CAL_RECORD_TYPE_EXTENDED,
45 typedef int (*cal_record_create_cb)(calendar_record_h* out_record);
46 typedef int (*cal_record_destroy_cb)(calendar_record_h record, bool delete_child);
47 typedef int (*cal_record_clone_cb)(calendar_record_h record, calendar_record_h* out_record);
48 typedef int (*cal_record_get_str_cb)(calendar_record_h record, unsigned int property_id, char** out_str);
49 typedef int (*cal_record_get_str_p_cb)(calendar_record_h record, unsigned int property_id, char** out_str);
50 typedef int (*cal_record_get_int_cb)(calendar_record_h record, unsigned int property_id, int* out_value);
51 typedef int (*cal_record_get_double_cb)(calendar_record_h record, unsigned int property_id, double* out_value);
52 typedef int (*cal_record_get_lli_cb)(calendar_record_h record, unsigned int property_id, long long int* out_value);
53 typedef int (*cal_record_get_caltime_cb)(calendar_record_h record, unsigned int property_id, calendar_time_s* out_value);
54 typedef int (*cal_record_set_str_cb)(calendar_record_h record, unsigned int property_id, const char* value);
55 typedef int (*cal_record_set_int_cb)(calendar_record_h record, unsigned int property_id, int value);
56 typedef int (*cal_record_set_double_cb)(calendar_record_h record, unsigned int property_id, double value);
57 typedef int (*cal_record_set_lli_cb)(calendar_record_h record, unsigned int property_id, long long int value);
58 typedef int (*cal_record_set_caltime_cb)(calendar_record_h record, unsigned int property_id, calendar_time_s value);
59 typedef int (*cal_record_add_child_record_cb)(calendar_record_h record, unsigned int property_id, calendar_record_h child_record);
60 typedef int (*cal_record_remove_child_record_cb)(calendar_record_h record, unsigned int property_id, calendar_record_h child_record);
61 typedef int (*cal_record_get_child_record_count_cb)(calendar_record_h record, unsigned int property_id, unsigned int* count);
62 typedef int (*cal_record_get_child_record_at_p_cb)(calendar_record_h record, unsigned int property_id, int index, calendar_record_h* child_record);
63 typedef int (*cal_record_clone_child_record_list_cb)(calendar_record_h record, unsigned int property_id, calendar_list_h* out_list);
66 CAL_PROPERTY_FLAG_PROJECTION = 0x00000001,
67 CAL_PROPERTY_FLAG_DIRTY = 0x00000002,
68 } cal_properties_flag_e;
71 cal_record_create_cb create;
72 cal_record_destroy_cb destroy;
73 cal_record_clone_cb clone;
74 cal_record_get_str_cb get_str;
75 cal_record_get_str_p_cb get_str_p;
76 cal_record_get_int_cb get_int;
77 cal_record_get_double_cb get_double;
78 cal_record_get_lli_cb get_lli;
79 cal_record_get_caltime_cb get_caltime;
80 cal_record_set_str_cb set_str;
81 cal_record_set_int_cb set_int;
82 cal_record_set_double_cb set_double;
83 cal_record_set_lli_cb set_lli;
84 cal_record_set_caltime_cb set_caltime;
85 cal_record_add_child_record_cb add_child_record;
86 cal_record_remove_child_record_cb remove_child_record;
87 cal_record_get_child_record_count_cb get_child_record_count;
88 cal_record_get_child_record_at_p_cb get_child_record_at_p;
89 cal_record_clone_child_record_list_cb clone_child_record_list;
90 } cal_record_plugin_cb_s;
93 cal_record_type_e type;
94 cal_record_plugin_cb_s *plugin_cb;
96 unsigned int properties_max_count;
97 unsigned char *properties_flags;
98 unsigned char property_flag;
101 #define CAL_RECORD_INIT_COMMON(common, intype, cb, uri) do {\
102 (common)->type = (intype);\
103 (common)->plugin_cb = (cb);\
104 (common)->view_uri = (uri);\
105 (common)->properties_max_count = 0;\
106 (common)->properties_flags = NULL;\
107 (common)->property_flag = 0;\
110 #define CAL_RECORD_COPY_COMMON(dst, src) do {\
111 (dst)->type = (src)->type;\
112 (dst)->plugin_cb = (src)->plugin_cb;\
113 (dst)->view_uri = (src)->view_uri;\
114 (dst)->properties_max_count = (src)->properties_max_count;\
115 if ((src)->properties_flags) {\
116 (dst)->properties_flags = calloc((dst)->properties_max_count, sizeof(char));\
117 if ((dst)->properties_flags)\
118 memcpy((dst)->properties_flags, (src)->properties_flags, sizeof(char)*(dst)->properties_max_count);\
120 (dst)->property_flag = (src)->property_flag;\
123 #define CAL_RECORD_RESET_COMMON(src) do {\
124 if ((src)->properties_flags) {\
125 free((src)->properties_flags); \
126 (src)->properties_max_count = 0;\
127 (src)->properties_flags = NULL;\
128 (src)->property_flag = 0;\
132 cal_record_plugin_cb_s* cal_record_get_plugin_cb(cal_record_type_e type);
134 bool cal_record_check_property_flag(calendar_record_h record, unsigned int property_id, cal_properties_flag_e flag);
135 int cal_record_set_projection(calendar_record_h record, const unsigned int *projection, const int projection_count, int properties_max_count);
137 int cal_record_set_str(calendar_record_h record, unsigned int property_id, const char* value);
138 int cal_record_set_int(calendar_record_h record, unsigned int property_id, int value);
139 int cal_record_set_double(calendar_record_h record, unsigned int property_id, double value);
140 int cal_record_set_lli(calendar_record_h record, unsigned int property_id, long long int value);
141 int cal_record_set_caltime(calendar_record_h record, unsigned int property_id, calendar_time_s value);
147 #endif /* __CALENDAR_SERVICE_RECORD_H__ */