summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhay Agarwal <ay.agarwal@samsung.com>2019-10-04 16:05:12 +0900
committersaerome.kim <saerome.kim@samsung.com>2019-10-04 20:06:49 +0900
commitda808f97cec0a17f7a1ac31d41f6ceecdb643688 (patch)
treea93e43af641c90de17f89f94dae03322bd53366d
parent3973ca485b568dbcacec4141824687d51837b128 (diff)
downloaduser-awareness-da808f97cec0a17f7a1ac31d41f6ceecdb643688.tar.gz
user-awareness-da808f97cec0a17f7a1ac31d41f6ceecdb643688.tar.bz2
user-awareness-da808f97cec0a17f7a1ac31d41f6ceecdb643688.zip
Add API to get service specific device discriminant
Change-Id: I4651c96e27ac8fae5f98ceae4e198becc444260a Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
-rw-r--r--include/user-awareness.h25
-rw-r--r--src/user-awareness-service.c27
-rw-r--r--test/uat-devices.c28
3 files changed, 78 insertions, 2 deletions
diff --git a/include/user-awareness.h b/include/user-awareness.h
index 6070c88..b36d510 100644
--- a/include/user-awareness.h
+++ b/include/user-awareness.h
@@ -1838,6 +1838,31 @@ int ua_service_set_device_discriminant(
/**
* @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Gets 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[out] 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_get_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/src/user-awareness-service.c b/src/user-awareness-service.c
index de38275..9949572 100644
--- a/src/user-awareness-service.c
+++ b/src/user-awareness-service.c
@@ -719,6 +719,33 @@ int ua_service_set_device_discriminant(ua_service_h service_handle,
return UA_ERROR_NONE;
}
+int ua_service_get_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_get_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_get_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 0bc0bdf..6b71985 100644
--- a/test/uat-devices.c
+++ b/test/uat-devices.c
@@ -47,7 +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 */
+static char g_service_device_discriminant[MENU_DATA_SIZE + 1] = {"1",}; /**< 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 */
@@ -988,6 +988,28 @@ static int run_ua_service_set_device_discriminant(
return RET_SUCCESS;
}
+static int run_ua_service_get_device_discriminant(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+ gboolean discriminant = true;
+
+ msg("ua_service_get_device_discriminant");
+
+ check_if(NULL == g_service_h);
+ check_if(NULL == g_device_h);
+
+ ret = ua_service_get_device_discriminant(g_service_h, g_device_h, &discriminant);
+
+ msg(" - ua_service_add_device() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ if (UA_ERROR_NONE == ret)
+ msgb("Device Discriminant %d", discriminant);
+
+ return RET_SUCCESS;
+}
+
static int run_ua_service_foreach_added_devices(MManager *mm,
struct menu_data *menu)
{
@@ -1197,7 +1219,9 @@ struct menu_data menu_ua_devices[] = {
NULL, run_ua_service_remove_device, NULL },
{ "25", "ua_service_set_device_discriminant",
menu_ua_service_set_device_discriminant, NULL, NULL },
- { "26", "ua_service_foreach_added_devices",
+ { "26", "ua_service_get_device_discriminant",
+ NULL, run_ua_service_get_device_discriminant, NULL },
+ { "27", "ua_service_foreach_added_devices",
NULL, run_ua_service_foreach_added_devices, NULL },
{ NULL, NULL, },
};