[Internal: web-api issues fixed]
authorsanghyuk Ko <sanghyuk.ko@samsung.com>
Wed, 8 May 2013 06:32:02 +0000 (15:32 +0900)
committersanghyuk Ko <sanghyuk.ko@samsung.com>
Wed, 8 May 2013 06:32:02 +0000 (15:32 +0900)
[Problem]
-
[Cause]
-
[Solution]
- when profile refresh, check account_id validance.
- fixed that interval value check error.
- fixed taht uri value return error.

Change-Id: Iab230400d429017e7596b4f257b86212abab46d8

include/common/common_define_internal.h
src/agent/framework/task/oma_ds_engine_controller_task.c
src/agent/service-engine/se_account.c
src/agent/service-engine/se_sync.c

index 75075e7..7187d27 100755 (executable)
 #define DEFINE_DIVE_SERVER_ID "syn.samsungdive.com"
 #define DEFINE_DIVE_DEFAULT_NEXT_NONCE "pcwds"
 
+#define DEFINE_SYNC_INTERVAL_NONE_STR "None"
 #define DEFINE_SYNC_INTERVAL_5_MINUTES_STR "5 minutes"
 #define DEFINE_SYNC_INTERVAL_15_MINUTES_STR "15 minutes"
 #define DEFINE_SYNC_INTERVAL_1_HOUR_STR "1 hour"
index 6aedaa6..a68bee5 100755 (executable)
@@ -576,10 +576,10 @@ sync_agent_ec_task_error_e add_profile_task_process(unsigned int param_cnt, sync
        int syncType = 0;
        int interval = 0;
        GList *categories = NULL;
-       int accountId;
+       int accountId = 0;
 
-       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_STRUCT, &profileName);
        sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
@@ -593,19 +593,24 @@ sync_agent_ec_task_error_e add_profile_task_process(unsigned int param_cnt, sync
        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;
+               _DEBUG_ERROR("add_profile failed!!");
 
-       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);
+               result = 0;
+               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);
+       } else {
 
-       /*step 2 : start refresh_from_service for added account */
-       void *in_param_value_array[1] = { &accountId };
-       int in_param_index_array[1] = { 0 };
-       sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_INT };
-       unsigned int request_msg_id = 0;
-       sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, NULL, NULL, (int *)&request_msg_id);
+               result = 1;
+               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 };
+               int in_param_index_array[1] = { 0 };
+               sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_INT };
+               unsigned int request_msg_id = 0;
+               sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, NULL, NULL, (int *)&request_msg_id);
+       }
 
        _EXTERN_FUNC_EXIT;
        return err;
