From 4def41d2feed69bf32a8a2dcfe2fad7aaa54c154 Mon Sep 17 00:00:00 2001 From: Daehyeon Jung Date: Mon, 11 Mar 2019 14:54:03 +0900 Subject: [PATCH] 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 " <