3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 #include <glib/gprintf.h>
23 #include <calendar2.h>
24 #include <calendar_types2.h>
26 #include "utility/sync_util.h"
27 #include "plugin/data_converter_interface.h"
28 #include "encoding_util.h"
29 #include "in_datastore_info_task.h"
30 #include "vcalendar_string_util.h"
33 #define EXPORT_API __attribute__ ((visibility("default")))
36 #ifndef SYNC_AGENT_LOG
38 #define LOG_TAG "PLUGIN_DC_VCALENDAR"
41 static int _free_obj_field_info(sync_agent_plugin_field_info_s * field_list, int count);
42 static int _set_obj_field_info(sync_agent_plugin_field_info_s ** field_list, int count, vcalendar_field_list_s * input_list);
43 static sync_agent_da_return_e _convert_service_error_to_common_error(calendar_error_e err);
45 EXPORT_API sync_agent_da_return_e sync_agent_plugin_converter(const void *agent_data, void **service_data)
49 retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "agent_data is NULL. FAIL !!!");
51 calendar_list_h calendar_list = NULL;
52 calendar_record_h temp_service_data = NULL;
53 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
54 int service_ret = CALENDAR_ERROR_NONE;
55 const char *temp_agent_data = (const char *)agent_data;
56 char *image_path = has_image_import(temp_agent_data);
57 char *temp_image_path = NULL;
61 _DEBUG_INFO("temp_agent_data= %s", temp_agent_data);
63 // 1. priority converting : it should be excuted before calendar_vcalendar_parse_to_calendar
64 if (strstr(temp_agent_data, "\r\nPRIORITY:") != NULL) {
65 _DEBUG_INFO("priority is founed");
66 temp = strdup(temp_agent_data);
67 temp = replace_priority_data(temp, false);
68 temp_agent_data = temp;
71 // 2. if the vcalendar has until : NONE rrule, then max rrule should be converted : it should be excuted before calendar_vcalendar_parse_to_calendar
72 if (strstr(temp_agent_data, RRULE_KEYWORD) != NULL) {
73 temp = strdup(temp_agent_data);
74 temp_agent_data = replace_max_rrule_data(temp);
78 service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &calendar_list);
79 if (service_ret != CALENDAR_ERROR_NONE) {
80 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
81 ret = _convert_service_error_to_common_error(service_ret);
85 if (calendar_list == NULL) {
86 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_vcalendar_parse_to_calendar() -> temp_service_data is null, err[%d] !!", service_ret);
87 ret = SYNC_AGENT_DA_ERRORS;
91 service_ret = calendar_list_first(calendar_list);
92 if (service_ret != CALENDAR_ERROR_NONE) {
93 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
94 ret = _convert_service_error_to_common_error(service_ret);
100 service_ret = calendar_list_get_current_record_p(calendar_list, &temp_service_data);
101 if ((service_ret != CALENDAR_ERROR_NONE) || (temp_service_data == NULL)) {
102 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
106 service_ret = calendar_record_get_uri_p(temp_service_data, &uri);
107 if (service_ret != CALENDAR_ERROR_NONE) {
108 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
112 if (!strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri))) {
113 _DEBUG_INFO("this is todo");
116 else if (!strncmp(uri, _calendar_extended_property._uri, strlen(_calendar_extended_property._uri))) {
117 _DEBUG_INFO("this is extended");
121 _DEBUG_INFO("%s is wrong uri", uri);
123 } while(calendar_list_next(calendar_list) != CALENDAR_ERROR_NO_DATA);
125 // 1. timezone setting : it should be excuted after calendar_vcalendar_parse_to_calendar
126 service_ret = calendar_record_set_str(temp_service_data, _calendar_todo.start_tzid, "Asia/Seoul");
127 if (service_ret != CALENDAR_ERROR_NONE) {
128 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
129 ret = _convert_service_error_to_common_error(service_ret);
130 /*i think when set return fail then going throw input schedule */
133 service_ret = calendar_record_set_str(temp_service_data, _calendar_todo.due_tzid, "Asia/Seoul");
134 if (service_ret != CALENDAR_ERROR_NONE) {
135 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
136 ret = _convert_service_error_to_common_error(service_ret);
137 /*i think when set return fail then going throw input schedule */
140 // 2. "no due date" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
141 if (strstr((char *)temp_agent_data, MAX_DUE_DATE_KEYWORD) != NULL) {
142 _DEBUG_INFO("no due date setting");
144 calendar_time_s cal_time_end = { 0, };
145 service_ret = calendar_record_get_caltime(temp_service_data, _calendar_todo.due_time, &cal_time_end);
146 if (service_ret != CALENDAR_ERROR_NONE) {
147 _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
148 ret = _convert_service_error_to_common_error(service_ret);
151 cal_time_end.type = CALENDAR_TIME_UTIME;
152 cal_time_end.time.utime = CALENDAR_TODO_NO_DUE_DATE;
153 service_ret = calendar_record_set_caltime(temp_service_data, _calendar_todo.due_time, cal_time_end);
154 if (service_ret != CALENDAR_ERROR_NONE) {
155 _DEBUG_ERROR("calendar_record_set_caltime() Fail: err[%d]", service_ret);
156 ret = _convert_service_error_to_common_error(service_ret);
160 // 3. add image info : it should be excuted after calendar_vcalendar_parse_to_calendar
161 if( image_path != NULL ) {
162 _DEBUG_INFO("image is founded. %s", image_path);
164 ///////////////////////////////////// S Note temporary code ////////////////////////////
165 if (strstr(image_path, "=\r\n") != NULL) {
166 temp_image_path = get_value_by_token(image_path, "/opt/usr/apps/com.samsung.smemo/data/", "=\r\n");
167 _DEBUG_INFO("temp_image_path = %s", temp_image_path);
168 token = (char *)calloc(1000, sizeof(char));
170 _DEBUG_ERROR("token calloc() is failed");
171 ret = SYNC_AGENT_DA_ERRORS;
175 snprintf(token, 1000, "%s=\r\n", temp_image_path);
176 _DEBUG_INFO("token = %s", token);
178 temp = get_value_by_token(image_path, token, ".png");
185 image_path = (char *)calloc(1000, sizeof(char));
186 if (image_path == NULL) {
187 _DEBUG_ERROR("image_path is null");
188 ret = SYNC_AGENT_DA_ERRORS;
192 snprintf(image_path, 1000, "/opt/usr/apps/com.samsung.smemo/data/%s%s.png", temp_image_path, temp);
193 _DEBUG_INFO("image_path = %s", image_path);
195 ///////////////////////////////////// S Note temporary code ////////////////////////////
197 calendar_record_h image_record = NULL;
199 service_ret = calendar_record_create(_calendar_extended_property._uri, &image_record);
200 if (service_ret != CALENDAR_ERROR_NONE) {
201 _DEBUG_ERROR("calendar_record_create() Fail! err[%d]\n", service_ret);
202 ret = _convert_service_error_to_common_error(service_ret);
205 service_ret = calendar_record_set_str(image_record, _calendar_extended_property.key, CALENDAR_IMAGE_KEYWORD_PHOTO);
206 if (service_ret != CALENDAR_ERROR_NONE) {
207 _DEBUG_ERROR("calendar_record_set_str() Fail! err[%d]\n", service_ret);
208 ret = _convert_service_error_to_common_error(service_ret);
211 service_ret = calendar_record_set_str(image_record, _calendar_extended_property.value, image_path);
212 if (service_ret != CALENDAR_ERROR_NONE) {
213 _DEBUG_ERROR("calendar_record_set_str() Fail! err[%d]\n", service_ret);
214 ret = _convert_service_error_to_common_error(service_ret);
217 service_ret = calendar_record_add_child_record(temp_service_data, _calendar_todo.extended, image_record);
218 if (service_ret != CALENDAR_ERROR_NONE) {
219 _DEBUG_ERROR("calendar_record_add_child_record() Fail! err[%d]\n", service_ret);
220 ret = _convert_service_error_to_common_error(service_ret);
224 *service_data = (void *)temp_service_data;
225 _DEBUG_INFO("calendar_vcalendar_parse_to_calendar() Success!\n");
228 _DEBUG_INFO("return part");
230 if (calendar_list != NULL) {
231 service_ret = calendar_list_destroy(calendar_list, false);
232 if (service_ret != CALENDAR_ERROR_NONE) {
233 _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
235 calendar_list = NULL;
241 if (temp_image_path) {
242 free(temp_image_path);
243 temp_image_path = NULL;
258 sync_agent_da_return_e _vtodo_merge_new_to_old(calendar_record_h old_service_data, calendar_record_h new_service_data)
261 retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
262 retvm_if(new_service_data == NULL, SYNC_AGENT_DA_ERRORS, "new_service_data is NULL. FAIL !!!");
265 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
269 service_ret = calendar_record_get_int(new_service_data, _calendar_todo.priority, &priority);
270 if (service_ret != CALENDAR_ERROR_NONE) {
271 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int Fail! err[%d]\n", service_ret);
272 return SYNC_AGENT_DA_ERRORS;
274 _DEBUG_INFO("priority= %d", priority);
276 service_ret = calendar_record_set_int(old_service_data, _calendar_todo.priority, priority);
277 if (service_ret != CALENDAR_ERROR_NONE) {
278 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int() Fail! err[%d]\n", service_ret);
279 return SYNC_AGENT_DA_ERRORS;
283 char *description = 0;
284 service_ret = calendar_record_get_str_p(new_service_data, _calendar_todo.description, &description);
285 if (service_ret != CALENDAR_ERROR_NONE) {
286 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
287 return SYNC_AGENT_DA_ERRORS;
289 _DEBUG_INFO("description = %s", description);
291 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.description, description);
292 if (service_ret != CALENDAR_ERROR_NONE) {
293 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
294 return SYNC_AGENT_DA_ERRORS;
298 calendar_time_s task_time_start = { 0, };
299 service_ret = calendar_record_get_caltime(new_service_data, _calendar_todo.start_time, &task_time_start);
300 if (service_ret != CALENDAR_ERROR_NONE) {
301 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_caltime() Fail! err[%d]\n", service_ret);
302 return SYNC_AGENT_DA_ERRORS;
305 service_ret = calendar_record_set_caltime(old_service_data, _calendar_todo.start_time, task_time_start);
306 if (service_ret != CALENDAR_ERROR_NONE) {
307 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_caltime() Fail! err[%d]\n", service_ret);
308 return SYNC_AGENT_DA_ERRORS;
312 calendar_time_s task_time_end = { 0, };
313 service_ret = calendar_record_get_caltime(new_service_data, _calendar_todo.due_time, &task_time_end);
314 if (service_ret != CALENDAR_ERROR_NONE) {
315 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_caltime() Fail! err[%d]\n", service_ret);
316 return SYNC_AGENT_DA_ERRORS;
319 service_ret = calendar_record_set_caltime(old_service_data, _calendar_todo.due_time, task_time_end);
320 if (service_ret != CALENDAR_ERROR_NONE) {
321 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_caltime() Fail! err[%d]\n", service_ret);
322 return SYNC_AGENT_DA_ERRORS;
327 service_ret = calendar_record_get_str_p(new_service_data, _calendar_todo.summary, &summary);
328 if (service_ret != CALENDAR_ERROR_NONE) {
329 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
330 return SYNC_AGENT_DA_ERRORS;
333 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.summary, summary);
334 if (service_ret != CALENDAR_ERROR_NONE) {
335 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
336 return SYNC_AGENT_DA_ERRORS;
341 service_ret = calendar_record_get_str_p(new_service_data, _calendar_todo.location, &location);
342 if (service_ret != CALENDAR_ERROR_NONE) {
343 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str_p() Fail! err[%d]\n", service_ret);
344 return SYNC_AGENT_DA_ERRORS;
347 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.location, location);
348 if (service_ret != CALENDAR_ERROR_NONE) {
349 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
350 return SYNC_AGENT_DA_ERRORS;
356 calendar_time_s caltime = {0};
358 service_ret = calendar_record_get_int(new_service_data, _calendar_todo.freq, &num);
359 if (service_ret != CALENDAR_ERROR_NONE) {
360 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(freq) Fail! err[%d]\n", service_ret);
361 return SYNC_AGENT_DA_ERRORS;
363 service_ret = calendar_record_set_int(old_service_data, _calendar_todo.freq, num);
364 if (service_ret != CALENDAR_ERROR_NONE) {
365 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(freq) Fail! err[%d]\n", service_ret);
366 return SYNC_AGENT_DA_ERRORS;
369 service_ret = calendar_record_get_int(new_service_data, _calendar_todo.range_type, &num);
370 if (service_ret != CALENDAR_ERROR_NONE) {
371 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(range_type) Fail! err[%d]\n", service_ret);
372 return SYNC_AGENT_DA_ERRORS;
374 service_ret = calendar_record_set_int(old_service_data, _calendar_todo.range_type, num);
375 if (service_ret != CALENDAR_ERROR_NONE) {
376 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(range_type) Fail! err[%d]\n", service_ret);
377 return SYNC_AGENT_DA_ERRORS;
380 service_ret = calendar_record_get_caltime(new_service_data, _calendar_todo.until_time, &caltime);
381 if (service_ret != CALENDAR_ERROR_NONE) {
382 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_caltime(until_time) Fail! err[%d]\n", service_ret);
383 return SYNC_AGENT_DA_ERRORS;
385 service_ret = calendar_record_set_caltime(old_service_data, _calendar_todo.until_time, caltime);
386 if (service_ret != CALENDAR_ERROR_NONE) {
387 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_caltime(until_time) Fail! err[%d]\n", service_ret);
388 return SYNC_AGENT_DA_ERRORS;
391 service_ret = calendar_record_get_int(new_service_data, _calendar_todo.count, &num);
392 if (service_ret != CALENDAR_ERROR_NONE) {
393 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(count) Fail! err[%d]\n", service_ret);
394 return SYNC_AGENT_DA_ERRORS;
396 service_ret = calendar_record_set_int(old_service_data, _calendar_todo.count, num);
397 if (service_ret != CALENDAR_ERROR_NONE) {
398 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(count) Fail! err[%d]\n", service_ret);
399 return SYNC_AGENT_DA_ERRORS;
402 service_ret = calendar_record_get_int(new_service_data, _calendar_todo.interval, &num);
403 if (service_ret != CALENDAR_ERROR_NONE) {
404 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(interval) Fail! err[%d]\n", service_ret);
405 return SYNC_AGENT_DA_ERRORS;
407 service_ret = calendar_record_set_int(old_service_data, _calendar_todo.interval, num);
408 if (service_ret != CALENDAR_ERROR_NONE) {
409 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(interval) Fail! err[%d]\n", service_ret);
410 return SYNC_AGENT_DA_ERRORS;
413 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.bysecond, &text);
414 if (service_ret != CALENDAR_ERROR_NONE) {
415 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(bysecond) Fail! err[%d]\n", service_ret);
416 return SYNC_AGENT_DA_ERRORS;
418 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.bysecond, text);
419 if (service_ret != CALENDAR_ERROR_NONE) {
420 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(bysecond) Fail! err[%d]\n", service_ret);
421 return SYNC_AGENT_DA_ERRORS;
424 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byminute, &text);
425 if (service_ret != CALENDAR_ERROR_NONE) {
426 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byminute) Fail! err[%d]\n", service_ret);
427 return SYNC_AGENT_DA_ERRORS;
429 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byminute, text);
430 if (service_ret != CALENDAR_ERROR_NONE) {
431 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byminute) Fail! err[%d]\n", service_ret);
432 return SYNC_AGENT_DA_ERRORS;
435 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byhour, &text);
436 if (service_ret != CALENDAR_ERROR_NONE) {
437 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byhour) Fail! err[%d]\n", service_ret);
438 return SYNC_AGENT_DA_ERRORS;
440 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byhour, text);
441 if (service_ret != CALENDAR_ERROR_NONE) {
442 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byhour) Fail! err[%d]\n", service_ret);
443 return SYNC_AGENT_DA_ERRORS;
446 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byday, &text);
447 if (service_ret != CALENDAR_ERROR_NONE) {
448 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byday) Fail! err[%d]\n", service_ret);
449 return SYNC_AGENT_DA_ERRORS;
451 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byday, text);
452 if (service_ret != CALENDAR_ERROR_NONE) {
453 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byday) Fail! err[%d]\n", service_ret);
454 return SYNC_AGENT_DA_ERRORS;
457 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.bymonthday, &text);
458 if (service_ret != CALENDAR_ERROR_NONE) {
459 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(bymonthday) Fail! err[%d]\n", service_ret);
460 return SYNC_AGENT_DA_ERRORS;
462 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.bymonthday, text);
463 if (service_ret != CALENDAR_ERROR_NONE) {
464 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(bymonthday) Fail! err[%d]\n", service_ret);
465 return SYNC_AGENT_DA_ERRORS;
468 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byyearday, &text);
469 if (service_ret != CALENDAR_ERROR_NONE) {
470 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byyearday) Fail! err[%d]\n", service_ret);
471 return SYNC_AGENT_DA_ERRORS;
473 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byyearday, text);
474 if (service_ret != CALENDAR_ERROR_NONE) {
475 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byyearday) Fail! err[%d]\n", service_ret);
476 return SYNC_AGENT_DA_ERRORS;
479 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.byweekno, &text);
480 if (service_ret != CALENDAR_ERROR_NONE) {
481 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(byweekno) Fail! err[%d]\n", service_ret);
482 return SYNC_AGENT_DA_ERRORS;
484 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.byweekno, text);
485 if (service_ret != CALENDAR_ERROR_NONE) {
486 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(byweekno) Fail! err[%d]\n", service_ret);
487 return SYNC_AGENT_DA_ERRORS;
490 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.bymonth, &text);
491 if (service_ret != CALENDAR_ERROR_NONE) {
492 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(bymonth) Fail! err[%d]\n", service_ret);
493 return SYNC_AGENT_DA_ERRORS;
495 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.bymonth, text);
496 if (service_ret != CALENDAR_ERROR_NONE) {
497 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(bymonth) Fail! err[%d]\n", service_ret);
498 return SYNC_AGENT_DA_ERRORS;
501 service_ret = calendar_record_get_str(new_service_data, _calendar_todo.bysetpos, &text);
502 if (service_ret != CALENDAR_ERROR_NONE) {
503 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(bysetpos) Fail! err[%d]\n", service_ret);
504 return SYNC_AGENT_DA_ERRORS;
506 service_ret = calendar_record_set_str(old_service_data, _calendar_todo.bysetpos, text);
507 if (service_ret != CALENDAR_ERROR_NONE) {
508 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(bysetpos) Fail! err[%d]\n", service_ret);
509 return SYNC_AGENT_DA_ERRORS;
512 service_ret = calendar_record_get_int(new_service_data, _calendar_todo.wkst, &num);
513 if (service_ret != CALENDAR_ERROR_NONE) {
514 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(wkst) Fail! err[%d]\n", service_ret);
515 return SYNC_AGENT_DA_ERRORS;
517 service_ret = calendar_record_set_int(old_service_data, _calendar_todo.wkst, num);
518 if (service_ret != CALENDAR_ERROR_NONE) {
519 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(wkst) Fail! err[%d]\n", service_ret);
520 return SYNC_AGENT_DA_ERRORS;
524 calendar_record_h new_alarm_record = NULL;
525 calendar_record_h old_alarm_record = NULL;
526 calendar_time_s alarm_time = {0};
527 int new_data_has_alarm = 0;
528 int old_data_has_alarm = 0;
535 service_ret = calendar_record_get_int(new_service_data, _calendar_todo.has_alarm, &new_data_has_alarm);
536 if (service_ret != CALENDAR_ERROR_NONE) {
537 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(has_alarm) Fail! err[%d]\n", service_ret);
538 return SYNC_AGENT_DA_ERRORS;
540 _DEBUG_INFO("new_data_has_alarm = %d", new_data_has_alarm);
542 service_ret = calendar_record_get_int(old_service_data, _calendar_todo.has_alarm, &old_data_has_alarm);
543 if (service_ret != CALENDAR_ERROR_NONE) {
544 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(has_alarm) Fail! err[%d]\n", service_ret);
545 return SYNC_AGENT_DA_ERRORS;
547 _DEBUG_INFO("old_data_has_alarm = %d", old_data_has_alarm);
549 if (new_data_has_alarm == 0 && old_data_has_alarm == 1) {
550 _DEBUG_INFO("alarm record shoud be deleted");
552 service_ret = calendar_record_get_child_record_at_p(old_service_data, _calendar_todo.calendar_alarm, 0, &old_alarm_record);
553 if (service_ret != CALENDAR_ERROR_NONE) {
554 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_child_record_at_p() Fail! err[%d]\n", service_ret);
555 return SYNC_AGENT_DA_ERRORS;
558 service_ret = calendar_record_remove_child_record(old_service_data, _calendar_todo.calendar_alarm, old_alarm_record);
559 if (service_ret != CALENDAR_ERROR_NONE) {
560 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_remove_child_record() Fail! err[%d]\n", service_ret);
561 return SYNC_AGENT_DA_ERRORS;
564 else if (new_data_has_alarm == 1) {
565 service_ret = calendar_record_get_child_record_at_p(new_service_data, _calendar_todo.calendar_alarm, 0, &new_alarm_record);
566 if (service_ret != CALENDAR_ERROR_NONE) {
567 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_child_record_at_p(_calendar_todo.calendar_alarm) Fail! err[%d]\n", service_ret);
568 return SYNC_AGENT_DA_ERRORS;
571 service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.type, &type);
572 if (service_ret != CALENDAR_ERROR_NONE) {
573 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(type) Fail! err[%d]\n", service_ret);
574 return SYNC_AGENT_DA_ERRORS;
577 service_ret = calendar_record_get_lli(new_alarm_record, _calendar_alarm.time, &alarm_time.time.utime);
578 if (service_ret != CALENDAR_ERROR_NONE) {
579 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(time) Fail! err[%d]\n", service_ret);
580 return SYNC_AGENT_DA_ERRORS;
583 service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.tick, &tick);
584 if (service_ret != CALENDAR_ERROR_NONE) {
585 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(tick) Fail! err[%d]\n", service_ret);
586 return SYNC_AGENT_DA_ERRORS;
589 service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.tick_unit, &tick_unit);
590 if (service_ret != CALENDAR_ERROR_NONE) {
591 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(tick_unit) Fail! err[%d]\n", service_ret);
592 return SYNC_AGENT_DA_ERRORS;
595 service_ret = calendar_record_get_str(new_alarm_record, _calendar_alarm.description, &description);
596 if (service_ret != CALENDAR_ERROR_NONE) {
597 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str(description) Fail! err[%d]\n", service_ret);
598 return SYNC_AGENT_DA_ERRORS;
601 service_ret = calendar_record_get_int(new_alarm_record, _calendar_alarm.alarm_id, &alarm_id);
602 if (service_ret != CALENDAR_ERROR_NONE) {
603 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_int(alarm_id) Fail! err[%d]\n", service_ret);
604 return SYNC_AGENT_DA_ERRORS;
607 if (old_data_has_alarm == 0) {
608 _DEBUG_INFO("alarm record should be created");
610 service_ret = calendar_record_create(_calendar_alarm._uri, &old_alarm_record);
611 if (service_ret != CALENDAR_ERROR_NONE) {
612 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_create Fail! err[%d]\n", service_ret);
613 return SYNC_AGENT_DA_ERRORS;
616 else if (old_data_has_alarm == 1) {
617 _DEBUG_INFO("alarm record should be overwrited");
619 service_ret = calendar_record_get_child_record_at_p(old_service_data, _calendar_todo.calendar_alarm, 0, &old_alarm_record);
620 if (service_ret != CALENDAR_ERROR_NONE) {
621 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_child_record_at_p(_calendar_alarm._uri) Fail! err[%d]\n", service_ret);
622 return SYNC_AGENT_DA_ERRORS;
626 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] this is an error. new_data_has_alarm = %d, old_data_has_alarm = %d", new_data_has_alarm, old_data_has_alarm);
627 return SYNC_AGENT_DA_ERRORS;
630 service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.type, type);
631 if (service_ret != CALENDAR_ERROR_NONE) {
632 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(type) Fail! err[%d]\n", service_ret);
633 return SYNC_AGENT_DA_ERRORS;
636 service_ret = calendar_record_set_lli(old_alarm_record, _calendar_alarm.time, alarm_time.time.utime);
637 if (service_ret != CALENDAR_ERROR_NONE) {
638 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_lli(time) Fail! err[%d]\n", service_ret);
639 return SYNC_AGENT_DA_ERRORS;
642 service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.tick, tick);
643 if (service_ret != CALENDAR_ERROR_NONE) {
644 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(tick) Fail! err[%d]\n", service_ret);
645 return SYNC_AGENT_DA_ERRORS;
648 service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.tick_unit, tick_unit);
649 if (service_ret != CALENDAR_ERROR_NONE) {
650 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(tick_unit) Fail! err[%d]\n", service_ret);
651 return SYNC_AGENT_DA_ERRORS;
654 service_ret = calendar_record_set_str(old_alarm_record, _calendar_alarm.description, description);
655 if (service_ret != CALENDAR_ERROR_NONE) {
656 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_str(description) Fail! err[%d]\n", service_ret);
657 return SYNC_AGENT_DA_ERRORS;
660 service_ret = calendar_record_set_int(old_alarm_record, _calendar_alarm.alarm_id, alarm_id);
661 if (service_ret != CALENDAR_ERROR_NONE) {
662 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int(alarm_id) Fail! err[%d]\n", service_ret);
663 return SYNC_AGENT_DA_ERRORS;
666 if (old_data_has_alarm == 0) {
667 _DEBUG_INFO("alarm record should be created - add child rocord(alarm)");
669 service_ret = calendar_record_add_child_record(old_service_data, _calendar_todo.calendar_alarm, old_alarm_record);
670 if (service_ret != CALENDAR_ERROR_NONE) {
671 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_child_record_at_p(_calendar_alarm._uri) Fail! err[%d]\n", service_ret);
672 return SYNC_AGENT_DA_ERRORS;
677 /* image is not supported Outlook sync. So, image field should be not merged (2013/01/14 concept) */
683 EXPORT_API sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_service_data, const void *agent_data, void **new_service_data)
687 retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
688 retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERRORS, "agent_data is NULL. FAIL !!!");
690 calendar_list_h calendar_list = NULL;
691 calendar_record_h temp_new_service_data = NULL;
692 calendar_record_h temp_old_service_data = (calendar_record_h) old_service_data;
693 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
694 int service_ret = CALENDAR_ERROR_NONE;
695 const char *temp_agent_data = (const char *)agent_data;
698 if (temp_agent_data == NULL) {
699 _DEBUG_ERROR("inputed temp_agent_data is null");
700 return SYNC_AGENT_DA_ERRORS;
703 _DEBUG_INFO("temp_agent_data= %s", temp_agent_data);
705 // 1. if the vcalendar has until : NONE rrule, then max rrule should be converted : it should be excuted before calendar_vcalendar_parse_to_calendar
706 if (strstr(temp_agent_data, RRULE_KEYWORD) != NULL) {
707 temp = strdup(temp_agent_data);
708 temp_agent_data = replace_max_rrule_data(temp);
712 // 2. priority converting : it should be excuted before calendar_vcalendar_parse_to_calendar
713 if (strstr(temp_agent_data, "\r\nPRIORITY:") != NULL) {
714 _DEBUG_INFO("priority is founed");
715 temp = strdup(temp_agent_data);
716 temp = replace_priority_data(temp, false);
717 temp_agent_data = temp;
720 _DEBUG_INFO("temp_agent_data= %s", temp_agent_data);
721 service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &calendar_list);
722 if (service_ret != CALENDAR_ERROR_NONE) {
723 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
724 *new_service_data = NULL;
727 _DEBUG_INFO("[dc_vcalendar-task_plugIn] calendar_vcalendar_parse_to_calendar() success!\n");
729 service_ret = calendar_list_first(calendar_list);
730 if (service_ret != CALENDAR_ERROR_NONE) {
731 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
736 calendar_list_get_count(calendar_list, &count);
737 _DEBUG_INFO("count = %d", count);
742 service_ret = calendar_list_get_current_record_p(calendar_list, &temp_new_service_data);
743 if ((service_ret != CALENDAR_ERROR_NONE) || (temp_new_service_data == NULL)) {
744 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
748 service_ret = calendar_record_get_uri_p(temp_new_service_data, &uri);
749 if (service_ret != CALENDAR_ERROR_NONE) {
750 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_uri_p() Fail! : err[%d]", service_ret);
753 _DEBUG_INFO("temp_new_service_data URI = %s", uri);
755 if (!strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri))) {
756 _DEBUG_INFO("this is todo");
757 ret = _vtodo_merge_new_to_old(temp_old_service_data, temp_new_service_data);
758 if (ret != SYNC_AGENT_DA_SUCCESS) {
759 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_set_int() Fail! err[%d]\n", ret);
762 // 1. "no due date" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
763 if (strstr((char *)temp_agent_data, MAX_DUE_DATE_KEYWORD) != NULL) {
764 _DEBUG_INFO("no due date setting");
766 calendar_time_s cal_time_end = { 0, };
767 service_ret = calendar_record_get_caltime(temp_old_service_data, _calendar_todo.due_time, &cal_time_end);
768 if (service_ret != CALENDAR_ERROR_NONE) {
769 _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
770 ret = _convert_service_error_to_common_error(service_ret);
773 cal_time_end.type = CALENDAR_TIME_UTIME;
774 cal_time_end.time.utime = CALENDAR_TODO_NO_DUE_DATE;
775 service_ret = calendar_record_set_caltime(temp_old_service_data, _calendar_todo.due_time, cal_time_end);
776 if (service_ret != CALENDAR_ERROR_NONE) {
777 _DEBUG_ERROR("calendar_record_set_caltime() Fail: err[%d]", service_ret);
778 ret = _convert_service_error_to_common_error(service_ret);
782 else if (!strncmp(uri, _calendar_extended_property._uri, strlen(_calendar_extended_property._uri))) {
783 _DEBUG_INFO("this is extended");
784 ret = calendar_record_get_str(temp_new_service_data, _calendar_extended_property.key, &key);
785 if (service_ret != CALENDAR_ERROR_NONE) {
786 _DEBUG_ERROR("[dc_vcalendar-task_plugIn] calendar_record_get_str() Fail! : err[%d]", service_ret);
789 _DEBUG_INFO("key = %s", key);
790 if (strncmp(key, "VERSION", strlen("VERSION"))) {
791 _DEBUG_INFO("this is extended, not VCALENDAR:VERSION extend");
792 calendar_record_add_child_record(temp_old_service_data, _calendar_todo.extended, temp_new_service_data);
795 } while(calendar_list_next(calendar_list) != CALENDAR_ERROR_NO_DATA);
796 *new_service_data = temp_old_service_data;
799 _DEBUG_INFO("return_part");
800 if (calendar_list != NULL) {
801 service_ret = calendar_list_destroy(calendar_list, false);
802 if (service_ret != CALENDAR_ERROR_NONE) {
803 _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
805 calendar_list = NULL;
807 ret = _convert_service_error_to_common_error(service_ret);
812 EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *service_data, void **agent_data)
816 retvm_if(service_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "service_data is NULL. FAIL !!!");
818 calendar_list_h list = NULL;
819 calendar_record_h temp_service_data = (calendar_record_h) service_data;
820 calendar_record_h image_item = (calendar_record_h) temp_service_data;
821 calendar_record_h extended_version = NULL;
822 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
823 int service_ret = CALENDAR_ERROR_NONE;
824 char *temp_agent_data = NULL;
826 _DEBUG_INFO("converter start");
827 service_ret = calendar_list_create(&list);
828 if (service_ret != CALENDAR_ERROR_NONE) {
829 _DEBUG_ERROR("calendar_list_create() Fail!: err[%d]", service_ret);
830 ret = _convert_service_error_to_common_error(service_ret);
834 // 1. extended vcalendar version : it should be excuted before calendar_vcalendar_make_from_records
835 service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_version);
836 if (service_ret != CALENDAR_ERROR_NONE) {
837 _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
838 ret = SYNC_AGENT_DA_ERRORS;
842 service_ret = calendar_record_set_str(extended_version, _calendar_extended_property.key, "VERSION");
843 if (service_ret != CALENDAR_ERROR_NONE) {
844 _DEBUG_ERROR("calendar_record_set_str() Fail!: err[%d]", service_ret);
845 ret = SYNC_AGENT_DA_ERRORS;
849 service_ret = calendar_record_set_str(extended_version, _calendar_extended_property.value, ":1.0");
850 if (service_ret != CALENDAR_ERROR_NONE) {
851 _DEBUG_ERROR("calendar_record_create() Fail!: err[%d]", service_ret);
852 ret = SYNC_AGENT_DA_ERRORS;
856 service_ret = calendar_list_add(list, extended_version);
857 if (service_ret != CALENDAR_ERROR_NONE || list == NULL) {
858 _DEBUG_ERROR("calendar_list_add() Fail!: err[%d]", service_ret);
859 ret = _convert_service_error_to_common_error(service_ret);
863 service_ret = calendar_list_add(list, temp_service_data);
864 if (service_ret != CALENDAR_ERROR_NONE || list == NULL) {
865 _DEBUG_ERROR("calendar_list_add() Fail!: err[%d]", service_ret);
866 ret = _convert_service_error_to_common_error(service_ret);
870 service_ret = calendar_vcalendar_make_from_records(list, &temp_agent_data);
871 _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
872 if (service_ret != CALENDAR_ERROR_NONE) {
873 _DEBUG_ERROR("calendar_vcalendar_make_from_records() Fail!: err[%d]", service_ret);
874 ret = _convert_service_error_to_common_error(service_ret);
878 // 1. remove 'timezone' : after calendar_vcalendar_make_from_records
879 temp_agent_data = remove_timezone(temp_agent_data);
880 _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
882 // 2. image converting : it should be excuted after calendar_vcalendar_make_from_records
883 char *image_path = has_image_export(image_item);
884 if( image_path != NULL ) {
885 _DEBUG_INFO("image is founded.");
886 temp_agent_data = replace_image_data(temp_agent_data, image_path);
889 // 3. task priority converting : it should be excuted after calendar_vcalendar_make_from_records
890 if (strstr(temp_agent_data, "\r\nPRIORITY:") != NULL) {
891 _DEBUG_INFO("priority is founed");
892 temp_agent_data = replace_priority_data(temp_agent_data, true);
895 // originally, vtodo has not DTSTART, but exceptively DTSTART should be added for alarm time setting at Kies
896 // 4. DTSTART converting : it should be excuted after calendar_vcalendar_make_from_records
897 if (strstr(temp_agent_data, END_VTODO_KEYWORD) != NULL) {
898 temp_agent_data = replace_string(temp_agent_data, END_VTODO_KEYWORD, "\r\nDTSTART:20370101T090000\r\nEND:VTODO\r\n");
901 // originally, "NO DUE DATE" vtodo has not "DUE:xxxxxx", but exceptively DUE should be added for alarm time setting at Kies
902 // 5. DUE converting : it should be excuted after calendar_vcalendar_make_from_records
903 if (strstr(temp_agent_data, DUEDATE_KEYWORD) == NULL) {
904 temp_agent_data = replace_string(temp_agent_data, END_VTODO_KEYWORD, "\r\nDUE:20370101T090000\r\nEND:VTODO\r\n");
908 _DEBUG_INFO("return_part");
909 *agent_data = (void *)temp_agent_data;
912 service_ret = calendar_list_destroy(list, true);
913 if (service_ret != CALENDAR_ERROR_NONE) {
914 _DEBUG_ERROR("calendar_list_destroy() Fail!: err[%d]", service_ret);
915 ret = _convert_service_error_to_common_error(service_ret);
918 _DEBUG_INFO("agent_data = %s", *agent_data);
923 EXPORT_API void *sync_agent_plugin_alloc_object()
926 _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
931 EXPORT_API int sync_agent_plugin_free_object(void *in_object)
934 _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
939 EXPORT_API void *sync_agent_plugin_set_value(void *in_object, int key, char *extension_key, void *value)
942 _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
948 EXPORT_API void *sync_agent_plugin_get_value(void *in_object, int key, char *extension_key)
951 _DEBUG_INFO("[dc_vcalendar-task_plugIn] not implement !!");
956 EXPORT_API sync_agent_plugin_object_info_s *sync_agent_plugin_get_obj_info()
960 sync_agent_plugin_object_info_s *obj_info = (sync_agent_plugin_object_info_s *) calloc(1, sizeof(sync_agent_plugin_object_info_s));
961 if (obj_info == NULL) {
962 _DEBUG_ERROR("CALLOC failed !!!");
966 obj_info->type = VCALENDAR_TYPE;
967 obj_info->version = VCALENDAR_VERSION;
968 obj_info->field_cnt = sizeof(vcalendar_field_list) / sizeof(vcalendar_field_list_s);
970 if (obj_info->field_cnt > 0)
971 if (_set_obj_field_info(&(obj_info->field_list), obj_info->field_cnt, vcalendar_field_list) == 0) {
973 if (obj_info != NULL)
985 EXPORT_API int sync_agent_plugin_free_obj_info(sync_agent_plugin_object_info_s * obj_info)
989 if (obj_info != NULL) {
990 if (obj_info->field_cnt > 0)
991 if (_free_obj_field_info(obj_info->field_list, obj_info->field_cnt) == 0)
1002 static int _free_obj_field_info(sync_agent_plugin_field_info_s * field_list, int count)
1006 int field_count = 0;
1007 sync_agent_plugin_field_info_s *child = NULL;
1009 if (field_list != NULL) {
1010 for (field_count = 0; field_count < count; field_count++) {
1011 child = field_list + field_count;
1012 if (child->field_child_cnt > 0)
1013 if (_free_obj_field_info(child->field_child_list, child->field_child_cnt) == 0)
1024 static int _set_obj_field_info(sync_agent_plugin_field_info_s ** field_list, int count, vcalendar_field_list_s * input_list)
1028 int field_count = 0;
1029 sync_agent_plugin_field_info_s *child = NULL;
1031 *field_list = (sync_agent_plugin_field_info_s *) calloc(count, sizeof(sync_agent_plugin_field_info_s));
1032 if (*field_list == NULL) {
1033 _DEBUG_ERROR("CALLOC failed !!!");
1037 for (field_count = 0; field_count < count; field_count++) {
1038 child = (*field_list) + field_count;
1039 child->field_name = input_list[field_count].field_name;
1040 _DEBUG_TRACE("[%s]", child->field_name);
1042 if (input_list[field_count].field_enum == VCALENDAR_FIELD_BEGIN || input_list[field_count].field_enum == VCALENDAR_FIELD_END) {
1043 child->field_child_cnt = sizeof(vcalendar_field_list_begin_end) / sizeof(vcalendar_field_list_s);
1044 _DEBUG_TRACE("----------");
1045 _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_begin_end);
1046 _DEBUG_TRACE("==========");
1047 } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_VERSION) {
1048 child->field_child_cnt = sizeof(vcalendar_field_list_version) / sizeof(vcalendar_field_list_s);
1049 _DEBUG_TRACE("----------");
1050 _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_version);
1051 _DEBUG_TRACE("==========");
1052 } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_CATEGORIES) {
1053 child->field_child_cnt = sizeof(vcalendar_field_list_categories) / sizeof(vcalendar_field_list_s);
1054 _DEBUG_TRACE("----------");
1055 _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_categories);
1056 _DEBUG_TRACE("==========");
1057 } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_STATUS) {
1058 child->field_child_cnt = sizeof(vcalendar_field_list_status) / sizeof(vcalendar_field_list_s);
1059 _DEBUG_TRACE("----------");
1060 _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_status);
1061 _DEBUG_TRACE("==========");
1070 static sync_agent_da_return_e _convert_service_error_to_common_error(calendar_error_e err)
1074 sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
1075 _DEBUG_TRACE("[da_calendar_plugIn] Error Code : %d\n", err);
1078 case CALENDAR_ERROR_DB_RECORD_NOT_FOUND:
1079 case CALENDAR_ERROR_NO_DATA:
1080 ret = SYNC_AGENT_DA_ERR_NO_DATA;
1082 case CALENDAR_ERROR_OUT_OF_MEMORY:
1083 ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
1085 case CALENDAR_ERROR_INVALID_PARAMETER:
1086 ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
1088 case CALENDAR_ERROR_ITERATOR_END:
1089 case CALENDAR_ERROR_NONE:
1090 ret = SYNC_AGENT_DA_SUCCESS;
1093 * CALENDAR_ERROR_DB_FAILED
1094 * CALENDAR_ERROR_NOW_IN_PROGRESS
1095 * CALENDAR_ERROR_ALREADY_IN_PROGRESS
1096 * CALENDAR_ERROR_NOT_PERMITTED
1099 ret = SYNC_AGENT_DA_ERRORS;