[JIRA:N_SE-30007] Get profilesNum failed.
authorsanghyuk Ko <sanghyuk.ko@samsung.com>
Tue, 30 Apr 2013 04:27:04 +0000 (13:27 +0900)
committersanghyuk Ko <sanghyuk.ko@samsung.com>
Thu, 2 May 2013 01:58:00 +0000 (10:58 +0900)
[Problem]
-
[Cause]
-
[Solution]
- When synchronising, edit/delete request block.
- calendar connect/disconnect api changed.
- When synchronising, check account_id validance.

Change-Id: I292dada19155ed1a7f915c3f6e4553543b88e7bc

include/event/oma_ds_api.h
src/framework/event/oma_ds_api.c
src/fw-plugins/common-public/calendar/src/plugin_interface.c
test/client/oma-ds/oma_ds_client.c

index 979fff0..f763f3f 100755 (executable)
@@ -31,7 +31,8 @@ extern "C" {
  */
        typedef enum {
                SYNC_AGENT_DS_FAIL = -1,        /**< Fail */
-               SYNC_AGENT_DS_SUCCESS = 0       /**< Successful */
+               SYNC_AGENT_DS_SUCCESS = 0,      /**< Successful */
+               SYNC_AGENT_DS_SYNCHRONISING = 1 /**< Synchronising */
        } sync_agent_ds_error_e;
 
 /**
index 92323e9..44992c1 100755 (executable)
@@ -41,6 +41,7 @@
 
 #define SYNC_AGENT_DS_API_RESULT_FAILURE       0
 #define SYNC_AGENT_DS_API_RESULT_SUCCESS       1
+#define SYNC_AGENT_DS_API_RESULT_SYNCHRONISING 2
 
 #define SYNC_TYPE_SLOW_SYNC_STR "Full"
 #define SYNC_TYPE_TWO_WAY_STR "Update both"
@@ -635,6 +636,8 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h pro
        // set profile name
        profile_info->profile_name = g_strdup(profile_name);
 
+       _DEBUG_INFO("profile_name: [%s]",profile_name);
+
        if (profile_info->profile_name == NULL) {
                _DEBUG_ERROR("g_strdup failed !!");
                return SYNC_AGENT_DS_FAIL;
@@ -664,6 +667,10 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_server_info(ds_profile_h prof
        server_info->id = g_strdup(id);
        server_info->password = g_strdup(password);
 
+       _DEBUG_INFO("addr: [%s]",addr);
+       _DEBUG_INFO("id: [%s]",id);
+       _DEBUG_INFO("password: [%s]",password);
+
        if ((server_info->addr == NULL)
            || (server_info->id == NULL)
            || (server_info->password == NULL)) {
@@ -720,6 +727,10 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profil
        sync_info->sync_type = sync_type;
        sync_info->interval = interval;
 
+       _DEBUG_INFO("sync_mode: [%d]",sync_mode);
+       _DEBUG_INFO("sync_type: [%d]",sync_type);
+       _DEBUG_INFO("interval: [%d]",interval);
+
        _EXTERN_FUNC_EXIT;
 
        return result;
@@ -753,6 +764,11 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_
        category_info->src_uri = src_uri;
        category_info->tgt_uri = g_strdup(tgt_uri);
 
+       _DEBUG_INFO("service_type: [%d]",service_type);
+       _DEBUG_INFO("enabled: [%d]",enabled);
+       _DEBUG_INFO("src_uri: [%d]",src_uri);
+       _DEBUG_INFO("tgt_uri: [%s]",tgt_uri);
+
        profile_info->service_list = g_list_append(profile_info->service_list, category_info);
 
        _EXTERN_FUNC_EXIT;
@@ -891,17 +907,14 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_sync_info(ds_profile_h profil
 
        if (sync_info->sync_mode < 0) {
                _DEBUG_ERROR("sync_mode is invalid !!");
-               return SYNC_AGENT_DS_FAIL;
        }
 
        if (sync_info->sync_type < 0) {
                _DEBUG_ERROR("sync_type is invalid !!");
-               return SYNC_AGENT_DS_FAIL;
        }
 
        if (sync_info->interval < 0) {
                _DEBUG_ERROR("interval is invalid !!");
-               return SYNC_AGENT_DS_FAIL;
        }
 
        _EXTERN_FUNC_EXIT;
@@ -925,11 +938,12 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_sync_service_info(ds_profile_
        *category_list = g_list_copy(profile_info->service_list);
 
        if (*category_list == NULL) {
-               _DEBUG_ERROR("g_list_copy failed !!");
-               return SYNC_AGENT_DS_FAIL;
+               _DEBUG_ERROR("category_list is NULL!!");
        }
 
        category_count = g_list_length(*category_list);
+       _DEBUG_INFO("category_count: [%d]", category_count);
+
        for (; i < category_count; i++) {
                category_info = (sync_agent_ds_service_info *) g_list_nth_data(*category_list, i);
 
@@ -1001,6 +1015,10 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_add_profile(ds_profile_h profile_
        sync_agent_ds_service_info *category_info = NULL;
        int category_count = 0;
        int i = 0;
+       int profile_name_len = 0;
+       int server_addr_len = 0;
+       int server_id_len = 0;
+       int server_password_len = 0;
 
        /* create empty event packet */
        request_event = sync_agent_create_event(event_type);
@@ -1010,6 +1028,23 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_add_profile(ds_profile_h profile_
                return SYNC_AGENT_DS_FAIL;
        }
 
+       profile_name_len = strlen(profile_info->profile_name);
+       server_addr_len = strlen(server_info->addr);
+       server_id_len = strlen(server_info->id);
+       server_password_len = strlen(server_info->password);
+
+       if ((profile_name_len == 0) || (server_addr_len == 0) || (server_id_len == 0) || (server_password_len == 0)) {
+               _DEBUG_ERROR("input value is invalid!!");
+               _DEBUG_INFO("profile_info->profile_name: [%s]", profile_info->profile_name);
+               _DEBUG_INFO("server_info->addr: [%s]", server_info->addr);
+               _DEBUG_INFO("server_info->id: [%s]", server_info->id);
+               _DEBUG_INFO("server_info->password: [%s]", server_info->password);
+               sync_agent_free_event(request_event);
+
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
        /* add request parameter to event packet */
        _DEBUG_INFO("profile_name = %s", profile_info->profile_name);
        sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_name);
@@ -1179,8 +1214,8 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_profile(int profile_id, ds_pr
        _DEBUG_INFO("sync_mode = %d", sync_info->sync_mode);
        _DEBUG_INFO("sync_type = %d", sync_info->sync_type);
        _DEBUG_INFO("interval = %d", sync_info->interval);
-       _DEBUG_VERBOSE("lastSyncStatus = %d\n", profile_info->last_sync_status);
-       _DEBUG_VERBOSE("lastSyncTime = %d\n", profile_info->last_sync_time);
+       _DEBUG_INFO("lastSyncStatus = %d\n", profile_info->last_sync_status);
+       _DEBUG_INFO("lastSyncTime = %d\n", profile_info->last_sync_time);
 
        /* free request & response event */
        sync_agent_free_event(request_event);
@@ -1454,6 +1489,14 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_update_profile(ds_profile_h profi
                return SYNC_AGENT_DS_FAIL;
        }
 
+       if (api_result ==SYNC_AGENT_DS_API_RESULT_SYNCHRONISING) {
+               _DEBUG_ERROR("api_result = synchronising");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_SYNCHRONISING;
+       }
+
        /* free request & response event */
        sync_agent_free_event(request_event);
        sync_agent_free_event_data(response_event);
@@ -1521,6 +1564,14 @@ EXPORT_API sync_agent_ds_error_e sync_agent_ds_delete_profile(ds_profile_h profi
                return SYNC_AGENT_DS_FAIL;
        }
 
+       if (api_result ==SYNC_AGENT_DS_API_RESULT_SYNCHRONISING) {
+               _DEBUG_ERROR("api_result = synchronising");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_SYNCHRONISING;
+       }
+
        /* free request & response event */
        sync_agent_free_event(request_event);
        sync_agent_free_event_data(response_event);
index 6f0d162..ac8ba8c 100755 (executable)
@@ -237,7 +237,7 @@ EXPORT_API sync_agent_da_return_e sync_agent_plugin_open_service(void)
        _EXTERN_FUNC_ENTER;
 
        sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
-       int err = calendar_connect();
+       int err = calendar_connect_on_thread();
 
        if (err != CALENDAR_ERROR_NONE) {
                _DEBUG_ERROR("[calendar] calendar_connect Fail!\n");
@@ -255,7 +255,7 @@ EXPORT_API sync_agent_da_return_e sync_agent_plugin_close_service(void)
        _EXTERN_FUNC_ENTER;
 
        sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
-       int err = calendar_disconnect();
+       int err = calendar_disconnect_on_thread();
 
        if (err != CALENDAR_ERROR_NONE) {
                _DEBUG_ERROR("[calendar] calendar_disconnect Fail!\n");
index 0022ceb..a091f9e 100755 (executable)
@@ -373,6 +373,9 @@ static gboolean __test_delete_profile()
        if (result == SYNC_AGENT_DS_SUCCESS) {
                _DEBUG_VERBOSE("Success to delete profile!");
                is_test_successful = TRUE;
+       } else if (result == SYNC_AGENT_DS_SYNCHRONISING) {
+               _DEBUG_VERBOSE("profile is synchronising!!");
+               is_test_successful = FALSE;
        } else {
                _DEBUG_VERBOSE("Failed to delete profile!");
                is_test_successful = FALSE;
@@ -774,6 +777,8 @@ static gboolean __test_start_sync()
        sync_agent_ds_free_profile_info(profile_h);
 
        _INNER_FUNC_EXIT;
+
+       return is_test_successful;
 }
 
 static gboolean __test_stop_sync()
@@ -815,6 +820,8 @@ static gboolean __test_stop_sync()
        sync_agent_ds_free_profile_info(profile_h);
 
        _INNER_FUNC_EXIT;
+
+       return is_test_successful;
 }
 
 int _session_process_noti_cb(sync_agent_event_data_s * request, void *data)