summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhay Agarwal <ay.agarwal@samsung.com>2019-09-30 19:34:39 +0900
committersaerome.kim <saerome.kim@samsung.com>2019-10-04 20:06:39 +0900
commit3973ca485b568dbcacec4141824687d51837b128 (patch)
tree62367ce4c020c6f724098d8de16569642cb06b49
parent01fa75da97a96bc8783b027f4a5b056119ca8060 (diff)
downloaduser-awareness-3973ca485b568dbcacec4141824687d51837b128.tar.gz
user-awareness-3973ca485b568dbcacec4141824687d51837b128.tar.bz2
user-awareness-3973ca485b568dbcacec4141824687d51837b128.zip
service specific device discriminant
Change-Id: Idff3ea4d729aa408c51152dee5bfd49c4bf3bf98 Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
-rw-r--r--include/user-awareness.h25
-rw-r--r--packaging/capi-network-ua.spec2
-rw-r--r--src/user-awareness-service.c29
-rw-r--r--test/uat-devices.c37
4 files changed, 91 insertions, 2 deletions
diff --git a/include/user-awareness.h b/include/user-awareness.h
index 638b3b8..6070c88 100644
--- a/include/user-awareness.h
+++ b/include/user-awareness.h
@@ -1813,6 +1813,31 @@ int ua_service_remove_device(
/**
* @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Sets device discriminant for a specific service.
+ * @since_tizen 5.5
+ *
+ * @param[in] service_handle The service handle.
+ * @param[in] device_handle The device handle.
+ * @param[in] discriminant The device discriminant.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UA_ERROR_NONE Successful
+ * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @exception
+ * @pre
+ * @post
+ *
+ * @see ua_service_add_device()
+ * @see ua_service_remove_device()
+ */
+int ua_service_set_device_discriminant(
+ ua_service_h service_handle,
+ ua_device_h device_handle,
+ gboolean discriminant);
+
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
* @brief Retrieves the service handle of all the added services.
* @since_tizen 5.5
*
diff --git a/packaging/capi-network-ua.spec b/packaging/capi-network-ua.spec
index cd1a757..a09984f 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.10.5
+Version: 0.11.0
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 86b84f8..de38275 100644
--- a/src/user-awareness-service.c
+++ b/src/user-awareness-service.c
@@ -691,6 +691,35 @@ int ua_service_remove_device(ua_service_h service_handle, ua_device_h device_han
return UA_ERROR_NONE;
}
+int ua_service_set_device_discriminant(ua_service_h service_handle,
+ ua_device_h device_handle, gboolean discriminant)
+{
+ FUNC_ENTRY;
+ int ret;
+
+ ua_service_info_s* service_info = (ua_service_info_s*)service_handle;
+ ua_dev_info_s* device_info = (ua_dev_info_s*)device_handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(service_info);
+ UA_VALIDATE_INPUT_PARAMETER(device_handle);
+ UA_VALIDATE_HANDLE(service_handle, ua_services_list);
+ UA_PRINT_DEVICE_HANDLE(device_handle);
+ retv_if(device_info->isadded == FALSE, UA_ERROR_INVALID_PARAMETER);
+
+ ret = _ua_get_error_code(_uam_service_set_device_discriminant(service_info->name,
+ device_info->device_id, _ua_to_uam_tech_type(device_info->type),
+ discriminant));
+ if (UA_ERROR_NONE != ret) {
+ UA_ERR("_uam_service_set_device_discriminant returned %s",
+ _ua_get_error_string(ret));
+ return ret;
+ }
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+
int ua_service_foreach_added_services(ua_service_added_service_cb foreach_cb,
void *user_data)
{
diff --git a/test/uat-devices.c b/test/uat-devices.c
index fc2ec33..0bc0bdf 100644
--- a/test/uat-devices.c
+++ b/test/uat-devices.c
@@ -47,6 +47,7 @@ static char g_payload_service_id[MENU_DATA_SIZE + 1] = {0,}; /**< payload servic
static char g_payload_device_icon[MENU_DATA_SIZE + 1] = {0,}; /**< payload device_icon for the selected device */
static char g_payload_purpose[MENU_DATA_SIZE + 1] = {0,}; /**< payload purpose for the selected device */
static char g_payload_duid_str[MENU_DATA_SIZE + 1] = {0,}; /**< payload duid for the selected device */
+static char g_service_device_discriminant[MENU_DATA_SIZE + 1] = {0,}; /**< Discriminant for a device in a service */
char g_selected_device_id[MENU_DATA_SIZE + 1] = {0,}; /**< Selected device id */
extern char g_service_str[MENU_DATA_SIZE + 1]; /**< Service name string */
@@ -962,6 +963,31 @@ static int run_ua_service_remove_device(
return RET_SUCCESS;
}
+static int run_ua_service_set_device_discriminant(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+ int temp = 1;
+ gboolean discriminant = true;
+
+ msg("ua_service_set_device_discriminant");
+
+ check_if(NULL == g_service_h);
+ check_if(NULL == g_device_h);
+
+ if (strlen(g_service_device_discriminant))
+ temp = (int)strtol(g_service_device_discriminant, NULL, 10);
+
+ if (0 == temp)
+ discriminant = false;
+ ret = ua_service_set_device_discriminant(g_service_h, g_device_h, discriminant);
+
+ msg(" - ua_service_add_device() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ return RET_SUCCESS;
+}
+
static int run_ua_service_foreach_added_devices(MManager *mm,
struct menu_data *menu)
{
@@ -1041,6 +1067,13 @@ static struct menu_data menu_ua_rm_dev_by_addr[] = {
{ NULL, NULL, },
};
+static struct menu_data menu_ua_service_set_device_discriminant[] = {
+ { "1", "discriminant (0:disable 1:enable)",
+ NULL, NULL, g_service_device_discriminant },
+ { "2", "run", NULL,
+ run_ua_service_set_device_discriminant, NULL },
+ { NULL, NULL, },
+};
static struct menu_data menu_ua_devlist_by_mac[] = {
{ "1", "MAC",
@@ -1162,7 +1195,9 @@ struct menu_data menu_ua_devices[] = {
NULL, run_ua_service_add_device, NULL },
{ "24", "ua_service_remove_device",
NULL, run_ua_service_remove_device, NULL },
- { "25", "ua_service_foreach_added_devices",
+ { "25", "ua_service_set_device_discriminant",
+ menu_ua_service_set_device_discriminant, NULL, NULL },
+ { "26", "ua_service_foreach_added_devices",
NULL, run_ua_service_foreach_added_devices, NULL },
{ NULL, NULL, },
};