4 * Copyright (c) 2012 - 2013 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.
20 #include <stdlib.h> //calloc
21 #include <stdbool.h> //bool
24 #include "cal_internal.h"
25 #include "cal_typedef.h"
28 static int __cal_record_updated_info_create( calendar_record_h* out_record );
29 static int __cal_record_updated_info_destroy( calendar_record_h record, bool delete_child );
30 static int __cal_record_updated_info_clone( calendar_record_h record, calendar_record_h* out_record );
31 static int __cal_record_updated_info_get_int( calendar_record_h record, unsigned int property_id, int* out_value );
32 static int __cal_record_updated_info_set_int( calendar_record_h record, unsigned int property_id, int value );
34 cal_record_plugin_cb_s _cal_record_updated_info_plugin_cb = {
35 .create = __cal_record_updated_info_create,
36 .destroy = __cal_record_updated_info_destroy,
37 .clone = __cal_record_updated_info_clone,
40 .get_int = __cal_record_updated_info_get_int,
45 .set_int = __cal_record_updated_info_set_int,
49 .add_child_record = NULL,
50 .remove_child_record = NULL,
51 .get_child_record_count = NULL,
52 .get_child_record_at_p = NULL,
53 .clone_child_record_list = NULL
56 static int __cal_record_updated_info_create( calendar_record_h* out_record )
58 cal_updated_info_s *temp = NULL;
59 int ret= CALENDAR_ERROR_NONE, type = 0;
61 type = CAL_RECORD_TYPE_UPDATED_INFO;
63 temp = (cal_updated_info_s*)calloc(1,sizeof(cal_updated_info_s));
64 retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_updated_info_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
66 *out_record = (calendar_record_h)temp;
71 static int __cal_record_updated_info_destroy( calendar_record_h record, bool delete_child )
73 int ret = CALENDAR_ERROR_NONE;
75 cal_updated_info_s *temp = (cal_updated_info_s*)(record);
82 static int __cal_record_updated_info_clone( calendar_record_h record, calendar_record_h* out_record )
84 cal_updated_info_s *out_data = NULL;
85 cal_updated_info_s *src_data = NULL;
87 src_data = (cal_updated_info_s*)(record);
89 out_data = calloc(1, sizeof(cal_updated_info_s));
90 retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_updated_info_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
92 CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
94 out_data->type = src_data->type;
95 out_data->id = src_data->id;
96 out_data->calendar_id = src_data->calendar_id;
97 out_data->version = src_data->version;
99 *out_record = (calendar_record_h)out_data;
101 return CALENDAR_ERROR_NONE;
104 static int __cal_record_updated_info_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
106 cal_updated_info_s *rec = (cal_updated_info_s*)(record);
108 switch( property_id )
110 case CAL_PROPERTY_UPDATED_INFO_ID:
111 *out_value = (rec->id);
113 case CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID:
114 *out_value = (rec->calendar_id);
116 case CAL_PROPERTY_UPDATED_INFO_TYPE:
117 *out_value = (rec->type);
119 case CAL_PROPERTY_UPDATED_INFO_VERSION:
120 *out_value = (rec->version);
123 ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
124 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 )
135 case CAL_PROPERTY_UPDATED_INFO_ID:
138 case CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID:
139 (rec->calendar_id) = value;
141 case CAL_PROPERTY_UPDATED_INFO_TYPE:
144 case CAL_PROPERTY_UPDATED_INFO_VERSION:
145 (rec->version) = value;
148 ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
149 return CALENDAR_ERROR_INVALID_PARAMETER;
152 return CALENDAR_ERROR_NONE;