}
-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;
}
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);
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.");
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
* @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
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
* @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.