Fix query API (iotcon_query_get/set_resource_types->type) 06/58706/3
authorsung.goo.kim <sung.goo.kim@samsung.com>
Wed, 3 Feb 2016 03:06:07 +0000 (12:06 +0900)
committersung.goo.kim <sung.goo.kim@samsung.com>
Wed, 3 Feb 2016 22:00:11 +0000 (07:00 +0900)
Change-Id: If49da3acbaf487d035d5cb692cc1ee51ec67aa6f

lib/icl-query.c
lib/include/iotcon-query.h

index b65ecb4afff41c847ff4d8264b070d4d5b930230..9cf2d8f43502de56652e42908d8f11d9e47c334b 100644 (file)
@@ -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.");
index 4ac482f2b0f8a1a5793af9b0ed29c512b1a49fed..af874a474f20bb665a4e8de9a191247e84ce79f1 100644 (file)
@@ -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.