[Internal: merge private->RSA , Patch create momanager.db]
[platform/core/system/sync-agent.git] / src / fw-plugins / common-public / vcalendar / src / plugin_interface.c
index bed35d3..7270276 100755 (executable)
@@ -117,8 +117,8 @@ EXPORT_API sync_agent_da_return_e sync_agent_plugin_converter(const void *agent_
        set_timezone(temp_agent_data, temp_service_data);
 
        // 2. "all day" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
-       if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL) {
-               insert_allday_data((char *)agent_data, temp_service_data);
+       if (strstr((char *)agent_data, "\r\n"ALLDAY_PREFIX"SET") != NULL) {
+               set_allday((char *)agent_data, temp_service_data, false);
        }
 
        // 3. add image info : it should be excuted after calendar_vcalendar_parse_to_calendar
@@ -515,8 +515,8 @@ EXPORT_API sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_
                        }
 
                        // 1. "all day" setting : it should be excuted after calendar_vcalendar_parse_to_calendar
-                       if (strstr((char *)temp_agent_data, "\r\nX-ALLDAY:SET") != NULL) {
-                               insert_allday_data((char *)temp_agent_data, temp_old_service_data);
+                       if (strstr((char *)temp_agent_data, "\r\n"ALLDAY_PREFIX"SET") != NULL) {
+                               set_allday((char *)temp_agent_data, temp_old_service_data, false);
                        }
                }
                else if (!strncmp(uri, _calendar_extended_property._uri, strlen(_calendar_extended_property._uri))) {
@@ -570,10 +570,8 @@ EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *serv
 
        calendar_list_h list = NULL;
        calendar_record_h temp_service_data = (calendar_record_h) service_data;
-       calendar_record_h item = (calendar_record_h) temp_service_data;
        calendar_record_h image_item = (calendar_record_h) temp_service_data;
-       calendar_record_h extended_version = NULL;
-       calendar_time_s cal_start_time = { 0, };
+
        sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
        sync_agent_calendar_exdate_t *exdate_struct = NULL;
        int service_ret = CALENDAR_ERROR_NONE;
@@ -583,57 +581,21 @@ EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *serv
 
        _DEBUG_INFO("converter start");
 
-       service_ret = calendar_record_get_caltime(item, _calendar_event.start_time, &cal_start_time);
-       goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_caltime() Fail!: err[%d]", service_ret);
-
        // 1. "all day" setting : it should be excuted before calendar_vcalendar_make_from_records
-       if (cal_start_time.type == CALENDAR_TIME_LOCALTIME) {
-               calendar_record_h extended_allday = NULL;
-               service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_allday);
-               goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_create() Fail!: err[%d]", service_ret);
-
-               service_ret = calendar_record_set_str(extended_allday, _calendar_extended_property.key, "X-ALLDAY");
-               goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
-
-               service_ret = calendar_record_set_str(extended_allday, _calendar_extended_property.value, ":SET");
-               goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
-
-               service_ret = calendar_record_add_child_record(temp_service_data, _calendar_event.extended, extended_allday);
-               goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_add_child_record() Fail!: err[%d]", service_ret);
-       }
+       set_allday(NULL, temp_service_data, true);
 
        // 2. "EXTYPE" setting, '1' means deleted, '2' means updated : it should be excuted before calendar_vcalendar_make_from_records
        exdate_struct = (sync_agent_calendar_exdate_t *)calloc(1, sizeof(sync_agent_calendar_exdate_t));
        goto_if(exdate_struct == NULL, "exdate_struct is NULL");
-
        get_exdate_data(temp_service_data, exdate_struct);
 
        // 3. extended vcalendar version : it should be excuted before calendar_vcalendar_make_from_records
