SET(ADAPTOR-CLIENT-LIB "service-adaptor-client")
FILE(GLOB ADAPTOR-CLIENT-SRCS
- ${CMAKE_SOURCE_DIR}/api/client/src/*.c
- ${CMAKE_SOURCE_DIR}/api/client/src/dbus/*.c
- ${CMAKE_SOURCE_DIR}/api/client/src/util/*.c
+ ${CMAKE_SOURCE_DIR}/api/client/src/service_adaptor_client.c
+ ${CMAKE_SOURCE_DIR}/api/client/src/service_adaptor_client_storage.c
+ ${CMAKE_SOURCE_DIR}/api/client/src/dbus/dbus_client.c
+ ${CMAKE_SOURCE_DIR}/api/client/src/dbus/dbus_client_layer.c
+ ${CMAKE_SOURCE_DIR}/api/client/src/dbus/dbus_client_storage.c
+ ${CMAKE_SOURCE_DIR}/api/client/src/util/service_adaptor_client_util.c
)
INCLUDE_DIRECTORIES(
*/
int _dbus_connect_service_adaptor(service_adaptor_error_s *error);
-int _dbus_disconnect_service_adaptor(service_adaptor_error_s *error);
-
int _dbus_get_plugin_list(plugin_entry_t ***plugin_list, unsigned int *plugins_len, service_adaptor_error_s *error);
int _dbus_is_login_required(service_plugin_h plugin, bool *required, service_adaptor_error_s *error);
int _dbus_start_service(service_plugin_h plugin, int service_flag, const char *security_cookie, service_adaptor_error_s *error);
-int _dbus_external_request(const char *service_name,
- int service_flag,
- const char *api_uri,
- unsigned char *input_str,
- int input_len,
- unsigned char **output_str,
- int *output_len,
- service_adaptor_error_s *error);
-
#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_H__ */
GVariant *parameters,
gpointer user_data);
-/**
- * @brief
- * @param[out]
- * @param[out]
- * @return
- * @pre This function requires opened DBus connection by service-adaptor-client-storage.c
- */
-int _dbus_download_file(const char *service_name,
- const char *server_path,
- const char *download_path,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _dbus_download_thumbnail(const char *service_name,
- const char *server_path,
- const char *download_path,
- int thumbnail_size,
- service_adaptor_error_s *error);
-
int _dbus_download_file_async(const char *service_name,
const char *server_path,
const char *download_path,
void *user_data,
service_adaptor_error_s *error);
-int _dbus_upload_file(const char *service_name,
- const char *upload_path,
- const char *server_path,
- service_storage_file_h *file_info,
- void *user_data,
- service_adaptor_error_s *error);
-
int _dbus_upload_file_async(const char *service_name,
const char *upload_path,
const char *server_path,
void *user_data,
service_adaptor_error_s *error);
-int _dbus_get_root_folder_path(const char *service_name,
- char **root_folder_path,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _dbus_make_directory(const char *service_name,
- const char *folder_path,
- service_storage_file_h *file_info,
- void *user_data,
- service_adaptor_error_s *error);
-
int _dbus_remove_file(const char *service_name,
const char *file_path,
void *user_data,
service_adaptor_error_s *error);
-int _dbus_remove_directory(const char *service_name,
- const char *folder_path,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _dbus_move_file(const char *service_name,
- const char *src_file_path,
- const char *dst_file_path,
- service_storage_file_h *file_info,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _dbus_move_directory(const char *service_name,
- const char *src_folder_path,
- const char *dst_folder_path,
- service_storage_file_h *file_info,
- void *user_data,
- service_adaptor_error_s *error);
-
int _dbus_get_file_list(const char *service_name,
const char *parent_path,
service_storage_file_h **file_info_list,
long long int _task_id,
service_adaptor_error_s *error);
-
-
-
-///////////////////// private feature
-
-
-int _private_dbus_download_file_async(const char *service_name,
- const char *server_path,
- const char *download_path,
- service_adaptor_file_h *file_handle,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _private_dbus_upload_file_async(const char *service_name,
- const char *upload_path,
- const char *server_path,
- service_adaptor_file_h *file_handle,
- void *user_data,
- service_adaptor_error_s *error);
-
-
-
-int _dbus_download_file_publish(const char *service_name,
- const char *server_path,
- const char *download_path,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _dbus_download_file_publish_async(const char *service_name,
- const char *server_path,
- const char *download_path,
- service_adaptor_file_h *file_handle,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _dbus_upload_file_publish(const char *service_name,
- const char *upload_path,
- const char *server_path,
- char **publish_url,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _dbus_upload_file_publish_async(const char *service_name,
- const char *upload_path,
- const char *server_path,
- service_adaptor_file_h *file_handle,
- void *user_data,
- service_adaptor_error_s *error);
-
-int _dbus_get_file_status(const char *service_name,
- service_adaptor_file_h file_handle,
- service_adaptor_file_status_s **status,
- void **server_data,
- service_adaptor_error_s *error);
-
-int _dbus_cancel_file_transfer(const char *service_name,
- service_adaptor_file_h file_handle,
- void **server_data,
- service_adaptor_error_s *error);
-
-int _dbus_pause_file_transfer(const char *service_name,
- service_adaptor_file_h file_handle,
- void **server_data,
- service_adaptor_error_s *error);
-
-int _dbus_resume_file_transfer(const char *service_name,
- service_adaptor_file_h file_handle,
- void **server_data,
- service_adaptor_error_s *error);
-
-
int _dbus_get_privilege_check_result(const char *service_name,
const char *privilege_name,
void **server_data,
service_adaptor_error_s *error);
-///////////////////// private feature
-
#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_STORAGE_H__ */
FUNCTION PROTOTYPES
==================================================================================================*/
-/**
-* @brief Registers File Progress Listener
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] callback the callback function to invoke
-* @param[in] user_data specifies user_data passed in API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_register_file_progress_listener(service_adaptor_h handle,
- service_adaptor_file_progress_cb callback,
- void *user_data);
-
-/**
-* @brief Unregisters File Progress Listener
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] user_data specifies user_data passed in API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_unregister_file_progress_listener(service_adaptor_h handle,
- void *user_data);
-
-/**
-* @brief Registers File Transfer Completion Listener
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] callback the callback function to invoke
-* @param[in] user_data specifies user_data passed in API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_register_file_transfer_completion_listener(service_adaptor_h handle,
- service_adaptor_file_transfer_completion_cb callback,
- void *user_data);
-
-/**
-* @brief Unregisters File Transfer Completion Listener
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] user_data specifies user_data passed in API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_unregister_file_transfer_completion_listener(service_adaptor_h handle,
- void *user_data);
-
-/**
-* @brief Downloads a server file and writes it to local file
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] server_path specifies server url of file to download
-* @param[in] download_path specifies local path where we expect downloaded file to be written
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_download_file(service_adaptor_h handle,
- const char *server_path,
- const char *download_path,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Downloads a server file and writes it to local file (Async)
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] server_path specifies server url of file to download
-* @param[in] download_path specifies local path where we expect downloaded file to be written
-* @param[out] file_handle specifies file description
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_download_file_async(service_adaptor_h handle,
- const char *server_path,
- const char *download_path,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Uploads a local file to server path
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] upload_path specifies local path for upload
-* @param[in] server_path specifies server url of file to download
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_upload_file(service_adaptor_h handle,
- const char *upload_path,
- const char *server_path,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Uploads a local file to server path (Async)
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] upload_path specifies local path for upload
-* @param[in] server_path specifies server url of file to download
-* @param[out] file_handle specifies file description
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_upload_file_async(service_adaptor_h handle,
- const char *upload_path,
- const char *server_path,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Downloads a server file and writes it to local file
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] publish_url specifies publish url of file to download
-* @param[in] download_path specifies local path where we expect downloaded file to be written
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_download_file_publish(service_adaptor_h handle,
- const char *publish_url,
- const char *download_path,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Downloads a server file and writes it to local file (Async)
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] publish_url specifies publish url of file to download
-* @param[in] download_path specifies local path where we expect downloaded file to be written
-* @param[out] file_handle specifies file description
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_download_file_publish_async(service_adaptor_h handle,
- const char *publish_url,
- const char *download_path,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Uploads a local file to server path
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] upload_path specifies local path for upload
-* @param[in] server_path specifies server url of file to download
-* @param[out] publish_url specifies publish url
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_upload_file_publish(service_adaptor_h handle,
- const char *upload_path,
- const char *server_path,
- char **publish_url,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Uploads a local file to server path (Async)
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] upload_path specifies local path for upload
-* @param[in] server_path specifies server url of file to download
-* @param[out] file_handle specifies file description
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_upload_file_publish_async(service_adaptor_h handle,
- const char *upload_path,
- const char *server_path,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Downloads a thumbnail file and writes it to local file
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] publish_url specifies publish url of file to download
-* @param[in] download_path specifies local path where we expect downloaded file to be written
-* @param[in] size specifies size of thumbnail
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_download_thumbnail_publish(service_adaptor_h handle,
- const char *publish_url,
- const char *download_path,
- service_adaptor_thumbnail_size_e size,
- service_adaptor_error_s **error_code,
- void *user_data);
-
-/**
-* @brief Requests File Status
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] file_handle specifies file description
-* @param[out] status specifies status of file transfer
-* @param[out] error_code specifies error code
-* @param[out] server_data specifies server_data (json) received from Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_get_file_status(service_adaptor_h handle,
- service_adaptor_file_h file_handle,
- service_adaptor_file_status_s **status,
- service_adaptor_error_s **error_code,
- void **server_data);
-
-/**
-* @brief Cancels File Transfer
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] file_handle specifies file description
-* @param[out] error_code specifies error code
-* @param[out] server_data specifies server_data (json) received from Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_cancel_file_transfer(service_adaptor_h handle,
- service_adaptor_file_h file_handle,
- service_adaptor_error_s **error_code,
- void **server_data);
-
-/**
-* @brief Pause File Transfer
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] file_handle specifies file description
-* @param[out] error_code specifies error code
-* @param[out] server_data specifies server_data (json) received from Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_pause_file_transfer(service_adaptor_h handle,
- service_adaptor_file_h file_handle,
- service_adaptor_error_s **error_code,
- void **server_data);
-
-/**
-* @brief Resume File Transfer
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] file_handle specifies file description
-* @param[out] error_code specifies error code
-* @param[out] server_data specifies server_data (json) received from Server API
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-service_adaptor_result_e service_adaptor_resume_file_transfer(service_adaptor_h handle,
- service_adaptor_file_h file_handle,
- service_adaptor_error_s **error_code,
- void **server_data);
#endif /* __PRIVATE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__ */
service_adaptor_signal_code_e signal,
char *msg);
-/**
-* @brief Callback for getting async external operation result
-*
-* @param[in] result Result code for async operation (see #service_adaptor_error_e)
-* @param[in] out_params Created bundle, if the special API returns optional values, get result from this bundle (reference to plugin's SPEC)
-* @param[in] user_data Passed data from request function
-* @remarks You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. 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 data
-* @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_adaptor_external_request_async()
-* @see service_adaptor_get_last_result()
-* @see service_adaptor_get_last_error_message()
-* @return void
-* @pre #service_adaptor_external_request_async() will invoke this callback.
-*/
-typedef void (*service_adaptor_external_response_cb)(int result,
- bundle *out_params,
- void *user_data);
/*==================================================================================================
FUNCTION PROTOTYPES
==================================================================================================*/
-/**
-* @brief Connects Service Adaptor
-*
-* @param[out] handle specifies Service Adaptor handle
-* @param[in] callback the callback function to invoke
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-int service_adaptor_connect(service_adaptor_h *handle,
- service_adaptor_signal_cb callback);
-
-/**
-* @brief Disconnects Service Adaptor
-*
-* @param[in] handle the handle which is returned in service_adaptor_connect
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-int service_adaptor_disconnect(service_adaptor_h handle);
-
-/**
-* @brief Sets IMSI
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] imsi specifies Mobile station identification number
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-int service_adaptor_set_imsi(service_adaptor_h handle,
- const char *imsi);
-
-int service_adaptor_set_plugin(service_adaptor_h handle,
- const char *plugin_uri);
-
-/**
-* @brief Free the list of auth plugin
-*
-* @param[in] plugins specifies the list of auth plugin
-* @param[in] plugins_len specifies length of auth plugins
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
-*/
-int service_adaptor_free_plugins(service_adaptor_plugin_h *plugins,
- unsigned int plugins_len);
-
-/**
-* @brief Requests external API to plugin directly (Sync)
-* @since_tizen 2.4
-* @param[in] handle The handle of service-adaptor
-* @param[in] service_flag The special API direction to specific plugin (refer to #service_plugin_service_type_e)
-* @param[in] api_uri The special API signature that is described plugin's SPEC
-* @param[in] in_params Created bundle, if the special API needs optional parameter, insert to bundle (refer to plugin's SPEC)
-* @param[in] out_params Created bundle, if the special API returns optional values, get result from this bundle (refer to plugin's SPEC)
-* @remarks @a in_params must be created using bundle_create()
-* @remarks @a out_params must be released memory using bundle_free()
-* @remarks You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. Error codes and messages are described in Service Plugin.
-* @see service_adaptor_get_last_result()
-* @see service_adaptor_get_last_error_message() (refer to #service_plugin_service_type_e)
-* @return 0 on success, otherwise a negative error value
-* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
-* @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
-*/
-int service_adaptor_external_request(service_adaptor_h handle,
- int service_flag,
- const char *api_uri,
- bundle *in_params,
- bundle **out_params);
-
-/**
-* @brief Requests external API to plugin directly (Async)
-* @since_tizen 2.4
-* @param[in] handle The handle of service-adaptor
-* @param[in] service_flag The special API direction to specific plugin
-* @param[in] api_uri The special API signature that is descrypted plugin's SPEC
-* @param[in] in_params Created bundle, if the special API needs optional parameter, insert to bundle (reference to plugin's SPEC)
-* @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 You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. Error codes and messages are described in Service Plugin.
-* @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_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
-* @post #service_adaptor_external_response_cb() will be invoked
-*/
-int service_adaptor_external_request_async(service_adaptor_h handle,
- int service_flag,
- const char *api_uri,
- bundle *in_params,
- service_adaptor_external_response_cb callback,
- void *user_data);
#endif /* __PRIVATE_SERVICE_ADAPTOR_CLIENT_H__ */
client_app_type_e app_type;
};
-
-
-
-
-/**
-* @brief Callback for getting login result
-* @since_tizen 2.4
-*
-* @param[in] result Result code for login request (see #service_adaptor_error_e)
-* @param[in] user_data Passed data from request function
-* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
-* @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_NETWORK_UNREACHABLE Failed by network issue
-* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
-* @see #service_adaptor_error_e
-* @see service_plugin_request_login()
-* @pre #service_plugin_request_login() will invoke this callback.
-*/
-typedef void (*service_plugin_login_cb)(int result,
- void *user_data);
-
-
-
/**
* @brief Set callback for changing state of Service Adaptor
* @since_tizen 2.4
service_adaptor_signal_cb callback,
void *user_data);
-/**
-* @brief Set callback for changing state of Service Adaptor
-* @since_tizen 2.4
-*
-* @param[in] service_adaptor The handle of Service Adaptor
-* @remarks @a service_adaptor must be released memory using service_adaptor_destroy() when you finish using 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_HANDLE Invalid handle
-* @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_unset_state_changed_cb(service_adaptor_h service_adaptor);
-
-/**
-* @brief Gets whether a plugin is logined or not logined
-* @details 'Login' includes both authentication(sign-in by user) and authorization (allowed by user) <br>
-* If plugin does not need authentication or authorization, service_plugin_is_login_required() API's result is true on anytime.
-* @since_tizen 2.4
-*
-* @param[in] plugin The handle for use Plugin APIs
-* @param[out] required true on login required, otherwise false
-* @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
-*/
-int service_plugin_is_login_required(service_plugin_h plugin,
- bool *required);
-
-/**
-* @brief Requests login to plugin
-* @details 'Login' includes both authentication(sign-in by user) and authorization (allowed by user) <br>
-* If the plugin does not logined by user, you must request login using this API.<br>
-* You can check whether logined or not using service_plugin_is_login_required().<br>
-* If not logined, you will be failed #service_plugin_start().<br>
-* Of caurse, if plugin does not need authentication or authorization, service_plugin_is_login_required() API's result is true on anytime.
-* @since_tizen 2.4
-*
-* @param[in] plugin The handle for use Plugin APIs
-* @param[in] callback The callback for getting result this operation
-* @param[in] user_data The user data to be passed to the callback function
-* @see service_plugin_start()
-* @see service_plugin_login_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_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_UNKNOWN Unknown error
-* @post #service_plugin_login_cb() will be invoked
-*/
-int service_plugin_request_login(service_plugin_h plugin,
- service_plugin_login_cb callback,
- void *user_data);
-
/**
* @brief The type for Service Adaptor
*/
-/**
-* @brief Downloads a server file and writes it to local file
-* @since_tizen 2.4
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] server_path specifies server url of file to download
-* @param[in] download_path specifies local path where we expect downloaded file to be written
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-
-int service_storage_download_file(service_plugin_h handle,
- const char *storage_path,
- const char *local_path);
-
-/**
-* @brief Requests download thumbnail from storage (internal)
-* @since_tizen 2.4
-*
-* @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 <b>level</b> of thumbnail, the level is defined service plugin SPEC
-* @remarks If @a thumbnail_size is <b>0</b>, gets default size thumbnail, the default size must be defined plugin SPEC
-* @remarks If @a thumbnail_size is <b>-1</b>, gets minimum size thumbnail be supported plugin
-* @remarks If @a thumbnail_size is <b>-2</b>, gets maximum size thumbnail be supported plugin
-* @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 <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
-* @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_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_download_thumbnail(service_plugin_h handle,
- const char *storage_path,
- const char *local_path,
- int thumbnail_size);
-
-/**
-* @brief Uploads a local file to server path
-* @since_tizen 2.4
-* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
-* @see service_storage_file_h
-* @see service_storage_unref_file_info
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] upload_path specifies local path for upload
-* @param[in] server_path specifies server url of file to download
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @remarks 'file_info' is needed memory free using 'service_storage_unref_file_info()'
-* @see service_storage_unref_file_info()
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-int service_storage_upload_file(service_plugin_h handle,
- const char *local_path,
- const char *storage_path,
- service_storage_file_h *file_info);
-/**
-* @brief Get root diretory path
-* @since_tizen 2.4
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[out] dir_path specifies be mounted path
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-int service_storage_get_root_directory(service_plugin_h handle,
- char **dir_path);
-
-/**
-* @brief Make directory in storage
-* @since_tizen 2.4
-* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
-* @see service_storage_file_h
-* @see service_storage_unref_file_info
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] dir_path specifies directory path will be made
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @remarks 'file_info' is needed memory free using 'service_storage_unref_file_info()'
-* @see service_storage_unref_file_info()
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-int service_storage_make_directory(service_plugin_h handle,
- const char *dir_path,
- service_storage_file_h *file_info);
-
-/**
-* @brief Remove file in storage
-* @since_tizen 2.4
-* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
-* @see service_storage_file_h
-* @see service_storage_unref_file_info
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] file_path specifies file path will be removed
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-int service_storage_remove_file(service_plugin_h handle,
- const char *file_path);
-
-/**
-* @brief Remove directory in storage
-* @since_tizen 2.4
-* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
-* @see service_storage_file_h
-* @see service_storage_unref_file_info
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] file_path specifies directory path will be removed
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-int service_storage_remove_directory(service_plugin_h handle,
- const char *dir_path);
-
-/**
-* @brief Move file in storage
-* @since_tizen 2.4
-* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
-* @see service_storage_file_h
-* @see service_storage_unref_file_info
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] src_file_path specifies source file path will move
-* @param[in] dst_file_path specifies destination file path will be moved
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @remarks 'file_info' is needed memory free using 'service_storage_unref_file_info()'
-* @see service_storage_unref_file_info()
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-int service_storage_move_file(service_plugin_h handle,
- const char *src_file_path,
- const char *dst_file_path,
- service_storage_file_h *file_info);
-
-/**
-* @brief Move directory in storage
-* @since_tizen 2.4
-* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
-* @see service_storage_file_h
-* @see service_storage_unref_file_info
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] src_file_path specifies source directory path will move
-* @param[in] dst_file_path specifies destination directory path will be moved
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @remarks 'file_info' is needed memory free using 'service_storage_unref_file_info()'
-* @see service_storage_unref_file_info()
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-int service_storage_move_directory(service_plugin_h handle,
- const char *src_dir_path,
- const char *dst_dir_path,
- service_storage_file_h *file_info);
-
-/**
-* @brief Get directory entries in storage
-* @since_tizen 2.4
-*
-* @param[in] handle specifies Service Adaptor handle
-* @param[in] dir_path specifies parent directory path
-* @param[out] file_info_list specifies file_info entries in 'dir_path'
-* @param[out] file_info_list_len specifies file_info entries count
-* @param[out] error_code specifies error code
-* @param[in] user_data specifies user_data (json) passed in Server API
-* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
-* @see service_adaptor_error_s
-* @remarks 'file_info_list[<index>]' is needed memory free using 'service_storage_unref_file_info()'
-* @see service_storage_unref_file_info()
-* @remarks 'file_info_list' is needed memory free using 'free()' after free for each element
-* @see free()
-* @return 0 on success, otherwise a negative error value
-* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
-*/
-int service_storage_get_directory_entries(service_plugin_h handle,
- const char *dir_path,
- service_storage_file_h **file_info_list,
- unsigned int *file_info_list_len);
-
-
/**
* @brief Gets result after finishing storage task
* @since_tizen 2.4
}
FUNC_END();
}
-
+//LCOV_EXCL_START
static void on_name_vanished(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
}
FUNC_END();
}
+//LCOV_EXCL_STOP
static void _service_signal_emitter(void *data)
{
FUNC_END();
}
-static void on_service_signal(GDBusProxy *proxy,
- gchar *sender_name,
- gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
-{
- FUNC_START();
-
- if (0 == g_strcmp0(signal_name, DBUS_SERVICE_ADAPTOR_SIGNAL)) {
- service_adaptor_task_h task = _signal_queue_get_task(SIGNAL_SERVICE_ADAPTOR);
-
- if (NULL == task) {
- FUNC_STOP();
- return;
- }
-
- struct _internal_service_signal_data_s *signal_context =
- (struct _internal_service_signal_data_s *)g_malloc0(sizeof(struct _internal_service_signal_data_s));
-
- if (NULL == signal_context) {
- FUNC_STOP();
- return;
- } else {
- signal_context->msg = NULL;
- signal_context->task = NULL;
- }
-
- GVariant *call_result[2];
- call_result[0] = g_variant_get_child_value(parameters, 0);
- call_result[1] = g_variant_get_child_value(parameters, 1);
-
- signal_context->code = g_variant_get_uint64(call_result[0]);
- signal_context->msg = ipc_g_variant_dup_string(call_result[1]);
- signal_context->task = task;
-
-
- GError *worker_error = NULL;
- g_thread_try_new("service-adaptor-client-signal-emitter", (GThreadFunc) _service_signal_emitter,
- (void *) signal_context, &worker_error);
-
- g_clear_error(&worker_error);
- worker_error = NULL;
- }
-
- FUNC_END();
-}
-
static void on_signal(GDBusProxy *proxy,
gchar *sender_name,
gchar *signal_name,
GVariant *parameters,
gpointer user_data)
{
- if (0 == strncmp(signal_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH)) {
- on_service_signal(proxy,
- sender_name,
- signal_name,
- parameters,
- user_data);
- } else if (0 == strncmp(signal_name, DBUS_MESSAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
- on_message_signal(proxy,
- sender_name,
- signal_name,
- parameters,
- user_data);
- } else if (0 == strncmp(signal_name, DBUS_STORAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
+ if (0 == strncmp(signal_name, DBUS_STORAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
on_storage_signal(proxy,
sender_name,
signal_name,
parameters,
user_data);
- } else if (0 == strncmp(signal_name, DBUS_PUSH_ADAPTOR, DBUS_NAME_LENGTH)) {
- on_push_signal(proxy,
- sender_name,
- signal_name,
- parameters,
- user_data);
}
-
}
/******************************************************************************
* @param builder Builder
* @param data String to be added
*/
+/*
void __safe_g_variant_builder_add_string(GVariantBuilder *builder,
const char *data)
{
g_variant_builder_add(builder, "(s)", data);
}
}
+*/
char *ipc_g_variant_dup_string(GVariant *string)
{
return ret;
}
-int _dbus_disconnect_service_adaptor(service_adaptor_error_s *error)
-{
- FUNC_START();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- ipc_check_proxy(sac_interface_proxy);
-
- char executable_path[1000] = {0, };
- int executable_path_len = 0;
- executable_path_len = readlink("/proc/self/exe", executable_path, 1000);
-
- if (executable_path_len <= 0)
- snprintf(executable_path, strlen("notfound") + 1, "%s", "notfound");
-
- char *client_info = g_strdup_printf("%s %d", executable_path, (int)getpid());
-
- sac_info("[DM] client info <%s>", client_info);
- GVariant *req = g_variant_new("("service_adaptor_essential_s_type")", client_info);
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_DISCONNECT_SERVICE_ADAPTOR_METHOD,
- req,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &g_error);
-
- if (NULL == call_result) {
- error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
- ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
-
- if (NULL != g_error) {
- error->msg = __SAFE_STRDUP(g_error->message);
- g_error_free(g_error);
- }
- } else {
- if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
- error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
- error->msg = strdup("D-Bus return type error");
- ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
- } else {
- GVariant *call_result_struct[2];
- call_result_struct[0] = g_variant_get_child_value(call_result, 0);
- call_result_struct[1] = g_variant_get_child_value(call_result, 1);
-
- uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
- error->code = remote_call_result;
- error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
- ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
- }
-
- g_variant_unref(call_result_struct[0]);
- g_variant_unref(call_result_struct[1]);
- }
-
- g_variant_unref(call_result);
- }
-
-/* g_variant_unref(req);*/
- free(client_info);
-
- FUNC_END();
- return ret;
-}
-
int _dbus_get_plugin_list(plugin_entry_t ***plugin_list,
unsigned int *plugins_len,
service_adaptor_error_s *error)
return ret;
}
-int _dbus_is_login_required(service_plugin_h plugin,
- bool *required,
- service_adaptor_error_s *error)
-{
- FUNC_START();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariantBuilder *builder_in = NULL;
- _create_raw_data_from_plugin_property((void *)(plugin->optional_property), &builder_in);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_IS_AUTH_METHOD,
- g_variant_new("(" service_adaptor_is_auth_req_s_type ")",
- plugin->plugin_uri,
- builder_in),
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- bool is_auth = false;
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE("(b)"),
-
- GVariant *res_info_struct = g_variant_get_child_value(call_result_struct[0], 0);
- is_auth = g_variant_get_boolean(res_info_struct);
- g_variant_unref(res_info_struct);
- );
-
- *required = !is_auth;
-
- return ret;
-}
-
-struct __login_request_context {
- void *callback;
- void *user_data;
-};
-
-static void __dbus_login_result_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
-
- service_adaptor_error_s error = {0LL, NULL};
- GError *g_error = NULL;
-
- GVariant *result_obj = g_dbus_proxy_call_finish(_dbus_get_sac_interface_proxy(), res, &g_error);
- int result = _ipc_get_simple_result(result_obj, g_error, &error);
- if (SERVICE_ADAPTOR_ERROR_NONE != result) {
- service_adaptor_set_last_result(error.code, error.msg);
- }
-
- struct __login_request_context *context = (struct __login_request_context *)user_data;
- service_plugin_login_cb callback = (service_plugin_login_cb)(context->callback);
-
- callback(result, context->user_data);
-
- free(context);
- if (g_error) {
- g_error_free(g_error);
- }
-}
-
-int _dbus_request_login(service_plugin_h plugin,
- void *callback,
- void *user_data,
- service_adaptor_error_s *error)
-{
- FUNC_START();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- struct __login_request_context *context = (struct __login_request_context *)calloc(1, sizeof(struct __login_request_context));
- if (NULL == context) {
- error->code = SERVICE_ADAPTOR_ERROR_UNKNOWN;
- error->msg = strdup("Memory allocation failed");
- return SERVICE_ADAPTOR_ERROR_UNKNOWN;
- }
- context->callback = callback;
- context->user_data = user_data;
-
- GVariantBuilder *builder_in = NULL;
- _create_raw_data_from_plugin_property((void *)(plugin->optional_property), &builder_in);
-
- g_dbus_proxy_call(sac_interface_proxy,
- DBUS_JOIN_METHOD,
- g_variant_new("(" service_adaptor_join_req_s_type ")",
- plugin->plugin_uri,
- builder_in),
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- __dbus_login_result_callback,
- (void *)context);
-
- return ret;
-}
int _dbus_start_service(service_plugin_h plugin,
int service_flag,
return ret;
}
-int _dbus_external_request(const char *service_name,
- int service_flag,
- const char *api_uri,
- unsigned char *input_str,
- int input_len,
- unsigned char **output_str,
- int *output_len,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariantBuilder *builder_in = g_variant_builder_new(G_VARIANT_TYPE(service_adaptor_raw_data_s_type));
- for (int k = 0; k < input_len; k++) {
- g_variant_builder_add(builder_in, "(y)", (guchar)input_str[k]);
- }
-
- sac_debug_func("input_str_len(%d)", input_len);
- /* sac_debug_func("input_str(%s)", input_str); */
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_EXTERNAL_REQ_METHOD,
- g_variant_new("(" private_service_adaptor_external_req_s_type ")",
- service_name,
- (int32_t) service_flag,
- api_uri,
- builder_in),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &g_error);
-
- g_variant_builder_unref(builder_in);
-
- sac_debug("%s API sent", PRIVATE_DBUS_EXTERNAL_REQ_METHOD);
-
- if (NULL == call_result) {
- error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
- ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
-
- if (NULL != g_error) {
- error->msg = __SAFE_STRDUP(g_error->message);
- g_error_free(g_error);
- }
- } else {
- if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(service_adaptor_raw_data_s_type)))) {
- error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
- error->msg = strdup("D-Bus return type error");
- ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
- } else {
- FUNC_STEP();
- GVariant *call_result_struct[3];
- call_result_struct[0] = g_variant_get_child_value(call_result, 0);
- call_result_struct[1] = g_variant_get_child_value(call_result, 1);
- call_result_struct[2] = g_variant_get_child_value(call_result, 2);
-
-
- uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
- error->code = remote_call_result;
- error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
- ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
- } else {
-
- int raw_data_len = g_variant_n_children(call_result_struct[0]);
- unsigned char *raw_data = (unsigned char *) calloc((raw_data_len + 1), sizeof(unsigned char));
-
- if (NULL != raw_data) {
- for (int k = 0; k < raw_data_len; k++) {
- g_variant_get_child(call_result_struct[0], k, "(y)", &(raw_data[k]));
- }
- *output_str = raw_data;
- *output_len = raw_data_len;
- }
- sac_debug_func("output_str_len(%d)", raw_data_len);
- /* sac_debug_func("output_str(%s)", raw_data); */
- }
-
- g_variant_unref(call_result_struct[0]);
- g_variant_unref(call_result_struct[1]);
- g_variant_unref(call_result_struct[2]);
- }
-
- g_variant_unref(call_result);
- }
-
- return ret;
-}
-
+//LCOV_EXCL_START
static void *_on_dbus_disappeared_cb(void *data)
{
FUNC_START();
FUNC_END();
return NULL;
}
+//LCOV_EXCL_STOP
* Private interface definition
******************************************************************************/
-/******************************************************************************
- private feature
-******************************************************************************/
-
-void __private_get_file_progress_type(GVariant *parameters,
- service_adaptor_file_h *file_handle,
- uint64_t *progress_size,
- uint64_t *total_size)
-{
- GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
- GVariant *res_struct[private_service_adaptor_file_progress_s_type_length];
-
- for (size_t j = 0; j < private_service_adaptor_file_progress_s_type_length; j++) {
- res_struct[j] = g_variant_get_child_value(in_parameters, j);
- }
-
- int idx = 0;
- *file_handle = (service_adaptor_file_h) calloc(1, sizeof(service_adaptor_file_s));
- if (NULL != *file_handle) {
- (*file_handle)->file_description = g_variant_get_int32(res_struct[idx]);
- }
- idx++;
- *progress_size = g_variant_get_uint64(res_struct[idx++]);
- *total_size = g_variant_get_uint64(res_struct[idx++]);
-
- for (size_t j = 0; j < private_service_adaptor_file_progress_s_type_length; j++) {
- g_variant_unref(res_struct[j]);
- }
-}
-
-void __private_get_file_transfer_completion_type(GVariant *parameters,
- service_adaptor_file_h *file_handle,
- char **publish_url)
-{
- GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
- GVariant *res_struct[private_service_adaptor_file_transfer_completion_s_type_length];
-
- for (size_t j = 0; j < private_service_adaptor_file_transfer_completion_s_type_length; j++) {
- res_struct[j] = g_variant_get_child_value(in_parameters, j);
- }
-
- int idx = 0;
- *file_handle = (service_adaptor_file_h) calloc(1, sizeof(service_adaptor_file_s));
- if (NULL != *file_handle) {
- (*file_handle)->file_description = g_variant_get_int32(res_struct[idx]);
- }
- idx++;
- *publish_url = ipc_g_variant_dup_string(res_struct[idx++]);
-
- for (size_t j = 0; j < private_service_adaptor_file_transfer_completion_s_type_length; j++) {
- g_variant_unref(res_struct[j]);
- }
-}
-
-void __private_get_file_status_res_type(GVariant *call_result_struct,
- service_adaptor_file_status_s **status,
- void **server_data)
-{
- GVariant *res_info_struct[private_service_adaptor_file_status_res_s_type_length];
-
- for (size_t j = 0; j < private_service_adaptor_file_status_res_s_type_length; j++) {
- res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
- }
-
- int idx = 0;
- *status = (service_adaptor_file_status_s *) calloc(1, sizeof(service_adaptor_file_status_s));
- if (NULL != *status) {
- (*status)->total_size = g_variant_get_int64(res_info_struct[idx++]);
- (*status)->transferred_size = g_variant_get_int64(res_info_struct[idx++]);
- (*status)->status = g_variant_get_int64(res_info_struct[idx++]);
- }
-
- for (size_t j = 0; j < private_service_adaptor_file_status_res_s_type_length; j++) {
- g_variant_unref(res_info_struct[j]);
- }
-}
-
-void __private_get_file_handle_res_type(GVariant *call_result,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s *error,
- int *ret)
-{
- if (NULL != file_handle) {
- if (((*file_handle) = (service_adaptor_file_h) calloc(1, sizeof(struct _service_adaptor_file_s)))) {
- GVariant *fd = g_variant_get_child_value(call_result, 0);
- (*file_handle)->file_description = g_variant_get_int32(fd);
- } else {
- *ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
- error->code = SERVICE_ADAPTOR_ERROR_UNKNOWN;
- error->msg = strdup("Critical : Memory allocation failed");
- }
- }
-}
-
-/******************************************************************************
- private feature
-******************************************************************************/
-
void __get_file_progress_type(GVariant *parameters,
long long int *_file_uid,
unsigned long long *_progress_size,
*file_info = _file_info;
}
-
-void __get_get_root_folder_path_res_type(GVariant *call_result_struct,
- char **root_folder_path)
-{
- GVariant *res_info_struct[service_adaptor_get_root_folder_path_res_s_type_length];
-
- for (size_t j = 0; j < service_adaptor_get_root_folder_path_res_s_type_length; j++) {
- res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
- }
-
- int idx = 0;
- *root_folder_path = ipc_g_variant_dup_string(res_info_struct[idx++]);
-
- for (size_t j = 0; j < service_adaptor_get_root_folder_path_res_s_type_length; j++) {
- g_variant_unref(res_info_struct[j]);
- }
-}
-
void __get_get_file_list_res_type(GVariant *in_parameters,
service_storage_file_h **file_info_list,
unsigned int *file_info_list_len)
storage_task->state_callback(_state, storage_task->state_user_data);
}
}
- } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_STORAGE_FILE_PROGRESS_SIGNAL)) {
-/******************************************************************************
- private feature
-******************************************************************************/
- service_adaptor_file_h file_handle = NULL;
- uint64_t progress_size = 0;
- uint64_t total_size = 0;
- service_adaptor_error_s *error_code = NULL;
-
- __private_get_file_progress_type(parameters, &file_handle, &progress_size, &total_size);
-
- service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID);
-
- if (NULL == task) {
- free(file_handle);
- return;
- }
-
- GVariant *call_result[2];
- call_result[0] = g_variant_get_child_value(parameters, 1);
- call_result[1] = g_variant_get_child_value(parameters, 2);
-
- uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
- error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
-
- if (NULL != error_code) {
- error_code->code = remote_call_result;
- error_code->msg = ipc_g_variant_dup_string(call_result[1]);
- }
- }
-
- service_adaptor_file_progress_cb callback = (service_adaptor_file_progress_cb) task->callback;
-
- if (NULL != callback) {
- callback(task->handle, file_handle, progress_size, total_size, error_code, task->user_data);
- }
- if (NULL != error_code) {
- free(error_code->msg);
- free(error_code);
- }
- free(file_handle);
- } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_STORAGE_FILE_TRANSFER_COMPLETION_SIGNAL)) {
- service_adaptor_file_h file_handle = NULL;
- char *publish_url = NULL;
- service_adaptor_error_s *error_code = NULL;
-
- __private_get_file_transfer_completion_type(parameters, &file_handle, &publish_url);
-
- service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID);
-
- if (NULL == task) {
- free(file_handle);
- return;
- }
-
- GVariant *call_result[2];
- call_result[0] = g_variant_get_child_value(parameters, 1);
- call_result[1] = g_variant_get_child_value(parameters, 2);
-
- uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
- error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
-
- if (NULL != error_code) {
- error_code->code = remote_call_result;
- error_code->msg = ipc_g_variant_dup_string(call_result[1]);
- }
- }
-
- service_adaptor_file_transfer_completion_cb callback = (service_adaptor_file_transfer_completion_cb) task->callback;
-
- if (NULL != callback) {
- callback(task->handle, file_handle, publish_url, error_code, task->user_data);
- }
- if (NULL != error_code) {
- free(error_code->msg);
- free(error_code);
- }
- free(file_handle);
}
-
-/******************************************************************************
- private feature
-******************************************************************************/
-
-
}
-/** @brief
- * @return service_adaptor_error_s
- * @remarks :
- */
-int _dbus_download_file(const char *service_name,
- const char *server_path,
- const char *download_path,
+int _dbus_remove_file(const char *service_name,
+ const char *file_path,
void *user_data,
service_adaptor_error_s *error)
{
ipc_check_proxy(sac_interface_proxy);
- if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+ GVariant *request = g_variant_new("(" service_adaptor_remove_file_req_s_type ")", service_name, file_path);
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_DOWNLOAD_FILE_METHOD,
+ DBUS_REMOVE_FILE_METHOD,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
ret = _ipc_get_simple_result(call_result, g_error, error);
return ret;
+
+
}
-/** @brief
- * @return service_adaptor_error_s
- * @remarks :
- */
-int _dbus_download_thumbnail(const char *service_name,
- const char *server_path,
- const char *download_path,
- int thumbnail_size,
+int _dbus_get_file_list(const char *service_name,
+ const char *parent_path,
+ service_storage_file_h **file_info_list,
+ unsigned int *file_info_list_len,
+ void *user_data,
service_adaptor_error_s *error)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
ipc_check_proxy(sac_interface_proxy);
- GVariant *request = g_variant_new("(" service_adaptor_download_thumbnail_req_s_type ")", service_name, server_path, download_path, (int32_t)thumbnail_size);
+ GVariant *request = g_variant_new("(" service_adaptor_get_file_list_req_s_type ")", service_name, parent_path);
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_DOWNLOAD_THUMBNAIL_METHOD,
+ DBUS_GET_FILE_LIST_METHOD,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&g_error);
- ret = _ipc_get_simple_result(call_result, g_error, error);
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_get_file_list_res_s_type),
+ __get_get_file_list_res_type(call_result_struct[0], file_info_list, file_info_list_len);
+ );
return ret;
}
-int _dbus_upload_file(const char *service_name,
- const char *upload_path,
- const char *server_path,
- service_storage_file_h *file_info,
- void *user_data,
+int _dbus_open_upload_file(const char *_service_name,
+ const char *_file_path,
+ const char *_upload_path,
+ long long int *_task_id,
service_adaptor_error_s *error)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
GError *g_error = NULL;
GVariant *call_result = NULL;
- service_storage_file_h _file_info = NULL;
GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
ipc_check_proxy(sac_interface_proxy);
- if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+ GVariant *request = g_variant_new("(" service_adaptor_open_upload_file_req_s_type ")", _service_name, _file_path, _upload_path);
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_UPLOAD_FILE_METHOD,
+ DBUS_OPEN_UPLOAD_FILE_METHOD,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&g_error);
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
- __get_file_info_s_type(call_result_struct[0], &_file_info);
- *file_info = _file_info;
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+ long long int file_uid = 0;
+ __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+ *_task_id = file_uid;
);
return ret;
}
-int _dbus_get_root_folder_path(const char *service_name,
- char **root_folder_path,
- void *user_data,
+int _dbus_open_download_file(const char *_service_name,
+ const char *_storage_path,
+ const char *_download_path,
+ long long int *_task_id,
service_adaptor_error_s *error)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
ipc_check_proxy(sac_interface_proxy);
- if ((NULL == service_name) || (NULL == root_folder_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" service_adaptor_get_root_folder_path_req_s_type ")", __safe_add_string(service_name));
+ GVariant *request = g_variant_new("(" service_adaptor_open_download_file_req_s_type ")", _service_name, _storage_path, _download_path);
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_GET_ROOT_FOLDER_PATH_METHOD,
+ DBUS_OPEN_DOWNLOAD_FILE_METHOD,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&g_error);
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_get_root_folder_path_res_s_type),
- __get_get_root_folder_path_res_type(call_result_struct[0], root_folder_path);
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+ long long int file_uid = 0;
+ __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+ *_task_id = file_uid;
);
return ret;
}
-
-int _dbus_make_directory(const char *service_name,
- const char *folder_path,
- service_storage_file_h *file_info,
- void *user_data,
+int _dbus_open_download_thumbnail(const char *_service_name,
+ const char *_storage_path,
+ const char *_download_path,
+ int _thumbnail_size,
+ long long int *_task_id,
service_adaptor_error_s *error)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
GError *g_error = NULL;
GVariant *call_result = NULL;
- service_storage_file_h _file_info = NULL;
GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
ipc_check_proxy(sac_interface_proxy);
- if ((NULL == service_name) || (NULL == folder_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" service_adaptor_make_directory_req_s_type ")", service_name, folder_path);
+ GVariant *request = g_variant_new("(" service_adaptor_open_download_thumbnail_req_s_type ")", _service_name, _storage_path, _download_path, _thumbnail_size);
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_MAKE_DIRECTORY_METHOD,
+ DBUS_OPEN_DOWNLOAD_THUMBNAIL_METHOD,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&g_error);
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
- __get_file_info_s_type(call_result_struct[0], &_file_info);
- *file_info = _file_info;
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+ long long int file_uid = 0;
+ __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+ *_task_id = file_uid;
);
return ret;
-
}
-int _dbus_remove_file(const char *service_name,
- const char *file_path,
- void *user_data,
+int __dbus_send_simple_fd_for_task(GVariant *request,
+ const char *_method_name,
service_adaptor_error_s *error)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
ipc_check_proxy(sac_interface_proxy);
- GVariant *request = g_variant_new("(" service_adaptor_remove_file_req_s_type ")", service_name, file_path);
-
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_REMOVE_FILE_METHOD,
+ _method_name,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
ret = _ipc_get_simple_result(call_result, g_error, error);
return ret;
+}
+int _dbus_close_file_task(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error)
+{
+ GVariant *request = g_variant_new("("service_adaptor_close_file_req_s_type")", _service_name, (int64_t)_task_id);
+
+ return __dbus_send_simple_fd_for_task(request, DBUS_CLOSE_FILE_METHOD, error);
}
-int _dbus_remove_directory(const char *service_name,
- const char *folder_path,
- void *user_data,
+int _dbus_cancel_upload_file(const char *_service_name,
+ long long int _task_id,
service_adaptor_error_s *error)
{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
+ GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_UPLOAD_FILE_METHOD, error);
+}
- ipc_check_proxy(sac_interface_proxy);
+int _dbus_cancel_download_file(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error)
+{
+ GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
- GVariant *request = g_variant_new("(" service_adaptor_remove_directory_req_s_type ")", service_name, folder_path);
+ return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_DOWNLOAD_FILE_METHOD, error);
+}
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_REMOVE_DIRECTORY_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
+int _dbus_cancel_download_thumbnail(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error)
+{
+ GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
- ret = _ipc_get_simple_result(call_result, g_error, error);
+ return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_DOWNLOAD_THUMBNAIL_METHOD, error);
+}
- return ret;
-}
-int _dbus_move_file(const char *service_name,
- const char *src_file_path,
- const char *dst_file_path,
- service_storage_file_h *file_info,
- void *user_data,
+
+int _dbus_start_upload_file(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ bool _need_progress,
+ bool _need_state,
service_adaptor_error_s *error)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
GError *g_error = NULL;
GVariant *call_result = NULL;
- service_storage_file_h _file_info = NULL;
GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
ipc_check_proxy(sac_interface_proxy);
- GVariant *request = g_variant_new("(" service_adaptor_move_file_req_s_type ")",
- service_name, src_file_path, dst_file_path);
+ GVariant *request = g_variant_new("("service_adaptor_start_upload_file_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, _need_progress, _need_state);
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_MOVE_FILE_METHOD,
+ DBUS_START_UPLOAD_FILE_METHOD,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
NULL,
&g_error);
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
- __get_file_info_s_type(call_result_struct[0], &_file_info);
- *file_info = _file_info;
- );
+ ret = _ipc_get_simple_result(call_result, g_error, error);
return ret;
-
-
}
-int _dbus_move_directory(const char *service_name,
- const char *src_folder_path,
- const char *dst_folder_path,
- service_storage_file_h *file_info,
- void *user_data,
+
+int _dbus_start_download_file(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ bool _need_progress,
+ bool _need_state,
service_adaptor_error_s *error)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
GError *g_error = NULL;
GVariant *call_result = NULL;
- service_storage_file_h _file_info = NULL;
GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
ipc_check_proxy(sac_interface_proxy);
- GVariant *request = g_variant_new("(" service_adaptor_move_directory_req_s_type ")", __safe_add_string(service_name), __safe_add_string(src_folder_path), __safe_add_string(dst_folder_path));
+ GVariant *request = g_variant_new("("service_adaptor_start_download_file_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, _need_progress, _need_state);
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_MOVE_DIRECTORY_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
- __get_file_info_s_type(call_result_struct[0], &_file_info);
- *file_info = _file_info;
- );
-
- return ret;
-}
-
-int _dbus_get_file_list(const char *service_name,
- const char *parent_path,
- service_storage_file_h **file_info_list,
- unsigned int *file_info_list_len,
- void *user_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariant *request = g_variant_new("(" service_adaptor_get_file_list_req_s_type ")", service_name, parent_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_GET_FILE_LIST_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_get_file_list_res_s_type),
- __get_get_file_list_res_type(call_result_struct[0], file_info_list, file_info_list_len);
- );
-
- return ret;
-}
-
-int _dbus_open_upload_file(const char *_service_name,
- const char *_file_path,
- const char *_upload_path,
- long long int *_task_id,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariant *request = g_variant_new("(" service_adaptor_open_upload_file_req_s_type ")", _service_name, _file_path, _upload_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_OPEN_UPLOAD_FILE_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
- long long int file_uid = 0;
- __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
- *_task_id = file_uid;
- );
-
- return ret;
-}
-
-int _dbus_open_download_file(const char *_service_name,
- const char *_storage_path,
- const char *_download_path,
- long long int *_task_id,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariant *request = g_variant_new("(" service_adaptor_open_download_file_req_s_type ")", _service_name, _storage_path, _download_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_OPEN_DOWNLOAD_FILE_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
- long long int file_uid = 0;
- __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
- *_task_id = file_uid;
- );
-
- return ret;
-}
-
-int _dbus_open_download_thumbnail(const char *_service_name,
- const char *_storage_path,
- const char *_download_path,
- int _thumbnail_size,
- long long int *_task_id,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariant *request = g_variant_new("(" service_adaptor_open_download_thumbnail_req_s_type ")", _service_name, _storage_path, _download_path, _thumbnail_size);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_OPEN_DOWNLOAD_THUMBNAIL_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
- long long int file_uid = 0;
- __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
- *_task_id = file_uid;
- );
-
- return ret;
-}
-
-int __dbus_send_simple_fd_for_task(GVariant *request,
- const char *_method_name,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- _method_name,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- ret = _ipc_get_simple_result(call_result, g_error, error);
-
- return ret;
-}
-
-
-int _dbus_close_file_task(const char *_service_name,
- long long int _task_id,
- service_adaptor_error_s *error)
-{
- GVariant *request = g_variant_new("("service_adaptor_close_file_req_s_type")", _service_name, (int64_t)_task_id);
-
- return __dbus_send_simple_fd_for_task(request, DBUS_CLOSE_FILE_METHOD, error);
-}
-
-int _dbus_cancel_upload_file(const char *_service_name,
- long long int _task_id,
- service_adaptor_error_s *error)
-{
- GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
-
- return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_UPLOAD_FILE_METHOD, error);
-}
-
-int _dbus_cancel_download_file(const char *_service_name,
- long long int _task_id,
- service_adaptor_error_s *error)
-{
- GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
-
- return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_DOWNLOAD_FILE_METHOD, error);
-}
-
-int _dbus_cancel_download_thumbnail(const char *_service_name,
- long long int _task_id,
- service_adaptor_error_s *error)
-{
- GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
-
- return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_DOWNLOAD_THUMBNAIL_METHOD, error);
-}
-
-
-
-
-
-int _dbus_start_upload_file(const char *_service_name,
- long long int _task_id,
- const char *_storage_path,
- bool _need_progress,
- bool _need_state,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariant *request = g_variant_new("("service_adaptor_start_upload_file_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, _need_progress, _need_state);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_START_UPLOAD_FILE_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- ret = _ipc_get_simple_result(call_result, g_error, error);
-
- return ret;
-}
-
-
-int _dbus_start_download_file(const char *_service_name,
- long long int _task_id,
- const char *_storage_path,
- bool _need_progress,
- bool _need_state,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariant *request = g_variant_new("("service_adaptor_start_download_file_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, _need_progress, _need_state);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_START_DOWNLOAD_FILE_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- ret = _ipc_get_simple_result(call_result, g_error, error);
-
- return ret;
-}
-
-
-int _dbus_start_download_thumbnail(const char *_service_name,
- long long int _task_id,
- const char *_storage_path,
- int _thumbnail_size,
- bool _need_progress,
- bool _need_state,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- GVariant *request = g_variant_new("("service_adaptor_start_download_thumbnail_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, (int32_t)_thumbnail_size, _need_progress, _need_state);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- DBUS_START_DOWNLOAD_THUMBNAIL_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- ret = _ipc_get_simple_result(call_result, g_error, error);
-
- return ret;
-}
-
-
-/******************************************************************************
- private feature
-******************************************************************************/
-
-
-int _private_dbus_upload_file_async(const char *service_name,
- const char *upload_path,
- const char *server_path,
- service_adaptor_file_h *file_handle,
- void *user_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_UPLOAD_FILE_ASYNC_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
- __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
- );
-
- return ret;
-}
-
-
-
-int _private_dbus_download_file_async(const char *service_name,
- const char *server_path,
- const char *download_path,
- service_adaptor_file_h *file_handle,
- void *user_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_DOWNLOAD_FILE_ASYNC_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
- __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
- );
-
- return ret;
-}
-
-
-
-
-/** @brief
- * @return service_adaptor_error_s
- * @remarks :
- */
-int _dbus_download_file_publish(const char *service_name,
- const char *server_path,
- const char *download_path,
- void *user_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- ret = _ipc_get_simple_result(call_result, g_error, error);
-
- return ret;
-}
-
-int _dbus_download_file_publish_async(const char *service_name,
- const char *server_path,
- const char *download_path,
- service_adaptor_file_h *file_handle,
- void *user_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_ASYNC_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
- __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
- );
-
- return ret;
-}
-
-int _dbus_upload_file_publish(const char *service_name,
- const char *upload_path,
- const char *server_path,
- char **publish_url,
- void *user_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_publish_s_type),
- if (NULL != publish_url) {
- GVariant *url = g_variant_get_child_value(call_result_struct[0], 0);
- *publish_url = ipc_g_variant_dup_string(url);
- }
- );
-
- return ret;
-}
-
-int _dbus_upload_file_publish_async(const char *service_name,
- const char *upload_path,
- const char *server_path,
- service_adaptor_file_h *file_handle,
- void *user_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_ASYNC_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
- __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
- );
-
- return ret;
-}
-
-int _dbus_get_file_status(const char *service_name,
- service_adaptor_file_h file_handle,
- service_adaptor_file_status_s **status,
- void **server_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == file_handle)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_GET_FILE_STATUS_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_status_res_s_type),
- if (NULL != status) {
- __private_get_file_status_res_type(call_result_struct[0], status, server_data);
- }
- );
-
- return ret;
-}
-
-int _dbus_cancel_file_transfer(const char *service_name,
- service_adaptor_file_h file_handle,
- void **server_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == file_handle)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_CANCEL_FILE_TRANSFER_METHOD,
+ DBUS_START_DOWNLOAD_FILE_METHOD,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
return ret;
}
-int _dbus_pause_file_transfer(const char *service_name,
- service_adaptor_file_h file_handle,
- void **server_data,
- service_adaptor_error_s *error)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- GError *g_error = NULL;
- GVariant *call_result = NULL;
-
- GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
-
- ipc_check_proxy(sac_interface_proxy);
-
- if ((NULL == service_name) || (NULL == file_handle)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
-
- call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_PAUSE_FILE_TRANSFER_METHOD,
- request,
- G_DBUS_CALL_FLAGS_NONE,
- G_MAXINT,
- NULL,
- &g_error);
-
- ret = _ipc_get_simple_result(call_result, g_error, error);
-
- return ret;
-}
-int _dbus_resume_file_transfer(const char *service_name,
- service_adaptor_file_h file_handle,
- void **server_data,
+int _dbus_start_download_thumbnail(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ int _thumbnail_size,
+ bool _need_progress,
+ bool _need_state,
service_adaptor_error_s *error)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
ipc_check_proxy(sac_interface_proxy);
- if ((NULL == service_name) || (NULL == file_handle)) {
- error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- error->msg = strdup("Invalid Param");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+ GVariant *request = g_variant_new("("service_adaptor_start_download_thumbnail_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, (int32_t)_thumbnail_size, _need_progress, _need_state);
call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
- PRIVATE_DBUS_RESUME_FILE_TRANSFER_METHOD,
+ DBUS_START_DOWNLOAD_THUMBNAIL_METHOD,
request,
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT,
return ret;
}
-
-
-/******************************************************************************
- private feature
-******************************************************************************/
service_adaptor_task_h task = (service_adaptor_task_h) g_malloc0(sizeof(service_adaptor_task_s));
if (NULL == task) {
+ // LCOV_EXCL_START
FUNC_STOP();
return -1;
+ // LCOV_EXCL_STOP
}
task->id = _id;
* @return int
* @remarks :
*/
+ /*
int _signal_queue_add_task(int64_t _id,
uint32_t _callback,
void *_handle,
FUNC_END();
return 0;
}
+*/
/** @brief Adds Task in Queue
* @return service_adaptor_task_h
* @return int
* @remarks :
*/
+ /*
int _signal_queue_del_task(service_adaptor_task_h _task)
{
FUNC_START();
FUNC_END();
return 0;
}
-
-/** @brief Adds Task in Queue
- * @return int
- * @remarks :
- */
-int _signal_queue_del_task_by_id(int id)
-{
- FUNC_START();
- service_adaptor_task_h target = NULL;
-
- int i, len = g_list_length(g_service_adaptor_signal_queue);
- for (i = 0; i < len; i++) {
- for (GList *list = g_list_first(g_service_adaptor_signal_queue); list != NULL; list = g_list_next(list)) {
- service_adaptor_task_h data = (service_adaptor_task_h) list->data;
-
- if ((NULL != data) && (id == data->id)) {
- target = data;
- break;
- }
- }
-
- if (NULL != target) {
- g_service_adaptor_signal_queue = g_list_remove(g_service_adaptor_signal_queue, target);
- g_free(target);
- }
- }
-
- FUNC_END();
- return 0;
-}
+*/
/** @brief Clears Task in Queue
* @return void
FUNC_END();
}
+/*
int service_adaptor_check_handle_validate(service_adaptor_h handle)
{
if ((NULL == handle) || (NULL == g_service_adaptor)) {
return 0;
}
}
+*/
void _service_adaptor_set_last_result(int code, const char *message)
{
return ret;
}
-/** @brief Connects Service Adaptor
- * @return int
- * @remarks :
- */
-int service_adaptor_set_state_changed_cb(service_adaptor_h handle,
- service_adaptor_signal_cb callback,
- void *user_data)
-{
- FUNC_START();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- if (NULL == handle) {
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- handle->on_signal = callback;
- _signal_queue_add_task(SIGNAL_SERVICE_ADAPTOR, (uint32_t) callback, handle, user_data);
-
- FUNC_END();
- return ret;
-}
-
-int service_adaptor_unset_state_changed_cb(service_adaptor_h handle)
-{
- FUNC_START();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- if (NULL == handle) {
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- handle->on_signal = NULL;
-
- FUNC_END();
- return ret;
-}
-
-
int service_adaptor_foreach_plugin(service_adaptor_h handle,
service_adaptor_plugin_cb callback,
void *user_data)
sac_api_end(ret);
return ret;
}
-
-
-int service_plugin_is_login_required(service_plugin_h plugin,
- bool *required)
-{
- sac_api_start();
- sac_check_param_null(plugin, "plugin");
- sac_check_param_null(required, "required");
-
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error = {0ULL, NULL};
- bool _required = false;
-
- ret = _dbus_is_login_required(plugin, &_required, &error);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-int service_plugin_request_login(service_plugin_h plugin,
- service_plugin_login_cb callback,
- void *user_data)
-{
- sac_api_start();
- sac_check_param_null(plugin, "plugin");
- sac_check_param_null(callback, "callback");
-
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error = {0ULL, NULL};
-
- ret = _dbus_request_login(plugin, (void *)callback, user_data, &error);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-/************************* private feature */
-
-/** @brief Connects Service Adaptor
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_connect(service_adaptor_h *handle,
- service_adaptor_signal_cb callback)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_h service = NULL;
-
-#ifdef __DEBUG_GLIB_ERROR
- glog_handler_init();
-#endif
-
- g_mutex_lock(&connections_counter_mutex);
-
- if (NULL == handle) {
- g_mutex_unlock(&connections_counter_mutex);
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (0 < connections_counter) {
- sac_error("Handle already connected");
- g_mutex_unlock(&connections_counter_mutex);
-
- return SERVICE_ADAPTOR_ERROR_UNKNOWN;
- }
-
- service = (service_adaptor_h) calloc(1, sizeof(service_adaptor_s));
-
- if (NULL == service) {
- service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
- g_mutex_unlock(&connections_counter_mutex);
- return SERVICE_ADAPTOR_ERROR_UNKNOWN;
- }
-/*
- int trd = 0;
- char fingerprint[50] = {0, };
- snprintf(fingerprint, 50, "%s/%d", SERVICE_ADAPTOR_START_KEY_PATH, getpid());
- sac_debug("Trigger open : %s", fingerprint);
- trd = open(fingerprint, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
- if (0 > trd) {
- sac_error("Trigger open failed (%d)", trd);
- free(service);
- g_mutex_unlock(&connections_counter_mutex);
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-*/
- int dbus_ret = _dbus_client_layer_init();
-
- if (0 == dbus_ret) {
- sac_info("Proxy creation success");
- }
-
- service_adaptor_error_s error;
- error.msg = NULL;
-
- ret = _dbus_connect_service_adaptor(&error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(service);
-/*
- close(trd);
- remove(fingerprint);
-*/
- g_mutex_unlock(&connections_counter_mutex);
- free(error.msg);
- return ret;
- }
-
- service->service_name = NULL;
- service->user_id = NULL;
- service->app_id = NULL;
- service->service_id = 0;
- service->imsi = NULL;
- service->on_signal = callback;
- service->plugin = NULL;
- g_mutex_init(&service->set_auth_mutex);
-
- *handle = service;
- g_service_adaptor = service;
- sac_info("Connects success handle (%p) instance (%p)", handle, service);
- connections_counter = connections_counter + 1;
-
- _signal_queue_add_task(SIGNAL_SERVICE_ADAPTOR, (uint32_t) callback, *handle, NULL);
-/*
- close(trd);
- remove(fingerprint);
-*/
- g_mutex_unlock(&connections_counter_mutex);
-
- sac_api_end(ret);
- return ret;
-}
-
-/** @brief Disconnects Service Adaptor
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_disconnect(service_adaptor_h handle)
-{
- sac_api_start();
- if (NULL == handle) {
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- g_mutex_lock(&connections_counter_mutex);
-
- if (0 >= connections_counter) {
- connections_counter = 0;
- g_service_adaptor = NULL;
- g_mutex_unlock(&connections_counter_mutex);
-
- ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
- return ret;
- }
-
- service_adaptor_error_s error;
- error.msg = NULL;
-
- ret = _dbus_disconnect_service_adaptor(&error);
- if (ret) {
- sac_error("disconnect error : %s", error.msg);
- free(error.msg);
- error.msg = NULL;
- }
-
- if (NULL != handle) {
- __SAFE_FREE(handle->service_name);
- __SAFE_FREE(handle->user_id);
-
- __SAFE_FREE(handle->app_id);
- __SAFE_FREE(handle->imsi);
-
- if (NULL != handle->plugin) {
- __SAFE_FREE(handle->plugin->name);
- }
-
- __SAFE_FREE(handle->plugin);
- handle->on_signal = NULL;
- __SAFE_FREE(handle);
- }
-
- connections_counter = connections_counter - 1;
-
- if (0 == connections_counter) {
- _dbus_client_layer_deinit();
- }
-
- g_service_adaptor = NULL;
- g_mutex_unlock(&connections_counter_mutex);
-
- sac_api_end(ret);
- return ret;
-}
-
-/** @brief Sets IMSI
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_set_imsi(service_adaptor_h handle,
- const char *imsi)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- if ((NULL == handle) || (NULL == imsi)) {
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL != handle->imsi) {
- free(handle->imsi);
- handle->imsi = NULL;
- }
-
- handle->imsi = _safe_strdup(imsi);
- if (NULL == handle->imsi) {
- ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-int service_adaptor_set_plugin(service_adaptor_h handle,
- const char *plugin_uri)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- if ((NULL == handle) || (NULL == plugin_uri)) {
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- service_adaptor_plugin_h plugin = NULL;
- plugin = (service_adaptor_plugin_h) calloc(1, sizeof(service_adaptor_plugin_s));
- char *_plugin_uri = strdup(plugin_uri);
- if ((NULL == plugin) || (NULL == _plugin_uri)) {
- free(plugin);
- free(_plugin_uri);
- return SERVICE_ADAPTOR_ERROR_UNKNOWN;
- }
-
- plugin->name = _plugin_uri;
- plugin->login = true;
-
- handle->plugin = plugin;
-
- sac_api_end(ret);
- return ret;
-}
-
-/** @brief Free plugins
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_free_plugins(service_adaptor_plugin_h * plugins,
- unsigned int plugins_len)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- if ((NULL == plugins) || (0U == plugins_len)) {
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- for (int i = 0; i < plugins_len; i++) {
- if (NULL == plugins[i]) {
- continue;
- }
-
- free(plugins[i]->name);
- free(plugins[i]);
- }
-
- free(plugins);
- plugins = NULL;
-
- sac_api_end(ret);
- return ret;
-}
-
-int service_adaptor_external_request(service_adaptor_h handle,
- int service_flag,
- const char *api_uri,
- bundle *in_params,
- bundle **out_params)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (0 == service_flag) || (NULL == api_uri) || (NULL == in_params) || (NULL == out_params)) {
- service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER,
- "Invalid Argument : Not null params");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (service_adaptor_check_handle_validate(handle)) {
- service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle (Not connected handle)");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-/*
- if (NULL == handle->service_name) {
- service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid State");
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-*/
-
- unsigned char *input_str = NULL;
- unsigned char *output_str = NULL;
- int input_len = 0;
- int output_len = 0;
-
- ret = bundle_encode(in_params, &input_str, &input_len);
-
- ret = _dbus_external_request(sac_safe_add_string(handle->service_name), service_flag, api_uri, input_str, input_len, &output_str, &output_len, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- service_adaptor_set_last_result(error.code, error.msg);
- } else {
- *out_params = bundle_decode(output_str, output_len);
- if (NULL == *out_params) {
- ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
- }
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-int service_adaptor_external_request_async(service_adaptor_h handle,
- int service_flag,
- const char *api_uri,
- bundle *in_params,
- service_adaptor_external_response_cb callback,
- void *user_data)
-{
- service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED, "Not supported yet (TBD)");
- return SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED;
-}
-/************************* private feature */
return 0;
}
-
-/** @brief Uploads a server file and writes it to local file
- * @return int
- * @remarks :
- */
-int service_storage_upload_file(service_plugin_h handle,
- const char *upload_path,
- const char *server_path,
- service_storage_file_h *file_info)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == upload_path) || (NULL == server_path)) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_upload_file(handle->service_handle_name, upload_path, server_path, file_info, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-/** @brief Requests
- * @return int
- * @remarks :
- */
-int service_storage_get_root_directory(service_plugin_h handle,
- char **root_folder_path)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if (NULL == handle) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_get_root_folder_path(handle->service_handle_name, root_folder_path, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-/** @brief Requests
- * @return int
- * @remarks :
- */
-int service_storage_make_directory(service_plugin_h handle,
- const char *folder_path,
- service_storage_file_h *file_info)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if (NULL == handle) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_make_directory(handle->service_handle_name, folder_path, file_info, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-
-/** @brief Requests
- * @return int
- * @remarks :
- */
-int service_storage_remove_file(service_plugin_h handle,
- const char *file_path)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == file_path)) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_remove_file(handle->service_handle_name, file_path, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-
-/** @brief Requests
- * @return int
- * @remarks :
- */
-int service_storage_remove_directory(service_plugin_h handle,
- const char *folder_path)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == folder_path)) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_remove_directory(handle->service_handle_name, folder_path, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-
-/** @brief Requests
- * @return int
- * @remarks :
- */
-int service_storage_move_file(service_plugin_h handle,
- const char *src_file_path,
- const char *dst_file_path,
- service_storage_file_h *file_info)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == src_file_path) || (NULL == dst_file_path)) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_move_file(handle->service_handle_name, src_file_path, dst_file_path, file_info, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-
-/** @brief Requests
- * @return int
- * @remarks :
- */
-int service_storage_move_directory(service_plugin_h handle,
- const char *src_folder_path,
- const char *dst_folder_path,
- service_storage_file_h *file_info)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == src_folder_path) || (NULL == dst_folder_path) || (NULL == file_info)) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_move_directory(handle->service_handle_name, src_folder_path, dst_folder_path, file_info, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-/** @brief Requests
- * @return int
- * @remarks :
- */
-int service_storage_get_directory_entries(service_plugin_h handle,
- const char *parent_path,
- service_storage_file_h **file_info_list,
- unsigned int *file_info_list_len)
-
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == parent_path) || (NULL == file_info_list) || (NULL == file_info_list_len)) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_get_file_list(handle->service_handle_name, parent_path, file_info_list, file_info_list_len, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-int service_storage_download_file(service_plugin_h handle,
- const char *cloud_path,
- const char *download_path)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == cloud_path) || (NULL == download_path)) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_download_file(handle->service_handle_name, cloud_path, download_path, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-int service_storage_download_thumbnail(service_plugin_h handle,
- const char *storage_path,
- const char *local_path,
- int thumbnail_size)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == storage_path) || (NULL == local_path)) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_download_thumbnail(handle->service_handle_name, storage_path, local_path, thumbnail_size, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
/******* Async implementation */
int service_storage_create_upload_task(service_plugin_h plugin,
return ret;
}
-
-
-int service_storage_check_privilege(service_plugin_h handle,
- const char *privilege_name)
-{
- sac_api_start();
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if (NULL == handle) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == handle->service_handle_name) {
- FUNC_STOP();
- return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
- }
-
- ret = _dbus_get_privilege_check_result(handle->service_handle_name, privilege_name, NULL, &error);
-
- if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
- service_adaptor_set_last_result(error.code, error.msg);
- free(error.msg);
- }
-
- sac_api_end(ret);
- return ret;
-}
-
-
-/******************************** private feature */
-
-
-/** @brief Registers File Progress Listener
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_register_file_progress_listener(service_adaptor_h handle,
- service_adaptor_file_progress_cb callback,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- _signal_queue_add_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID, (uint32_t) callback, handle, user_data);
-
- return ret;
-}
-
-/** @brief Unregisters File Progress Listener
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_unregister_file_progress_listener(service_adaptor_h handle,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID);
-
- if (NULL == task) {
- return SERVICE_ADAPTOR_ERROR_UNKNOWN;
- }
-
- _signal_queue_del_task(task);
-
- return ret;
-}
-
-/** @brief Registers File Transfer Completion Listener
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_register_file_transfer_completion_listener(service_adaptor_h handle,
- service_adaptor_file_transfer_completion_cb callback,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- _signal_queue_add_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID, (uint32_t) callback, handle, user_data);
-
- return ret;
-}
-
-/** @brief Unregisters Forward Online Message Listener
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_unregister_file_transfer_completion_listener(service_adaptor_h handle,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
- service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID);
-
- if (NULL == task) {
- return SERVICE_ADAPTOR_ERROR_UNKNOWN;
- }
-
- _signal_queue_del_task(task);
-
- return ret;
-}
-
-/** @brief Downloads a server file and writes it to local file
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_download_file(service_adaptor_h handle,
- const char *server_path,
- const char *download_path,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == server_path) || (NULL == download_path)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_download_file(handle->service_name, server_path, download_path, user_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Downloads a server file and writes it to local file (Async)
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_download_file_async(service_adaptor_h handle,
- const char *server_path,
- const char *download_path,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == server_path) || (NULL == download_path)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _private_dbus_download_file_async(handle->service_name, server_path, download_path, file_handle, user_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Uploads a server file and writes it to local file
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_upload_file(service_adaptor_h handle,
- const char *upload_path,
- const char *server_path,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- service_storage_file_h file = NULL;
- ret = _dbus_upload_file(handle->service_name, upload_path, server_path, &file, user_data, &error);
- service_storage_unref_file_info(&file);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Uploads a server file and writes it to local file (Async)
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_upload_file_async(service_adaptor_h handle,
- const char *upload_path,
- const char *server_path,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _private_dbus_upload_file_async(handle->service_name, upload_path, server_path, file_handle, user_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Downloads a server file and writes it to local file
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_download_file_publish(service_adaptor_h handle,
- const char *publish_url,
- const char *download_path,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_download_file_publish(handle->service_name, publish_url, download_path, user_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Downloads a server file and writes it to local file (Async)
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_download_file_publish_async(service_adaptor_h handle,
- const char *publish_url,
- const char *download_path,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_download_file_publish_async(handle->service_name, publish_url, download_path, file_handle, user_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Uploads a server file and writes it to local file
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_upload_file_publish(service_adaptor_h handle,
- const char *upload_path,
- const char *server_path,
- char **publish_url,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path) || (NULL == publish_url)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_upload_file_publish(handle->service_name, upload_path, server_path, publish_url, user_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Uploads a server file and writes it to local file (Async)
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_upload_file_publish_async(service_adaptor_h handle,
- const char *upload_path,
- const char *server_path,
- service_adaptor_file_h *file_handle,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_upload_file_publish_async(handle->service_name, upload_path, server_path, file_handle, user_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Downloads a thumbnail file and writes it to local file
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_download_thumbnail_publish(service_adaptor_h handle,
- const char *publish_url,
- const char *download_path,
- service_adaptor_thumbnail_size_e size,
- service_adaptor_error_s **error_code,
- void *user_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
- char thumbnail_url[2048] = {0,};
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- char public_token[1024], auth_code[1024];
- sscanf(publish_url, "%[^'?']?auth_code=%s", public_token, auth_code);
- snprintf(thumbnail_url, 2048, "%s_%d?auth_code=%s", public_token, size, auth_code);
-
- ret = _dbus_download_file_publish(handle->service_name, thumbnail_url, download_path, user_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Requests File Status
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_get_file_status(service_adaptor_h handle,
- service_adaptor_file_h file_handle,
- service_adaptor_file_status_s **status,
- service_adaptor_error_s **error_code,
- void **server_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle) || (NULL == status)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_get_file_status(handle->service_name, file_handle, status, server_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Cancels File Transfer
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_cancel_file_transfer(service_adaptor_h handle,
- service_adaptor_file_h file_handle,
- service_adaptor_error_s **error_code,
- void **server_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_cancel_file_transfer(handle->service_name, file_handle, server_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Pause File Transfer
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_pause_file_transfer(service_adaptor_h handle,
- service_adaptor_file_h file_handle,
- service_adaptor_error_s **error_code,
- void **server_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_pause_file_transfer(handle->service_name, file_handle, server_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/** @brief Resume File Transfer
- * @return int
- * @remarks :
- */
-SERVICE_ADAPTOR_CLIENT_PUBLIC_API
-int service_adaptor_resume_file_transfer(service_adaptor_h handle,
- service_adaptor_file_h file_handle,
- service_adaptor_error_s **error_code,
- void **server_data)
-{
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
- service_adaptor_error_s error;
- error.msg = NULL;
-
- if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
- sac_error("Invalid Parameter");
- _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
- return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
- }
-
- ret = _dbus_resume_file_transfer(handle->service_name, file_handle, server_data, &error);
-
- if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
- _assign_error_code(&error, error_code);
- }
-
- return ret;
-}
-
-/******************************** private feature */
#include <bundle.h>
+// LCOV_EXCL_START
/** @brief NULL-pointer safe string duplication function
* This function will not crash if source string pointer is NULL. It is user's
* responsibility to free the result pointer.
return SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
}
}
-
+// LCOV_EXCL_STOP
int _ipc_get_simple_result(GVariant *call_result, GError *g_error, service_adaptor_error_s *error)
{
error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
if (NULL != g_error) {
+ // LCOV_EXCL_START
sac_error("G_IO_ERROR DEBUG (%d)", (int)(g_error->code));
if (g_error->code == G_IO_ERROR_TIMED_OUT) {
ret = SERVICE_ADAPTOR_ERROR_TIMED_OUT;
}
error->msg = __SAFE_STRDUP(g_error->message);
g_error_free(g_error);
+ // LCOV_EXCL_STOP
}
} else {
if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ // LCOV_EXCL_START
error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
error->msg = strdup("D-Bus return type error");
ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ // LCOV_EXCL_STOP
} else {
GVariant *call_result_struct[2];
call_result_struct[0] = g_variant_get_child_value(call_result, 0);
uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ // LCOV_EXCL_START
error->code = remote_call_result;
error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
ret = _get_result_code(remote_call_result);
+ // LCOV_EXCL_STOP
}
g_variant_unref(call_result_struct[0]);
g_variant_unref(call_result_struct[1]);
printf("service_auth_oauth1_get_access_token() Request Successed\n");
}
- char *cloud_path = tzplatform_mkstr(TZ_SYS_ROOT,"/cloud");
+ char *cloud_path = tzplatform_mkstr(TZ_SYS_ROOT, "/cloud");
service_storage_cloud_file_h file = NULL;
ret = service_storage_cloud_file_create(service_plugin, &file);
ret = service_storage_cloud_file_set_callback(file, _service_storage_cloud_file_cb, NULL);