From 512f0263860655175a2e381fedf8a58dbcc92b5d Mon Sep 17 00:00:00 2001 From: Yongjin Kim Date: Wed, 19 Aug 2015 14:14:53 +0900 Subject: [PATCH] Operate all functions of 2.4 APIs Change-Id: Ibdf743724bbeecb71bafcf8a828fa7676fd62226 Signed-off-by: Yongjin Kim --- client/sal_service_storage.c | 46 ++++++++++++++++++++++++++++++++++++-- client/sal_service_task.c | 12 ++++++++++ client/sal_service_task_internal.h | 2 ++ client/sal_storage_provider.h | 3 +++ packaging/service-adaptor.spec | 2 +- 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/client/sal_service_storage.c b/client/sal_service_storage.c index 9207dc6..a6676dc 100644 --- a/client/sal_service_storage.c +++ b/client/sal_service_storage.c @@ -342,7 +342,17 @@ API int service_storage_get_file_list(service_plugin_h plugin, RETV_IF(NULL == dir_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - return SERVICE_ADAPTOR_ERROR_NONE; + service_storage_cloud_file_h file = NULL; + service_storage_cloud_file_create(plugin, &file); + service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_GET_FILE_LIST_URI); + service_storage_cloud_file_set_cloud_path(file, dir_path); + + service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s)); + service_task->cloud_file = file; + service_task->storage_file_list_callback = callback; + service_task->user_data = user_data; + + return service_task_start(service_task); } API int service_storage_remove(service_plugin_h plugin, @@ -354,7 +364,17 @@ API int service_storage_remove(service_plugin_h plugin, RETV_IF(NULL == remove_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - return SERVICE_ADAPTOR_ERROR_NONE; + service_storage_cloud_file_h file = NULL; + service_storage_cloud_file_create(plugin, &file); + service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_REMOVE_FILE_URI); + service_storage_cloud_file_set_cloud_path(file, remove_path); + + service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s)); + service_task->cloud_file = file; + service_task->storage_result_callback = callback; + service_task->user_data = user_data; + + return service_task_start(service_task); } API int service_storage_create_upload_task(service_plugin_h plugin, @@ -509,6 +529,8 @@ API int service_storage_file_list_clone(service_storage_file_list_h src_list, RETV_IF(NULL == src_list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == dst_list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + *dst_list = src_list; + return SERVICE_ADAPTOR_ERROR_NONE; } @@ -525,6 +547,9 @@ API int service_storage_file_list_get_length(service_storage_file_list_h list, RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == length, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + service_storage_cloud_file_h file = (service_storage_cloud_file_h) list; + *length = file->size; + return SERVICE_ADAPTOR_ERROR_NONE; } @@ -535,6 +560,9 @@ API int service_storage_file_list_foreach_file(service_storage_file_list_h list, RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + service_storage_cloud_file_h file = (service_storage_cloud_file_h) list; + callback((service_storage_file_h) file, user_data); + return SERVICE_ADAPTOR_ERROR_NONE; } @@ -544,6 +572,8 @@ API int service_storage_file_clone(service_storage_file_h src_file, RETV_IF(NULL == src_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == dst_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + *dst_file = src_file; + return SERVICE_ADAPTOR_ERROR_NONE; } @@ -560,6 +590,9 @@ API int service_storage_file_is_dir(service_storage_file_h file, RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == is_dir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file; + *is_dir = cloud_file->is_dir; + return SERVICE_ADAPTOR_ERROR_NONE; } @@ -569,6 +602,9 @@ API int service_storage_file_get_size(service_storage_file_h file, RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file; + *size = cloud_file->size; + return SERVICE_ADAPTOR_ERROR_NONE; } @@ -578,6 +614,9 @@ API int service_storage_file_get_logical_path(service_storage_file_h file, RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file; + *path = strdup(cloud_file->cloud_path); + return SERVICE_ADAPTOR_ERROR_NONE; } @@ -587,5 +626,8 @@ API int service_storage_file_get_physical_path(service_storage_file_h file, RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file; + *path = strdup(cloud_file->cloud_path); + return SERVICE_ADAPTOR_ERROR_NONE; } diff --git a/client/sal_service_task.c b/client/sal_service_task.c index 1c2510b..ddc9ebc 100644 --- a/client/sal_service_task.c +++ b/client/sal_service_task.c @@ -74,6 +74,18 @@ static void _service_task_async_func(gpointer data, gpointer user_data) { task->storage_state_callback(SERVICE_STORAGE_TASK_COMPLETED, task->user_data); } + if (NULL != task->storage_result_callback) + { + task->storage_result_callback(SERVICE_ADAPTOR_ERROR_NONE, task->user_data); + } + if (NULL != task->storage_file_list_callback) + { + service_storage_cloud_file_h file_list = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s)); + file_list->is_dir = false; + file_list->cloud_path = "/sample.txt"; + file_list->size = 1; + task->storage_file_list_callback(SERVICE_ADAPTOR_ERROR_NONE, (service_storage_cloud_file_h) file_list, task->user_data); + } } //****************************************************************************** diff --git a/client/sal_service_task_internal.h b/client/sal_service_task_internal.h index bb5e387..981fbef 100644 --- a/client/sal_service_task_internal.h +++ b/client/sal_service_task_internal.h @@ -45,6 +45,8 @@ typedef struct _service_task_s // temp service_storage_task_progress_cb storage_progress_callback; service_storage_task_state_cb storage_state_callback; + service_storage_result_cb storage_result_callback; + service_storage_file_list_cb storage_file_list_callback; void *user_data; } service_task_s; diff --git a/client/sal_storage_provider.h b/client/sal_storage_provider.h index 3053fce..bf61e06 100644 --- a/client/sal_storage_provider.h +++ b/client/sal_storage_provider.h @@ -53,6 +53,9 @@ typedef struct _storage_provider_s { // Cloud service_adaptor_error_e (*cloud_remove_file)(const char *cloud_path); + service_adaptor_error_e (*cloud_download_file)(const char *cloud_path, const char *local_path); + service_adaptor_error_e (*cloud_upload_file)(const char *local_path, const char *cloud_path); + service_adaptor_error_e (*cloud_download_file_thumbnail)(const char *cloud_path, const char *local_path); // Posix } storage_provider_s; diff --git a/packaging/service-adaptor.spec b/packaging/service-adaptor.spec index 7e3e81a..80510ed 100644 --- a/packaging/service-adaptor.spec +++ b/packaging/service-adaptor.spec @@ -1,6 +1,6 @@ Name: service-adaptor Summary: Service Adaptor Framework for Convergence -Version: 1.1.2 +Version: 1.1.3 Release: 1 Group: System/Libraries License: Apache-2.0 -- 2.7.4