From 71af117b165cc9267a4054336ec5655ba0b67d0b Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 28 Aug 2018 20:23:21 +0900 Subject: [PATCH 01/16] Change inclusion guard name - Change it according to review guide. Signed-off-by: Junghyun Yeon --- include/capability-manager.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/capability-manager.h b/include/capability-manager.h index d8a84bf..52e831a 100644 --- a/include/capability-manager.h +++ b/include/capability-manager.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a apache 2.0 license that can be // found in the LICENSE file. -#ifndef INCLUDE_CAPABILITY_MANAGER_H_ -#define INCLUDE_CAPABILITY_MANAGER_H_ +#ifndef __TIZEN_APPFW_CAPABILITY_MANAGER_H__ +#define __TIZEN_APPFW_CAPABILITY_MANAGER_H__ #include @@ -249,4 +249,4 @@ int capmgr_package_info_get_version(capmgr_package_info_h remote_package_info, } #endif -#endif // INCLUDE_CAPABILITY_MANAGER_H_ +#endif // __TIZEN_APPFW_CAPABILITY_MANAGER_H__ -- 2.7.4 From 32bb0305e069de9e46c635bb400490cf5e217dea Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 27 Aug 2018 11:50:12 +0900 Subject: [PATCH 02/16] Add comments for doxygen Signed-off-by: Junghyun Yeon --- include/capability-manager.h | 427 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 382 insertions(+), 45 deletions(-) diff --git a/include/capability-manager.h b/include/capability-manager.h index 52e831a..41986c6 100644 --- a/include/capability-manager.h +++ b/include/capability-manager.h @@ -11,236 +11,573 @@ extern "C" { #endif +/** + * @file capability-manager.h + */ + +/** + * @addtogroup CAPI_CAPABILITY_MANAGER_MODULE + * @{ + */ /** - * @brief + * @brief Enumerations for Capability Manager Errors. + * @since_tizen 5.0 */ typedef enum { - CAPMGR_ERROR_NONE = TIZEN_ERROR_NONE, - CAPMGR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, - CAPMGR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, - CAPMGR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, + CAPMGR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + CAPMGR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + CAPMGR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + CAPMGR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */ } capmgr_error_e; +/** + * @brief Enumerations for Capability Manager app control result type. + * @since_tizen 5.0 + */ typedef enum { - CAPMGR_APP_CONTROL_RESULT_OK, + CAPMGR_APP_CONTROL_RESULT_OK, /**< Successful */ } capmgr_app_control_result_e; /** - * @brief + * @brief Capability Manager device handle. + * @since_tizen 5.0 */ typedef struct capmgr_device_s* capmgr_device_h; /** - * @brief + * @brief Capability Manager app control handle. + * @since_tizen 5.0 */ typedef struct capmgr_app_control_s* capmgr_app_control_h; /** - * @brief + * @brief Capability Manager package info handle. + * @since_tizen 5.0 */ typedef struct capmgr_package_info_s* capmgr_package_info_h; /** - * @brief + * @brief Called to retrieve information of devices currently discovered. + * @since_tizen 5.0 + * + * @remarks The @a device can be used only in the callback. To use outside, make a copy. + * @param[in] device Device handle + * @param[in] user_data The user data to be passed to the callback function + * @see capmgr_device_foreach_devices() */ typedef int (*capmgr_device_foreach_cb)(const capmgr_device_h device, void* user_data); /** - * @brief + * @brief Called when send app control request has finished. + * @since_tizen 5.0 + * + * @remarks The @a request, @reply can be used only in the callback. To use outside, make a copy. + * @param[in] request Capability Manager app control handle contains data to be sent + * @param[in] reply Capability Manager app control handle which contains + * reply for request + * @param[in] result App control send result + * @param[in] user_data The user data to be passed to the callback function + * @see capmgr_app_control_send() */ typedef int (*capmgr_app_control_reply_cb)(const capmgr_app_control_h request, const capmgr_app_control_h reply, capmgr_app_control_result_e result, void* user_data); /** - * @brief + * @brief Called for each remote package info. + * @since_tizen 5.0 + * + * @remarks The @a remote_package_info can be used only in the callback. To use outside, make a copy. + * @param[in] remote_package_info Capability Manager package info handle + * @param[in] user_data The user data to be passed to the callback function + * @see capmgr_package_info_foreach_packages() */ typedef int (*capmgr_package_info_foreach_package_cb)( const capmgr_package_info_h remote_package_info, void* user_data); /** - * @brief + * @brief Called for each application of remote package. + * @since_tizen 5.0 + * + * @remarks The @a appid can be used only in the callback. To use outside, make a copy. + * @param[in] appid Application ID of remote application + * @param[in] user_data The user data to be passed to the callback function + * @see capmgr_package_info_foreach_applications() */ typedef int (*capmgr_package_info_foreach_app_cb)( const char* appid, void* user_data); /** - * @brief + * @brief Retrieves all remote device info stored on local device. + * @since_tizen 5.0 + * + * @param[in] cb The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_IO_ERROR Internal I/O error + * @post This function invokes capmgr_device_foreach_cb() for each remote device information. + * @see capmgr_device_foreach_cb() + * */ int capmgr_device_foreach_devices(capmgr_device_foreach_cb cb, void* user_data); /** - * @brief + * @brief Clones the remote device information handle. + * @since_tizen 5.0 + * @param[in] device The remote device handle + * @param[out] device_clone A newly created remote device information handle, if successfully cloned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_device_clone(const capmgr_device_h device, capmgr_device_h* device_clone); /** - * @brief + * @brief Destroys the remote device information handle and releases all its resources. + * @since_tizen 5.0 + * @param[in] device The remote device information handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @see capmgr_device_clone() + * @see capmgr_device_foreach_devices() */ int capmgr_device_destroy(capmgr_device_h device); /** - * @brief + * @brief Gets the device ID with the given remote device context. + * @since_tizen 5.0 + * @remarks You must release @a device_id using free(). + * @param[in] device The remote device information handle + * @param[out] device_id The remote device ID of the given remote device context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_device_clone() + * @see capmgr_device_foreach_devices() */ int capmgr_device_get_device_id(capmgr_device_h device, char** device_id); /** - * @brief + * @brief Gets the model name with the given remote device context. + * @since_tizen 5.0 + * @remarks You must release @a model_name using free(). + * @param[in] device The remote device information handle + * @param[out] model_name The model name of the given remote device context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_device_clone() + * @see capmgr_device_foreach_devices() */ int capmgr_device_get_model_name(capmgr_device_h device, char** model_name); /** - * @brief + * @brief Gets the device name with the given remote device context. + * @since_tizen 5.0 + * @remarks You must release @a device_name using free(). + * @param[in] device The remote device information handle + * @param[out] device_name The device name of the given remote device context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_device_clone() + * @see capmgr_device_foreach_devices() */ int capmgr_device_get_device_name(capmgr_device_h device, char** device_name); /** - * @brief + * @brief Gets the platform verion with the given remote device context. + * @since_tizen 5.0 + * @remarks You must release @a platform_ver using free(). + * @param[in] device The remote device information handle + * @param[out] platform_ver The platform version of the given remote device context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_device_clone() + * @see capmgr_device_foreach_devices() */ int capmgr_device_get_platform_ver(capmgr_device_h device, char** platform_ver); /** - * @brief + * @brief Gets the profile with the given remote device context. + * @since_tizen 5.0 + * @remarks You must release @a profile using free(). + * @param[in] device The remote device information handle + * @param[out] profile The profile value of the given remote device context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_device_clone() + * @see capmgr_device_foreach_devices() */ int capmgr_device_get_profile(capmgr_device_h device, char** profile); /** - * @brief + * @brief Gets the software verion with the given remote device context. + * @since_tizen 5.0 + * @remarks You must release @a sw_ver using free(). + * @param[in] device The remote device information handle + * @param[out] sw_ver The software version of the given remote device context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_device_clone() + * @see capmgr_device_foreach_devices() */ int capmgr_device_get_sw_ver(capmgr_device_h device, char** sw_ver); /** - * @brief + * @brief Creates a remote app control handle. + * @since_tizen 5.0 + * @remarks You must release @a app_control using capmgr_app_control_destroy(). + * + * @param[out] app_control The remote app control handle that is newly created on success + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @see capmgr_app_control_destroy() */ int capmgr_app_control_create(capmgr_app_control_h* app_control); /** - * @brief + * @brief Clones the remote app control handle. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[out] app_control_clone A newly created remote app control handle, if successfully cloned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_clone(const capmgr_app_control_h app_control, capmgr_app_control_h* app_control_clone); /** - * @brief + * @brief Destroys the remote app control handle and releases all its resources. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @see capmgr_app_control_create() */ int capmgr_app_control_destroy(capmgr_app_control_h app_control); /** - * @brief + * @brief Gets the remote device handle from the given app control context. + * @since_tizen 5.0 + * @remarks You must release @a device using capmgr_device_destroy(). + * @param[in] app_control The remote app control handle + * @param[out] device The remote device handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_app_control_destroy() */ int capmgr_app_control_get_device(capmgr_app_control_h app_control, capmgr_device_h* device); /** - * @brief + * @brief Gets the operation value from the given remote app control context. + * @since_tizen 5.0 + * @remarks You must release @a operation using free(). + * @param[in] app_control The remote app control handle + * @param[out] operation The operation value + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_app_control_destroy() */ int capmgr_app_control_get_operation(capmgr_app_control_h app_control, char** operation); /** - * @brief + * @brief Gets the URI value from the given remote app control context. + * @since_tizen 5.0 + * @remarks You must release @a uri using free(). + * @param[in] app_control The remote app control handle + * @param[out] uri The URI value + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_app_control_destroy() */ int capmgr_app_control_get_uri(capmgr_app_control_h app_control, char** uri); /** - * @brief + * @brief Gets the MIME value from the given remote app control context. + * @since_tizen 5.0 + * @remarks You must release @a mime using free(). + * @param[in] app_control The remote app control handle + * @param[out] mime The MIME value + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_app_control_destroy() */ int capmgr_app_control_get_mime(capmgr_app_control_h app_control, char** mime); /** - * @brief + * @brief Gets the application ID from the given remote app control context. + * @since_tizen 5.0 + * @remarks You must release @a appid using free(). + * @param[in] app_control The remote app control handle + * @param[out] appid The application ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_app_control_destroy() */ int capmgr_app_control_get_appid(capmgr_app_control_h app_control, char** appid); /** - * @brief + * @brief Gets the extra data corresponding to given key from remote app control context. + * @since_tizen 5.0 + * @remarks You must release @a value using free(). + * @param[in] app_control The remote app control handle + * @param[in] key The key value + * @param[out] value The value related with given key + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_app_control_destroy() */ int capmgr_app_control_get_extra_data(capmgr_app_control_h app_control, const char* key, char** value); /** - * @brief + * @brief Sets the target remote device to given remote app control context. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[in] device The remote device handle to set + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_set_device(capmgr_app_control_h app_control, const capmgr_device_h device); /** - * @brief + * @brief Sets the operation value to given remote app control context. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[in] operation The operation value to set + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_set_operation(capmgr_app_control_h app_control, const char* operation); /** - * @brief + * @brief Sets the URI value to given remote app control context. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[in] uri The URI value to set + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_set_uri(capmgr_app_control_h app_control, const char* uri); /** - * @brief + * @brief Sets the MIME value to given remote app control context. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[in] mime The MIME value to set + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_set_mime(capmgr_app_control_h app_control, const char* mime); /** - * @brief + * @brief Sets the application ID to given remote app control context. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[in] appid The application ID to set + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_set_appid(capmgr_app_control_h app_control, const char* appid); /** - * @brief + * @brief Sets the extra data to given remote app control context. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[in] key The key of extra data to set + * @param[in] value The value corresponding to key. + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_add_extra_data(capmgr_app_control_h app_control, const char* key, const char* value); /** - * @brief + * @brief Removes the extra data corresponding to given key at remote app control context. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[in] key The key of extra data to remove + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_remove_extra_data(capmgr_app_control_h app_control, const char* key); /** - * @brief + * @brief Sends the app control to remote device specified at handle. + * @since_tizen 5.0 + * @param[in] app_control The remote app control handle + * @param[in] cb Callback to be invoked when send has done + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_app_control_send(capmgr_app_control_h app_control, capmgr_app_control_reply_cb cb, void* user_data); /** - * @brief + * @brief Retrieves all packages installed at specified remote device and invoke callback each of it. + * @since_tizen 5.0 + * @param[in] device The remote device handle + * @param[in] cb Callback to be invoked for each package + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_IO_ERROR I/O error + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_package_info_foreach_packages(const capmgr_device_h device, capmgr_package_info_foreach_package_cb cb, void* user_data); /** - * @brief + * @brief Retrieves all applications belongs to given package and invoke callback each of it. + * @since_tizen 5.0 + * @param[in] remote_package_info The package information installed at specific remote device + * @param[in] cb Callback to be invoked for each application + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_IO_ERROR I/O error + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_package_info_foreach_applications( const capmgr_package_info_h remote_package_info, capmgr_package_info_foreach_app_cb cb, void* user_data); /** - * @brief + * @brief Gets the package ID from given remote package information. + * @since_tizen 5.0 + * @remarks You must release @a pkgid using free(). + * @param[in] remote_package_info The package information installed at specific remote device + * @param[in] pkgid The package ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_package_info_get_pkgid(capmgr_package_info_h remote_package_info, char** pkgid); /** - * @brief + * @brief Gets the label from given remote package information. + * @since_tizen 5.0 + * @remarks You must release @a label using free(). + * @param[in] remote_package_info The package information installed at specific remote device + * @param[in] label The label of package + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_package_info_get_label(capmgr_package_info_h remote_package_info, char** label); - /** - * @brief + * @brief Gets the version from given remote package information. + * @since_tizen 5.0 + * @remarks You must release @a version using free(). + * @param[in] remote_package_info The package information installed at specific remote device + * @param[in] version The version of package + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ int capmgr_package_info_get_version(capmgr_package_info_h remote_package_info, char** version); -- 2.7.4 From f3c5a083b7248e73ff64dfb79a911870830650ff Mon Sep 17 00:00:00 2001 From: Daeheyon Jung Date: Thu, 30 Aug 2018 18:57:52 +0900 Subject: [PATCH 03/16] Add Send File Function Change-Id: I5765d48ad50e0aac545e0dd6a7660f6e6af0f8b1 Signed-off-by: Daeheyon Jung --- include/capability-manager_internal.h | 75 +++++++++++++ packaging/capi-appfw-capmgr.spec | 1 + src/client_internal.cc | 199 ++++++++++++++++++++++++++++++++++ src/dbus.cc | 87 +++++++++++++-- src/dbus.h | 3 + src/dbus_signal.h | 36 ++++++ tools/capmgr_test.cc | 91 ++++++++++++++-- 7 files changed, 472 insertions(+), 20 deletions(-) create mode 100755 include/capability-manager_internal.h create mode 100755 src/client_internal.cc mode change 100644 => 100755 src/dbus.cc mode change 100644 => 100755 src/dbus.h create mode 100755 src/dbus_signal.h mode change 100644 => 100755 tools/capmgr_test.cc diff --git a/include/capability-manager_internal.h b/include/capability-manager_internal.h new file mode 100755 index 0000000..ff3afdc --- /dev/null +++ b/include/capability-manager_internal.h @@ -0,0 +1,75 @@ +// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by a apache 2.0 license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CAPABILITY_MANAGER_INTERNAL_H_ +#define INCLUDE_CAPABILITY_MANAGER_INTERNAL_H_ + +#include "include/capability-manager.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct capmgr_file_s* capmgr_file_h; + +typedef int (*capmgr_file_finish_cb)(capmgr_file_h file, + int result, void* user_data); + +typedef int (*capmgr_file_progress_cb)( + capmgr_file_h file, int64_t sent_size, int64_t total_size, + void* user_data); + +/** + * @brief + */ +int capmgr_file_create(capmgr_file_h* file); + +/** + * @brief + */ +int capmgr_file_destroy(capmgr_file_h file); + +/** + * @brief + */ +int capmgr_file_set_device(capmgr_file_h file, + const capmgr_device_h device); + +/** + * @brief + */ +int capmgr_file_set_path(capmgr_file_h file, + const char* file_path); + +/** + * @brief + */ +int capmgr_file_set_finish_cb(capmgr_file_h file, + capmgr_file_finish_cb cb, void* user_data); + +/** + * @brief + */ +int capmgr_file_set_progress_cb(capmgr_file_h file, + capmgr_file_progress_cb cb, void* user_data); + +/** + * @brief + */ +int capmgr_file_send(capmgr_file_h file); + +/* TODO(darrenh.jung) +int capmgr_file_abort(capmgr_file_h file); + +int capmgr_file_cleanup(capmgr_file_h file); + +int capmgr_file_resume(capmgr_file_h file); +*/ + +#ifdef __cplusplus +} +#endif + +#endif // INCLUDE_CAPABILITY_MANAGER_INTERNAL_H_ diff --git a/packaging/capi-appfw-capmgr.spec b/packaging/capi-appfw-capmgr.spec index b33eae0..37a2323 100644 --- a/packaging/capi-appfw-capmgr.spec +++ b/packaging/capi-appfw-capmgr.spec @@ -54,5 +54,6 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %files devel %{_includedir}/capability-manager.h +%{_includedir}/capability-manager_internal.h %{_libdir}/pkgconfig/%{name}.pc %{_libdir}/lib%{name}.so diff --git a/src/client_internal.cc b/src/client_internal.cc new file mode 100755 index 0000000..c6ba05e --- /dev/null +++ b/src/client_internal.cc @@ -0,0 +1,199 @@ +// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by a apache 2.0 license that can be +// found in the LICENSE file. + +#include + +#include +#include +#include +#include +#include + +#include "include/capability-manager.h" +#include "include/capability-manager_internal.h" +#include "src/dbus.h" +#include "src/dbus_signal.h" +#include "src/utils/logging.h" + +#define API __attribute__((visibility("default"))) + +struct capmgr_finish_cb_s { + int (*callback)(capmgr_file_h, int, void*); + void* user_data; +}; + +struct capmgr_progress_cb_s { + int (*callback)(capmgr_file_h, int64_t, int64_t, void*); + void* user_data; +}; + +struct capmgr_file_s { + capmgr_device_h device; + char* path; + capmgr::DBusSignal* ds; + capmgr_finish_cb_s finish_cb; + capmgr_progress_cb_s progress_cb; +}; + +int __default_finish_cb(capmgr_file_h file, int result, void *user_data) { + LOG(DEBUG) << "finished with: " << result; + return 0; +} + +int __default_progress_cb(capmgr_file_h file, int64_t sent_size, + int64_t total_size, void *user_data) { + LOG(DEBUG) << "progress: " << sent_size << "/" << total_size; + return 0; +} + +API int capmgr_file_create(capmgr_file_h* file) { + if (!file) + return CAPMGR_ERROR_INVALID_PARAMETER; + + try { + capmgr_file_s* f = new capmgr_file_s(); + capmgr_file_set_finish_cb(f, __default_finish_cb, nullptr); + capmgr_file_set_progress_cb(f, __default_progress_cb, nullptr); + + *file = f; + } catch (const std::bad_alloc& e) { + LOG(ERROR) << e.what(); + return CAPMGR_ERROR_OUT_OF_MEMORY; + } + + return CAPMGR_ERROR_NONE; +} + +API int capmgr_file_destroy(capmgr_file_h file) { + if (!file) + return CAPMGR_ERROR_INVALID_PARAMETER; + + capmgr_device_destroy(file->device); + free(file->path); + delete file->ds; + delete file; + + return CAPMGR_ERROR_NONE; +} + +API int capmgr_file_set_device(capmgr_file_h file, + const capmgr_device_h device) { + if (!file || !device) + return CAPMGR_ERROR_INVALID_PARAMETER; + + if (file->device) + capmgr_device_destroy(file->device); + + int ret = capmgr_device_clone(device, &file->device); + if (ret != CAPMGR_ERROR_NONE) + return CAPMGR_ERROR_OUT_OF_MEMORY; + + return CAPMGR_ERROR_NONE; +} + +API int capmgr_file_set_path(capmgr_file_h file, + const char* path) { + if (!file || !path) + return CAPMGR_ERROR_INVALID_PARAMETER; + + if (file->path) + free(file->path); + + file->path = strdup(path); + if (!file->path) + return CAPMGR_ERROR_OUT_OF_MEMORY; + + return CAPMGR_ERROR_NONE; +} + +API int capmgr_file_set_finish_cb(capmgr_file_h file, + capmgr_file_finish_cb cb, void *user_data) { + if (!file) + return CAPMGR_ERROR_INVALID_PARAMETER; + + file->finish_cb.callback = cb; + file->finish_cb.user_data = user_data; + + return CAPMGR_ERROR_NONE; +} + +API int capmgr_file_set_progress_cb(capmgr_file_h file, + capmgr_file_progress_cb cb, void *user_data) { + if (!file) + return CAPMGR_ERROR_INVALID_PARAMETER; + + file->progress_cb.callback = cb; + file->progress_cb.user_data = user_data; + + return CAPMGR_ERROR_NONE; +} + +void capmgr_send_file_callback(GVariant* result, void* user_data) { + capmgr_file_h file = reinterpret_cast(user_data); + LOG(INFO) << "Send File Callback called: " << file->path; + delete file->ds; + file->ds = nullptr; + + int r = 0; + g_variant_get(result, "(i)", &r); + LOG(DEBUG) << "result:" << r; + if (file->finish_cb.callback) + file->finish_cb.callback(file, r, file->finish_cb.user_data); +} + +void capmgr_progress_callback(GVariant* param, void* user_data) { + capmgr_file_h file = reinterpret_cast(user_data); + + gchar* file_path; + int64_t sent_size; + int64_t total_size; + + g_variant_get(param, "(sxx)", &file_path, &sent_size, &total_size); + // file_path may key for search handlers for multiple file handling. + + if (file->progress_cb.callback) { + file->progress_cb.callback(file, sent_size, total_size, + file->progress_cb.user_data); + } +} + +API int capmgr_file_send(capmgr_file_h file) { + if (!file || !file->device || !file->path) + return CAPMGR_ERROR_INVALID_PARAMETER; + + int ret; + char* device_id; + ret = capmgr_device_get_device_id(file->device, &device_id); + if (ret != CAPMGR_ERROR_NONE) { + LOG(ERROR) << "Failed to get device id"; + return CAPMGR_ERROR_INVALID_PARAMETER; + } + + GVariant* gv = g_variant_new("(&s&s)", device_id, file->path); + if (!gv) { + LOG(ERROR) << "Failed to create GVariant"; + free(device_id); + return CAPMGR_ERROR_INVALID_PARAMETER; + } + + file->ds = new capmgr::DBusSignal("SendFileProgressChanged"); + file->ds->RegisterHandler(capmgr_progress_callback, file); + file->ds->Subscribe(); + + if (!capmgr::ProxyCallAsync("SendFile", gv, capmgr_send_file_callback, + file)) { + LOG(ERROR) << "Failed to dbus method call"; + g_variant_unref(gv); + delete file->ds; + file->ds = nullptr; + free(device_id); + // errcode? + return CAPMGR_ERROR_INVALID_PARAMETER; + } + + g_variant_unref(gv); + free(device_id); + + return CAPMGR_ERROR_NONE; +} diff --git a/src/dbus.cc b/src/dbus.cc old mode 100644 new mode 100755 index edd3138..8b3c3f1 --- a/src/dbus.cc +++ b/src/dbus.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "src/dbus.h" +#include "src/dbus_signal.h" #include #include @@ -37,25 +38,93 @@ void MethodCallback(GObject* source_object, GAsyncResult* res, delete cbdata; } -} // namespace +void SignalCallback(GDBusProxy* proxy, gchar* sender_name, gchar* signal_name, + GVariant* parameters, gpointer user_data) { + capmgr::DBusSignal* ds = reinterpret_cast(user_data); -namespace capmgr { + LOG(INFO) << "Signal recieved " << signal_name; + if (g_strcmp0(ds->GetSignalName(), signal_name) == 0) { + LOG(INFO) << "progress callback called"; + ds->Emit(parameters); + } +} -bool ProxyCallAsync(const char* method, GVariant* params, DBusCallback cb, - void* user_data) { +bool InitDBusProxy(GDBusConnection** connection, GDBusProxy** proxy) { GError* error = nullptr; GDBusConnection* conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error); - if (!conn || error) { + if (!conn) { LOG(ERROR) << "g_bus_get_sync() failed: " << error->message; + g_object_unref(error); return false; } - GDBusProxy* proxy = g_dbus_proxy_new_sync(conn, + + GDBusProxy* p = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, nullptr, kDBusServiceName, kDBusObjectPath, kDBusInterfaceName, nullptr, &error); - if (!proxy || error) { + if (!p) { LOG(ERROR) << "g_dbus_proxy_new_sync() failed: " << error->message; + g_object_unref(error); + g_object_unref(conn); + return false; + } + + *connection = conn; + *proxy = p; + return true; +} + +void DisposeDBusProxy(GDBusConnection* conn, GDBusProxy* proxy) { + if (proxy) + g_object_unref(proxy); + if (conn) { + g_dbus_connection_flush_sync(conn, nullptr, nullptr); g_object_unref(conn); + } +} + +} // namespace + +namespace capmgr { + +DBusSignal::DBusSignal(const std::string& signal_name) + : signal_name_ { signal_name } {} + +DBusSignal::~DBusSignal() { + DisposeDBusProxy(this->conn_, this->proxy_); +} + +void DBusSignal::RegisterHandler(DBusCallback cb, void* user_data) { + this->cb_ = cb; + this->user_data_ = user_data; +} + +void DBusSignal::Emit(GVariant* param) { + this->cb_(param, this->user_data_); +} + +bool DBusSignal::Subscribe() { + if (!InitDBusProxy(&this->conn_, &this->proxy_)) { + LOG(ERROR) << "DBus initilization failed"; + return false; + } + + g_signal_connect(this->proxy_, "g-signal", G_CALLBACK(SignalCallback), this); + + return true; +} + +const char* DBusSignal::GetSignalName() { + return this->signal_name_.c_str(); +} + +bool ProxyCallAsync(const char* method, GVariant* params, DBusCallback cb, + void* user_data) { + GDBusConnection* conn = nullptr; + GDBusProxy* proxy = nullptr; + + if (!InitDBusProxy(&conn, &proxy)) { + LOG(ERROR) << "DBus initilization failed"; return false; } @@ -67,9 +136,7 @@ bool ProxyCallAsync(const char* method, GVariant* params, DBusCallback cb, g_dbus_proxy_call(proxy, method, params, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, MethodCallback, cbdata); - g_object_unref(proxy); - g_dbus_connection_flush_sync(conn, nullptr, nullptr); - g_object_unref(conn); + DisposeDBusProxy(conn, proxy); return true; } diff --git a/src/dbus.h b/src/dbus.h old mode 100644 new mode 100755 index 5520488..83336a3 --- a/src/dbus.h +++ b/src/dbus.h @@ -6,6 +6,9 @@ #define DBUS_H_ #include +#include + +#include #include "include/capability-manager.h" diff --git a/src/dbus_signal.h b/src/dbus_signal.h new file mode 100755 index 0000000..ea78cbf --- /dev/null +++ b/src/dbus_signal.h @@ -0,0 +1,36 @@ +// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by a apache 2.0 license that can be +// found in the LICENSE file. + +#ifndef DBUS_SIGNAL_H_ +#define DBUS_SIGNAL_H_ + +#include +#include + +#include + +#include "src/dbus.h" + +namespace capmgr { + +class DBusSignal { + public: + explicit DBusSignal(const std::string& signal_name); + ~DBusSignal(); + void RegisterHandler(DBusCallback cb, void* user_data); + bool Subscribe(); + const char* GetSignalName(); + void Emit(GVariant* param); + + private: + std::string signal_name_; + DBusCallback cb_; + void* user_data_; + GDBusProxy* proxy_; + GDBusConnection* conn_; +}; + +} // namespace capmgr + +#endif // DBUS_SIGNAL_H_ diff --git a/tools/capmgr_test.cc b/tools/capmgr_test.cc old mode 100644 new mode 100755 index 76dcb79..d57b732 --- a/tools/capmgr_test.cc +++ b/tools/capmgr_test.cc @@ -10,6 +10,7 @@ #include #include "include/capability-manager.h" +#include "include/capability-manager_internal.h" namespace bpo = boost::program_options; @@ -43,6 +44,10 @@ class Client { const capmgr_app_control_h reply, capmgr_app_control_result_e result, void* user_data); + static int FileFinishCb(capmgr_file_h file, int result, void* user_data); + static int FileProgressCb(capmgr_file_h file, + int64_t sent_size, int64_t total_size, void* user_data); + GMainLoop* loop_; GDBusConnection* conn_; GDBusProxy* proxy_; @@ -213,24 +218,71 @@ void Client::SendFile(const std::string& device_id, return; } - if (file_path.empty()) { - std::cout << "File path is missing!" << std::endl; + capmgr_device_h device = nullptr; + struct cbdata cbdata = {&device, device_id}; + int ret = capmgr_device_foreach_devices(DeviceForeachCb, &cbdata); + if (ret != CAPMGR_ERROR_NONE) { + std::cout << "capmgr_device_foreach_devices() failed: " << ret + << std::endl; + return; + } + + if (*cbdata.device == nullptr) { + std::cout << "There is no such device!" << std::endl; + return; + } + + capmgr_file_h file; + ret = capmgr_file_create(&file); + if (ret != CAPMGR_ERROR_NONE) { + std::cout << "capmgr_file_create() failed: " << ret << std::endl; + capmgr_device_destroy(device); + return; + } + + ret = capmgr_file_set_device(file, device); + if (ret != CAPMGR_ERROR_NONE) { + std::cout << "capmgr_file_set_device() failed: " << ret + << std::endl; + capmgr_device_destroy(device); + capmgr_file_destroy(file); + return; + } + + ret = capmgr_file_set_path(file, file_path.c_str()); + if (ret != CAPMGR_ERROR_NONE) { + std::cout << "capmgr_file_set_path() failed: " << ret + << std::endl; + capmgr_device_destroy(device); + capmgr_file_destroy(file); return; } - std::cout << "Send file " << file_path << " to " << device_id << std::endl; + ret = capmgr_file_set_finish_cb(file, FileFinishCb, this); + if (ret != CAPMGR_ERROR_NONE) { + std::cout << "capmgr_file_set_finish_cb() failed: " << ret + << std::endl; + capmgr_device_destroy(device); + capmgr_file_destroy(file); + return; + } - GVariant* params = g_variant_new("(ss)", device_id.c_str(), - file_path.c_str()); - if (!params) { - std::cout << "out of memory" << std::endl; + ret = capmgr_file_set_progress_cb(file, FileProgressCb, this); + if (ret != CAPMGR_ERROR_NONE) { + std::cout << "capmgr_file_set_progress_cb() failed: " << ret + << std::endl; + capmgr_device_destroy(device); + capmgr_file_destroy(file); return; } - GVariant* ret = ProxyCallSync("SendFile", params); + ret = capmgr_file_send(file); + if (ret != CAPMGR_ERROR_NONE) + std::cout << "capmgr_file_send failed: " << ret + << std::endl; - g_object_unref(params); - g_object_unref(ret); + capmgr_device_destroy(device); + WaitForResult(); } GVariant* Client::ProxyCallSync(const char* method, GVariant* params) { @@ -252,6 +304,25 @@ void Client::Quit() { g_main_loop_quit(loop_); } +int Client::FileFinishCb(capmgr_file_h file, + int result, void* user_data) { + std::cout << "FileFinishCb called: " << result << std::endl; + + capmgr_file_destroy(file); + + Client* client = static_cast(user_data); + client->Quit(); + return 0; +} + +int Client::FileProgressCb(capmgr_file_h file, int64_t sent_size, + int64_t total_size, void* user_data) { + std::cout << "FileProgressCb called (" + << sent_size << "/" << total_size << ")bytes sent" << std::endl; + + return 0; +} + int Client::AppControlCb(const capmgr_app_control_h request, const capmgr_app_control_h reply, capmgr_app_control_result_e result, void* user_data) { -- 2.7.4 From c582453d1fdf531ac3315769dbc3cf15b63a75e3 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 10 Oct 2018 16:33:34 +0900 Subject: [PATCH 04/16] Add missing linker flag and option Change-Id: Ia03aaa308ac24ba6412589a849c5d5c0402bb08d Signed-off-by: Sangyoon Jang --- CMakeLists.txt | 1 + src/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69272ee..77e1752 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -ffunction-sect ## Linker flags SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed,--gc-sections") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed,--gc-sections,--no-undefined") SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5187397..f4280e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,7 @@ APPLY_PKG_CONFIG(${TARGET_LIB_CAPMGR} PUBLIC DLOG_DEPS GIO_DEPS GLIB_DEPS + SQLITE_DEPS ) SET_TARGET_PROPERTIES(${TARGET_LIB_CAPMGR} PROPERTIES VERSION ${FULLVER}) -- 2.7.4 From 78aa5d403a5a9c9c3b659b2dc4f83976b82a5073 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 24 Oct 2018 14:45:39 +0900 Subject: [PATCH 05/16] Remove unnecessary excutable bit in file mode Change-Id: I77dee12b75975fd9097889d4e801738c5007a24d Signed-off-by: Sangyoon Jang --- include/capability-manager_internal.h | 0 src/client_internal.cc | 0 src/dbus.cc | 0 src/dbus.h | 0 src/dbus_signal.h | 0 tools/capmgr_test.cc | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/capability-manager_internal.h mode change 100755 => 100644 src/client_internal.cc mode change 100755 => 100644 src/dbus.cc mode change 100755 => 100644 src/dbus.h mode change 100755 => 100644 src/dbus_signal.h mode change 100755 => 100644 tools/capmgr_test.cc diff --git a/include/capability-manager_internal.h b/include/capability-manager_internal.h old mode 100755 new mode 100644 diff --git a/src/client_internal.cc b/src/client_internal.cc old mode 100755 new mode 100644 diff --git a/src/dbus.cc b/src/dbus.cc old mode 100755 new mode 100644 diff --git a/src/dbus.h b/src/dbus.h old mode 100755 new mode 100644 diff --git a/src/dbus_signal.h b/src/dbus_signal.h old mode 100755 new mode 100644 diff --git a/tools/capmgr_test.cc b/tools/capmgr_test.cc old mode 100755 new mode 100644 -- 2.7.4 From a3da96bf5dcb4e1d685610f46b27823ca6f4c50e Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 24 Oct 2018 17:34:23 +0900 Subject: [PATCH 06/16] Rename header file as capability_manager.h Make it consistent as other native API headers. Change-Id: I6f346bd0ec9d6931817b114b3f10a5fd59f6b0c6 Signed-off-by: Sangyoon Jang --- include/{capability-manager.h => capability_manager.h} | 2 +- .../{capability-manager_internal.h => capability_manager_internal.h} | 2 +- packaging/capi-appfw-capmgr.spec | 4 ++-- src/client.cc | 2 +- src/client_internal.cc | 4 ++-- src/dbus.h | 2 +- tools/capmgr_test.cc | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) rename include/{capability-manager.h => capability_manager.h} (99%) rename include/{capability-manager_internal.h => capability_manager_internal.h} (97%) diff --git a/include/capability-manager.h b/include/capability_manager.h similarity index 99% rename from include/capability-manager.h rename to include/capability_manager.h index 41986c6..e7f1de5 100644 --- a/include/capability-manager.h +++ b/include/capability_manager.h @@ -12,7 +12,7 @@ extern "C" { #endif /** - * @file capability-manager.h + * @file capability_manager.h */ /** diff --git a/include/capability-manager_internal.h b/include/capability_manager_internal.h similarity index 97% rename from include/capability-manager_internal.h rename to include/capability_manager_internal.h index ff3afdc..e24a6ec 100644 --- a/include/capability-manager_internal.h +++ b/include/capability_manager_internal.h @@ -5,7 +5,7 @@ #ifndef INCLUDE_CAPABILITY_MANAGER_INTERNAL_H_ #define INCLUDE_CAPABILITY_MANAGER_INTERNAL_H_ -#include "include/capability-manager.h" +#include "include/capability_manager.h" #ifdef __cplusplus extern "C" { diff --git a/packaging/capi-appfw-capmgr.spec b/packaging/capi-appfw-capmgr.spec index 37a2323..ae05be9 100644 --- a/packaging/capi-appfw-capmgr.spec +++ b/packaging/capi-appfw-capmgr.spec @@ -53,7 +53,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %{_bindir}/capmgr-test %files devel -%{_includedir}/capability-manager.h -%{_includedir}/capability-manager_internal.h +%{_includedir}/capability_manager.h +%{_includedir}/capability_manager_internal.h %{_libdir}/pkgconfig/%{name}.pc %{_libdir}/lib%{name}.so diff --git a/src/client.cc b/src/client.cc index 4d94287..5356173 100644 --- a/src/client.cc +++ b/src/client.cc @@ -13,7 +13,7 @@ #include #include -#include "include/capability-manager.h" +#include "include/capability_manager.h" #include "src/dbus.h" #include "src/sql_connection.h" #include "src/sql_statement.h" diff --git a/src/client_internal.cc b/src/client_internal.cc index c6ba05e..172d7fd 100644 --- a/src/client_internal.cc +++ b/src/client_internal.cc @@ -10,8 +10,8 @@ #include #include -#include "include/capability-manager.h" -#include "include/capability-manager_internal.h" +#include "include/capability_manager.h" +#include "include/capability_manager_internal.h" #include "src/dbus.h" #include "src/dbus_signal.h" #include "src/utils/logging.h" diff --git a/src/dbus.h b/src/dbus.h index 83336a3..5053cd6 100644 --- a/src/dbus.h +++ b/src/dbus.h @@ -10,7 +10,7 @@ #include -#include "include/capability-manager.h" +#include "include/capability_manager.h" namespace capmgr { diff --git a/tools/capmgr_test.cc b/tools/capmgr_test.cc index d57b732..8c79856 100644 --- a/tools/capmgr_test.cc +++ b/tools/capmgr_test.cc @@ -9,8 +9,8 @@ #include -#include "include/capability-manager.h" -#include "include/capability-manager_internal.h" +#include "include/capability_manager.h" +#include "include/capability_manager_internal.h" namespace bpo = boost::program_options; -- 2.7.4 From cc51a4f532e7a20d3ceaffeaf092b5895abf5f14 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 25 Oct 2018 10:16:09 +0900 Subject: [PATCH 07/16] Add a missing API Add capmgr_app_control_get_device(). Change-Id: Ie3a86199d2f61aa1027bdb9d10226e68b1f83495 Signed-off-by: Sangyoon Jang --- src/client.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/client.cc b/src/client.cc index 5356173..a2f05c3 100644 --- a/src/client.cc +++ b/src/client.cc @@ -252,6 +252,18 @@ API int capmgr_app_control_destroy(capmgr_app_control_h app_control) { return CAPMGR_ERROR_NONE; } +API int capmgr_app_control_get_device(capmgr_app_control_h app_control, + capmgr_device_h* device) { + if (!app_control || !device) + return CAPMGR_ERROR_INVALID_PARAMETER; + + int ret = capmgr_device_clone(app_control->device, device); + if (ret != CAPMGR_ERROR_NONE) + return ret; + + return CAPMGR_ERROR_NONE; +} + API int capmgr_app_control_get_operation(capmgr_app_control_h app_control, char** operation) { if (!app_control || !operation) -- 2.7.4 From 91d0f8d96118e277df59f431c08d30856c3927db Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 25 Oct 2018 13:38:05 +0900 Subject: [PATCH 08/16] Fix allocating structure object Use "new A()" style to zero initialize. Change-Id: I1baf86c4b8e8130ba81a7b7e10107eb5681f8faf Signed-off-by: Sangyoon Jang --- src/client.cc | 10 +++++----- src/dbus.cc | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client.cc b/src/client.cc index a2f05c3..b01f4ee 100644 --- a/src/client.cc +++ b/src/client.cc @@ -88,7 +88,7 @@ API int capmgr_device_clone(const capmgr_device_h device, return CAPMGR_ERROR_INVALID_PARAMETER; try { - struct capmgr_device_s* clone = new struct capmgr_device_s; + struct capmgr_device_s* clone = new struct capmgr_device_s(); clone->device_id = device->device_id; clone->model_name = device->model_name; @@ -191,7 +191,7 @@ API int capmgr_app_control_create(capmgr_app_control_h* app_control) { return CAPMGR_ERROR_INVALID_PARAMETER; try { - struct capmgr_app_control_s* control = new struct capmgr_app_control_s; + struct capmgr_app_control_s* control = new struct capmgr_app_control_s(); control->b = bundle_create(); if (!control->b) { delete control; @@ -218,7 +218,7 @@ API int capmgr_app_control_clone(const capmgr_app_control_h app_control, return CAPMGR_ERROR_INVALID_PARAMETER; try { - struct capmgr_app_control_s* clone = new struct capmgr_app_control_s; + struct capmgr_app_control_s* clone = new struct capmgr_app_control_s(); int ret = capmgr_device_clone(app_control->device, &clone->device); if (ret != CAPMGR_ERROR_NONE) { @@ -468,7 +468,7 @@ void capmgr_dbus_callback(GVariant* result, void* user_data) { g_variant_iter_free(iter); struct cbdata* cbdata = reinterpret_cast(user_data); - struct capmgr_app_control_s* reply = new struct capmgr_app_control_s; + struct capmgr_app_control_s* reply = new struct capmgr_app_control_s(); reply->b = bundle_decode(data, len); if (!reply->b) { LOG(ERROR) << "Invalid bundle data!"; @@ -520,7 +520,7 @@ API int capmgr_app_control_send(capmgr_app_control_h app_control, return r; } - struct cbdata* cbdata = new struct cbdata; + struct cbdata* cbdata = new struct cbdata(); cbdata->request = clone; cbdata->cb = cb; cbdata->user_data = user_data; diff --git a/src/dbus.cc b/src/dbus.cc index 8b3c3f1..ec092d9 100644 --- a/src/dbus.cc +++ b/src/dbus.cc @@ -129,7 +129,7 @@ bool ProxyCallAsync(const char* method, GVariant* params, DBusCallback cb, } // will be freed at MethodCallback() - struct cbdata* cbdata = new struct cbdata; + struct cbdata* cbdata = new struct cbdata(); cbdata->cb = cb; cbdata->user_data = user_data; -- 2.7.4 From 3b6451caca10ce615beeaee8f795772968a0095a Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 25 Oct 2018 15:47:45 +0900 Subject: [PATCH 09/16] Fix capmgr_app_control_set_device() If device is already set, destroy the previous one. Change-Id: I40a305fbf7472645dc6cb994f34a49e3f6b33a76 Signed-off-by: Sangyoon Jang --- src/client.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client.cc b/src/client.cc index b01f4ee..97a9d7e 100644 --- a/src/client.cc +++ b/src/client.cc @@ -353,6 +353,9 @@ API int capmgr_app_control_set_device(capmgr_app_control_h app_control, if (!app_control || !device) return CAPMGR_ERROR_INVALID_PARAMETER; + if (app_control->device) + capmgr_device_destroy(app_control->device); + int ret = capmgr_device_clone(device, &app_control->device); if (ret != CAPMGR_ERROR_NONE) return CAPMGR_ERROR_OUT_OF_MEMORY; -- 2.7.4 From 31f7aa294dc0dc72dffc1d4669ea7504428b0bf3 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Fri, 26 Oct 2018 11:01:14 +0900 Subject: [PATCH 10/16] Change API spec - Remove Apis about Package infomation - Add Apis about Application information Signed-off-by: Inkyun Kil --- include/capability_manager.h | 90 ++++++++++++++++++++------------------------ src/client.cc | 82 ++++++++++++++++------------------------ tools/capmgr_test.cc | 76 +++++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 98 deletions(-) diff --git a/include/capability_manager.h b/include/capability_manager.h index e7f1de5..a8affce 100644 --- a/include/capability_manager.h +++ b/include/capability_manager.h @@ -25,10 +25,14 @@ extern "C" { * @since_tizen 5.0 */ typedef enum { - CAPMGR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - CAPMGR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - CAPMGR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - CAPMGR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */ + /**< Successful */ + CAPMGR_ERROR_NONE = TIZEN_ERROR_NONE, + /**< Invalid parameter */ + CAPMGR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, + /**< Out of memory */ + CAPMGR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, + /**< Internal I/O error */ + CAPMGR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, } capmgr_error_e; /** @@ -52,10 +56,10 @@ typedef struct capmgr_device_s* capmgr_device_h; typedef struct capmgr_app_control_s* capmgr_app_control_h; /** - * @brief Capability Manager package info handle. + * @brief Capability Manager application info handle. * @since_tizen 5.0 */ -typedef struct capmgr_package_info_s* capmgr_package_info_h; +typedef struct capmgr_application_info_s* capmgr_application_info_h; /** * @brief Called to retrieve information of devices currently discovered. @@ -86,28 +90,16 @@ typedef int (*capmgr_app_control_reply_cb)(const capmgr_app_control_h request, void* user_data); /** - * @brief Called for each remote package info. + * @brief Called for each remote application info. * @since_tizen 5.0 * - * @remarks The @a remote_package_info can be used only in the callback. To use outside, make a copy. - * @param[in] remote_package_info Capability Manager package info handle - * @param[in] user_data The user data to be passed to the callback function - * @see capmgr_package_info_foreach_packages() - */ -typedef int (*capmgr_package_info_foreach_package_cb)( - const capmgr_package_info_h remote_package_info, void* user_data); - -/** - * @brief Called for each application of remote package. - * @since_tizen 5.0 - * - * @remarks The @a appid can be used only in the callback. To use outside, make a copy. - * @param[in] appid Application ID of remote application + * @remarks The @a remote_app_info can be used only in the callback. To use outside, make a copy. + * @param[in] remote_app_info Capability Manager Application Info handle * @param[in] user_data The user data to be passed to the callback function - * @see capmgr_package_info_foreach_applications() + * @see capmgr_application_info_foreach_applications() */ -typedef int (*capmgr_package_info_foreach_app_cb)( - const char* appid, void* user_data); +typedef int (*capmgr_application_info_foreach_app_cb)( + const capmgr_application_info_h remote_app_info, void* user_data); /** * @brief Retrieves all remote device info stored on local device. @@ -505,10 +497,10 @@ int capmgr_app_control_send(capmgr_app_control_h app_control, capmgr_app_control_reply_cb cb, void* user_data); /** - * @brief Retrieves all packages installed at specified remote device and invoke callback each of it. + * @brief Retrieves all applications installed at specified remote device and invoke callback each of it. * @since_tizen 5.0 * @param[in] device The remote device handle - * @param[in] cb Callback to be invoked for each package + * @param[in] cb Callback to be invoked for each application * @param[in] user_data The user data to be passed to the callback function * @return @c 0 on success, * otherwise a negative error value @@ -517,70 +509,70 @@ int capmgr_app_control_send(capmgr_app_control_h app_control, * @retval #CAPMGR_ERROR_IO_ERROR I/O error * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_package_info_foreach_packages(const capmgr_device_h device, - capmgr_package_info_foreach_package_cb cb, void* user_data); +int capmgr_application_info_foreach_applications( + const capmgr_device_h device, + capmgr_application_info_foreach_app_cb cb, + void* user_data); /** - * @brief Retrieves all applications belongs to given package and invoke callback each of it. + * @brief Gets the application ID from given remote application information. * @since_tizen 5.0 - * @param[in] remote_package_info The package information installed at specific remote device - * @param[in] cb Callback to be invoked for each application - * @param[in] user_data The user data to be passed to the callback function + * @remarks You must release @a appid using free(). + * @param[in] remote_app_info The application information installed at specific remote device + * @param[out] appid The application ID * @return @c 0 on success, * otherwise a negative error value * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CAPMGR_ERROR_IO_ERROR I/O error * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_package_info_foreach_applications( - const capmgr_package_info_h remote_package_info, - capmgr_package_info_foreach_app_cb cb, void* user_data); +int capmgr_application_info_get_appid(capmgr_application_info_h remote_app_info, + char** appid); /** - * @brief Gets the package ID from given remote package information. + * @brief Gets the package ID from given remote application information. * @since_tizen 5.0 * @remarks You must release @a pkgid using free(). - * @param[in] remote_package_info The package information installed at specific remote device - * @param[in] pkgid The package ID + * @param[in] remote_app_info The application information installed at specific remote device + * @param[out] pkgid The package ID * @return @c 0 on success, * otherwise a negative error value * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_package_info_get_pkgid(capmgr_package_info_h remote_package_info, +int capmgr_application_info_get_pkgid(capmgr_application_info_h remote_app_info, char** pkgid); /** - * @brief Gets the label from given remote package information. + * @brief Gets the label from given remote application information. * @since_tizen 5.0 * @remarks You must release @a label using free(). - * @param[in] remote_package_info The package information installed at specific remote device - * @param[in] label The label of package + * @param[in] remote_app_info The application information installed at specific remote device + * @param[out] label The label of application * @return @c 0 on success, * otherwise a negative error value * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_package_info_get_label(capmgr_package_info_h remote_package_info, +int capmgr_application_info_get_label(capmgr_application_info_h remote_app_info, char** label); /** - * @brief Gets the version from given remote package information. + * @brief Gets the version from given remote application information. * @since_tizen 5.0 * @remarks You must release @a version using free(). - * @param[in] remote_package_info The package information installed at specific remote device - * @param[in] version The version of package + * @param[in] remote_app_info The application information installed at specific remote device + * @param[out] version The version of application * @return @c 0 on success, * otherwise a negative error value * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_package_info_get_version(capmgr_package_info_h remote_package_info, - char** version); +int capmgr_application_info_get_version( + capmgr_application_info_h remote_app_info, char** version); #ifdef __cplusplus } diff --git a/src/client.cc b/src/client.cc index 97a9d7e..de41c94 100644 --- a/src/client.cc +++ b/src/client.cc @@ -42,11 +42,11 @@ struct capmgr_app_control_s { bundle* b; }; -struct capmgr_package_info_s { +struct capmgr_application_info_s { + std::string appid; std::string pkgid; std::string label; std::string version; - std::vector appid_list; }; API int capmgr_device_foreach_devices(capmgr_device_foreach_cb cb, @@ -543,50 +543,58 @@ API int capmgr_app_control_send(capmgr_app_control_h app_control, return CAPMGR_ERROR_NONE; } -API int capmgr_package_info_get_pkgid(capmgr_package_info_h remote_package_info, - char** pkgid) { - if (!remote_package_info || !pkgid || - remote_package_info->pkgid.empty()) +API int capmgr_application_info_get_appid( + capmgr_application_info_h remote_app_info, char** appid) { + if (!remote_app_info || !appid || remote_app_info->appid.empty()) return CAPMGR_ERROR_INVALID_PARAMETER; - *pkgid = strdup(remote_package_info->pkgid.c_str()); + *appid = strdup(remote_app_info->appid.c_str()); + if (*appid == nullptr) + return CAPMGR_ERROR_OUT_OF_MEMORY; + + return CAPMGR_ERROR_NONE; +} + +API int capmgr_application_info_get_pkgid( + capmgr_application_info_h remote_app_info, char** pkgid) { + if (!remote_app_info || !pkgid || remote_app_info->pkgid.empty()) + return CAPMGR_ERROR_INVALID_PARAMETER; + + *pkgid = strdup(remote_app_info->pkgid.c_str()); if (*pkgid == nullptr) return CAPMGR_ERROR_OUT_OF_MEMORY; return CAPMGR_ERROR_NONE; } -API int capmgr_package_info_get_label(capmgr_package_info_h remote_package_info, - char** label) { - if (!remote_package_info || !label || - remote_package_info->label.empty()) +API int capmgr_application_info_get_label( + capmgr_application_info_h remote_app_info, char** label) { + if (!remote_app_info || !label || remote_app_info->label.empty()) return CAPMGR_ERROR_INVALID_PARAMETER; - *label = strdup(remote_package_info->label.c_str()); + *label = strdup(remote_app_info->label.c_str()); if (*label == nullptr) return CAPMGR_ERROR_OUT_OF_MEMORY; return CAPMGR_ERROR_NONE; } -API int capmgr_package_info_get_version( - capmgr_package_info_h remote_package_info, char** version) { - if (!remote_package_info || !version || - remote_package_info->version.empty()) +API int capmgr_application_info_get_version( + capmgr_application_info_h remote_app_info, char** version) { + if (!remote_app_info || !version || remote_app_info->version.empty()) return CAPMGR_ERROR_INVALID_PARAMETER; - *version = strdup(remote_package_info->version.c_str()); + *version = strdup(remote_app_info->version.c_str()); if (*version == nullptr) return CAPMGR_ERROR_OUT_OF_MEMORY; return CAPMGR_ERROR_NONE; } -API int capmgr_package_info_foreach_packages(const capmgr_device_h device, - capmgr_package_info_foreach_package_cb cb, +API int capmgr_application_info_foreach_applications( + const capmgr_device_h device, + capmgr_application_info_foreach_app_cb cb, void* user_data) { - std::map pkg_map; - if (!cb) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -604,40 +612,16 @@ API int capmgr_package_info_foreach_packages(const capmgr_device_h device, if (stmt->BindString(1, device->device_id)) { while (stmt->Step() == capmgr::SQLStatement::StepResult::ROW) { - struct capmgr_package_info_s info; - std::string appid; + struct capmgr_application_info_s info; int idx = 0; - appid = stmt->GetColumnString(idx++); + info.appid = stmt->GetColumnString(idx++); info.pkgid = stmt->GetColumnString(idx++); info.label = stmt->GetColumnString(idx++); info.version = stmt->GetColumnString(idx++); - - auto search_info = pkg_map.find(appid); - if (search_info != pkg_map.end()) { - info.appid_list.emplace_back(appid); - pkg_map.emplace(appid, info); - } else { - struct capmgr_package_info_s found = search_info->second; - found.appid_list.emplace_back(appid); - } + if (cb(&info, user_data)) + break; } } - for (auto it = pkg_map.begin(); it != pkg_map.end(); it++) { - struct capmgr_package_info_s info = it->second; - if (cb(&info, user_data)) - break; - } - - return CAPMGR_ERROR_NONE; -} - -API int capmgr_package_info_foreach_applications( - const capmgr_package_info_h remote_pkg_info, - capmgr_package_info_foreach_app_cb cb, - void* user_data) { - if (!cb) - return CAPMGR_ERROR_INVALID_PARAMETER; - return CAPMGR_ERROR_NONE; } diff --git a/tools/capmgr_test.cc b/tools/capmgr_test.cc index 8c79856..6dad30b 100644 --- a/tools/capmgr_test.cc +++ b/tools/capmgr_test.cc @@ -34,6 +34,7 @@ class Client { void SendAppControl(const std::string& device_id, const std::string& appid); void SendFile(const std::string& device_id, const std::string& file_path); void ListDevices(); + void ListAppinfos(const std::string& device_id); private: GVariant* ProxyCallSync(const char* method, GVariant* params); @@ -112,6 +113,48 @@ int DeviceForeachCb(const capmgr_device_h device, void* user_data) { return 0; } +int AppForeachCb(const capmgr_application_info_h remote_app_info, + void* user_data) { + char* appid = nullptr; + char* pkgid = nullptr; + char* label = nullptr; + char* ver = nullptr; + + int ret = capmgr_application_info_get_appid(remote_app_info, &appid); + if (ret != CAPMGR_ERROR_NONE) + std::cout << "Failed to get appid" << std::endl; + + ret = capmgr_application_info_get_pkgid(remote_app_info, &pkgid); + if (ret != CAPMGR_ERROR_NONE) + std::cout << "Failed to get pkgid" << std::endl; + + ret = capmgr_application_info_get_label(remote_app_info, &label); + if (ret != CAPMGR_ERROR_NONE) + std::cout << "Failed to get label" << std::endl; + + ret = capmgr_application_info_get_version(remote_app_info, &ver); + if (ret != CAPMGR_ERROR_NONE) + std::cout << "Failed to get pkgid" << std::endl; + + std::cout << "==============================================" << std::endl; + try { + std::cout << "APPID: " << std::string(appid) << std::endl + << "PKGID: " << std::string(pkgid) << std::endl + << "Label: " << std::string(label) << std::endl + << "Version: " << std::string(ver) << std::endl; + } catch (...) { + std::cout << "Exception occured" << std::endl; + } + + free(appid); + free(pkgid); + free(label); + free(ver); + + return 0; +} + + Client::Client() { loop_ = g_main_loop_new(nullptr, FALSE); @@ -211,6 +254,36 @@ void Client::ListDevices() { << std::endl; } +void Client::ListAppinfos(const std::string& device_id) { + if (device_id.empty()) { + std::cout << "Target device is missing!" << std::endl; + return; + } + + capmgr_device_h device = nullptr; + struct cbdata cbdata = {&device, device_id}; + int ret = capmgr_device_foreach_devices(DeviceForeachCb, &cbdata); + if (ret != CAPMGR_ERROR_NONE) { + std::cout << "capmgr_device_foreach_devices() failed: " << ret + << std::endl; + return; + } + + if (*cbdata.device == nullptr) { + std::cout << "There is no such device!" << std::endl; + return; + } + + std::cout << "Target device is " <(), "send remote app-control") ("list-devices,l", "list remote devices") + ("list-appinfos,a", "list remote application infos") ("send-file,f", bpo::value(), "send file"); bpo::store(bpo::parse_command_line(argc, argv, options), opt_map); @@ -370,6 +444,8 @@ int main(int argc, char* argv[]) { opt_map["send-appcontrol"].as()); else if (opt_map.count("list-devices")) client.ListDevices(); + else if (opt_map.count("list-appinfos")) + client.ListAppinfos(opt_map["device"].as()); else if (opt_map.count("send-file")) client.SendFile(opt_map["device"].as(), opt_map["send-file"].as()); -- 2.7.4 From 2c44fa4f05f198984a256c348a520ee5cb058b07 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 29 Oct 2018 17:41:13 +0900 Subject: [PATCH 11/16] Add capmgr_application_info_clone() Change-Id: I84233af4d2aef6ef9587b00cfeb331a240aa9fbe Signed-off-by: Sangyoon Jang --- include/capability_manager.h | 15 +++++++++++++++ src/client.cc | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/capability_manager.h b/include/capability_manager.h index a8affce..4f7019b 100644 --- a/include/capability_manager.h +++ b/include/capability_manager.h @@ -515,6 +515,21 @@ int capmgr_application_info_foreach_applications( void* user_data); /** + * @brief Clones the remote application information handle. + * @since_tizen 5.0 + * @param[in] remote_app_info The remote application info handle + * @param[out] remote_app_info_clone A newly created remote application information handle, if successfully cloned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + */ +int capmgr_application_info_clone( + const capmgr_application_info_h remote_app_info, + capmgr_application_info_h* remote_app_info_clone); + +/** * @brief Gets the application ID from given remote application information. * @since_tizen 5.0 * @remarks You must release @a appid using free(). diff --git a/src/client.cc b/src/client.cc index de41c94..a6a08b7 100644 --- a/src/client.cc +++ b/src/client.cc @@ -543,6 +543,30 @@ API int capmgr_app_control_send(capmgr_app_control_h app_control, return CAPMGR_ERROR_NONE; } +API int capmgr_application_info_clone( + const capmgr_application_info_h remote_app_info, + capmgr_application_info_h* remote_app_info_clone) { + if (!remote_app_info || !remote_app_info_clone) + return CAPMGR_ERROR_INVALID_PARAMETER; + + struct capmgr_application_info_s* clone; + try { + clone = new struct capmgr_application_info_s(); + } catch (const std::bad_alloc& e) { + LOG(ERROR) << e.what(); + return CAPMGR_ERROR_OUT_OF_MEMORY; + } + + clone->appid = remote_app_info->appid; + clone->pkgid = remote_app_info->pkgid; + clone->label = remote_app_info->label; + clone->version = remote_app_info->version; + + *remote_app_info_clone = clone; + + return CAPMGR_ERROR_NONE; +} + API int capmgr_application_info_get_appid( capmgr_application_info_h remote_app_info, char** appid) { if (!remote_app_info || !appid || remote_app_info->appid.empty()) -- 2.7.4 From 239e5217ddff2e9c359e165db192c1256ce1ef49 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Wed, 7 Nov 2018 15:35:54 +0900 Subject: [PATCH 12/16] Add device handle to application information handle Signed-off-by: Inkyun Kil --- include/capability_manager.h | 29 +++++++++++++++++++++++++++++ src/client.cc | 33 +++++++++++++++++++++++++++++++++ tools/capmgr_test.cc | 15 ++++++++++++++- 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/include/capability_manager.h b/include/capability_manager.h index 4f7019b..e5b0a44 100644 --- a/include/capability_manager.h +++ b/include/capability_manager.h @@ -97,6 +97,7 @@ typedef int (*capmgr_app_control_reply_cb)(const capmgr_app_control_h request, * @param[in] remote_app_info Capability Manager Application Info handle * @param[in] user_data The user data to be passed to the callback function * @see capmgr_application_info_foreach_applications() + * @see capmgr_application_info_clone() */ typedef int (*capmgr_application_info_foreach_app_cb)( const capmgr_application_info_h remote_app_info, void* user_data); @@ -524,6 +525,7 @@ int capmgr_application_info_foreach_applications( * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @see capmgr_application_info_destroy() */ int capmgr_application_info_clone( const capmgr_application_info_h remote_app_info, @@ -589,6 +591,33 @@ int capmgr_application_info_get_label(capmgr_application_info_h remote_app_info, int capmgr_application_info_get_version( capmgr_application_info_h remote_app_info, char** version); +/** + * @brief Gets the remote device handle from the given remote application info context. + * @since_tizen 5.0 + * @remarks You must release @a device using capmgr_device_destroy(). + * @param[in] remote_app_info The application information installed at specific remote device + * @param[out] device The remote device handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + */ +int capmgr_application_info_get_device( + capmgr_application_info_h remote_app_info, capmgr_device_h* device); + +/** + * @brief Destroys the remote application information handle and releases all its resources. + * @since_tizen 5.0 + * @param[in] remote_app_info The remote application information handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #CAPMGR_ERROR_NONE Successful + * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter + * @see capmgr_application_info_clone() + */ +int capmgr_application_info_destroy(capmgr_application_info_h remote_app_info); + #ifdef __cplusplus } #endif diff --git a/src/client.cc b/src/client.cc index a6a08b7..7e64cb1 100644 --- a/src/client.cc +++ b/src/client.cc @@ -47,6 +47,7 @@ struct capmgr_application_info_s { std::string pkgid; std::string label; std::string version; + capmgr_device_h device; }; API int capmgr_device_foreach_devices(capmgr_device_foreach_cb cb, @@ -562,11 +563,29 @@ API int capmgr_application_info_clone( clone->label = remote_app_info->label; clone->version = remote_app_info->version; + int ret = capmgr_device_clone(remote_app_info->device, &(clone->device)); + if (ret != CAPMGR_ERROR_NONE) { + LOG(ERROR) << "Failed to clone capmgr device"; + delete clone; + return ret; + } + *remote_app_info_clone = clone; return CAPMGR_ERROR_NONE; } +API int capmgr_application_info_destroy( + capmgr_application_info_h remote_app_info) { + if (!remote_app_info) + return CAPMGR_ERROR_INVALID_PARAMETER; + + capmgr_device_destroy(remote_app_info->device); + delete remote_app_info; + + return CAPMGR_ERROR_NONE; +} + API int capmgr_application_info_get_appid( capmgr_application_info_h remote_app_info, char** appid) { if (!remote_app_info || !appid || remote_app_info->appid.empty()) @@ -615,6 +634,19 @@ API int capmgr_application_info_get_version( return CAPMGR_ERROR_NONE; } +API int capmgr_application_info_get_device( + capmgr_application_info_h remote_app_info, + capmgr_device_h* device) { + if (!remote_app_info || !device) + return CAPMGR_ERROR_INVALID_PARAMETER; + + int ret = capmgr_device_clone(remote_app_info->device, device); + if (ret != CAPMGR_ERROR_NONE) + return ret; + + return CAPMGR_ERROR_NONE; +} + API int capmgr_application_info_foreach_applications( const capmgr_device_h device, capmgr_application_info_foreach_app_cb cb, @@ -642,6 +674,7 @@ API int capmgr_application_info_foreach_applications( info.pkgid = stmt->GetColumnString(idx++); info.label = stmt->GetColumnString(idx++); info.version = stmt->GetColumnString(idx++); + info.device = device; if (cb(&info, user_data)) break; } diff --git a/tools/capmgr_test.cc b/tools/capmgr_test.cc index 6dad30b..b2adec7 100644 --- a/tools/capmgr_test.cc +++ b/tools/capmgr_test.cc @@ -119,6 +119,8 @@ int AppForeachCb(const capmgr_application_info_h remote_app_info, char* pkgid = nullptr; char* label = nullptr; char* ver = nullptr; + capmgr_device_h device = nullptr; + char* device_id = nullptr; int ret = capmgr_application_info_get_appid(remote_app_info, &appid); if (ret != CAPMGR_ERROR_NONE) @@ -136,12 +138,22 @@ int AppForeachCb(const capmgr_application_info_h remote_app_info, if (ret != CAPMGR_ERROR_NONE) std::cout << "Failed to get pkgid" << std::endl; + ret = capmgr_application_info_get_device(remote_app_info, &device); + if (ret != CAPMGR_ERROR_NONE) + std::cout << "Failed to get device" << std::endl; + std::cout << "==============================================" << std::endl; + + ret = capmgr_device_get_device_id(device, &device_id); + if (ret != CAPMGR_ERROR_NONE) + std::cout << "Failed to get device id" << std::endl; + try { std::cout << "APPID: " << std::string(appid) << std::endl << "PKGID: " << std::string(pkgid) << std::endl << "Label: " << std::string(label) << std::endl - << "Version: " << std::string(ver) << std::endl; + << "Version: " << std::string(ver) << std::endl + << "Device ID: " << std::string(device_id) << std::endl; } catch (...) { std::cout << "Exception occured" << std::endl; } @@ -150,6 +162,7 @@ int AppForeachCb(const capmgr_application_info_h remote_app_info, free(pkgid); free(label); free(ver); + capmgr_device_destroy(device); return 0; } -- 2.7.4 From f629b4e9148709ae3dcaffc63024d7b9c4195d72 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 14 Nov 2018 19:13:11 +0900 Subject: [PATCH 13/16] Fix crash when invalid parameter given Change-Id: I958f11b27d06c2a9ba4f69a79398f02ded984cec Signed-off-by: Sangyoon Jang --- src/client.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.cc b/src/client.cc index 7e64cb1..fa2030a 100644 --- a/src/client.cc +++ b/src/client.cc @@ -651,7 +651,7 @@ API int capmgr_application_info_foreach_applications( const capmgr_device_h device, capmgr_application_info_foreach_app_cb cb, void* user_data) { - if (!cb) + if (!device || !cb) return CAPMGR_ERROR_INVALID_PARAMETER; std::unique_ptr sql_conn( -- 2.7.4 From ba85b693deee438f0d1852e368cd2e0fe87805a5 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 24 Oct 2018 17:49:47 +0900 Subject: [PATCH 14/16] Add unit test Run /usr/bin/capi-appfw-capmgr-ut/unit-test after discovering at least one device. Change-Id: I261dc6b699e9b99f1b45940ae83e0b31a8cd75dc Signed-off-by: Sangyoon Jang --- CMakeLists.txt | 1 + packaging/capi-appfw-capmgr.spec | 11 ++ src/CMakeLists.txt | 2 + src/unit_tests/CMakeLists.txt | 16 ++ src/unit_tests/unit_test.cc | 401 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 431 insertions(+) create mode 100644 src/unit_tests/CMakeLists.txt create mode 100644 src/unit_tests/unit_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 77e1752..25bcfdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(GLIB_DEPS REQUIRED glib-2.0) PKG_CHECK_MODULES(SQLITE_DEPS REQUIRED sqlite3) FIND_PACKAGE(Boost REQUIRED COMPONENTS filesystem program_options system) +FIND_PACKAGE(GTest REQUIRED) INSTALL(DIRECTORY include/ DESTINATION ${INCLUDEDIR} FILES_MATCHING PATTERN "*.h") ADD_SUBDIRECTORY(src) diff --git a/packaging/capi-appfw-capmgr.spec b/packaging/capi-appfw-capmgr.spec index ae05be9..5d90a34 100644 --- a/packaging/capi-appfw-capmgr.spec +++ b/packaging/capi-appfw-capmgr.spec @@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest BuildRequires: boost-devel BuildRequires: cmake +BuildRequires: gtest-devel BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(capi-base-common) @@ -27,6 +28,13 @@ Requires: %{name} = %{version} %description devel This package contains header files of capability manager native API +%package tests +Summary: Unit-tests for capmgr native API +Requires: %{name} = %{version} + +%description tests +Unit-tests for capmgr native API + %prep %setup -q cp %{SOURCE1001} . @@ -57,3 +65,6 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %{_includedir}/capability_manager_internal.h %{_libdir}/pkgconfig/%{name}.pc %{_libdir}/lib%{name}.so + +%files tests +%{_bindir}/capi-appfw-capmgr-ut/* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4280e2..c5e8f33 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,3 +22,5 @@ SET_TARGET_PROPERTIES(${TARGET_LIB_CAPMGR} PROPERTIES SOVERSION ${MAJORVER}) INSTALL(TARGETS ${TARGET_LIB_CAPMGR} DESTINATION ${LIB_INSTALL_DIR}) CONFIGURE_FILE(capi-appfw-capmgr.pc.in capi-appfw-capmgr.pc @ONLY) INSTALL(FILES capi-appfw-capmgr.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) + +ADD_SUBDIRECTORY(unit_tests) diff --git a/src/unit_tests/CMakeLists.txt b/src/unit_tests/CMakeLists.txt new file mode 100644 index 0000000..bd06ad2 --- /dev/null +++ b/src/unit_tests/CMakeLists.txt @@ -0,0 +1,16 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ UNIT_TEST_SRCS) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) + +SET(TARGET_UNIT_TEST "unit-test") + +ADD_EXECUTABLE(${TARGET_UNIT_TEST} ${UNIT_TEST_SRCS}) + +APPLY_PKG_CONFIG(${TARGET_UNIT_TEST} PUBLIC + DLOG_DEPS + GTEST +) + +TARGET_LINK_LIBRARIES(${TARGET_UNIT_TEST} PUBLIC ${TARGET_LIB_CAPMGR}) + +INSTALL(TARGETS ${TARGET_UNIT_TEST} DESTINATION bin/capi-appfw-capmgr-ut/) diff --git a/src/unit_tests/unit_test.cc b/src/unit_tests/unit_test.cc new file mode 100644 index 0000000..ae68e56 --- /dev/null +++ b/src/unit_tests/unit_test.cc @@ -0,0 +1,401 @@ +// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by a apache 2.0 license that can be +// found in the LICENSE file. + +#include + +#include + +#include "include/capability_manager.h" +#include "src/utils/logging.h" + +namespace { + +int DeviceForeachCbForSetup(const capmgr_device_h device, void* user_data) { + capmgr_device_h* clone = reinterpret_cast(user_data); + int ret = capmgr_device_clone(device, clone); + if (ret != CAPMGR_ERROR_NONE) + return 0; + // use the first device + else + return 1; +} + +int ApplicationForeachCbForSetup( + const capmgr_application_info_h remote_app_info, void* user_data) { + capmgr_application_info_h* clone = + reinterpret_cast(user_data); + int ret = capmgr_application_info_clone(remote_app_info, clone); + if (ret != CAPMGR_ERROR_NONE) + return 0; + // use the first app + else + return 1; +} + +int DeviceForeachCb(const capmgr_device_h device, void* user_data) { + bool* is_hit = reinterpret_cast(user_data); + *is_hit = true; + return 1; +} + +int ApplicationForeachCb(const capmgr_application_info_h remote_app_info, + void* user_data) { + bool* is_hit = reinterpret_cast(user_data); + *is_hit = true; + + char* appid; + capmgr_application_info_get_appid(remote_app_info, &appid); + free(appid); + LOG(INFO) << appid; + return 0; +} + +const char kExtraDataKeyStr[] = "extra_key"; +const char kExtraDataValueStr[] = "extra_value"; + +class TestEnvironment : public ::testing::Environment { + public: + TestEnvironment() : device_(nullptr), app_control_(nullptr), + app_(nullptr) {} + void SetUp() override { + ASSERT_EQ(capmgr_device_foreach_devices(DeviceForeachCbForSetup, &device_), + CAPMGR_ERROR_NONE) << "Failed to init test environment!"; + ASSERT_NE(device_, nullptr); + char* device_id; + capmgr_device_get_device_id(device_, &device_id); + LOG(INFO) << "Selected device id is: " << device_id; + free(device_id); + ASSERT_EQ(capmgr_app_control_create(&app_control_), CAPMGR_ERROR_NONE); + ASSERT_NE(app_control_, nullptr); + ASSERT_EQ(capmgr_app_control_set_device(app_control_, device_), + CAPMGR_ERROR_NONE); + ASSERT_EQ(capmgr_app_control_set_operation(app_control_, "operation"), + CAPMGR_ERROR_NONE); + ASSERT_EQ(capmgr_app_control_set_uri(app_control_, "uri"), + CAPMGR_ERROR_NONE); + ASSERT_EQ(capmgr_app_control_set_mime(app_control_, "mime"), + CAPMGR_ERROR_NONE); + ASSERT_EQ(capmgr_app_control_set_appid(app_control_, "appid"), + CAPMGR_ERROR_NONE); + ASSERT_EQ(capmgr_app_control_add_extra_data(app_control_, kExtraDataKeyStr, + kExtraDataValueStr), CAPMGR_ERROR_NONE); + ASSERT_EQ(capmgr_application_info_foreach_applications(device_, + ApplicationForeachCbForSetup, &app_), CAPMGR_ERROR_NONE); + } + void TearDown() override { + capmgr_application_info_destroy(app_); + capmgr_app_control_destroy(app_control_); + capmgr_device_destroy(device_); + } + + capmgr_device_h device_; + capmgr_app_control_h app_control_; + capmgr_application_info_h app_; +}; + +TestEnvironment* env = nullptr; + +} // namespace + +namespace capmgr { + +class UnitTest : public ::testing::Test { + protected: + virtual void SetUp() {} + virtual void TearDown() {} +}; + +TEST_F(UnitTest, DeviceForeachDevicesPositiveTest) { + bool is_hit = false; + ASSERT_EQ(capmgr_device_foreach_devices(DeviceForeachCb, &is_hit), + CAPMGR_ERROR_NONE); + ASSERT_TRUE(is_hit); +} + +TEST_F(UnitTest, DeviceForeachDevicesNegativeTest) { + ASSERT_EQ(capmgr_device_foreach_devices(nullptr, nullptr), + CAPMGR_ERROR_INVALID_PARAMETER); +} + +TEST_F(UnitTest, DeviceClonePositiveTest) { + // need to get device + capmgr_device_h clone; + ASSERT_EQ(capmgr_device_clone(env->device_, &clone), CAPMGR_ERROR_NONE); +} + +TEST_F(UnitTest, DeviceCloneNegativeTest) { + capmgr_device_h clone; + ASSERT_EQ(capmgr_device_clone(nullptr, &clone), + CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ(capmgr_device_clone(env->device_, nullptr), + CAPMGR_ERROR_INVALID_PARAMETER); +} + +TEST_F(UnitTest, DeviceDestroyPositiveTest) { + capmgr_device_h clone; + ASSERT_EQ(capmgr_device_clone(env->device_, &clone), + CAPMGR_ERROR_NONE); + ASSERT_EQ(capmgr_device_destroy(clone), CAPMGR_ERROR_NONE); +} + +TEST_F(UnitTest, DeviceDestroyNegativeTest) { + ASSERT_EQ(capmgr_device_destroy(nullptr), CAPMGR_ERROR_INVALID_PARAMETER); +} + +#define DEVICE_GET_TEST_BLOCK(POSITIVE_TESTNAME, NEGATIVE_TESTNAME, ATTR) \ +TEST_F(UnitTest, POSITIVE_TESTNAME) { \ + char* ATTR = nullptr; \ + ASSERT_EQ(capmgr_device_get_##ATTR(env->device_, &ATTR), CAPMGR_ERROR_NONE); \ + ASSERT_NE(ATTR, nullptr); \ + free(ATTR); \ +} \ + \ +TEST_F(UnitTest, NEGATIVE_TESTNAME) { \ + char* ATTR; \ + ASSERT_EQ(capmgr_device_get_##ATTR(nullptr, &ATTR), \ + CAPMGR_ERROR_INVALID_PARAMETER); \ + ASSERT_EQ(capmgr_device_get_##ATTR(env->device_, nullptr), \ + CAPMGR_ERROR_INVALID_PARAMETER); \ +} \ + +DEVICE_GET_TEST_BLOCK(DeviceGetDeviceIdPositiveTest, + DeviceGetDeviceIdNegativeTest, device_id) + +DEVICE_GET_TEST_BLOCK(DeviceGetModelNamePositiveTest, + DeviceGetModelNameNegativeTest, model_name) + +DEVICE_GET_TEST_BLOCK(DeviceGetDeviceNamePositiveTest, + DeviceGetDeviceNameNegativeTest, device_name) + +DEVICE_GET_TEST_BLOCK(DeviceGetPlatformVerPositiveTest, + DeviceGetPlatformVerNegativeTest, platform_ver) + +DEVICE_GET_TEST_BLOCK(DeviceGetProfilePositiveTest, + DeviceGetProfileNegativeTest, profile) + +DEVICE_GET_TEST_BLOCK(DeviceGetSWVerPositiveTest, + DeviceGetSWVerNegativeTest, sw_ver) + +TEST_F(UnitTest, AppControlCreatePositiveTest) { + capmgr_app_control_h app_control; + ASSERT_EQ(capmgr_app_control_create(&app_control), CAPMGR_ERROR_NONE); + capmgr_app_control_destroy(app_control); +} + +TEST_F(UnitTest, AppControlCreateNegativeTest) { + ASSERT_EQ(capmgr_app_control_create(nullptr), CAPMGR_ERROR_INVALID_PARAMETER); +} + +TEST_F(UnitTest, AppControlDestroyPositiveTest) { + capmgr_app_control_h app_control; + ASSERT_EQ(capmgr_app_control_create(&app_control), CAPMGR_ERROR_NONE); + ASSERT_EQ(capmgr_app_control_destroy(app_control), CAPMGR_ERROR_NONE); +} + +TEST_F(UnitTest, AppControlDestroyNegativeTest) { + ASSERT_EQ(capmgr_app_control_destroy(nullptr), + CAPMGR_ERROR_INVALID_PARAMETER); +} + +TEST_F(UnitTest, AppControlGetDevicePositiveTest) { + capmgr_device_h device; + ASSERT_EQ(capmgr_app_control_get_device(env->app_control_, &device), + CAPMGR_ERROR_NONE); + capmgr_device_destroy(device); +} + +TEST_F(UnitTest, AppControlGetDeviceNegativeTest) { + capmgr_device_h device; + ASSERT_EQ(capmgr_app_control_get_device(nullptr, &device), + CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ(capmgr_app_control_get_device(env->app_control_, nullptr), + CAPMGR_ERROR_INVALID_PARAMETER); +} + +#define APP_CONTROL_GET_TEST_BLOCK(POSITIVE_TESTNAME, NEGATIVE_TESTNAME, ATTR) \ +TEST_F(UnitTest, POSITIVE_TESTNAME) { \ + char* ATTR = nullptr; \ + ASSERT_EQ(capmgr_app_control_get_##ATTR(env->app_control_, &ATTR), \ + CAPMGR_ERROR_NONE); \ + ASSERT_NE(ATTR, nullptr); \ + free(ATTR); \ +} \ + \ +TEST_F(UnitTest, NEGATIVE_TESTNAME) { \ + char* ATTR; \ + ASSERT_EQ(capmgr_app_control_get_##ATTR(nullptr, &ATTR), \ + CAPMGR_ERROR_INVALID_PARAMETER); \ + ASSERT_EQ(capmgr_app_control_get_##ATTR(env->app_control_, nullptr), \ + CAPMGR_ERROR_INVALID_PARAMETER); \ +} \ + +APP_CONTROL_GET_TEST_BLOCK(AppControlGetOperationPositiveTest, + AppControlGetOperationNegativeTest, operation) + +APP_CONTROL_GET_TEST_BLOCK(AppControlGetUriPositiveTest, + AppControlGetUriNegativeTest, uri) + +APP_CONTROL_GET_TEST_BLOCK(AppControlGetMimePositiveTest, + AppControlGetMimeNegativeTest, mime) + +APP_CONTROL_GET_TEST_BLOCK(AppControlGetAppidPositiveTest, + AppControlGetAppidNegativeTest, appid) + +TEST_F(UnitTest, AppControlGetExtraDataPositiveTest) { + char* value = nullptr; + ASSERT_EQ(capmgr_app_control_get_extra_data(env->app_control_, + kExtraDataKeyStr, &value), CAPMGR_ERROR_NONE); + ASSERT_NE(value, nullptr); + free(value); +} + +TEST_F(UnitTest, AppControlGetExtraDataNegativeTest) { + char* value; + ASSERT_EQ(capmgr_app_control_get_extra_data(nullptr, + kExtraDataKeyStr, &value), CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ(capmgr_app_control_get_extra_data(env->app_control_, + nullptr, &value), CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ(capmgr_app_control_get_extra_data(env->app_control_, + kExtraDataKeyStr, nullptr), CAPMGR_ERROR_INVALID_PARAMETER); +} + +TEST_F(UnitTest, AppControlSetDevicePositiveTest) { + ASSERT_EQ(capmgr_app_control_set_device(env->app_control_, env->device_), + CAPMGR_ERROR_NONE); +} + +TEST_F(UnitTest, AppControlSetDeviceNegativeTest) { + ASSERT_EQ(capmgr_app_control_set_device(nullptr, env->device_), + CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ(capmgr_app_control_set_device(env->app_control_, nullptr), + CAPMGR_ERROR_INVALID_PARAMETER); +} + +#define APP_CONTROL_SET_TEST_BLOCK(POSITIVE_TESTNAME, NEGATIVE_TESTNAME, ATTR) \ +TEST_F(UnitTest, POSITIVE_TESTNAME) { \ + ASSERT_EQ(capmgr_app_control_set_##ATTR(env->app_control_, "value"), \ + CAPMGR_ERROR_NONE); \ +} \ + \ +TEST_F(UnitTest, NEGATIVE_TESTNAME) { \ + ASSERT_EQ(capmgr_app_control_set_##ATTR(nullptr, "value"), \ + CAPMGR_ERROR_INVALID_PARAMETER); \ + ASSERT_EQ(capmgr_app_control_set_##ATTR(env->app_control_, nullptr), \ + CAPMGR_ERROR_INVALID_PARAMETER); \ +} \ + +APP_CONTROL_SET_TEST_BLOCK(AppControlSetOperationPositiveTest, + AppControlSetOperationNegativeTest, operation) + +APP_CONTROL_SET_TEST_BLOCK(AppControlSetUriPositiveTest, + AppControlSetUriNegativeTest, uri) + +APP_CONTROL_SET_TEST_BLOCK(AppControlSetMimePositiveTest, + AppControlSetMimeNegativeTest, mime) + +APP_CONTROL_SET_TEST_BLOCK(AppControlSetAppidPositiveTest, + AppControlSetAppidNegativeTest, appid) + +TEST_F(UnitTest, AppControlAddExtraDataPositiveTest) { + ASSERT_EQ( + capmgr_app_control_add_extra_data(env->app_control_, "key", "value"), + CAPMGR_ERROR_NONE); +} + +TEST_F(UnitTest, AppControlAddExtraDataNegativeTest) { + ASSERT_EQ( + capmgr_app_control_add_extra_data(nullptr, "key", "value"), + CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ( + capmgr_app_control_add_extra_data(env->app_control_, nullptr, "value"), + CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ( + capmgr_app_control_add_extra_data(env->app_control_, "key", nullptr), + CAPMGR_ERROR_INVALID_PARAMETER); +} + +TEST_F(UnitTest, AppControlRemoveExtraDataPositiveTest) { + ASSERT_EQ( + capmgr_app_control_add_extra_data(env->app_control_, "key2", "value2"), + CAPMGR_ERROR_NONE); + ASSERT_EQ( + capmgr_app_control_remove_extra_data(env->app_control_, "key2"), + CAPMGR_ERROR_NONE); + // should return such as CAPMGR_ERROR_NO_SUCH_KEY? + char* value; + ASSERT_EQ(capmgr_app_control_get_extra_data(env->app_control_, + "key2", &value), CAPMGR_ERROR_INVALID_PARAMETER); +} + +TEST_F(UnitTest, AppControlRemoveExtraDataNegativeTest) { + char* value; + ASSERT_EQ(capmgr_app_control_get_extra_data(nullptr, + kExtraDataKeyStr, &value), CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ(capmgr_app_control_get_extra_data(env->app_control_, + nullptr, &value), CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ(capmgr_app_control_get_extra_data(env->app_control_, + kExtraDataKeyStr, nullptr), CAPMGR_ERROR_INVALID_PARAMETER); +} + +// TODO(jeremy.jang) +/* +TEST_F(UnitTest, AppControlSendPositiveTest) { +} + +TEST_F(UnitTest, AppControlSendNegativeTest) { +} +*/ + +TEST_F(UnitTest, ApplicationInfoForeachPackagesPositiveTest) { + bool is_hit = false; + ASSERT_EQ(capmgr_application_info_foreach_applications(env->device_, + ApplicationForeachCb, &is_hit), CAPMGR_ERROR_NONE); + ASSERT_TRUE(is_hit); +} + +TEST_F(UnitTest, ApplicationInfoForeachPackagesNegativeTest) { + ASSERT_EQ(capmgr_application_info_foreach_applications(nullptr, + ApplicationForeachCb, nullptr), CAPMGR_ERROR_INVALID_PARAMETER); + ASSERT_EQ(capmgr_application_info_foreach_applications(env->device_, + nullptr, nullptr), CAPMGR_ERROR_INVALID_PARAMETER); +} + +#define APPLICATION_INFO_GET_TEST_BLOCK( \ + POSITIVE_TESTNAME, NEGATIVE_TESTNAME, ATTR) \ +TEST_F(UnitTest, POSITIVE_TESTNAME) { \ + char* ATTR = nullptr; \ + ASSERT_EQ(capmgr_application_info_get_##ATTR(env->app_, &ATTR), \ + CAPMGR_ERROR_NONE); \ + ASSERT_NE(ATTR, nullptr); \ + free(ATTR); \ +} \ + \ +TEST_F(UnitTest, NEGATIVE_TESTNAME) { \ + char* ATTR; \ + ASSERT_EQ(capmgr_application_info_get_##ATTR(nullptr, &ATTR), \ + CAPMGR_ERROR_INVALID_PARAMETER); \ + ASSERT_EQ(capmgr_application_info_get_##ATTR(env->app_, nullptr), \ + CAPMGR_ERROR_INVALID_PARAMETER); \ +} \ + +APPLICATION_INFO_GET_TEST_BLOCK(ApplicationInfoGetAppidPositiveTest, + ApplicationInfoGetAppidNegativeTest, appid) + +APPLICATION_INFO_GET_TEST_BLOCK(ApplicationInfoGetPkgidPositiveTest, + ApplicationInfoGetPkgidNegativeTest, pkgid) + +APPLICATION_INFO_GET_TEST_BLOCK(ApplicationInfoGetLabelPositiveTest, + ApplicationInfoGetLabelNegativeTest, label) + +APPLICATION_INFO_GET_TEST_BLOCK(ApplicationInfoGetVersionPositiveTest, + ApplicationInfoGetVersionNegativeTest, version) + +} // namespace capmgr + +int main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + ::env = static_cast( + ::testing::AddGlobalTestEnvironment(new TestEnvironment)); + return RUN_ALL_TESTS(); +} -- 2.7.4 From f25beaa71c7252caa73e7ccc28f8c847e176cec2 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 28 Nov 2018 20:13:19 +0900 Subject: [PATCH 15/16] Fix LogCatcher Fix format security error. Change-Id: Ia52ac22072436d27978bf4ed4b0cf4ed61f1e513 Signed-off-by: Sangyoon Jang --- src/utils/logging.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/logging.h b/src/utils/logging.h index 491521c..23683bc 100644 --- a/src/utils/logging.h +++ b/src/utils/logging.h @@ -70,7 +70,7 @@ class LogCatcher { : level_(level), tag_(tag) { } void operator&(const StringStream& str) const { - dlog_print(LogLevelToPriority(level_), tag_.c_str(), + dlog_print(LogLevelToPriority(level_), tag_.c_str(), "%s", Escape(str.str()).c_str()); } -- 2.7.4 From 4def41d2feed69bf32a8a2dcfe2fad7aaa54c154 Mon Sep 17 00:00:00 2001 From: Daehyeon Jung Date: Mon, 11 Mar 2019 14:54:03 +0900 Subject: [PATCH 16/16] Revise API header - Update since_tizen version. - Change application_info to app_info. - Add privilge for send app control. Change-Id: I855d4623c6f581a1856527a207d4a6e8242a2d12 Signed-off-by: Daehyeon Jung --- include/capability_manager.h | 223 +++++++++++++++++++++++-------------------- src/client.cc | 44 ++++----- src/unit_tests/unit_test.cc | 58 +++++------ tools/capmgr_test.cc | 32 +++---- 4 files changed, 187 insertions(+), 170 deletions(-) diff --git a/include/capability_manager.h b/include/capability_manager.h index e5b0a44..4aa9a1b 100644 --- a/include/capability_manager.h +++ b/include/capability_manager.h @@ -1,6 +1,18 @@ -// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved -// Use of this source code is governed by a apache 2.0 license that can be -// found in the LICENSE file. +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef __TIZEN_APPFW_CAPABILITY_MANAGER_H__ #define __TIZEN_APPFW_CAPABILITY_MANAGER_H__ @@ -21,66 +33,62 @@ extern "C" { */ /** - * @brief Enumerations for Capability Manager Errors. - * @since_tizen 5.0 + * @brief Enumeration for Capability Manager Errors. + * @since_tizen 5.5 */ typedef enum { - /**< Successful */ - CAPMGR_ERROR_NONE = TIZEN_ERROR_NONE, - /**< Invalid parameter */ - CAPMGR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, - /**< Out of memory */ - CAPMGR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, - /**< Internal I/O error */ - CAPMGR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, + CAPMGR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + CAPMGR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + CAPMGR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + CAPMGR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */ + CAPMGR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ } capmgr_error_e; /** - * @brief Enumerations for Capability Manager app control result type. - * @since_tizen 5.0 + * @brief Enumeration for Capability Manager app control result type. + * @since_tizen 5.5 */ typedef enum { - CAPMGR_APP_CONTROL_RESULT_OK, /**< Successful */ + CAPMGR_APP_CONTROL_RESULT_OK, /**< Successful */ } capmgr_app_control_result_e; /** * @brief Capability Manager device handle. - * @since_tizen 5.0 + * @since_tizen 5.5 */ typedef struct capmgr_device_s* capmgr_device_h; /** * @brief Capability Manager app control handle. - * @since_tizen 5.0 + * @since_tizen 5.5 */ typedef struct capmgr_app_control_s* capmgr_app_control_h; /** * @brief Capability Manager application info handle. - * @since_tizen 5.0 + * @since_tizen 5.5 */ -typedef struct capmgr_application_info_s* capmgr_application_info_h; +typedef struct capmgr_app_info_s* capmgr_app_info_h; /** * @brief Called to retrieve information of devices currently discovered. - * @since_tizen 5.0 + * @since_tizen 5.5 * * @remarks The @a device can be used only in the callback. To use outside, make a copy. * @param[in] device Device handle * @param[in] user_data The user data to be passed to the callback function - * @see capmgr_device_foreach_devices() + * @see capmgr_device_foreach_device() */ typedef int (*capmgr_device_foreach_cb)(const capmgr_device_h device, void* user_data); /** - * @brief Called when send app control request has finished. - * @since_tizen 5.0 + * @brief Called when a 'send app control' request has finished. + * @since_tizen 5.5 * * @remarks The @a request, @reply can be used only in the callback. To use outside, make a copy. - * @param[in] request Capability Manager app control handle contains data to be sent - * @param[in] reply Capability Manager app control handle which contains - * reply for request + * @param[in] request Capability Manager app control handle which contains data to be sent + * @param[in] reply Capability Manager app control handle which contains reply for request * @param[in] result App control send result * @param[in] user_data The user data to be passed to the callback function * @see capmgr_app_control_send() @@ -91,20 +99,21 @@ typedef int (*capmgr_app_control_reply_cb)(const capmgr_app_control_h request, /** * @brief Called for each remote application info. - * @since_tizen 5.0 + * @since_tizen 5.5 * * @remarks The @a remote_app_info can be used only in the callback. To use outside, make a copy. * @param[in] remote_app_info Capability Manager Application Info handle * @param[in] user_data The user data to be passed to the callback function - * @see capmgr_application_info_foreach_applications() - * @see capmgr_application_info_clone() + * @see capmgr_app_info_foreach_application() + * @see capmgr_app_info_clone() */ -typedef int (*capmgr_application_info_foreach_app_cb)( - const capmgr_application_info_h remote_app_info, void* user_data); +typedef int (*capmgr_app_info_foreach_app_cb)( + const capmgr_app_info_h remote_app_info, void* user_data); /** * @brief Retrieves all remote device info stored on local device. - * @since_tizen 5.0 + * @details This function iterates over the Capability Manager enabled devices in the local network. + * @since_tizen 5.5 * * @param[in] cb The callback function to invoke * @param[in] user_data The user data to be passed to the callback function @@ -117,12 +126,13 @@ typedef int (*capmgr_application_info_foreach_app_cb)( * @see capmgr_device_foreach_cb() * */ -int capmgr_device_foreach_devices(capmgr_device_foreach_cb cb, - void* user_data); +int capmgr_device_foreach_device(capmgr_device_foreach_cb cb, void* user_data); /** - * @brief Clones the remote device information handle. - * @since_tizen 5.0 + * @brief Clones the remote device information handle received from capmgr_device_foreach_device(). + * @since_tizen 5.5 + * + * @remarks You must release @a device_clone using capmgr_device_destroy(). * @param[in] device The remote device handle * @param[out] device_clone A newly created remote device information handle, if successfully cloned * @return @c 0 on success, @@ -136,20 +146,20 @@ int capmgr_device_clone(const capmgr_device_h device, /** * @brief Destroys the remote device information handle and releases all its resources. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] device The remote device information handle * @return @c 0 on success, * otherwise a negative error value * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @see capmgr_device_clone() - * @see capmgr_device_foreach_devices() + * @see capmgr_device_foreach_device() */ int capmgr_device_destroy(capmgr_device_h device); /** - * @brief Gets the device ID with the given remote device context. - * @since_tizen 5.0 + * @brief Gets the device ID of the given remote device context. + * @since_tizen 5.5 * @remarks You must release @a device_id using free(). * @param[in] device The remote device information handle * @param[out] device_id The remote device ID of the given remote device context @@ -159,13 +169,13 @@ int capmgr_device_destroy(capmgr_device_h device); * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory * @see capmgr_device_clone() - * @see capmgr_device_foreach_devices() + * @see capmgr_device_foreach_device() */ int capmgr_device_get_device_id(capmgr_device_h device, char** device_id); /** - * @brief Gets the model name with the given remote device context. - * @since_tizen 5.0 + * @brief Gets the model name of the given remote device context. + * @since_tizen 5.5 * @remarks You must release @a model_name using free(). * @param[in] device The remote device information handle * @param[out] model_name The model name of the given remote device context @@ -175,13 +185,13 @@ int capmgr_device_get_device_id(capmgr_device_h device, char** device_id); * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory * @see capmgr_device_clone() - * @see capmgr_device_foreach_devices() + * @see capmgr_device_foreach_device() */ int capmgr_device_get_model_name(capmgr_device_h device, char** model_name); /** - * @brief Gets the device name with the given remote device context. - * @since_tizen 5.0 + * @brief Gets the device name of the given remote device context. + * @since_tizen 5.5 * @remarks You must release @a device_name using free(). * @param[in] device The remote device information handle * @param[out] device_name The device name of the given remote device context @@ -191,13 +201,13 @@ int capmgr_device_get_model_name(capmgr_device_h device, char** model_name); * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory * @see capmgr_device_clone() - * @see capmgr_device_foreach_devices() + * @see capmgr_device_foreach_device() */ int capmgr_device_get_device_name(capmgr_device_h device, char** device_name); /** - * @brief Gets the platform verion with the given remote device context. - * @since_tizen 5.0 + * @brief Gets the platform verion of the given remote device context. + * @since_tizen 5.5 * @remarks You must release @a platform_ver using free(). * @param[in] device The remote device information handle * @param[out] platform_ver The platform version of the given remote device context @@ -207,13 +217,13 @@ int capmgr_device_get_device_name(capmgr_device_h device, char** device_name); * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory * @see capmgr_device_clone() - * @see capmgr_device_foreach_devices() + * @see capmgr_device_foreach_device() */ int capmgr_device_get_platform_ver(capmgr_device_h device, char** platform_ver); /** - * @brief Gets the profile with the given remote device context. - * @since_tizen 5.0 + * @brief Gets the profile of the given remote device context. + * @since_tizen 5.5 * @remarks You must release @a profile using free(). * @param[in] device The remote device information handle * @param[out] profile The profile value of the given remote device context @@ -223,13 +233,13 @@ int capmgr_device_get_platform_ver(capmgr_device_h device, char** platform_ver); * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory * @see capmgr_device_clone() - * @see capmgr_device_foreach_devices() + * @see capmgr_device_foreach_device() */ int capmgr_device_get_profile(capmgr_device_h device, char** profile); /** - * @brief Gets the software verion with the given remote device context. - * @since_tizen 5.0 + * @brief Gets the software verion of the given remote device context. + * @since_tizen 5.5 * @remarks You must release @a sw_ver using free(). * @param[in] device The remote device information handle * @param[out] sw_ver The software version of the given remote device context @@ -239,13 +249,13 @@ int capmgr_device_get_profile(capmgr_device_h device, char** profile); * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory * @see capmgr_device_clone() - * @see capmgr_device_foreach_devices() + * @see capmgr_device_foreach_device() */ int capmgr_device_get_sw_ver(capmgr_device_h device, char** sw_ver); /** * @brief Creates a remote app control handle. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a app_control using capmgr_app_control_destroy(). * * @param[out] app_control The remote app control handle that is newly created on success @@ -262,7 +272,8 @@ int capmgr_app_control_create(capmgr_app_control_h* app_control); /** * @brief Clones the remote app control handle. - * @since_tizen 5.0 + * @since_tizen 5.5 + * @remarks The newly created app_control should be destroyed by calling the capmgr_app_control_destroy() if it is no longer needed. * @param[in] app_control The remote app control handle * @param[out] app_control_clone A newly created remote app control handle, if successfully cloned * @return @c 0 on success, @@ -276,7 +287,7 @@ int capmgr_app_control_clone(const capmgr_app_control_h app_control, /** * @brief Destroys the remote app control handle and releases all its resources. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] app_control The remote app control handle * @return @c 0 on success, * otherwise a negative error value @@ -288,7 +299,7 @@ int capmgr_app_control_destroy(capmgr_app_control_h app_control); /** * @brief Gets the remote device handle from the given app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a device using capmgr_device_destroy(). * @param[in] app_control The remote app control handle * @param[out] device The remote device handle @@ -304,7 +315,7 @@ int capmgr_app_control_get_device(capmgr_app_control_h app_control, /** * @brief Gets the operation value from the given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a operation using free(). * @param[in] app_control The remote app control handle * @param[out] operation The operation value @@ -320,7 +331,7 @@ int capmgr_app_control_get_operation(capmgr_app_control_h app_control, /** * @brief Gets the URI value from the given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a uri using free(). * @param[in] app_control The remote app control handle * @param[out] uri The URI value @@ -336,7 +347,7 @@ int capmgr_app_control_get_uri(capmgr_app_control_h app_control, /** * @brief Gets the MIME value from the given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a mime using free(). * @param[in] app_control The remote app control handle * @param[out] mime The MIME value @@ -352,7 +363,7 @@ int capmgr_app_control_get_mime(capmgr_app_control_h app_control, /** * @brief Gets the application ID from the given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a appid using free(). * @param[in] app_control The remote app control handle * @param[out] appid The application ID @@ -368,7 +379,7 @@ int capmgr_app_control_get_appid(capmgr_app_control_h app_control, /** * @brief Gets the extra data corresponding to given key from remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a value using free(). * @param[in] app_control The remote app control handle * @param[in] key The key value @@ -385,7 +396,7 @@ int capmgr_app_control_get_extra_data(capmgr_app_control_h app_control, /** * @brief Sets the target remote device to given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] app_control The remote app control handle * @param[in] device The remote device handle to set * @return @c 0 on success, @@ -399,7 +410,7 @@ int capmgr_app_control_set_device(capmgr_app_control_h app_control, /** * @brief Sets the operation value to given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] app_control The remote app control handle * @param[in] operation The operation value to set * @return @c 0 on success, @@ -413,7 +424,7 @@ int capmgr_app_control_set_operation(capmgr_app_control_h app_control, /** * @brief Sets the URI value to given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] app_control The remote app control handle * @param[in] uri The URI value to set * @return @c 0 on success, @@ -427,7 +438,7 @@ int capmgr_app_control_set_uri(capmgr_app_control_h app_control, /** * @brief Sets the MIME value to given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] app_control The remote app control handle * @param[in] mime The MIME value to set * @return @c 0 on success, @@ -441,7 +452,7 @@ int capmgr_app_control_set_mime(capmgr_app_control_h app_control, /** * @brief Sets the application ID to given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] app_control The remote app control handle * @param[in] appid The application ID to set * @return @c 0 on success, @@ -455,7 +466,7 @@ int capmgr_app_control_set_appid(capmgr_app_control_h app_control, /** * @brief Sets the extra data to given remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] app_control The remote app control handle * @param[in] key The key of extra data to set * @param[in] value The value corresponding to key. @@ -470,7 +481,7 @@ int capmgr_app_control_add_extra_data(capmgr_app_control_h app_control, /** * @brief Removes the extra data corresponding to given key at remote app control context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] app_control The remote app control handle * @param[in] key The key of extra data to remove * @return @c 0 on success, @@ -484,7 +495,11 @@ int capmgr_app_control_remove_extra_data(capmgr_app_control_h app_control, /** * @brief Sends the app control to remote device specified at handle. - * @since_tizen 5.0 + * @remark The remote app should declare %http://tizen.org/privilege/d2d.remotelaunch privilege for receive. + * @since_tizen 5.5 + * @privlevel public + * @privilege %http://tizen.org/privilege/d2d.datasharing + * @privilege %http://tizen.org/privilege/appmanager.launch * @param[in] app_control The remote app control handle * @param[in] cb Callback to be invoked when send has done * @param[in] user_data The user data to be passed to the callback function @@ -493,13 +508,14 @@ int capmgr_app_control_remove_extra_data(capmgr_app_control_h app_control, * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CAPMGR_ERROR_PERMISSION_DENIED Permission denied */ int capmgr_app_control_send(capmgr_app_control_h app_control, capmgr_app_control_reply_cb cb, void* user_data); /** - * @brief Retrieves all applications installed at specified remote device and invoke callback each of it. - * @since_tizen 5.0 + * @brief Retrieves all applications installed on the specified remote device and invokes the callback each of them. + * @since_tizen 5.5 * @param[in] device The remote device handle * @param[in] cb Callback to be invoked for each application * @param[in] user_data The user data to be passed to the callback function @@ -510,14 +526,15 @@ int capmgr_app_control_send(capmgr_app_control_h app_control, * @retval #CAPMGR_ERROR_IO_ERROR I/O error * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_application_info_foreach_applications( +int capmgr_app_info_foreach_application( const capmgr_device_h device, - capmgr_application_info_foreach_app_cb cb, + capmgr_app_info_foreach_app_cb cb, void* user_data); /** * @brief Clones the remote application information handle. - * @since_tizen 5.0 + * @since_tizen 5.5 + * @remarks The newly created app_info should be destroyed by calling the capmgr_app_info_destroy() if it is no longer needed. * @param[in] remote_app_info The remote application info handle * @param[out] remote_app_info_clone A newly created remote application information handle, if successfully cloned * @return @c 0 on success, @@ -525,17 +542,17 @@ int capmgr_application_info_foreach_applications( * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory - * @see capmgr_application_info_destroy() + * @see capmgr_app_info_destroy() */ -int capmgr_application_info_clone( - const capmgr_application_info_h remote_app_info, - capmgr_application_info_h* remote_app_info_clone); +int capmgr_app_info_clone( + const capmgr_app_info_h remote_app_info, + capmgr_app_info_h* remote_app_info_clone); /** * @brief Gets the application ID from given remote application information. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a appid using free(). - * @param[in] remote_app_info The application information installed at specific remote device + * @param[in] remote_app_info The application information installed on the specific remote device * @param[out] appid The application ID * @return @c 0 on success, * otherwise a negative error value @@ -543,14 +560,14 @@ int capmgr_application_info_clone( * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_application_info_get_appid(capmgr_application_info_h remote_app_info, +int capmgr_app_info_get_appid(capmgr_app_info_h remote_app_info, char** appid); /** * @brief Gets the package ID from given remote application information. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a pkgid using free(). - * @param[in] remote_app_info The application information installed at specific remote device + * @param[in] remote_app_info The application information installed on the specific remote device * @param[out] pkgid The package ID * @return @c 0 on success, * otherwise a negative error value @@ -558,14 +575,14 @@ int capmgr_application_info_get_appid(capmgr_application_info_h remote_app_info, * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_application_info_get_pkgid(capmgr_application_info_h remote_app_info, +int capmgr_app_info_get_pkgid(capmgr_app_info_h remote_app_info, char** pkgid); /** * @brief Gets the label from given remote application information. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a label using free(). - * @param[in] remote_app_info The application information installed at specific remote device + * @param[in] remote_app_info The application information installed on the specific remote device * @param[out] label The label of application * @return @c 0 on success, * otherwise a negative error value @@ -573,14 +590,14 @@ int capmgr_application_info_get_pkgid(capmgr_application_info_h remote_app_info, * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_application_info_get_label(capmgr_application_info_h remote_app_info, +int capmgr_app_info_get_label(capmgr_app_info_h remote_app_info, char** label); /** * @brief Gets the version from given remote application information. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a version using free(). - * @param[in] remote_app_info The application information installed at specific remote device + * @param[in] remote_app_info The application information installed on the specific remote device * @param[out] version The version of application * @return @c 0 on success, * otherwise a negative error value @@ -588,14 +605,14 @@ int capmgr_application_info_get_label(capmgr_application_info_h remote_app_info, * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_application_info_get_version( - capmgr_application_info_h remote_app_info, char** version); +int capmgr_app_info_get_version( + capmgr_app_info_h remote_app_info, char** version); /** * @brief Gets the remote device handle from the given remote application info context. - * @since_tizen 5.0 + * @since_tizen 5.5 * @remarks You must release @a device using capmgr_device_destroy(). - * @param[in] remote_app_info The application information installed at specific remote device + * @param[in] remote_app_info The application information installed on the specific remote device * @param[out] device The remote device handle * @return @c 0 on success, * otherwise a negative error value @@ -603,20 +620,20 @@ int capmgr_application_info_get_version( * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAPMGR_ERROR_OUT_OF_MEMORY Out of memory */ -int capmgr_application_info_get_device( - capmgr_application_info_h remote_app_info, capmgr_device_h* device); +int capmgr_app_info_get_device( + capmgr_app_info_h remote_app_info, capmgr_device_h* device); /** * @brief Destroys the remote application information handle and releases all its resources. - * @since_tizen 5.0 + * @since_tizen 5.5 * @param[in] remote_app_info The remote application information handle * @return @c 0 on success, * otherwise a negative error value * @retval #CAPMGR_ERROR_NONE Successful * @retval #CAPMGR_ERROR_INVALID_PARAMETER Invalid parameter - * @see capmgr_application_info_clone() + * @see capmgr_app_info_clone() */ -int capmgr_application_info_destroy(capmgr_application_info_h remote_app_info); +int capmgr_app_info_destroy(capmgr_app_info_h remote_app_info); #ifdef __cplusplus } diff --git a/src/client.cc b/src/client.cc index fa2030a..6a6ffcb 100644 --- a/src/client.cc +++ b/src/client.cc @@ -42,7 +42,7 @@ struct capmgr_app_control_s { bundle* b; }; -struct capmgr_application_info_s { +struct capmgr_app_info_s { std::string appid; std::string pkgid; std::string label; @@ -50,7 +50,7 @@ struct capmgr_application_info_s { capmgr_device_h device; }; -API int capmgr_device_foreach_devices(capmgr_device_foreach_cb cb, +API int capmgr_device_foreach_device(capmgr_device_foreach_cb cb, void* user_data) { if (!cb) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -544,15 +544,15 @@ API int capmgr_app_control_send(capmgr_app_control_h app_control, return CAPMGR_ERROR_NONE; } -API int capmgr_application_info_clone( - const capmgr_application_info_h remote_app_info, - capmgr_application_info_h* remote_app_info_clone) { +API int capmgr_app_info_clone( + const capmgr_app_info_h remote_app_info, + capmgr_app_info_h* remote_app_info_clone) { if (!remote_app_info || !remote_app_info_clone) return CAPMGR_ERROR_INVALID_PARAMETER; - struct capmgr_application_info_s* clone; + struct capmgr_app_info_s* clone; try { - clone = new struct capmgr_application_info_s(); + clone = new struct capmgr_app_info_s(); } catch (const std::bad_alloc& e) { LOG(ERROR) << e.what(); return CAPMGR_ERROR_OUT_OF_MEMORY; @@ -575,8 +575,8 @@ API int capmgr_application_info_clone( return CAPMGR_ERROR_NONE; } -API int capmgr_application_info_destroy( - capmgr_application_info_h remote_app_info) { +API int capmgr_app_info_destroy( + capmgr_app_info_h remote_app_info) { if (!remote_app_info) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -586,8 +586,8 @@ API int capmgr_application_info_destroy( return CAPMGR_ERROR_NONE; } -API int capmgr_application_info_get_appid( - capmgr_application_info_h remote_app_info, char** appid) { +API int capmgr_app_info_get_appid( + capmgr_app_info_h remote_app_info, char** appid) { if (!remote_app_info || !appid || remote_app_info->appid.empty()) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -598,8 +598,8 @@ API int capmgr_application_info_get_appid( return CAPMGR_ERROR_NONE; } -API int capmgr_application_info_get_pkgid( - capmgr_application_info_h remote_app_info, char** pkgid) { +API int capmgr_app_info_get_pkgid( + capmgr_app_info_h remote_app_info, char** pkgid) { if (!remote_app_info || !pkgid || remote_app_info->pkgid.empty()) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -610,8 +610,8 @@ API int capmgr_application_info_get_pkgid( return CAPMGR_ERROR_NONE; } -API int capmgr_application_info_get_label( - capmgr_application_info_h remote_app_info, char** label) { +API int capmgr_app_info_get_label( + capmgr_app_info_h remote_app_info, char** label) { if (!remote_app_info || !label || remote_app_info->label.empty()) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -622,8 +622,8 @@ API int capmgr_application_info_get_label( return CAPMGR_ERROR_NONE; } -API int capmgr_application_info_get_version( - capmgr_application_info_h remote_app_info, char** version) { +API int capmgr_app_info_get_version( + capmgr_app_info_h remote_app_info, char** version) { if (!remote_app_info || !version || remote_app_info->version.empty()) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -634,8 +634,8 @@ API int capmgr_application_info_get_version( return CAPMGR_ERROR_NONE; } -API int capmgr_application_info_get_device( - capmgr_application_info_h remote_app_info, +API int capmgr_app_info_get_device( + capmgr_app_info_h remote_app_info, capmgr_device_h* device) { if (!remote_app_info || !device) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -647,9 +647,9 @@ API int capmgr_application_info_get_device( return CAPMGR_ERROR_NONE; } -API int capmgr_application_info_foreach_applications( +API int capmgr_app_info_foreach_application( const capmgr_device_h device, - capmgr_application_info_foreach_app_cb cb, + capmgr_app_info_foreach_app_cb cb, void* user_data) { if (!device || !cb) return CAPMGR_ERROR_INVALID_PARAMETER; @@ -668,7 +668,7 @@ API int capmgr_application_info_foreach_applications( if (stmt->BindString(1, device->device_id)) { while (stmt->Step() == capmgr::SQLStatement::StepResult::ROW) { - struct capmgr_application_info_s info; + struct capmgr_app_info_s info; int idx = 0; info.appid = stmt->GetColumnString(idx++); info.pkgid = stmt->GetColumnString(idx++); diff --git a/src/unit_tests/unit_test.cc b/src/unit_tests/unit_test.cc index ae68e56..3d19410 100644 --- a/src/unit_tests/unit_test.cc +++ b/src/unit_tests/unit_test.cc @@ -22,10 +22,10 @@ int DeviceForeachCbForSetup(const capmgr_device_h device, void* user_data) { } int ApplicationForeachCbForSetup( - const capmgr_application_info_h remote_app_info, void* user_data) { - capmgr_application_info_h* clone = - reinterpret_cast(user_data); - int ret = capmgr_application_info_clone(remote_app_info, clone); + const capmgr_app_info_h remote_app_info, void* user_data) { + capmgr_app_info_h* clone = + reinterpret_cast(user_data); + int ret = capmgr_app_info_clone(remote_app_info, clone); if (ret != CAPMGR_ERROR_NONE) return 0; // use the first app @@ -39,13 +39,13 @@ int DeviceForeachCb(const capmgr_device_h device, void* user_data) { return 1; } -int ApplicationForeachCb(const capmgr_application_info_h remote_app_info, +int ApplicationForeachCb(const capmgr_app_info_h remote_app_info, void* user_data) { bool* is_hit = reinterpret_cast(user_data); *is_hit = true; char* appid; - capmgr_application_info_get_appid(remote_app_info, &appid); + capmgr_app_info_get_appid(remote_app_info, &appid); free(appid); LOG(INFO) << appid; return 0; @@ -59,7 +59,7 @@ class TestEnvironment : public ::testing::Environment { TestEnvironment() : device_(nullptr), app_control_(nullptr), app_(nullptr) {} void SetUp() override { - ASSERT_EQ(capmgr_device_foreach_devices(DeviceForeachCbForSetup, &device_), + ASSERT_EQ(capmgr_device_foreach_device(DeviceForeachCbForSetup, &device_), CAPMGR_ERROR_NONE) << "Failed to init test environment!"; ASSERT_NE(device_, nullptr); char* device_id; @@ -80,18 +80,18 @@ class TestEnvironment : public ::testing::Environment { CAPMGR_ERROR_NONE); ASSERT_EQ(capmgr_app_control_add_extra_data(app_control_, kExtraDataKeyStr, kExtraDataValueStr), CAPMGR_ERROR_NONE); - ASSERT_EQ(capmgr_application_info_foreach_applications(device_, + ASSERT_EQ(capmgr_app_info_foreach_application(device_, ApplicationForeachCbForSetup, &app_), CAPMGR_ERROR_NONE); } void TearDown() override { - capmgr_application_info_destroy(app_); + capmgr_app_info_destroy(app_); capmgr_app_control_destroy(app_control_); capmgr_device_destroy(device_); } capmgr_device_h device_; capmgr_app_control_h app_control_; - capmgr_application_info_h app_; + capmgr_app_info_h app_; }; TestEnvironment* env = nullptr; @@ -108,13 +108,13 @@ class UnitTest : public ::testing::Test { TEST_F(UnitTest, DeviceForeachDevicesPositiveTest) { bool is_hit = false; - ASSERT_EQ(capmgr_device_foreach_devices(DeviceForeachCb, &is_hit), + ASSERT_EQ(capmgr_device_foreach_device(DeviceForeachCb, &is_hit), CAPMGR_ERROR_NONE); ASSERT_TRUE(is_hit); } TEST_F(UnitTest, DeviceForeachDevicesNegativeTest) { - ASSERT_EQ(capmgr_device_foreach_devices(nullptr, nullptr), + ASSERT_EQ(capmgr_device_foreach_device(nullptr, nullptr), CAPMGR_ERROR_INVALID_PARAMETER); } @@ -347,25 +347,25 @@ TEST_F(UnitTest, AppControlSendNegativeTest) { } */ -TEST_F(UnitTest, ApplicationInfoForeachPackagesPositiveTest) { +TEST_F(UnitTest, AppInfoForeachPackagesPositiveTest) { bool is_hit = false; - ASSERT_EQ(capmgr_application_info_foreach_applications(env->device_, + ASSERT_EQ(capmgr_app_info_foreach_application(env->device_, ApplicationForeachCb, &is_hit), CAPMGR_ERROR_NONE); ASSERT_TRUE(is_hit); } -TEST_F(UnitTest, ApplicationInfoForeachPackagesNegativeTest) { - ASSERT_EQ(capmgr_application_info_foreach_applications(nullptr, +TEST_F(UnitTest, AppInfoForeachPackagesNegativeTest) { + ASSERT_EQ(capmgr_app_info_foreach_application(nullptr, ApplicationForeachCb, nullptr), CAPMGR_ERROR_INVALID_PARAMETER); - ASSERT_EQ(capmgr_application_info_foreach_applications(env->device_, + ASSERT_EQ(capmgr_app_info_foreach_application(env->device_, nullptr, nullptr), CAPMGR_ERROR_INVALID_PARAMETER); } -#define APPLICATION_INFO_GET_TEST_BLOCK( \ +#define APP_INFO_GET_TEST_BLOCK( \ POSITIVE_TESTNAME, NEGATIVE_TESTNAME, ATTR) \ TEST_F(UnitTest, POSITIVE_TESTNAME) { \ char* ATTR = nullptr; \ - ASSERT_EQ(capmgr_application_info_get_##ATTR(env->app_, &ATTR), \ + ASSERT_EQ(capmgr_app_info_get_##ATTR(env->app_, &ATTR), \ CAPMGR_ERROR_NONE); \ ASSERT_NE(ATTR, nullptr); \ free(ATTR); \ @@ -373,23 +373,23 @@ TEST_F(UnitTest, POSITIVE_TESTNAME) { \ \ TEST_F(UnitTest, NEGATIVE_TESTNAME) { \ char* ATTR; \ - ASSERT_EQ(capmgr_application_info_get_##ATTR(nullptr, &ATTR), \ + ASSERT_EQ(capmgr_app_info_get_##ATTR(nullptr, &ATTR), \ CAPMGR_ERROR_INVALID_PARAMETER); \ - ASSERT_EQ(capmgr_application_info_get_##ATTR(env->app_, nullptr), \ + ASSERT_EQ(capmgr_app_info_get_##ATTR(env->app_, nullptr), \ CAPMGR_ERROR_INVALID_PARAMETER); \ } \ -APPLICATION_INFO_GET_TEST_BLOCK(ApplicationInfoGetAppidPositiveTest, - ApplicationInfoGetAppidNegativeTest, appid) +APP_INFO_GET_TEST_BLOCK(AppInfoGetAppidPositiveTest, + AppInfoGetAppidNegativeTest, appid) -APPLICATION_INFO_GET_TEST_BLOCK(ApplicationInfoGetPkgidPositiveTest, - ApplicationInfoGetPkgidNegativeTest, pkgid) +APP_INFO_GET_TEST_BLOCK(AppInfoGetPkgidPositiveTest, + AppInfoGetPkgidNegativeTest, pkgid) -APPLICATION_INFO_GET_TEST_BLOCK(ApplicationInfoGetLabelPositiveTest, - ApplicationInfoGetLabelNegativeTest, label) +APP_INFO_GET_TEST_BLOCK(AppInfoGetLabelPositiveTest, + AppInfoGetLabelNegativeTest, label) -APPLICATION_INFO_GET_TEST_BLOCK(ApplicationInfoGetVersionPositiveTest, - ApplicationInfoGetVersionNegativeTest, version) +APP_INFO_GET_TEST_BLOCK(AppInfoGetVersionPositiveTest, + AppInfoGetVersionNegativeTest, version) } // namespace capmgr diff --git a/tools/capmgr_test.cc b/tools/capmgr_test.cc index b2adec7..789bf9c 100644 --- a/tools/capmgr_test.cc +++ b/tools/capmgr_test.cc @@ -113,7 +113,7 @@ int DeviceForeachCb(const capmgr_device_h device, void* user_data) { return 0; } -int AppForeachCb(const capmgr_application_info_h remote_app_info, +int AppForeachCb(const capmgr_app_info_h remote_app_info, void* user_data) { char* appid = nullptr; char* pkgid = nullptr; @@ -122,23 +122,23 @@ int AppForeachCb(const capmgr_application_info_h remote_app_info, capmgr_device_h device = nullptr; char* device_id = nullptr; - int ret = capmgr_application_info_get_appid(remote_app_info, &appid); + int ret = capmgr_app_info_get_appid(remote_app_info, &appid); if (ret != CAPMGR_ERROR_NONE) std::cout << "Failed to get appid" << std::endl; - ret = capmgr_application_info_get_pkgid(remote_app_info, &pkgid); + ret = capmgr_app_info_get_pkgid(remote_app_info, &pkgid); if (ret != CAPMGR_ERROR_NONE) std::cout << "Failed to get pkgid" << std::endl; - ret = capmgr_application_info_get_label(remote_app_info, &label); + ret = capmgr_app_info_get_label(remote_app_info, &label); if (ret != CAPMGR_ERROR_NONE) std::cout << "Failed to get label" << std::endl; - ret = capmgr_application_info_get_version(remote_app_info, &ver); + ret = capmgr_app_info_get_version(remote_app_info, &ver); if (ret != CAPMGR_ERROR_NONE) std::cout << "Failed to get pkgid" << std::endl; - ret = capmgr_application_info_get_device(remote_app_info, &device); + ret = capmgr_app_info_get_device(remote_app_info, &device); if (ret != CAPMGR_ERROR_NONE) std::cout << "Failed to get device" << std::endl; @@ -211,9 +211,9 @@ void Client::SendAppControl(const std::string& device_id, capmgr_device_h device = nullptr; struct cbdata cbdata = {&device, device_id}; - int ret = capmgr_device_foreach_devices(DeviceForeachCb, &cbdata); + int ret = capmgr_device_foreach_device(DeviceForeachCb, &cbdata); if (ret != CAPMGR_ERROR_NONE) { - std::cout << "capmgr_device_foreach_devices() failed: " << ret + std::cout << "capmgr_device_foreach_device() failed: " << ret << std::endl; return; } @@ -261,9 +261,9 @@ void Client::SendAppControl(const std::string& device_id, } void Client::ListDevices() { - int ret = capmgr_device_foreach_devices(DeviceForeachCb, nullptr); + int ret = capmgr_device_foreach_device(DeviceForeachCb, nullptr); if (ret != CAPMGR_ERROR_NONE) - std::cout << "capmgr_device_foreach_devices() failed: " << ret + std::cout << "capmgr_device_foreach_device() failed: " << ret << std::endl; } @@ -275,9 +275,9 @@ void Client::ListAppinfos(const std::string& device_id) { capmgr_device_h device = nullptr; struct cbdata cbdata = {&device, device_id}; - int ret = capmgr_device_foreach_devices(DeviceForeachCb, &cbdata); + int ret = capmgr_device_foreach_device(DeviceForeachCb, &cbdata); if (ret != CAPMGR_ERROR_NONE) { - std::cout << "capmgr_device_foreach_devices() failed: " << ret + std::cout << "capmgr_device_foreach_device() failed: " << ret << std::endl; return; } @@ -288,10 +288,10 @@ void Client::ListAppinfos(const std::string& device_id) { } std::cout << "Target device is " <