From db4a5672819b978ab72f4b33d0f3d2742999e5fa Mon Sep 17 00:00:00 2001 From: Yongjin Kim Date: Fri, 7 Aug 2015 10:54:55 +0900 Subject: [PATCH] Add APIs of 2.4 Change-Id: Id6eb6ace89d749d7003257525b34026dcb36f70e Signed-off-by: youthkim --- CMakeLists.txt | 3 - client/sal_service_adaptor.c | 45 ++- client/sal_service_adaptor.h | 117 ++++++- client/sal_service_storage.c | 211 +++++++++++++ client/sal_service_storage.h | 580 ++++++++++++++++++++++++++++++++++ client/sal_service_storage_internal.h | 89 ++++++ test/test.c | 4 +- 7 files changed, 1038 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d5ebea..7f2a71f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,9 +42,6 @@ ADD_SUBDIRECTORY(test) # Define Install Files ########################################################## -#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/packaging/service-adaptor.service DESTINATION ${LIB_INSTALL_DIR}/systemd/user) -#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/packaging/org.tizen.serviceadaptor.client.service DESTINATION /usr/share/dbus-1/system-services) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/packaging/org.tizen.serviceadaptor.client.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.serviceadaptor.client.conf) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.serviceadaptor.client.conf DESTINATION /etc/dbus-1/system.d) diff --git a/client/sal_service_adaptor.c b/client/sal_service_adaptor.c index fbe67b0..a1998ec 100644 --- a/client/sal_service_adaptor.c +++ b/client/sal_service_adaptor.c @@ -47,7 +47,7 @@ typedef struct _service_adaptor_s GList *plugins; /* char **plugins (uri) */ GList *started_plugins; /* service_plugin_h **started_plugins */ } service_adaptor_s; -typedef struct _service_adaptor_s *service_adaptor_h; +//typedef struct _service_adaptor_s *service_adaptor_h; /** * @brief Describes infromation about Plugin Handle @@ -72,6 +72,22 @@ service_adaptor_h service_adaptor = NULL; //* Public interface definition //****************************************************************************** +API int service_adaptor_create(service_adaptor_h *service_adaptor) +{ + RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + *service_adaptor = (service_adaptor_h) g_malloc0(sizeof(service_adaptor_s)); + + return service_adaptor_connect(); +} + +API int service_adaptor_destroy(service_adaptor_h service_adaptor) +{ + RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return service_adaptor_disconnect(); +} + API int service_adaptor_connect() { SAL_FN_CALL; @@ -135,7 +151,14 @@ API int service_adaptor_disconnect() return SERVICE_ADAPTOR_ERROR_NONE; } -API int service_adaptor_foreach_plugin(service_adaptor_plugin_cb callback, void *user_data) +API int service_adaptor_foreach_plugin(service_adaptor_h service_adaptor, service_adaptor_plugin_cb callback, void *user_data) +{ + RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return service_adaptor_foreach_plugin2(callback, user_data); +} + +API int service_adaptor_foreach_plugin2(service_adaptor_plugin_cb callback, void *user_data) { SAL_FN_CALL; @@ -175,6 +198,13 @@ API int service_adaptor_get_last_error_message(char **message) return SERVICE_ADAPTOR_ERROR_NONE; } +API int service_adaptor_create_plugin(service_adaptor_h service_adaptor, const char *plugin_uri, service_plugin_h *plugin) +{ + RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return service_plugin_create(plugin_uri, plugin); +} + API int service_plugin_create(const char *uri, service_plugin_h *plugin) { SAL_FN_CALL; @@ -219,7 +249,7 @@ API int service_plugin_add_property(service_plugin_h plugin, const char *key, co RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); RETV_IF(NULL == value, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - g_hash_table_insert(plugin->property, key, value); + g_hash_table_insert(plugin->property, g_strdup(key), g_strdup(value)); return SERVICE_ADAPTOR_ERROR_NONE; } @@ -276,7 +306,14 @@ API int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb ca return SERVICE_ADAPTOR_ERROR_NONE; } -API int service_plugin_start(service_plugin_h plugin) +API int service_plugin_start(service_plugin_h plugin, int service_mask) +{ + RETV_IF(0 <= service_mask, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return service_plugin_start2(plugin); +} + +API int service_plugin_start2(service_plugin_h plugin) { SAL_FN_CALL; diff --git a/client/sal_service_adaptor.h b/client/sal_service_adaptor.h index 4116eee..fcfd3ea 100644 --- a/client/sal_service_adaptor.h +++ b/client/sal_service_adaptor.h @@ -45,6 +45,15 @@ typedef enum _service_plugin_type_e SERVICE_PLUGIN_STORAGE = (0x01 << 1), /**< Storage service type flag */ } service_plugin_type_e; +/** 2.4 + * @brief Type of service in plugin + */ +typedef enum _service_plugin_service_type_e +{ + SERVICE_PLUGIN_SERVICE_AUTH = (0x01 << 0), /**< Auth service type flag */ + SERVICE_PLUGIN_SERVICE_STORAGE = (0x01 << 1), /**< Storage service type flag */ +} service_plugin_service_type_e; + /** * @brief Definition for the service_plugin property: The application id be issued from service provider for 3rd party developer. * @since_tizen 2.4 @@ -72,6 +81,15 @@ typedef enum _service_plugin_type_e */ #define SERVICE_PLUGIN_PROPERTY_USER_ID "http://tizen.org/service-adaptor/plugin/property/user_id" +/** 2.4 +* @brief The handle for connection and managing plugin handle of Service Adaptor +* @details The handle can be created by service_adaptor_create()
+* When a handle is no longer needed, use service_adaptor_destroy() +* @see #service_adaptor_create() +* @see #service_adaptor_destroy() +*/ +typedef struct _service_adaptor_s *service_adaptor_h; + /** * @brief The handle for connection and managing handle of Service Plugin * @details The handle can be created by service_plugin_create()
@@ -117,6 +135,35 @@ typedef void (*service_plugin_login_cb)(int result, FUNCTION PROTOTYPES ==================================================================================================*/ +/** 2.4 +* @brief Create Service Adaptor +* @since_tizen 2.4 +* +* @param[out] service_adaptor The Service Adaptor handle +* @remarks @a service_adaptor must be released memory using service_adaptor_destroy(), when a program no longer needs any function of Service Adaptor +* @see service_adaptor_destroy() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +*/ +int service_adaptor_create(service_adaptor_h *service_adaptor); + +/** 2.4 +* @brief Destroy Service Adaptor +* @details It must called after a program no longer needs any function of Service Adaptor +* @since_tizen 2.4 +* +* @param[in] service_adaptor The handle of Service Adaptor +* @see service_adaptor_create() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @pre @a service_adaptor must be issued by service_adaptor_create() +*/ +int service_adaptor_destroy(service_adaptor_h service_adaptor); + /** * @brief Create Service Adaptor * @since_tizen 2.4 @@ -146,6 +193,25 @@ int service_adaptor_connect(); */ int service_adaptor_disconnect(); +/** 2.4 +* @brief Foreach the list of plugin +* @details Iterate to all installed plugin +* @since_tizen 2.4 +* +* @param[in] service_adaptor The handle of Service Adaptor +* @param[in] callback The callback for foreach plugin +* @param[in] user_data Passed data to callback +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no available plugins +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @pre @a service_adaptor must be issued by service_adaptor_create() +*/ +int service_adaptor_foreach_plugin(service_adaptor_h service_adaptor, + service_adaptor_plugin_cb callback, + void *user_data); + /** * @brief Foreach the list of plugin * @details Iterate to all installed plugin @@ -160,7 +226,7 @@ int service_adaptor_disconnect(); * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error * @pre @a service_adaptor must be issued by service_adaptor_create() */ -int service_adaptor_foreach_plugin(service_adaptor_plugin_cb callback, +int service_adaptor_foreach_plugin2(service_adaptor_plugin_cb callback, void *user_data); /** @@ -207,6 +273,26 @@ int service_adaptor_remove_plugin(service_adaptor_h adaptor_client, const char * int service_adaptor_get_auth(service_adaptor_h adaptor_client, const char *uri, service_auth_h *auth); */ +/** 2.4 +* @brief Create service plugin handle +* @details Create plugin handle using @a plugin_uri +* @since_tizen 2.4 +* +* @param[in] service_adaptor The handle of Service Adaptor +* @param[in] plugin_uri The specfic string for use plugin, this values are set by plugin +* @param[out] plugin The handle for use Plugin APIs +* @remarks @a plugin must be released memory using service_plugin_destroy() when you no longer needs plugin's API +* @see service_plugin_destroy() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @pre @a service_adaptor must be issued by service_adaptor_create() +*/ +int service_adaptor_create_plugin(service_adaptor_h service_adaptor, + const char *plugin_uri, + service_plugin_h *plugin); + /** * @brief Create service plugin handle * @details Create plugin handle using @a plugin_uri @@ -324,6 +410,32 @@ int service_plugin_get_property(service_plugin_h plugin, */ int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb callback, void *user_data); +/** 2.4 +* @brief Requests start initalization for service plugin +* @since_tizen 2.4 +* +* @param[in] plugin The handle for use Plugin APIs +* @param[in] service_mask The flag for use service plugins, this flag can be masked multiple enum (#service_plugin_service_type_e) +* @remarks @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e +* @remarks - for example, +* @remarks      int @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH; +* @remarks      @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE; +* @remarks      int ret = service_plugin_start(@a m_plugin, @a service_mask); +* @remarks If a program needs to stop plugin manually, use #service_plugin_stop().
But in #service_plugin_destroy(), automatically stop service plugin +* @see service_plugin_service_type_e +* @see service_plugin_stop() +* @return 0 on success, otherwise a negative error value +* @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED, request authorization to signup application +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED Need authorization +* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +*/ +int service_plugin_start(service_plugin_h plugin, + int service_mask); + /** * @brief Requests start initalization for service plugin * @since_tizen 2.4 @@ -346,7 +458,8 @@ int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb callba * @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon * @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error */ -int service_plugin_start(service_plugin_h plugin); +int service_plugin_start2(service_plugin_h plugin); + /** * @brief Requests stop manually for service plugin * @since_tizen 2.4 diff --git a/client/sal_service_storage.c b/client/sal_service_storage.c index cb17303..d6d0fe6 100644 --- a/client/sal_service_storage.c +++ b/client/sal_service_storage.c @@ -328,3 +328,214 @@ API int service_storage_cloud_file_destroy_task(service_task_h task) return SERVICE_ADAPTOR_ERROR_NONE; } + +//****************************************************************************** +//* 2.4 Public interface definition +//****************************************************************************** + +API int service_storage_get_file_list(service_plugin_h plugin, + const char *dir_path, + service_storage_file_list_cb callback, + void *user_data) +{ + RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dir_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_remove(service_plugin_h plugin, + const char *remove_path, + service_storage_result_cb callback, + void *user_data) +{ + RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == remove_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_create_upload_task(service_plugin_h plugin, + const char *file_path, + const char *upload_path, + service_storage_task_h *task) +{ + RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == file_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == upload_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_create_download_task(service_plugin_h plugin, + const char *storage_path, + const char *download_path, + service_storage_task_h *task) +{ + RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == storage_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == download_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_create_download_thumbnail_task (service_plugin_h plugin, + const char *storage_path, + const char *download_path, + int thumbnail_size, + service_storage_task_h *task) +{ + RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == storage_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == download_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(0 < thumbnail_size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_destroy_task(service_storage_task_h task) +{ + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_start_task(service_storage_task_h task) +{ + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_cancel_task(service_storage_task_h task) +{ + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_set_task_progress_cb(service_storage_task_h task, + service_storage_task_progress_cb callback, + void *user_data) +{ + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_unset_task_progress_cb(service_storage_task_h task) +{ + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_set_task_state_changed_cb(service_storage_task_h task, + service_storage_task_state_cb callback, + void *user_data) +{ + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_unset_task_state_changed_cb(service_storage_task_h task) +{ + RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_list_clone(service_storage_file_list_h src_list, + service_storage_file_list_h *dst_list) +{ + RETV_IF(NULL == src_list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dst_list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_list_destroy(service_storage_file_list_h list) +{ + RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_list_get_length(service_storage_file_list_h list, + int *length) +{ + RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == length, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_list_foreach_file(service_storage_file_list_h list, + service_storage_file_cb callback, + void *user_data) +{ + RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_clone(service_storage_file_h src_file, + service_storage_file_h *dst_file) +{ + RETV_IF(NULL == src_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dst_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_destroy(service_storage_file_h file) +{ + RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_is_dir(service_storage_file_h file, + bool *is_dir) +{ + RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == is_dir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_get_size(service_storage_file_h file, + unsigned long long *size) +{ + RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_get_logical_path(service_storage_file_h file, + char **path) +{ + RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} + +API int service_storage_file_get_physical_path(service_storage_file_h file, + char **path) +{ + RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); + + return SERVICE_ADAPTOR_ERROR_NONE; +} diff --git a/client/sal_service_storage.h b/client/sal_service_storage.h index a8c10e0..16e973a 100644 --- a/client/sal_service_storage.h +++ b/client/sal_service_storage.h @@ -65,6 +65,586 @@ int service_storage_cloud_file_foreach_file(service_storage_cloud_file_h file, s int service_storage_cloud_file_create_task(service_storage_cloud_file_h file, service_task_h *task); int service_storage_cloud_file_destroy_task(service_task_h task); +// 2.4 + +/** +* @brief The handle of async task for storage service +* @see #service_storage_create_download_task() +* @see #service_storage_create_upload_task() +*/ +typedef struct _service_storage_task_s *service_storage_task_h; + +/** +* @brief The handle of file or directory in storage +* @see #service_storage_file_clone() +* @see #service_storage_file_destroy() +*/ +typedef struct _service_storage_file_s *service_storage_file_h; + +/** +* @brief The list handle of file or directory in storage +* @see #service_storage_file_list_clone() +* @see #service_storage_file_list_destroy() +*/ +typedef struct _service_storage_file_list_s *service_storage_file_list_h; + +/** + * @brief Type of storage task + */ +typedef enum +{ + SERVICE_STORAGE_TASK_IN_PROGRESS = 1, /**< The task is progressing */ + SERVICE_STORAGE_TASK_COMPLETED = 2, /**< The task was completed */ + SERVICE_STORAGE_TASK_CANCELED = 3, /**< The task was canceled */ + SERVICE_STORAGE_TASK_FAILED = 4, /**< The task was failed */ +} service_storage_task_state_e; + +/** +* @brief Callback for changing state of storage task +* +* @param[in] state The state of storage task +* @param[in] user_data The user data passed from #service_storage_set_task_state_changed_cb() +* @return void +* @see #service_storage_unset_task_state_changed_cb() +* @pre #service_storage_set_task_state_changed_cb() will invoke this callback. +*/ +typedef void (*service_storage_task_state_cb)(service_storage_task_state_e state, + void *user_data); + +/** +* @brief Callback for progress of storage task +* +* @param[in] progress The progressed amount of storage task +* @param[in] total The total amount of storage task +* @param[in] user_data The user data passed from #service_storage_set_task_progress_cb() +* @return void +* @see #service_storage_unset_task_progress_cb() +* @pre #service_storage_set_task_progress_cb() will invoke this callback. +*/ +typedef void (*service_storage_task_progress_cb)(unsigned long long progress, + unsigned long long total, + void *user_data); + +/** +* @brief Callback for getting async storage operation result +* +* @param[in] result Result code for storage async operation (see #service_adaptor_error_e) +* @param[in] user_data Passed data from request function +* @remarks If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @see #service_adaptor_error_e +* @see service_storage_remove() +* @return void +* @pre #service_storage_remove() will invoke this callback. +*/ +typedef void (*service_storage_result_cb)(int result, + void *user_data); + + +/** +* @brief Callback for getting file list API +* +* @param[in] result Result code for #service_storage_get_file_list() (see #service_adaptor_error_e) +* @param[in] list The handle of file list +* @param[in] user_data Passed data from #service_storage_get_file_list() +* @remarks If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @see #service_adaptor_error_e +* @see #service_storage_file_list_h +* @return void +* @pre #service_storage_get_file_list() will invoke this callback. +*/ +typedef void (*service_storage_file_list_cb)(int result, + service_storage_file_list_h list, + void *user_data); + +/** +* @brief Callback for service_storage_file_list_foreach_file API +* +* @param[in] file The handle of file +* @param[in] user_data Passed data from #service_storage_file_list_foreach_file() +* @see #service_storage_file_h +* @return @c true to continue with the next iteration of the loop, +* otherwise @c false to break out of the loop +* @pre #service_storage_file_list_foreach_file() will invoke this callback. +*/ +typedef bool (*service_storage_file_cb)(service_storage_file_h file, + void *user_data); + +/** +* @brief Gets file list from storage, asynchronously. +* @since_tizen 2.4 +* @privlevel public +* @privilege %http://tizen.org/privilege/internet +* +* @param[in] plugin The handle for use Plugin APIs +* @param[in] dir_path The dir path (Physical path) +* @param[in] callback The callback for getting file list +* @param[in] user_data The user data to be passed to the callback function +* @remarks For the @a dir_path, "/" means root path. +* @remarks Reference details for "Logical path" and "Physical path" at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page +* @see service_plugin_start() +* @see service_storage_file_list_cb() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @pre API prerequires #service_plugin_start() +* @post #service_storage_file_list_cb() will be invoked +*/ +int service_storage_get_file_list(service_plugin_h plugin, + const char *dir_path, + service_storage_file_list_cb callback, + void *user_data); + +/** +* @brief Removes file or directory in storage +* @since_tizen 2.4 +* @privlevel public +* @privilege %http://tizen.org/privilege/internet +* +* @param[in] plugin The handle for use Plugin APIs +* @param[in] remove_path The target file or directory for remove (Physical path) +* @param[in] callback The callback for getting result this operation +* @param[in] user_data The user data to be passed to the callback function +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @remarks Reference details for "Logical path" and "Physical path" at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page +* @see service_plugin_start() +* @see service_storage_result_cb() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @pre API prerequires #service_plugin_start() +* @post #service_storage_result_cb() will be invoked +*/ +int service_storage_remove(service_plugin_h plugin, + const char *remove_path, + service_storage_result_cb callback, + void *user_data); + +/** +* @brief Creates storage task for upload file to storage +* @since_tizen 2.4 +* @privlevel public +* @privilege %http://tizen.org/privilege/internet +* +* @param[in] plugin The handle for use Plugin APIs +* @param[in] file_path The upload file path in local (Logical path) +* @param[in] upload_path The upload target path in storage (Physical path) +* @param[out] task The handle of download task +* @remarks @a task must be released memory using service_storage_destroy_task() when the task no longer run +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @remarks Reference details for "Logical path" and "Physical path" at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page +* @remarks http://tizen.org/privilege/mediastorage is needed if @a file_path is relevant to media storage. +* @remarks http://tizen.org/privilege/externalstorage is needed if @a file_path is relevant to external storage. +* @see service_plugin_start() +* @see service_storage_destroy_task() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files +* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin +* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @pre API prerequires #service_plugin_start() +*/ +int service_storage_create_upload_task(service_plugin_h plugin, + const char *file_path, + const char *upload_path, + service_storage_task_h *task); + +/** +* @brief Creates storage task for download file from storage +* @since_tizen 2.4 +* @privlevel public +* @privilege %http://tizen.org/privilege/internet +* +* @param[in] plugin The handle for use Plugin APIs +* @param[in] storage_path The source file path in storage (Physical path) +* @param[in] download_path The download path in local (Logical path) +* @param[out] task The handle of download task +* @remarks @a task must be released memory using service_storage_destroy_task() when the task no longer run +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @remarks Reference details for "Logical path" and "Physical path" at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page +* @remarks http://tizen.org/privilege/mediastorage is needed if @a download_path is relevant to media storage. +* @remarks http://tizen.org/privilege/externalstorage is needed if @a download_path is relevant to external storage. +* @see service_plugin_start() +* @see service_storage_destroy_task() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files +* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin +* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @pre API prerequires #service_plugin_start() +*/ +int service_storage_create_download_task(service_plugin_h plugin, + const char *storage_path, + const char *download_path, + service_storage_task_h *task); + +/** +* @brief Creates storage task for download thumbnail from storage +* @since_tizen 2.4 +* @privlevel public +* @privilege %http://tizen.org/privilege/internet +* +* @param[in] plugin The handle for use Plugin APIs +* @param[in] storage_path The source file path in storage (Physical path) +* @param[in] download_path The download path in local (Logical path) +* @param[in] thumbnail_size The size level of thumbnail, the level is defined service plugin SPEC +* @param[out] task The handle of download task +* @remarks If @a thumbnail_size is 0, gets default size thumbnail, the default size must be defined plugin SPEC +* @remarks If @a thumbnail_size is -1, gets minimum size thumbnail be supported plugin +* @remarks If @a thumbnail_size is -2, gets maximum size thumbnail be supported plugin +* @remarks @a task must be released memory using service_storage_destroy_task() when the task no longer run +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @remarks Reference details for "Logical path" and "Physical path" at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page +* @remarks http://tizen.org/privilege/mediastorage is needed if @a download_path is relevant to media storage. +* @remarks http://tizen.org/privilege/externalstorage is needed if @a download_path is relevant to external storage. +* @see service_plugin_start() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no thumbnail data +* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin +* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @pre API prerequires #service_plugin_start() +*/ +int service_storage_create_download_thumbnail_task (service_plugin_h plugin, + const char *storage_path, + const char *download_path, + int thumbnail_size, + service_storage_task_h *task); + +/** +* @brief Destroys storage task +* @since_tizen 2.4 +* +* @param[in] task The handle of storage task +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @see service_storage_create_download_task() +* @see service_storage_create_upload_task() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +*/ +int service_storage_destroy_task(service_storage_task_h task); + +/** +* @brief Starts storage task, asynchronously. +* @since_tizen 2.4 +* +* @param[in] task The handle of storage task +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @see service_storage_create_upload_task() +* @see service_storage_create_download_task() +* @see service_storage_create_download_thumbnail_task() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +*/ +int service_storage_start_task(service_storage_task_h task); + +/** +* @brief Cancels storage task, asynchronously. +* @since_tizen 2.4 +* +* @param[in] task The handle of storage task +* @remarks @a task must be released memory using service_storage_destroy_task() when the task no longer run +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @see service_storage_start_task() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +*/ +int service_storage_cancel_task(service_storage_task_h task); + +/** +* @brief Sets a callback function to be invoked when progress of the task running. +* @since_tizen 2.4 +* +* @param[in] task The handle of storage task +* @param[in] callback The callback function to register +* @param[in] user_data The user data to be passed to the callback function +* @remarks This function must be called before starting task (see #service_storage_start_task()) +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @see service_storage_start_task() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @post #service_storage_task_progress_cb() will be invoked +*/ +int service_storage_set_task_progress_cb(service_storage_task_h task, + service_storage_task_progress_cb callback, + void *user_data); + +/** +* @brief Unsets the progress callback function. +* @since_tizen 2.4 +* +* @param[in] task The handle of storage task +* @remarks This function must be called before starting task (see #service_storage_start_task()) +* @see service_storage_start_task() +* @see service_storage_set_task_progress_cb() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_unset_task_progress_cb(service_storage_task_h task); + + +/** +* @brief Sets a callback function to be invoked when change of the task running state. +* @since_tizen 2.4 +* +* @param[in] task The handle of storage task +* @param[in] callback The callback function to register +* @param[in] user_data The user data to be passed to the callback function +* @remarks This function must be called before starting task (see #service_storage_start_task()) +* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. +* @see service_storage_start_task() +* @see service_adaptor_get_last_result() +* @see service_adaptor_get_last_error_message() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon +* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal +* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error +* @post #service_storage_task_state_cb() will be invoked +*/ +int service_storage_set_task_state_changed_cb(service_storage_task_h task, + service_storage_task_state_cb callback, + void *user_data); + +/** +* @brief Unsets the state changed callback function. +* @since_tizen 2.4 +* +* @param[in] task The handle of storage task +* @remarks This function must be called before starting task (see #service_storage_start_task()) +* @see service_storage_start_task() +* @see service_storage_set_task_progress_cb() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_unset_task_state_changed_cb(service_storage_task_h task); + +/** +* @brief Clones the file list handle +* @since_tizen 2.4 +* +* @param[in] src_list The source handle +* @param[out] dst_list The destination handle +* @remarks @a file must be released memory using service_storage_file_list_destroy() when you no longer needs this handle +* @see service_storage_file_list_h +* @see service_storage_file_list_destroy() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_file_list_clone(service_storage_file_list_h src_list, + service_storage_file_list_h *dst_list); + +/** +* @brief Destroys the file list handle +* @since_tizen 2.4 +* +* @param[in] list The file list handle +* @remarks It must be used for cloned file list handle +* @see service_storage_file_list_h +* @see service_storage_file_list_clone() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_file_list_destroy(service_storage_file_list_h list); + +/** +* @brief Gets length of the file list handle +* @since_tizen 2.4 +* +* @param[in] list The file list handle +* @param[out] length The length of the file list handle +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_file_list_get_length(service_storage_file_list_h list, + int *length); + +/** +* @brief Foreach All of the file from file list +* @since_tizen 2.4 +* +* @param[in] list The file list handle +* @param[in] callback The callback for foreach file +* @param[in] user_data Passed data to callback +* @see #service_storage_file_cb +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files +*/ +int service_storage_file_list_foreach_file(service_storage_file_list_h list, + service_storage_file_cb callback, + void *user_data); + +/** +* @brief Clones the file handle +* @since_tizen 2.4 +* +* @param[in] src_file The source handle +* @param[out] dst_file The destination handle +* @remarks @a file must be released memory using service_storage_file_destroy() when you no longer needs this handle +* @see #service_storage_file_h +* @see #service_storage_file_destroy() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_file_clone(service_storage_file_h src_file, + service_storage_file_h *dst_file); + +/** +* @brief Destroys the file handle +* @details This function must be used for cloned file handle. +* @since_tizen 2.4 +* +* @param[in] file The handle of file or directory in storage +* @see service_storage_file_h +* @see service_storage_file_clone() +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_file_destroy(service_storage_file_h file); + +/** +* @brief Gets whether directory or file for file handle +* @since_tizen 2.4 +* +* @param[in] file The handle of file or directory in storage +* @param[out] is_dir true on directory, false on file +* @see service_storage_file_h +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_file_is_dir(service_storage_file_h file, + bool *is_dir); + +/** +* @brief Gets size of handle +* @since_tizen 2.4 +* +* @param[in] file The handle of file or directory in storage +* @param[out] size The size of file (byte) +* @see service_storage_file_h +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int service_storage_file_get_size(service_storage_file_h file, + unsigned long long *size); + +/** +* @brief Gets logical path from file handle +* @since_tizen 2.4 +* +* @param[in] file The handle of file or directory in storage +* @param[out] path The logical path of file +* @remarks @a path must be released using free() +* @remarks Reference details for "Logical path" and "Physical path" at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page +* @see #service_storage_file_h +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data +*/ +int service_storage_file_get_logical_path(service_storage_file_h file, + char **path); + +/** +* @brief Gets physical path from file handle +* @since_tizen 2.4 +* +* @param[in] file The handle of file or directory in storage +* @param[out] path The physical path of file +* @remarks @a path must be released using free() +* @remarks Reference details for "Logical path" and "Physical path" at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page +* @see #service_storage_file_h +* @return 0 on success, otherwise a negative error value +* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful +* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data +*/ +int service_storage_file_get_physical_path(service_storage_file_h file, + char **path); + #ifdef __cplusplus } #endif diff --git a/client/sal_service_storage_internal.h b/client/sal_service_storage_internal.h index 4e2a024..8f7df0a 100644 --- a/client/sal_service_storage_internal.h +++ b/client/sal_service_storage_internal.h @@ -57,6 +57,95 @@ typedef struct _service_storage_cloud_file_s int service_storage_cloud_start(service_storage_cloud_file_h file); int service_storage_cloud_stop(service_storage_cloud_file_h file); +/*================================================================================================== + 2.4 FUNCTION PROTOTYPES +==================================================================================================*/ + +/** + * Storage adaptor content type + */ +typedef enum _service_storage_file_content_type_e +{ + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DEFAULT = -1, // initalize value + + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_IMGAE = 160, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_VIDEO = 161, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_SOUND = 162, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_MUSIC = 163, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_OTHER = 164, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DOCUMENT = 165, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_THUMBNAIL = 166, + + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_CHUNK_MASK = 320, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_IMGAE_CHUNK = 480, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_VIDEO_CHUNK = 481, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_SOUND_CHUNK = 482, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_MUSIC_CHUNK = 483, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_OTHER_CHUNK = 484, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DOCUMENT_CHUNK = 485, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_THUMBNAIL_CHUNK = 486, + + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_FOLDER = 1024, + SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_METADATA = 2048, +} service_storage_content_type_e; + +typedef struct _service_storage_media_meta_s +{ + char *mime_type; + char *title; + char *album; + char *artist; + char *genere; + char *recorded_date; + int width; + int height; + int duration; + char *copyright; + char *track_num; + char *description; + char *composer; + char *year; + int bitrate; + int samplerate; + int channel; + char *extra_media_meta; +} service_storage_media_meta_s; + +typedef struct _service_storage_cloud_meta_s +{ + char *service_name; + unsigned long long usage_byte; + unsigned long long quota_byte; + char *extra_cloud_meta; +} service_storage_cloud_meta_s; + +/** +* @brief Describes file information description +*/ +struct _service_storage_file_s +{ + char *plugin_name; /**< specifies plugin name generated file_info */ + char *object_id; /**< specifies file object id be used in storage */ + char *storage_path; /**< specifies file path in storage */ + unsigned long long file_size; /**< specifies file size (recomend byte)*/ + unsigned long long created_time; /**< specifies timestamp */ + unsigned long long modified_time; /**< specifies timestamp */ + int file_info_index; /**< specifies file info index (wide use; e.g : chunk upload, multi download)*/ + service_storage_content_type_e content_type; /**< specifies file content type (reference service_adaptor_file_content_type_e) */ + + service_storage_media_meta_s *media_meta; + service_storage_cloud_meta_s *cloud_meta; + char *extra_file_info; /**< specifies content name in metadata */ +}; + + +typedef struct _service_storage_file_s service_storage_file_s; + +/** +* @brief The handle for File Description +*/ +typedef struct _service_storage_file_s *service_storage_file_h; + #ifdef __cplusplus } #endif diff --git a/test/test.c b/test/test.c index 46d64f5..a1af928 100644 --- a/test/test.c +++ b/test/test.c @@ -30,7 +30,7 @@ void _service_plugin_login_callback(int result, void *user_data) { int ret = SERVICE_ADAPTOR_ERROR_NONE; - ret = service_plugin_start(service_plugin); + ret = service_plugin_start2(service_plugin); if (SERVICE_ADAPTOR_ERROR_NONE != ret) { @@ -118,7 +118,7 @@ int main() int ret = SERVICE_ADAPTOR_ERROR_NONE; ret = service_adaptor_connect(); - ret = service_adaptor_foreach_plugin(_service_adaptor_plugin_callback, NULL); + ret = service_adaptor_foreach_plugin2(_service_adaptor_plugin_callback, NULL); loop = g_main_loop_new(NULL, FALSE); -- 2.7.4