Provide API to update service
authorAbhay Agarwal <ay.agarwal@samsung.com>
Fri, 11 Oct 2019 04:48:29 +0000 (13:48 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Fri, 11 Oct 2019 07:15:22 +0000 (16:15 +0900)
Change-Id: I85080d43b496762a1563b359ed3667e1a51b66f2
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
packaging/capi-network-ua.spec
src/user-awareness-service.c
test/uat-service.c

index b3f6185dffd8279dfeaa61d2137b6e440b67e58e..d4e3004c27d4f68a4b5a34821c4d8510ac503918 100644 (file)
@@ -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
index 9949572c3e49c125ab2f829ed147596274f31a3a..a860fc1a63505c0a39c8d8f2abd59753eafecad9 100644 (file)
@@ -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;
index 30525bc8964879f02549fe551cb4fe96af553832..cbd43fea0ac8629ab4af44d01b5d56cd0e619d87 100644 (file)
@@ -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, },
 };