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.
24 #include "cal_internal.h"
25 #include "cal_typedef.h"
27 #include "cal_record.h"
29 static int _cal_record_updated_info_create(calendar_record_h* out_record);
30 static int _cal_record_updated_info_destroy(calendar_record_h record, bool delete_child);
31 static int _cal_record_updated_info_clone(calendar_record_h record, calendar_record_h* out_record);
32 static int _cal_record_updated_info_get_int(calendar_record_h record, unsigned int property_id, int* out_value);
33 static int _cal_record_updated_info_set_int(calendar_record_h record, unsigned int property_id, int value);
35 cal_record_plugin_cb_s cal_record_updated_info_plugin_cb = {
36 .create = _cal_record_updated_info_create,
37 .destroy = _cal_record_updated_info_destroy,
38 .clone = _cal_record_updated_info_clone,
41 .get_int = _cal_record_updated_info_get_int,
46 .set_int = _cal_record_updated_info_set_int,
50 .add_child_record = NULL,
51 .remove_child_record = NULL,
52 .get_child_record_count = NULL,
53 .get_child_record_at_p = NULL,
54 .clone_child_record_list = NULL
57 static int _cal_record_updated_info_create(calendar_record_h* out_record)
59 cal_updated_info_s *temp = NULL;
60 int ret = CALENDAR_ERROR_NONE;
62 temp = calloc(1, sizeof(cal_updated_info_s));
63 RETVM_IF(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
65 *out_record = (calendar_record_h)temp;
70 static int _cal_record_updated_info_destroy(calendar_record_h record, bool delete_child)
72 int ret = CALENDAR_ERROR_NONE;
74 cal_updated_info_s *temp = (cal_updated_info_s*)(record);
81 static int _cal_record_updated_info_clone(calendar_record_h record, calendar_record_h* out_record)
83 cal_updated_info_s *out_data = NULL;
84 cal_updated_info_s *src_data = NULL;
86 src_data = (cal_updated_info_s*)(record);
88 out_data = calloc(1, sizeof(cal_updated_info_s));
89 RETVM_IF(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
91 CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
93 out_data->type = src_data->type;
94 out_data->id = src_data->id;
95 out_data->calendar_id = src_data->calendar_id;
96 out_data->version = src_data->version;
98 *out_record = (calendar_record_h)out_data;
100 return CALENDAR_ERROR_NONE;
103 static int _cal_record_updated_info_get_int(calendar_record_h record, unsigned int property_id, int* out_value)
105 cal_updated_info_s *rec = (cal_updated_info_s*)(record);
107 switch (property_id) {
108 case CAL_PROPERTY_UPDATED_INFO_ID:
109 *out_value = (rec->id);
111 case CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID:
112 *out_value = (rec->calendar_id);
114 case CAL_PROPERTY_UPDATED_INFO_TYPE:
115 *out_value = (rec->type);
117 case CAL_PROPERTY_UPDATED_INFO_VERSION:
118 *out_value = (rec->version);
121 /* LCOV_EXCL_START */
122 ERR("invalid parameter (property:0x%x)", property_id);
123 return CALENDAR_ERROR_INVALID_PARAMETER;
127 return CALENDAR_ERROR_NONE;
130 static int _cal_record_updated_info_set_int(calendar_record_h record, unsigned int property_id, int value)
132 cal_updated_info_s *rec = (cal_updated_info_s*)(record);
133 switch (property_id) {
134 case CAL_PROPERTY_UPDATED_INFO_ID:
137 case CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID:
138 (rec->calendar_id) = value;
140 case CAL_PROPERTY_UPDATED_INFO_TYPE:
143 case CAL_PROPERTY_UPDATED_INFO_VERSION:
144 (rec->version) = value;
147 /* LCOV_EXCL_START */
148 ERR("invalid parameter (property:0x%x)", property_id);
149 return CALENDAR_ERROR_INVALID_PARAMETER;
153 return CALENDAR_ERROR_NONE;