From 7af38a73eabc8dec73546acacd35715452b06a25 Mon Sep 17 00:00:00 2001 From: "sung.goo.kim" Date: Wed, 3 Feb 2016 12:06:07 +0900 Subject: [PATCH] Fix query API (iotcon_query_get/set_resource_types->type) Change-Id: If49da3acbaf487d035d5cb692cc1ee51ec67aa6f --- lib/icl-query.c | 36 +++++++++--------------------------- lib/include/iotcon-query.h | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/lib/icl-query.c b/lib/icl-query.c index b65ecb4..9cf2d8f 100644 --- a/lib/icl-query.c +++ b/lib/icl-query.c @@ -54,37 +54,22 @@ API void iotcon_query_destroy(iotcon_query_h query) } -API int iotcon_query_get_resource_types(iotcon_query_h query, - iotcon_resource_types_h *types) +API int iotcon_query_get_resource_type(iotcon_query_h query, + char **resource_type) { - int ret; - char *resource_type = NULL; - iotcon_resource_types_h types_temp = NULL; + char *type; RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER); - iotcon_query_lookup(query, ICL_QUERY_KEY_RESOURCE_TYPE, &resource_type); - if (NULL == resource_type) { + iotcon_query_lookup(query, ICL_QUERY_KEY_RESOURCE_TYPE, &type); + if (NULL == type) { ERR("resource_type is NULL"); return IOTCON_ERROR_NO_DATA; } - ret = iotcon_resource_types_create(&types_temp); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_resource_types_create() Fail(%d)", ret); - return ret; - } - - ret = iotcon_resource_types_add(types_temp, resource_type); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_resource_types_add() Fail(%d)", ret); - iotcon_resource_types_destroy(types_temp); - return ret; - } - - *types = types_temp; + *resource_type = type; return IOTCON_ERROR_NONE; } @@ -108,12 +93,11 @@ API int iotcon_query_get_interface(iotcon_query_h query, iotcon_interface_e *ifa return IOTCON_ERROR_NONE; } -API int iotcon_query_set_resource_types(iotcon_query_h query, iotcon_resource_types_h types) +API int iotcon_query_set_resource_type(iotcon_query_h query, const char *resource_type) { int length_old = 0; int length_new = 0; char *value = NULL; - char *resource_type = NULL; RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED); RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER); @@ -122,10 +106,8 @@ API int iotcon_query_set_resource_types(iotcon_query_h query, iotcon_resource_ty if (value) length_old = (sizeof(ICL_QUERY_KEY_RESOURCE_TYPE) - 1) + strlen(value) + 2; - if (types && types->type_list) { - resource_type = types->type_list->data; + if (resource_type && *resource_type) length_new = (sizeof(ICL_QUERY_KEY_RESOURCE_TYPE) - 1) + strlen(resource_type) + 2; - } if (ICL_QUERY_LENGTH_MAX < query->len - length_old + length_new) { ERR("Length of query is invalid."); diff --git a/lib/include/iotcon-query.h b/lib/include/iotcon-query.h index 4ac482f..af874a4 100644 --- a/lib/include/iotcon-query.h +++ b/lib/include/iotcon-query.h @@ -147,14 +147,14 @@ int iotcon_query_create(iotcon_query_h *query); void iotcon_query_destroy(iotcon_query_h query); /** - * @brief Gets resource types from the query. + * @brief Gets resource type from the query. * * @since_tizen 3.0 * - * @remarks @a types must not be released using iotcon_resource_types_destroy(). + * @remarks @a type must not be released using free(). * * @param[in] query The handle of the query - * @param[out] types Found resource types from query + * @param[out] resource_type Found resource type from query * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -167,12 +167,12 @@ void iotcon_query_destroy(iotcon_query_h query); * @see iotcon_query_destroy() * @see iotcon_query_add() * @see iotcon_query_remove() - * @see iotcon_query_set_resource_types() + * @see iotcon_query_set_resource_type() */ -int iotcon_query_get_resource_types(iotcon_query_h query, iotcon_resource_types_h *types); +int iotcon_query_get_resource_type(iotcon_query_h query, char **resource_type); /** - * @brief Gets resource types from the query. + * @brief Gets resource interface from the query. * @details @a iface could be one of #iotcon_interface_e. * * @since_tizen 3.0 @@ -195,12 +195,12 @@ int iotcon_query_get_resource_types(iotcon_query_h query, iotcon_resource_types_ int iotcon_query_get_interface(iotcon_query_h query, iotcon_interface_e *iface); /** - * @brief Sets the resource types into the query. + * @brief Sets the resource type into the query. * * @since_tizen 3.0 * * @param[in] query The handle of the query - * @param[in] types The resoure types to set into the query + * @param[in] resource_type The resoure type to set into the query * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful @@ -213,9 +213,9 @@ int iotcon_query_get_interface(iotcon_query_h query, iotcon_interface_e *iface); * @see iotcon_query_add() * @see iotcon_query_remove() * @see iotcon_query_lookup() - * @see iotcon_query_get_resource_types() + * @see iotcon_query_get_resource_type() */ -int iotcon_query_set_resource_types(iotcon_query_h query, iotcon_resource_types_h types); +int iotcon_query_set_resource_type(iotcon_query_h query, const char *resource_type); /** * @brief Sets the interface into the query. -- 2.34.1