From: Abhay Agarwal Date: Thu, 21 Jan 2021 07:59:30 +0000 (+0530) Subject: Modify service API's X-Git-Tag: submit/tizen/20210131.225751~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78ee4ea2a65a49f5dfb1fc7f54a9db9e64494983;p=platform%2Fcore%2Fapi%2Fuser-awareness.git Modify service API's This patch modifies service based API's (renames/ parameter modifications) New API's to be used in place of deprecated API's - ua_service_foreach_added() => ua_foreach_services() - ua_service_foreach_added_users() => ua_service_foreach_users() - ua_service_create(ua_service_h *service_handle) => ua_service_create(const char *name, ua_service_h *service_handle); Change-Id: Ic9b5ee8b7e5b84704807fc943007831b901f1bf9 Signed-off-by: Abhay Agarwal --- diff --git a/include/user-awareness-internal.h b/include/user-awareness-internal.h index 90b1b0c..62b521f 100755 --- a/include/user-awareness-internal.h +++ b/include/user-awareness-internal.h @@ -256,7 +256,8 @@ int ua_service_add_device(ua_service_h service_handle, ua_device_h device_handle * * @see ua_service_add_device() */ -int ua_service_remove_device(ua_service_h service_handle, ua_device_h device_handle) TIZEN_DEPRECATED_API; +int ua_service_remove_device(ua_service_h service_handle, + ua_device_h device_handle) TIZEN_DEPRECATED_API; /** * @internal @@ -300,7 +301,8 @@ int ua_service_foreach_added_devices(ua_service_h service_handle, * @post */ -int ua_device_set_discriminant(ua_device_h device_handle, bool discriminant) TIZEN_DEPRECATED_API; +int ua_device_set_discriminant(ua_device_h device_handle, + bool discriminant) TIZEN_DEPRECATED_API; /** * @internal diff --git a/include/user-awareness.h b/include/user-awareness.h index 8e96089..d11c18f 100755 --- a/include/user-awareness.h +++ b/include/user-awareness.h @@ -460,13 +460,13 @@ typedef bool (*ua_registered_user_cb)( * @remarks The @a service_handle can be used only in the callback. * * @param[in] service_handle The service handle. - * @param[in] user_data User data passed in ua_service_foreach_added(). + * @param[in] user_data User data passed in ua_foreach_services(). * * @exception * @pre * @post * - * @see ua_service_foreach_added() + * @see ua_foreach_services() */ typedef bool (*ua_service_added_cb)( ua_service_h service_handle, @@ -484,13 +484,13 @@ typedef bool (*ua_service_added_cb)( * * @param[in] service_handle The service handle. * @param[in] user_handle The user handle. - * @param[in] user_data User data passed in ua_service_foreach_added_users(). + * @param[in] user_data User data passed in ua_service_foreach_users(). * * @exception * @pre * @post * - * @see ua_service_foreach_added_users() + * @see ua_service_foreach_users() */ typedef bool (*ua_service_added_user_cb)( ua_service_h service_handle, @@ -1183,7 +1183,8 @@ int ua_user_foreach_devices( * * @remarks The @a service_handle should be destroyed by using #ua_service_destroy(). * - * @param[in] service_handle The service handle + * @param[in] name The service name information + * @param[out] service_handle The service handle * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful @@ -1197,7 +1198,8 @@ int ua_user_foreach_devices( * @see ua_service_destroy() */ int ua_service_create( - ua_service_h *service_handle); + const char *name, + ua_service_h *service_handle); /** * @ingroup CAPI_NETWORK_UA_MODULE @@ -1403,7 +1405,7 @@ int ua_service_get_detection_threshold( */ int ua_service_set_name( ua_service_h service_handle, - const char *name); + const char *name) TIZEN_DEPRECATED_API; /** * @ingroup CAPI_NETWORK_UA_MODULE @@ -1542,7 +1544,7 @@ int ua_service_get_device_discriminant( * * @see ua_service_added_cb() */ -int ua_service_foreach_added( +int ua_foreach_services( ua_service_added_cb foreach_cb, void *user_data); @@ -1565,7 +1567,7 @@ int ua_service_foreach_added( * * @see ua_service_added_user_cb() */ -int ua_service_foreach_added_users( +int ua_service_foreach_users( ua_service_h service_handle, ua_service_added_user_cb foreach_cb, void *user_data); diff --git a/src/user-awareness-service.c b/src/user-awareness-service.c index bb7acfe..7a6d7e9 100755 --- a/src/user-awareness-service.c +++ b/src/user-awareness-service.c @@ -315,13 +315,17 @@ done: return ret; } -int ua_service_create(ua_service_h *service_handle) +int ua_service_create(const char *name, + ua_service_h *service_handle) { FUNC_ENTRY; ua_service_info_s *service = NULL; UA_CHECK_INIT_STATUS(); UA_VALIDATE_INPUT_PARAMETER(service_handle); + UA_VALIDATE_INPUT_PARAMETER(name); + retv_if((strlen(name) > UAM_SERVICE_MAX_STRING_LEN), + UA_ERROR_INVALID_PARAMETER); service = g_malloc0(sizeof(ua_service_info_s)); if (!service) { @@ -330,7 +334,7 @@ int ua_service_create(ua_service_h *service_handle) return UA_ERROR_OUT_OF_MEMORY; /* LCOV_EXCL_STOP */ } - service->name = NULL; + service->name = g_strdup(name); /* Add service to list of services*/ *service_handle = (ua_service_h)service; @@ -469,6 +473,8 @@ int ua_service_set_name(ua_service_h service_handle, const char *name) { FUNC_ENTRY; + UA_DEPRECATED_LOG(__FUNCTION__, "ua_service_create"); + ua_service_info_s *service = (ua_service_info_s *)service_handle; UA_CHECK_INIT_STATUS(); @@ -686,7 +692,7 @@ int ua_service_add_device(ua_service_h service_handle, ua_device_h device_handle ua_service_info_s* service_info = (ua_service_info_s*)service_handle; ua_dev_info_s* dev_info = (ua_dev_info_s*)device_handle; - UA_DEPRECATED_LOG(__FUNCTION__, "TODO"); + UA_DEPRECATED_LOG(__FUNCTION__, "ua_service_add_user"); UA_CHECK_INIT_STATUS(); UA_VALIDATE_INPUT_PARAMETER(service_handle); @@ -726,7 +732,7 @@ int ua_service_remove_device(ua_service_h service_handle, ua_device_h device_han ua_service_info_s* service_info = (ua_service_info_s*)service_handle; ua_dev_info_s* dev_info = (ua_dev_info_s*)device_handle; - UA_DEPRECATED_LOG(__FUNCTION__, "TODO"); + UA_DEPRECATED_LOG(__FUNCTION__, "ua_service_remove_user"); UA_CHECK_INIT_STATUS(); UA_VALIDATE_INPUT_PARAMETER(service_handle); @@ -832,7 +838,7 @@ int ua_service_get_device_discriminant(ua_service_h service_handle, return UA_ERROR_NONE; } -int ua_service_foreach_added(ua_service_added_cb foreach_cb, +int ua_foreach_services(ua_service_added_cb foreach_cb, void *user_data) { FUNC_ENTRY; @@ -856,7 +862,7 @@ int ua_service_foreach_added(ua_service_added_cb foreach_cb, return UA_ERROR_NONE; } -int ua_service_foreach_added_users( +int ua_service_foreach_users( ua_service_h service_handle, ua_service_added_user_cb foreach_cb, void *user_data) diff --git a/test/uat-scenarios.c b/test/uat-scenarios.c index ea2e481..c092486 100755 --- a/test/uat-scenarios.c +++ b/test/uat-scenarios.c @@ -365,8 +365,8 @@ static int run_ua_scenario_foreach(MManager *mm, struct menu_data *menu) /* Get service list */ uat_clear_service_list(); - ret = ua_service_foreach_added(_foreach_added_service_cb, NULL); - msg(" - ua_service_foreach_added() ret: [0x%X] [%s]", + ret = ua_foreach_services(_foreach_added_service_cb, NULL); + msg(" - ua_foreach_services() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); /* Get user list */ diff --git a/test/uat-service.c b/test/uat-service.c index 0bbaec7..6c55458 100755 --- a/test/uat-service.c +++ b/test/uat-service.c @@ -296,7 +296,7 @@ int _uat_service_create() g_service_h = NULL; } - ret = ua_service_create(&g_service_h); + ret = ua_service_create(g_service_str, &g_service_h); msg(" - ua_service_create() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); @@ -327,22 +327,6 @@ static int run_ua_service_destroy(MManager *mm, struct menu_data *menu) return RET_SUCCESS; } -static int run_ua_service_set_name(MManager *mm, struct menu_data *menu) -{ - int ret = UA_ERROR_NONE; - - msg("ua_service_set_name"); - - check_if(NULL == g_service_h); - - ret = ua_service_set_name(g_service_h, g_service_str); - - msg(" - ua_service_set_name() ret: [0x%X] [%s]", - ret, uat_get_error_str(ret)); - - return RET_SUCCESS; -} - static int run_ua_service_set_detection_threshold(MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; @@ -462,17 +446,17 @@ static int run_ua_service_get_by_name(MManager *mm, struct menu_data *menu) return RET_SUCCESS; } -static int run_ua_service_foreach_added( +static int run_ua_foreach_services( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; - msg("ua_service_foreach_added"); + msg("ua_foreach_services"); uat_clear_service_list(); - ret = ua_service_foreach_added(_foreach_added_service_cb, NULL); + ret = ua_foreach_services(_foreach_added_service_cb, NULL); - msg(" - ua_service_foreach_added() ret: [0x%X] [%s]", + msg(" - ua_foreach_services() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; @@ -630,30 +614,30 @@ static int run_ua_service_remove_user(MManager *mm, struct menu_data *menu) } -static int run_ua_service_foreach_added_users( +static int run_ua_service_foreach_users( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; - msg("ua_service_foreach_added_users"); + msg("ua_service_foreach_users"); check_if(NULL == g_service_h); uat_clear_user_list(); - ret = ua_service_foreach_added_users(g_service_h, + ret = ua_service_foreach_users(g_service_h, _service_foreach_added_user_cb, NULL); - msg(" - ua_service_foreach_added_users() ret: [0x%X] [%s]", + msg(" - ua_service_foreach_users() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } -static struct menu_data menu_ua_service_set_name[] = { +static struct menu_data menu_ua_service_create[] = { { "1", "name", NULL, NULL, g_service_str }, { "2", "run", NULL, - run_ua_service_set_name, NULL }, + run_ua_service_create, NULL }, { NULL, NULL, }, }; @@ -685,7 +669,7 @@ static struct menu_data menu_ua_service_set_device_discriminant[] = { struct menu_data menu_sel_service[] = { { "1", "Service list", NULL, - run_ua_service_foreach_added, g_selected_service_id}, + run_ua_foreach_services, g_selected_service_id}, { "2", "Apply", NULL, uat_select_service, NULL }, { NULL, NULL, }, }; @@ -723,31 +707,29 @@ struct menu_data menu_sel_service_added_device[] = { struct menu_data menu_sel_service_added_user[] = { { "1", "User list", NULL, - run_ua_service_foreach_added_users, g_selected_user_idx}, + run_ua_service_foreach_users, g_selected_user_idx}, { "2", "Apply", NULL, uat_select_user, NULL }, { NULL, NULL, }, }; struct menu_data menu_ua_services[] = { { "1", "ua_service_create", - NULL, run_ua_service_create, NULL }, - { "2", "ua_service_set_name", - menu_ua_service_set_name, NULL, g_service_str }, - { "3", "ua_service_set_detection_threshold", + menu_ua_service_create, NULL, g_service_str }, + { "2", "ua_service_set_detection_threshold", menu_ua_service_set_detection_threshold, NULL, NULL }, - { "4", "ua_service_add", + { "3", "ua_service_add", NULL, run_ua_service_add, NULL }, - { "5", "ua_service_update", + { "4", "ua_service_update", NULL, run_ua_service_update, NULL }, - { "6", "ua_service_remove", + { "5", "ua_service_remove", NULL, run_ua_service_remove, NULL}, - { "7", "ua_service_destroy", + { "6", "ua_service_destroy", NULL, run_ua_service_destroy, NULL}, - { "8", "ua_service_get_default_service", + { "7", "ua_service_get_default_service", NULL, run_ua_service_get_default_service, NULL }, - { "9", "ua_service_get_by_name", + { "8", "ua_service_get_by_name", menu_ua_service_get_by_name, NULL, NULL }, - { "10", ANSI_COLOR_LIGHTMAGENTA "ua_service_foreach_added" ANSI_COLOR_NORMAL, + { "9", ANSI_COLOR_LIGHTMAGENTA "ua_foreach_services" ANSI_COLOR_NORMAL, menu_sel_service, NULL, NULL }, { "21", ANSI_COLOR_LIGHTGREEN "ua_service_add_device" ANSI_COLOR_NORMAL, NULL, run_ua_service_add_device, NULL }, @@ -763,7 +745,7 @@ struct menu_data menu_ua_services[] = { menu_ua_service_add_user, NULL, NULL }, { "32", ANSI_COLOR_LIGHTRED "ua_service_remove_user" ANSI_COLOR_NORMAL, menu_ua_service_remove_user, NULL, NULL }, - { "33", ANSI_COLOR_LIGHTMAGENTA "ua_service_foreach_added_users" ANSI_COLOR_NORMAL, + { "33", ANSI_COLOR_LIGHTMAGENTA "ua_service_foreach_users" ANSI_COLOR_NORMAL, menu_sel_service_added_user, NULL, NULL }, { NULL, NULL, }, };