-       service_ret = calendar_record_create(_calendar_extended_property._uri, &extended_version);
-       goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_create() Fail!: err[%d]", service_ret);
-
-       service_ret = calendar_record_set_str(extended_version, _calendar_extended_property.key, "VERSION");
-       goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
-
-       service_ret = calendar_record_set_str(extended_version, _calendar_extended_property.value, ":1.0");
-       goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_set_str() Fail!: err[%d]", service_ret);
-
-       service_ret = calendar_list_create(&list);
-       goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_list_create() Fail!: err[%d]", service_ret);
-
-       service_ret = calendar_list_add(list, extended_version);
-       goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_list_add() Fail!: err[%d]", service_ret);
-
-       service_ret = calendar_list_add(list, temp_service_data);
-       goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_list_add() Fail!: err[%d]", service_ret);
-
-       char *exdate = NULL;
-       service_ret = calendar_record_get_str(temp_service_data, _calendar_event.exdate, &exdate);
-       goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_record_get_str() Fail!: err[%d]", service_ret);
+       list = set_vcalendar_version(temp_service_data);
+       goto_if(list == NULL, "list is NULL");
 
        service_ret = calendar_vcalendar_make_from_records(list, &temp_agent_data);
-       _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
        goto_if(service_ret != CALENDAR_ERROR_NONE, "[vcalendar] calendar_vcalendar_make_from_records() Fail!: err[%d]", service_ret);
+       _DEBUG_INFO("temp_agent_data = %s", temp_agent_data);
 
        //  1. image converting : after calendar_vcalendar_make_from_records
        char *image_path = has_image_export(image_item);
@@ -677,8 +639,8 @@ EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *serv
                }
 
                // 2-2. remove EXTYPE at parent event
-               if (strstr(temp_agent_data, CR_EXTYPE_DELETE_KEYWORD) != NULL) {
-                       temp_agent_data = replace_string(temp_agent_data, CR_EXTYPE_DELETE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000");
+               if (strstr(temp_agent_data, "\r\n"EXTYPE_DELETE_KEYWORD) != NULL) {
+                       temp_agent_data = replace_string(temp_agent_data, "\r\n"EXTYPE_DELETE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000");
                }
 
                // 2-3. remove EXDATE at parent event
@@ -693,24 +655,21 @@ EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *serv
        }
        else if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_UPDATED_PARENT) {
                _DEBUG_INFO("CALENDAR_EXDATE_TYPE_UPDATED_PARENT start");
-               if (strstr(temp_agent_data, CR_EXTYPE_UPDATE_KEYWORD) != NULL) {
-                       temp_agent_data = replace_string(temp_agent_data, CR_EXTYPE_UPDATE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000");
+               if (strstr(temp_agent_data, "\r\n"EXTYPE_UPDATE_KEYWORD) != NULL) {
+                       temp_agent_data = replace_string(temp_agent_data, "\r\n"EXTYPE_UPDATE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000");
                }
        }
        else if (exdate_struct->exdate_type == CALENDAR_EXDATE_TYPE_UPDATED_CHILD) {
                _DEBUG_INFO("CALENDAR_EXDATE_TYPE_UPDATED_CHILD start");
                temp_agent_data = insert_exdate_data(temp_agent_data, exdate_struct, 0);
-               if (strstr(temp_agent_data, CR_EXTYPE_UPDATE_KEYWORD) != NULL) {
-                       temp_agent_data = replace_string(temp_agent_data, CR_EXTYPE_UPDATE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000\r\nX-EXTYPE:2");
+               if (strstr(temp_agent_data, "\r\n"EXTYPE_UPDATE_KEYWORD) != NULL) {
+                       temp_agent_data = replace_string(temp_agent_data, "\r\n"EXTYPE_UPDATE_KEYWORD, "\r\nUID:000000000000000000000000000000000000000000000000\r\nX-EXTYPE:2");
                }
        }
 
 return_part:
        _DEBUG_INFO("return_part");
        ret = _convert_service_error_to_common_error(service_ret);
-       _DEBUG_INFO("ret = %d", ret);
-
-       *agent_data = (void *)temp_agent_data;
 
        if (list != NULL)
                calendar_list_destroy(list, true);
@@ -723,6 +682,7 @@ return_part:
                exdate_struct = NULL;
        }
 
+       *agent_data = (void *)temp_agent_data;
        _DEBUG_INFO("agent_data = %s", *agent_data);
        _EXTERN_FUNC_EXIT;
        return ret;