[JIRA:N_SE-30007] Get profilesNum failed.
[framework/system/oma-ds-agent.git] / src / agent / framework / task / oma_ds_engine_controller_task.c
index ba7012d..6aedaa6 100755 (executable)
@@ -43,7 +43,7 @@ static void _free_resource_cp_list(void *list);
 
 static void _request_msg_info_free(request_msg_info_t * info);
 static void *_string_copy_struct(void *string);
-static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int request_id);
+static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int request_id, int profile_id);
 
 static void __free_resource_cp(resource_cp_s * resource);
 
@@ -116,7 +116,7 @@ static void __free_resource_cp(resource_cp_s * resource)
        _INNER_FUNC_EXIT;
 }
 
-static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int request_id)
+static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int request_id, int profile_id)
 {
        _INNER_FUNC_ENTER;
        request_msg_info_t *pInfo = (request_msg_info_t *) calloc(1, sizeof(request_msg_info_t));
@@ -124,6 +124,7 @@ static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int
 
        pInfo->sync_type = sync_type;
        pInfo->request_id = request_id;
+       pInfo->profile_id = profile_id;
 
        _INNER_FUNC_EXIT;
        return pInfo;
@@ -177,35 +178,30 @@ sync_agent_ec_task_spec_s *make_add_profile_task()
 {
        _EXTERN_FUNC_ENTER;
 
-       sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profileDirName", _string_copy_struct, free,
-                                                                                        true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
-                                                                                        true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
-                                                                                        true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
-                                                                                        true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("syncType", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("interval", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_sync_categorie_list,
+       sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_int("syncMode", true, false, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_int("syncType", true, false, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("interval", true, false, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_sync_categorie_list,
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
 
-       sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
-       sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("accountId", false, true, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("accountId", false, true, false, 0, 0, false, 0, false, 0, 0);
 
-       sync_agent_ec_param_spec_s *param_spec_array[11] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
-               pParam_spec6, pParam_spec7, pParam_spec8, pParam_spec9, pParam_spec10, pParam_spec11
+       sync_agent_ec_param_spec_s *param_spec_array[10] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
+               pParam_spec6, pParam_spec7, pParam_spec8, pParam_spec9, pParam_spec10
        };
 
        sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("add_profile",
                                                                                  add_profile_task_process, NULL, NULL,
-                                                                                 11, param_spec_array);
+                                                                                 10, param_spec_array);
 
        sync_agent_unref_param_spec(pParam_spec1);
        sync_agent_unref_param_spec(pParam_spec2);
@@ -217,7 +213,6 @@ sync_agent_ec_task_spec_s *make_add_profile_task()
        sync_agent_unref_param_spec(pParam_spec8);
        sync_agent_unref_param_spec(pParam_spec9);
        sync_agent_unref_param_spec(pParam_spec10);
-       sync_agent_unref_param_spec(pParam_spec11);
 
        _EXTERN_FUNC_EXIT;
        return pTask_spec;
@@ -236,12 +231,9 @@ sync_agent_ec_task_spec_s *make_edit_profile_task()
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
        sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free,
-                                                                                        true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("syncType", _string_copy_struct, free,
-                                                                                        true, false, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("interval", _string_copy_struct, free,
-                                                                                        true, false, false, NULL, false, NULL, false, NULL);
+       sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_int("syncMode", true, false, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("syncType", true, false, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_int("interval", true, false, false, 0, 0, false, 0, false, 0, 0);
        sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_sync_categorie_list,
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
 
@@ -274,19 +266,21 @@ sync_agent_ec_task_spec_s *make_delete_profile_task()
 {
        _EXTERN_FUNC_ENTER;
 
-       sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profiles", NULL, _free_delete_profile_list,
+       sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("profiles", NULL, _free_delete_profile_list,
                                                                                         true, false, false, NULL, false, NULL, false, NULL);
 
-       sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
 
-       sync_agent_ec_param_spec_s *param_spec_array[2] = { pParam_spec1, pParam_spec2 };
+       sync_agent_ec_param_spec_s *param_spec_array[3] = { pParam_spec1, pParam_spec2, pParam_spec3 };
 
        sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("delete_profile",
                                                                                  delete_profile_task_process, NULL, NULL,
-                                                                                 2, param_spec_array);
+                                                                                 3, param_spec_array);
 
        sync_agent_unref_param_spec(pParam_spec1);
        sync_agent_unref_param_spec(pParam_spec2);
+       sync_agent_unref_param_spec(pParam_spec3);
 
        _EXTERN_FUNC_EXIT;
        return pTask_spec;
@@ -297,32 +291,32 @@ sync_agent_ec_task_spec_s *make_get_profile_data_task()
        _EXTERN_FUNC_ENTER;
 
        sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
+
        sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
-       sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
-                                                                                        false, true, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("profile_dir_name", _string_copy_struct, free,
                                                                                         false, true, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("profile_name", _string_copy_struct, free,
                                                                                         false, true, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
                                                                                         false, true, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
                                                                                         false, true, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("syncType", _string_copy_struct, free,
+       sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
                                                                                         false, true, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_structure("interval", _string_copy_struct, free,
-                                                                                        false, true, false, NULL, false, NULL, false, NULL);
-       sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("lastSessionStatus", false, true, false, 0, 0, false, 0, false, 0, 0);
-       sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("lastSessionTime", false, true, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_int("syncMode", false, true, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_int("syncType", false, true, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("interval", false, true, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("lastSessionStatus", false, true, false, 0, 0, false, 0, false, 0, 0);
+       sync_agent_ec_param_spec_s *pParam_spec12 = sync_agent_alloc_param_spec_int("lastSessionTime", false, true, false, 0, 0, false, 0, false, 0, 0);
 
-       sync_agent_ec_param_spec_s *param_spec_array[11] = { pParam_spec1, pParam_spec2, pParam_spec3,
+       sync_agent_ec_param_spec_s *param_spec_array[12] = { pParam_spec1, pParam_spec2, pParam_spec3,
                pParam_spec4, pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8,
-               pParam_spec9, pParam_spec10, pParam_spec11
+               pParam_spec9, pParam_spec10, pParam_spec11, pParam_spec12
        };
 
        sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_data",
                                                                                  get_profile_data_task_process, NULL, NULL,
-                                                                                 11, param_spec_array);
+                                                                                 12, param_spec_array);
 
        sync_agent_unref_param_spec(pParam_spec1);
        sync_agent_unref_param_spec(pParam_spec2);
@@ -335,6 +329,7 @@ sync_agent_ec_task_spec_s *make_get_profile_data_task()
        sync_agent_unref_param_spec(pParam_spec9);
        sync_agent_unref_param_spec(pParam_spec10);
        sync_agent_unref_param_spec(pParam_spec11);
+       sync_agent_unref_param_spec(pParam_spec12);
 
        _EXTERN_FUNC_EXIT;
        return pTask_spec;
@@ -349,8 +344,7 @@ sync_agent_ec_task_spec_s *make_get_profile_sync_category_task()
 
        sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
        sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_int("enabled", false, true, false, 0, 0, false, 0, false, 0, 0);
-       sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("srcURI", _string_copy_struct, free,
-                                                                                        false, true, false, NULL, false, NULL, false, NULL);
+       sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_int("srcURI", false, true, false, 0, 0, false, 0, false, 0, 0);
        sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("tgtURI", _string_copy_struct, free,
                                                                                         false, true, false, NULL, false, NULL, false, NULL);
        sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
@@ -574,39 +568,37 @@ sync_agent_ec_task_error_e add_profile_task_process(unsigned int param_cnt, sync
 
        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
 
-       char *profileDirName = NULL;
        char *profileName = NULL;
        char *addr = NULL;
        char *id = NULL;
        char *password = NULL;
-       char *syncMode = NULL;
-       char *syncType = NULL;
-       char *interval = NULL;
+       int syncMode = 0;
+       int syncType = 0;
+       int interval = 0;
        GList *categories = NULL;
        int accountId;
 
        bool res;
        int result;
 
-       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileDirName);
-       sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
-       sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
-       sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
-       sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
-       sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
-       sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncType);
-       sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &interval);
-       sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
+       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
+       sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
+       sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+       sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+       sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncMode);
+       sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
+       sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
+       sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
 
-       res = add_profile(profileDirName, profileName, addr, id, password, syncMode, syncType, interval, categories, &accountId);
+       res = add_profile(profileName, addr, id, password, syncMode, syncType, interval, categories, &accountId);
        if (res == false) {
                err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
                result = 0;
        } else
                result = 1;
 
-       sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
-       sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+       sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+       sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
 
        /*step 2 : start refresh_from_service for added account */
        void *in_param_value_array[1] = { &accountId };
@@ -625,35 +617,54 @@ sync_agent_ec_task_error_e edit_profile_task_process(unsigned int param_cnt, syn
 
        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
 
-       int accountId;
+       int profile_id = 0;
+       int sync_profile_id = 0;
        char *profileName = NULL;
        char *addr = NULL;
        char *id = NULL;
        char *password = NULL;
-       char *syncMode = NULL;
-       char *syncType = NULL;
-       char *interval = NULL;
+       int syncMode = 0;
+       int syncType = 0;
+       int interval = 0;
        GList *categories = NULL;
 
-       bool res;
-       int result;
+       bool res = false;
+       int result = 0;
 
-       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &profile_id);
        sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
        sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
        sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
        sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
-       sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
-       sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncType);
-       sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &interval);
+       sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncMode);
+       sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
+       sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
        sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
 
-       res = edit_profile(accountId, profileName, addr, id, password, syncMode, syncType, interval, categories);
+       // get sync_profile_id
+       res = get_synchronizing_profile_id(&sync_profile_id);
+
        if (res == false) {
-               err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
-               result = 0;
-       } else
-               result = 1;
+               _DEBUG_INFO("get_synchronizing_profile_id failed!!");
+       }
+
+       _DEBUG_INFO("profile_id: [%d]", profile_id);
+       _DEBUG_INFO("sync_profile_id: [%d]", sync_profile_id);
+
+       if (sync_profile_id != profile_id) {
+               res = edit_profile(profile_id, profileName, addr, id, password, syncMode, syncType, interval, categories);
+               if (res == false) {
+                       err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+                       _DEBUG_INFO("edit_profile failed!!");
+                       result = 0;
+               } else {
+                       _DEBUG_INFO("edit_profile success!!");
+                       result = 1;
+               }
+       } else {
+               _DEBUG_INFO("profile is synchronising!!");
+               result = 2;
+       }
 
        sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
 
@@ -665,21 +676,43 @@ sync_agent_ec_task_error_e delete_profile_task_process(unsigned int param_cnt, s
 {
        _EXTERN_FUNC_ENTER;
 
-       bool res;
-       int result;
+       bool res = false;
+       int result = 0;
        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
 
+       int profile_id = 0;
+       int sync_profile_id = 0;
        GList *profiles = NULL;
-       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles);
 
-       res = delete_profiles(profiles);
-       if (res == 0) {
-               err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
-               result = 0;
-       } else
-               result = 1;
+       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &profile_id);
+       sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles);
 
-       sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+       // get sync_profile_id
+       res = get_synchronizing_profile_id(&sync_profile_id);
+
+       if (res == false) {
+               _DEBUG_INFO("get_synchronizing_profile_id failed!!");
+       }
+
+       _DEBUG_INFO("profile_id: [%d]", profile_id);
+       _DEBUG_INFO("sync_profile_id: [%d]", sync_profile_id);
+
+       if (sync_profile_id != profile_id) {
+               res = delete_profiles(profiles);
+               if (res == 0) {
+                       err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+                       _DEBUG_INFO("delete_profiles failed!!");
+                       result = 0;
+               } else {
+                       _DEBUG_INFO("delete_profiles success!!");
+                       result = 1;
+               }
+       } else {
+               _DEBUG_INFO("profile is synchronising!!");
+               result = 2;
+       }
+
+       sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
 
        _EXTERN_FUNC_EXIT;
        return err;
@@ -693,22 +726,23 @@ sync_agent_ec_task_error_e get_profile_data_task_process(unsigned int param_cnt,
        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
 
        int accountId = 0;
+       char *profile_dir_name = NULL;
        char *profileName = NULL;
        char *addr = NULL;
        char *id = NULL;
        char *password = NULL;
-       char *syncMode = NULL;
-       char *syncType = NULL;
-       char *interval = NULL;
+       int sync_mode = 0;
+       int syncType = 0;
+       int interval = 0;
        int lastSessionStatus;
        int lastSessionTime;
        int result;
        bool res;
 
        sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
-       retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
+       retvm_if(accountId < 1, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
 
-       res = get_profile_data(accountId, &profileName, &addr, &id, &password, &syncMode, &syncType, &interval, &lastSessionStatus, &lastSessionTime);
+       res = get_profile_data(accountId, &profile_dir_name, &profileName, &addr, &id, &password, &sync_mode, &syncType, &interval, &lastSessionStatus, &lastSessionTime);
        if (res == false) {
                err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
                result = 0;
@@ -716,15 +750,16 @@ sync_agent_ec_task_error_e get_profile_data_task_process(unsigned int param_cnt,
                result = 1;
 
        sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
-       sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
-       sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
-       sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
-       sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
-       sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
-       sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncType);
-       sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &interval);
-       sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionStatus);
-       sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionTime);
+       sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profile_dir_name);
+       sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
+       sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
+       sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+       sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+       sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &sync_mode);
+       sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &syncType);
+       sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &interval);
+       sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionStatus);
+       sync_agent_set_param_value(&(param_array[11]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionTime);
 
        _EXTERN_FUNC_EXIT;
        return err;
@@ -741,7 +776,7 @@ sync_agent_ec_task_error_e get_profile_sync_category_task_process(unsigned int p
        int contentType;
 
        int enabled = 0;
-       char *srcURI = NULL;
+       int srcURI = 0;
        char *tgtURI = NULL;
        char *id = NULL;
        char *password = NULL;
@@ -762,7 +797,7 @@ sync_agent_ec_task_error_e get_profile_sync_category_task_process(unsigned int p
 
        sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
        sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &enabled);
-       sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &srcURI);
+       sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &srcURI);
        sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &tgtURI);
        sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
        sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
@@ -948,11 +983,15 @@ sync_agent_ec_task_error_e get_all_profiles_data_task_process(unsigned int param
 
 }
 
-void insert_request_msg_info(int sync_type, unsigned int request_id)
+void insert_request_msg_info(int sync_type, unsigned int request_id, int profile_id)
 {
        _EXTERN_FUNC_ENTER;
 
-       sync_request_id_list = g_list_prepend(sync_request_id_list, _create_request_msg_info(sync_type, request_id));
+       _DEBUG_INFO("sync_type: [%d]", sync_type);
+       _DEBUG_INFO("request_id: [%d]", request_id);
+       _DEBUG_INFO("profile_id: [%d]", profile_id);
+
+       sync_request_id_list = g_list_prepend(sync_request_id_list, _create_request_msg_info(sync_type, request_id, profile_id));
 
        _EXTERN_FUNC_EXIT;
 }
@@ -1006,6 +1045,31 @@ bool get_synchronizing_request_id(unsigned int *pRequest_id)
        return success;
 }
 
+bool get_synchronizing_profile_id(int *pProfile_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool success = false;
+       request_msg_info_t *pMsg_info = NULL;
+       GList *iter = NULL;
+
+       for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
+               pMsg_info = iter->data;
+
+               if (pMsg_info->sync_type == SYNC_MODE_MANUAL || pMsg_info->sync_type == SYNC_MODE_PERIODIC || pMsg_info->sync_type == SYNC_MODE_SAN) {
+                       success = true;
+                       *pProfile_id = pMsg_info->profile_id;
+
+                       sync_request_id_list = g_list_first(sync_request_id_list);
+
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return success;
+}
+
 bool get_manual_sync_request_id(unsigned int *pRequest_id)
 {
        _EXTERN_FUNC_ENTER;