@@ -655,7 +660,7 @@ sync_agent_ec_task_error_e edit_profile_task_process(unsigned int param_cnt, syn
                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!!");
+                       _DEBUG_ERROR("edit_profile failed!!");
                        result = 0;
                } else {
                        _DEBUG_INFO("edit_profile success!!");
@@ -701,7 +706,7 @@ sync_agent_ec_task_error_e delete_profile_task_process(unsigned int param_cnt, s
                res = delete_profiles(profiles);
                if (res == 0) {
                        err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
-                       _DEBUG_INFO("delete_profiles failed!!");
+                       _DEBUG_ERROR("delete_profiles failed!!");
                        result = 0;
                } else {
                        _DEBUG_INFO("delete_profiles success!!");
@@ -734,10 +739,10 @@ sync_agent_ec_task_error_e get_profile_data_task_process(unsigned int param_cnt,
        int sync_mode = 0;
        int syncType = 0;
        int interval = 0;
-       int lastSessionStatus;
-       int lastSessionTime;
-       int result;
-       bool res;
+       int lastSessionStatus = 0;
+       int lastSessionTime = 0;
+       int result = 0;
+       bool res = false;
 
        sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
        retvm_if(accountId < 1, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
@@ -745,6 +750,7 @@ sync_agent_ec_task_error_e get_profile_data_task_process(unsigned int param_cnt,
        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;
+               _DEBUG_ERROR("get_profile_data failed!!");
                result = 0;
        } else
                result = 1;
@@ -773,14 +779,14 @@ sync_agent_ec_task_error_e get_profile_sync_category_task_process(unsigned int p
        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
 
        int accountId = 0;
-       int contentType;
+       int contentType = 0;
 
        int enabled = 0;
        int srcURI = 0;
        char *tgtURI = NULL;
        char *id = NULL;
        char *password = NULL;
-       bool res;
+       bool res = false;
        int result = 0;
 
        sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
@@ -791,6 +797,7 @@ sync_agent_ec_task_error_e get_profile_sync_category_task_process(unsigned int p
        res = get_profile_sync_category(accountId, contentType, &enabled, &srcURI, &tgtURI, &id, &password);
        if (res == false) {
                err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+               _DEBUG_ERROR("get_profile_sync_category failed!!");
                result = 0;
        } else
                result = 1;
@@ -813,7 +820,7 @@ sync_agent_ec_task_error_e get_profile_statistics_task_process(unsigned int para
        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
 
        int accountId = 0;
-       int contentType;
+       int contentType = 0;
 
        char *dbSynced = NULL;
        int lastSessionTime = -1;
@@ -826,8 +833,8 @@ sync_agent_ec_task_error_e get_profile_statistics_task_process(unsigned int para
        int client2Server_NrOfDelete = 0;
        int client2Server_NrOfReplace = 0;
 
-       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);
        retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
@@ -839,6 +846,7 @@ sync_agent_ec_task_error_e get_profile_statistics_task_process(unsigned int para
 
        if (res == false) {
                err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+               _DEBUG_ERROR("get_profile_statistics failed!!");
                result = 0;
        } else
                result = 1;
@@ -882,10 +890,10 @@ sync_agent_ec_task_error_e add_profile_cp_task_process(unsigned int param_cnt, s
        char *id = NULL;
        char *password = NULL;
        GList *categories = NULL;
-       int accountId;
+       int accountId = 0;
 
-       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_STRUCT, &profileName);
        sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
@@ -896,6 +904,7 @@ sync_agent_ec_task_error_e add_profile_cp_task_process(unsigned int param_cnt, s
        res = add_profile_cp(profileName, addr, id, password, categories, &accountId);
        if (res == false) {
                err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+               _DEBUG_ERROR("add_profile_cp failed!!");
                result = 0;
        } else
                result = 1;
@@ -913,14 +922,16 @@ sync_agent_ec_task_error_e refresh_from_service_task_process(unsigned int param_
 
        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
 
-       int accountId;
-       bool res;
+       int accountId = 0;
+       bool res = false;
 
        sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
 
        res = refresh_from_service_all(accountId);
-       if (res == false)
+       if (res == false) {
                err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+               _DEBUG_ERROR("refresh_from_service_all failed!!");
+       }
 
        _EXTERN_FUNC_EXIT;
        return err;
@@ -963,14 +974,15 @@ sync_agent_ec_task_error_e get_all_profiles_data_task_process(unsigned int param
 
        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
 
-       bool res;
-       int result;
+       bool res = false;
+       int result = 0;
        GList *profiles_data = NULL;
 
        res = get_all_profiles_data(&profiles_data);
 
        if (res == false) {
                err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+               _DEBUG_ERROR("get_all_profiles_data failed!!");
                result = 0;
        } else
                result = 1;
index 474672a..757dd1f 100755 (executable)
@@ -173,7 +173,7 @@ static char * _convert_to_interval_str(int interval)
                interval_str = DEFINE_SYNC_INTERVAL_1_MONTH_STR;
                break;
        default:
-               _DEBUG_ERROR("interval is invalid!!");
+               interval_str = DEFINE_SYNC_INTERVAL_NONE_STR;
                break;
        }
 
index 367b89b..a50098d 100755 (executable)
@@ -134,11 +134,11 @@ static int __convert_src_uri_value(char *src_uri)
 
        if (strcmp(src_uri,DEFINE_SOURCE_CONTACT_URI) == 0) {
                src_uri_value = SRC_URI_CONTACT;
-       } else if (strcmp(src_uri,DEFINE_SOURCE_CALENDAR_URI)) {
+       } else if (strcmp(src_uri,DEFINE_SOURCE_CALENDAR_URI) == 0) {
                src_uri_value = SRC_URI_CALENDAR;
-       } else if (strcmp(src_uri,DEFINE_SOURCE_MEMO_URI)) {
+       } else if (strcmp(src_uri,DEFINE_SOURCE_MEMO_URI) == 0) {
                src_uri_value = SRC_URI_MEMO;
-       } else if (strcmp(src_uri,DEFINE_SOURCE_CALLLOG_URI)) {
+       } else if (strcmp(src_uri,DEFINE_SOURCE_CALLLOG_URI) == 0) {
                src_uri_value = SRC_URI_CALLLOG;
        } else {
                _DEBUG_ERROR("src_uri is invalid!!");
@@ -155,7 +155,6 @@ static se_error_type_e _session_process(int account_id, alert_type_e server_sync
        char *profileDirName = NULL;
        se_error_type_e err = SE_INTERNAL_OK;
        bool result;
-       int sync_type_value = 0;
 
        result = get_config(account_id, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, &profileDirName);
        if (result == false) {
@@ -164,11 +163,9 @@ static se_error_type_e _session_process(int account_id, alert_type_e server_sync
                goto error;
        }
 
-      sync_type_value = __convert_alert_to_sync_type_value(server_sync_type);
-       _DEBUG_INFO("sync_type_value: [%d]", sync_type_value);
-
        if (profileDirName != NULL) {
-               err = session_process(profileDirName, sync_type_value, process, error);
+               _DEBUG_INFO("profileDirName: [%s]", profileDirName);
+               err = session_process(profileDirName, server_sync_type, process, error);
                if (err != SE_INTERNAL_OK) {
                        _DEBUG_ERROR("failed to send noti");
                        goto error;
@@ -803,6 +800,13 @@ static se_error_type_e _assemble_changed_datastores(int account_id, alert_type_e
 {
        _INNER_FUNC_ENTER;
 
+       if (account_id < 1){
+               _DEBUG_ERROR("account_id is invalid!!");
+               return SE_INTERNAL_ERROR;
+       } else {
+               _DEBUG_INFO("account_id: [%d]", account_id);
+       }
+
        se_error_type_e err = SE_INTERNAL_OK;
        changed_datastore_s *pChangedDatastore = NULL;
        sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
@@ -2657,7 +2661,12 @@ bool synchronize(int account_id, char *sync_mode, san_package_s * san_package)
 {
        _EXTERN_FUNC_ENTER;
 
-       _DEBUG_INFO("accountID = %d", account_id);
+       if (account_id < 1) {
+               _DEBUG_ERROR("account_id is invalid!!");
+               return false;
+       }
+
+       _DEBUG_INFO("account_id = %d", account_id);
        _DEBUG_INFO("sync_mode = %s", sync_mode);
 
        /*FIXME remove msg file */
@@ -3295,6 +3304,13 @@ bool refresh_from_service_all(int account_id)
 {
        _EXTERN_FUNC_ENTER;
 
+       if (account_id < 1) {\r
+               _DEBUG_ERROR("account_id is invalid!!");
+               return false;
+       } else {
+               _DEBUG_INFO("account_id: [%d]", account_id);
+       }
+
        se_error_type_e err = SE_INTERNAL_OK;
 
        sync_agent_da_return_e da_err = sync_agent_open_agent();