diff options
author | Abhay Agarwal <ay.agarwal@samsung.com> | 2019-10-11 13:48:29 +0900 |
---|---|---|
committer | saerome.kim <saerome.kim@samsung.com> | 2019-10-11 16:15:22 +0900 |
commit | 66f04b2e121961f0d485575d23d0326ff591f57c (patch) | |
tree | 28d3bf439d238ca00d81ffef7657d2a2403e9d4b | |
parent | 53212558fcb79d659ca10f2ca77c0e4ed6d10a14 (diff) | |
download | user-awareness-66f04b2e121961f0d485575d23d0326ff591f57c.tar.gz user-awareness-66f04b2e121961f0d485575d23d0326ff591f57c.tar.bz2 user-awareness-66f04b2e121961f0d485575d23d0326ff591f57c.zip |
Provide API to update service
Change-Id: I85080d43b496762a1563b359ed3667e1a51b66f2
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
-rw-r--r-- | packaging/capi-network-ua.spec | 2 | ||||
-rw-r--r-- | src/user-awareness-service.c | 32 | ||||
-rw-r--r-- | test/uat-service.c | 27 |
3 files changed, 56 insertions, 5 deletions
diff --git a/packaging/capi-network-ua.spec b/packaging/capi-network-ua.spec index b3f6185..d4e3004 100644 --- a/packaging/capi-network-ua.spec +++ b/packaging/capi-network-ua.spec @@ -1,6 +1,6 @@ Name: capi-network-ua Summary: User Awareness Framework CAPI -Version: 0.11.6 +Version: 0.11.7 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/user-awareness-service.c b/src/user-awareness-service.c index 9949572..a860fc1 100644 --- a/src/user-awareness-service.c +++ b/src/user-awareness-service.c @@ -375,6 +375,38 @@ int ua_service_add(ua_service_h service_handle) return UA_ERROR_NONE; } +int ua_service_update(ua_service_h service_handle) +{ + FUNC_ENTRY; + + int ret; + uam_service_info_s uam_service; + ua_service_info_s *service = (ua_service_info_s *)service_handle; + + UA_VALIDATE_INPUT_PARAMETER(service_handle); + UA_VALIDATE_HANDLE(service_handle, ua_services_list); + + retv_if(NULL == service->name, UA_ERROR_INVALID_PARAMETER); + retv_if(service->isadded != TRUE, UA_ERROR_INVALID_PARAMETER); + + memset(&uam_service, 0, sizeof(uam_service_info_s)); + g_strlcpy(uam_service.name, service->name, UAM_SERVICE_MAX_STRING_LEN); + uam_service.presence_threshold = service->presence_threshold; + uam_service.absence_threshold = service->absence_threshold; + + ret = _ua_get_error_code(_uam_update_service(&uam_service)); + if (UA_ERROR_NONE != ret) { + /* LCOV_EXCL_START */ + UA_ERR("Failed with error: %s(0x%X)", + _ua_get_error_string(ret), ret); + return ret; + /* LCOV_EXCL_STOP */ + } + + FUNC_EXIT; + return UA_ERROR_NONE; +} + int ua_service_remove(ua_service_h service_handle) { FUNC_ENTRY; diff --git a/test/uat-service.c b/test/uat-service.c index 30525bc..cbd43fe 100644 --- a/test/uat-service.c +++ b/test/uat-service.c @@ -211,6 +211,23 @@ static int run_ua_service_add( return RET_SUCCESS; } +static int run_ua_service_update( + MManager *mm, struct menu_data *menu) +{ + int ret = UA_ERROR_NONE; + + msg("ua_service_update"); + + check_if(NULL == g_service_h); + + ret = ua_service_update(g_service_h); + + msg(" - ua_service_update() ret: [0x%X] [%s]", + ret, uat_get_error_str(ret)); + + return RET_SUCCESS; +} + static int run_ua_service_remove( MManager *mm, struct menu_data *menu) { @@ -303,13 +320,15 @@ struct menu_data menu_ua_services[] = { menu_ua_service_set_detection_threshold, NULL, NULL }, { "5", "ua_service_add", NULL, run_ua_service_add, NULL }, - { "6", "ua_service_remove", + { "6", "ua_service_update", + NULL, run_ua_service_update, NULL }, + { "7", "ua_service_remove", NULL, run_ua_service_remove, NULL}, - { "7", "ua_service_destroy", + { "8", "ua_service_destroy", NULL, run_ua_service_destroy, NULL}, - { "8", "ua_service_get_by_name", + { "9", "ua_service_get_by_name", menu_ua_service_get_by_name, NULL, NULL }, - { "9", "ua_service_foreach_added_services", + { "10", "ua_service_foreach_added_services", NULL, run_ua_service_foreach_added_services, NULL }, { NULL, NULL, }, }; |