return;
}
- ret = iotcon_resource_types_insert(resource_types, type);
+ ret = iotcon_resource_types_add(resource_types, type);
if (IOTCON_ERROR_NONE != ret) {
iotcon_resource_types_destroy(resource_types);
return;
return;
}
- iotcon_query_insert(query, "key", "value");
+ iotcon_query_add(query, "key", "value");
iotcon_remote_resource_get(resource, query, &_on_get, NULL);
iotcon_query_destroy(query);
if (IOTCON_ERROR_NONE != ret) {
return;
}
- ret = iotcon_observers_insert(observers, observer_id);
+ ret = iotcon_observers_add(observers, observer_id);
if (IOTCON_ERROR_NONE != ret) {
return;
}
if (IOTCON_ERROR_NONE != ret) {
return;
}
- ret = iotcon_observers_delete(observers, observer_id);
+ ret = iotcon_observers_remove(observers, observer_id);
if (IOTCON_ERROR_NONE != ret) {
return;
}
return;
}
- ret = iotcon_resource_types_insert(resource_types, type);
+ ret = iotcon_resource_types_add(resource_types, type);
if (IOTCON_ERROR_NONE != ret) {
iotcon_resource_types_destroy(resource_types);
return;
return;
}
- ret = iotcon_resource_types_insert(types, "core.light");
+ ret = iotcon_resource_types_add(types, "core.light");
if (IOTCON_ERROR_NONE != ret) {
iotcon_resource_types_destroy(types);
iotcon_representation_destroy(resp_repr);
return;
}
- ret = iotcon_list_insert_double(bright_step_list, 100.0, -1);
+ ret = iotcon_list_add_double(bright_step_list, 100.0, -1);
if (IOTCON_ERROR_NONE != ret) {
iotcon_list_destroy(bright_step_list);
iotcon_resource_types_destroy(types);
return;
}
- ret = iotcon_list_insert_double(bright_step_list, 200.0, -1);
+ ret = iotcon_list_add_double(bright_step_list, 200.0, -1);
if (IOTCON_ERROR_NONE != ret) {
iotcon_list_destroy(bright_step_list);
iotcon_resource_types_destroy(types);
return;
}
- ret = iotcon_list_insert_double(bright_step_list, 300.0, -1);
+ ret = iotcon_list_add_double(bright_step_list, 300.0, -1);
if (IOTCON_ERROR_NONE != ret) {
iotcon_list_destroy(bright_step_list);
iotcon_resource_types_destroy(types);
return;
}
- ret = iotcon_list_insert_double(bright_step_list, 400.0, -1);
+ ret = iotcon_list_add_double(bright_step_list, 400.0, -1);
if (IOTCON_ERROR_NONE != ret) {
iotcon_list_destroy(bright_step_list);
iotcon_resource_types_destroy(types);
return;
}
- ret = iotcon_list_insert_double(bright_step_list, 500.0, -1);
+ ret = iotcon_list_add_double(bright_step_list, 500.0, -1);
if (IOTCON_ERROR_NONE != ret) {
iotcon_list_destroy(bright_step_list);
iotcon_resource_types_destroy(types);
}
-API int iotcon_observers_insert(iotcon_observers_h observers, int obs_id)
+API int iotcon_observers_add(iotcon_observers_h observers, int obs_id)
{
RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
}
-API int iotcon_observers_delete(iotcon_observers_h observers, int obs_id)
+API int iotcon_observers_remove(iotcon_observers_h observers, int obs_id)
{
RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
/* iotcon_options_h can have up to 2 options.
* option id is always situated between 2048 and 3000.
* Length of option data is less than or equal to 15. */
-API int iotcon_options_insert(iotcon_options_h options, unsigned short id,
+API int iotcon_options_add(iotcon_options_h options, unsigned short id,
const char *data)
{
RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
}
-API int iotcon_options_delete(iotcon_options_h options, unsigned short id)
+API int iotcon_options_remove(iotcon_options_h options, unsigned short id)
{
gboolean is_removed;
}
while (g_variant_iter_loop(&iter, "b", &b))
- iotcon_list_insert_bool(list, b, -1);
+ iotcon_list_add_bool(list, b, -1);
} else if (g_variant_type_equal(G_VARIANT_TYPE("ai"), type)) {
int i;
ret = iotcon_list_create(IOTCON_TYPE_INT, &list);
}
while (g_variant_iter_loop(&iter, "i", &i))
- iotcon_list_insert_int(list, i, -1);
+ iotcon_list_add_int(list, i, -1);
} else if (g_variant_type_equal(G_VARIANT_TYPE("ad"), type)) {
double d;
ret = iotcon_list_create(IOTCON_TYPE_DOUBLE, &list);
}
while (g_variant_iter_loop(&iter, "d", &d))
- iotcon_list_insert_double(list, d, -1);
+ iotcon_list_add_double(list, d, -1);
} else if (g_variant_type_equal(G_VARIANT_TYPE("as"), type)) {
char *s;
ret = iotcon_list_create(IOTCON_TYPE_STR, &list);
}
while (g_variant_iter_loop(&iter, "s", &s))
- iotcon_list_insert_str(list, s, -1);
+ iotcon_list_add_str(list, s, -1);
} else if (g_variant_type_equal(G_VARIANT_TYPE("v"), type)) {
GVariant *value;
iotcon_list_h list_value;
while (g_variant_iter_loop(&iter, "v", &value)) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_ARRAY)) {
list_value = _icl_state_list_from_gvariant(value);
- iotcon_list_insert_list(list, list_value, -1);
+ iotcon_list_add_list(list, list_value, -1);
} else if (g_variant_is_of_type(value, G_VARIANT_TYPE("a{sv}"))) {
GVariantIter *state_iter;
g_variant_get(value, "(&a{sv})", &state_iter);
_icl_state_from_gvariant(state_value, state_iter);
- iotcon_list_insert_state(list, state_value, -1);
+ iotcon_list_add_state(list, state_value, -1);
}
}
}
}
while (g_variant_iter_loop(resource_types, "s", &resource_type))
- iotcon_resource_types_insert(repr->res_types, resource_type);
+ iotcon_resource_types_add(repr->res_types, resource_type);
}
g_variant_iter_free(resource_types);
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
}
+API int iotcon_query_get_resource_tyeps(iotcon_query_h query, iotcon_resource_types_h *types)
+{
+ int ret;
+ char *resource_type = NULL;
+ iotcon_resource_types_h types_temp = NULL;
+
+ RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
+
+ iotcon_query_lookup(query, ICL_QUERY_KEY_RESOURCE_TYPE, &resource_type);
+ if (NULL == resource_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;
+
+ return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_query_get_interface(iotcon_query_h query, int *iface)
+{
+ char *iface_str = NULL;
+
+ RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == iface, IOTCON_ERROR_INVALID_PARAMETER);
+
+ iotcon_query_lookup(query, ICL_QUERY_KEY_INTERFACE, &iface_str);
+ if (NULL == iface_str) {
+ ERR("iface_str is NULL");
+ return IOTCON_ERROR_NO_DATA;
+ }
+
+ *iface = atoi(iface_str);
+
+ return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_query_set_resource_types(iotcon_query_h query, iotcon_resource_types_h types)
+{
+ int length_old = 0;
+ int length_new = 0;
+ char *value = NULL;
+ char *resource_type = NULL;
+
+ RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
+
+ value = g_hash_table_lookup(query->hash, ICL_QUERY_KEY_RESOURCE_TYPE);
+ 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;
+ 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.");
+ return IOTCON_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (value)
+ iotcon_query_remove(query, ICL_QUERY_KEY_RESOURCE_TYPE);
+
+ if (resource_type)
+ iotcon_query_add(query, ICL_QUERY_KEY_RESOURCE_TYPE, resource_type);
+
+ return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_query_set_interface(iotcon_query_h query, iotcon_interface_e iface)
+{
+ int length_old = 0;
+ int length_new = 0;
+ char *value = NULL;
+ char iface_str[ICL_QUERY_LENGTH_MAX] = {0};
+
+ RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
+
+ value = g_hash_table_lookup(query->hash, ICL_QUERY_KEY_INTERFACE);
+ if (value)
+ length_old = (sizeof(ICL_QUERY_KEY_INTERFACE) - 1) + strlen(value) + 2;
+
+ snprintf(iface_str, sizeof(iface_str), "%d", iface);
+ length_new = (sizeof(ICL_QUERY_KEY_INTERFACE) - 1) + strlen(iface_str) + 2;
+
+ if (ICL_QUERY_LENGTH_MAX < query->len - length_old + length_new) {
+ ERR("Length of query is invalid.");
+ return IOTCON_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (value)
+ iotcon_query_remove(query, ICL_QUERY_KEY_INTERFACE);
+
+ iotcon_query_add(query, ICL_QUERY_KEY_INTERFACE, iface_str);
+
+ return IOTCON_ERROR_NONE;
+}
+
/* The full length of query should be less than or equal to 64. */
-API int iotcon_query_insert(iotcon_query_h query, const char *key, const char *value)
+API int iotcon_query_add(iotcon_query_h query, const char *key, const char *value)
{
int query_len;
}
-API int iotcon_query_delete(iotcon_query_h query, const char *key)
+API int iotcon_query_remove(iotcon_query_h query, const char *key)
{
gboolean is_removed;
int query_len;
*/
#define ICL_QUERY_LENGTH_MAX 64
+#define ICL_QUERY_KEY_RESOURCE_TYPE "rt"
+#define ICL_QUERY_KEY_INTERFACE "if"
struct icl_query {
int len;
}
while (g_variant_iter_loop(options, "(q&s)", &option_id, &option_data))
- iotcon_options_insert(header_options, option_id, option_data);
+ iotcon_options_add(header_options, option_id, option_data);
}
g_variant_iter_free(options);
}
while (g_variant_iter_loop(options, "(q&s)", &option_id, &option_data))
- iotcon_options_insert(header_options, option_id, option_data);
+ iotcon_options_add(header_options, option_id, option_data);
}
g_variant_iter_free(options);
}
while (g_variant_iter_loop(options, "(q&s)", &option_id, &option_data))
- iotcon_options_insert(header_options, option_id, option_data);
+ iotcon_options_add(header_options, option_id, option_data);
}
g_variant_iter_free(options);
}
}
- ret = iotcon_options_insert(resource->header_options, id, data);
+ ret = iotcon_options_add(resource->header_options, id, data);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_options_insert() Fail(%d)", ret);
+ ERR("iotcon_options_add() Fail(%d)", ret);
return IOTCON_FUNC_STOP;
}
}
while (g_variant_iter_loop(types_iter, "s", &res_type))
- iotcon_resource_types_insert(res_types, res_type);
+ iotcon_resource_types_add(res_types, res_type);
ret = iotcon_remote_resource_create(host_addr, uri_path, !!is_observable, res_types, ifaces,
&resource);
}
-API int iotcon_list_insert_int(iotcon_list_h list, int val, int pos)
+API int iotcon_list_add_int(iotcon_list_h list, int val, int pos)
{
iotcon_value_h value;
}
-API int iotcon_list_insert_bool(iotcon_list_h list, bool val, int pos)
+API int iotcon_list_add_bool(iotcon_list_h list, bool val, int pos)
{
iotcon_value_h value;
}
-API int iotcon_list_insert_double(iotcon_list_h list, double val, int pos)
+API int iotcon_list_add_double(iotcon_list_h list, double val, int pos)
{
iotcon_value_h value;
}
-API int iotcon_list_insert_str(iotcon_list_h list, char *val, int pos)
+API int iotcon_list_add_str(iotcon_list_h list, char *val, int pos)
{
iotcon_value_h value;
}
-API int iotcon_list_insert_list(iotcon_list_h list, iotcon_list_h val, int pos)
+API int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos)
{
iotcon_value_h value;
}
-API int iotcon_list_insert_state(iotcon_list_h list, iotcon_state_h val, int pos)
+API int iotcon_list_add_state(iotcon_list_h list, iotcon_state_h val, int pos)
{
iotcon_value_h value;
}
-static int _icl_list_del_nth_value(iotcon_list_h list, int pos)
+static int _icl_list_remove_nth_value(iotcon_list_h list, int pos)
{
iotcon_value_h value;
}
-API int iotcon_list_del_nth(iotcon_list_h list, int pos)
+API int iotcon_list_remove_nth(iotcon_list_h list, int pos)
{
int ret;
- ret = _icl_list_del_nth_value(list, pos);
+ ret = _icl_list_remove_nth_value(list, pos);
if (IOTCON_ERROR_NONE != ret)
- ERR("_icl_list_del_nth_value() Fail(%d)", ret);
+ ERR("_icl_list_remove_nth_value() Fail(%d)", ret);
return ret;
}
return IOTCON_ERROR_NONE;
}
-API int iotcon_state_del(iotcon_state_h state, const char *key)
+API int iotcon_state_unset(iotcon_state_h state, const char *key)
{
int ret;
/* The length of resource type should be less than or equal to 61.
* Duplicate strings are not allowed. */
-API int iotcon_resource_types_insert(iotcon_resource_types_h types, const char *type)
+API int iotcon_resource_types_add(iotcon_resource_types_h types, const char *type)
{
char *resource_type;
}
-API int iotcon_resource_types_delete(iotcon_resource_types_h types, const char *type)
+API int iotcon_resource_types_remove(iotcon_resource_types_h types, const char *type)
{
GList *found_node;
}
while (g_variant_iter_loop(options, "(q&s)", &option_id, &option_data))
- iotcon_options_insert(request.header_options, option_id, option_data);
+ iotcon_options_add(request.header_options, option_id, option_data);
}
g_variant_iter_free(options);
}
while (g_variant_iter_loop(query, "(&s&s)", &key, &value))
- iotcon_query_insert(request.query, key, value);
+ iotcon_query_add(request.query, key, value);
}
g_variant_iter_free(query);
if (IOTCON_OBSERVE_REGISTER == request.observation_info.action) {
if (NULL == resource->observers)
iotcon_observers_create(&resource->observers);
- iotcon_observers_insert(resource->observers, observer_id);
+ iotcon_observers_add(resource->observers, observer_id);
} else if (IOTCON_OBSERVE_DEREGISTER == request.observation_info.action) {
- iotcon_observers_delete(resource->observers, observer_id);
+ iotcon_observers_remove(resource->observers, observer_id);
}
}
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_NO_DATA No data available
*/
-int iotcon_state_del(iotcon_state_h state, const char *key);
+int iotcon_state_unset(iotcon_state_h state, const char *key);
/**
* @brief Gets the type of a value at the given key.
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_INVALID_TYPE Invalid type
*/
-int iotcon_list_insert_int(iotcon_list_h list, int val, int pos);
+int iotcon_list_add_int(iotcon_list_h list, int val, int pos);
/**
* @brief Inserts a new element boolean value into the list at the given position.
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_INVALID_TYPE Invalid type
*/
-int iotcon_list_insert_bool(iotcon_list_h list, bool val, int pos);
+int iotcon_list_add_bool(iotcon_list_h list, bool val, int pos);
/**
* @brief Inserts a new element double value into the list at the given position.
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_INVALID_TYPE Invalid type
*/
-int iotcon_list_insert_double(iotcon_list_h list, double val, int pos);
+int iotcon_list_add_double(iotcon_list_h list, double val, int pos);
/**
* @brief Inserts a new element string value into the list at the given position.
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_INVALID_TYPE Invalid type
*/
-int iotcon_list_insert_str(iotcon_list_h list, char *val, int pos);
+int iotcon_list_add_str(iotcon_list_h list, char *val, int pos);
/**
* @brief Inserts a new element list into the list at the given position.
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_INVALID_TYPE Invalid type
*/
-int iotcon_list_insert_list(iotcon_list_h list, iotcon_list_h val, int pos);
+int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos);
/**
* @brief Inserts a new element state value into the list at the given position.
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_INVALID_TYPE Invalid type
*/
-int iotcon_list_insert_state(iotcon_list_h list, iotcon_state_h val, int pos);
+int iotcon_list_add_state(iotcon_list_h list, iotcon_state_h val, int pos);
/**
* @brief Gets the integer value at the given position.
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_NO_DATA No data available
*/
-int iotcon_list_del_nth(iotcon_list_h list, int pos);
+int iotcon_list_remove_nth(iotcon_list_h list, int pos);
/**
* @brief Gets the type of the list.
typedef struct icl_presence* iotcon_presence_h;
/**
+ * @brief The handle of resource types
+ * @details iotcon_resource_types_h is an opaque data structure to have list\n
+ * of resource types. A resource type is datatype of string.
+ *
+ * @since_tizen 3.0
+ */
+typedef struct icl_resource_types* iotcon_resource_types_h;
+
+
+/**
+ * @brief Creates a new resource types handle.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[out] ret_types A newly allocated list of resource types handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see iotcon_resource_types_destroy()
+ * @see iotcon_resource_types_add()
+ * @see iotcon_resource_types_remove()
+ * @see iotcon_resource_types_clone()
+ */
+int iotcon_resource_types_create(iotcon_resource_types_h *ret_types);
+
+/**
+ * @brief Free a resource types handle.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] types The handle of the resource types
+ *
+ * @return void
+ *
+ * @see iotcon_resource_types_create()
+ * @see iotcon_resource_types_add()
+ * @see iotcon_resource_types_remove()
+ * @see iotcon_resource_types_clone()
+ */
+void iotcon_resource_types_destroy(iotcon_resource_types_h types);
+
+/**
+ * @brief Inserts a resource type into the list.
+ *
+ * @since_tizen 3.0
+ * @remarks The length of resource type should be less than or equal to 61. \n
+ * Duplicate strings are not allowed.
+ *
+ * @param[in] types The handle of the resource types
+ * @param[in] type The string data to insert into the resource types
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see iotcon_resource_types_create()
+ * @see iotcon_resource_types_destroy()
+ * @see iotcon_resource_types_remove()
+ * @see iotcon_resource_types_clone()
+ */
+int iotcon_resource_types_add(iotcon_resource_types_h types, const char *type);
+
+/**
+ * @brief Delete a resource type form the list.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] types The handle of the resource types
+ * @param[in] type The string data to delete from the resource types
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
+ *
+ * @see iotcon_resource_types_create()
+ * @see iotcon_resource_types_destroy()
+ * @see iotcon_resource_types_add()
+ * @see iotcon_resource_types_clone()
+ */
+int iotcon_resource_types_remove(iotcon_resource_types_h types, const char *type);
+
+/**
+ * @brief Specifies the type of function passed to iotcon_resource_types_foreach()
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] type The value of the resource types
+ * @param[in] user_data The user data to pass to the function
+ *
+ * @return #IOTCON_FUNC_CONTINUE to continue with the next function of the loop,
+ * otherwise #IOTCON_FUNC_STOP to break out of the loop
+ * @retval #IOTCON_FUNC_STOP stop to call next function
+ * @retval #IOTCON_FUNC_CONTINUE continue to call next function
+ *
+ * @pre iotcon_resource_types_foreach() will invoke this callback function.
+ *
+ * @see iotcon_resource_types_foreach()
+ */
+typedef int (*iotcon_resource_types_foreach_cb)(const char *type, void *user_data);
+
+/**
+ * @brief Gets all of the resource types of the list by invoking the callback function.
+ * @details iotcon_resource_types_foreach_cb() will be called for each type.\n
+ * If iotcon_resource_types_foreach_cb() returns #IOTCON_FUNC_STOP, iteration will be stop.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] types The handle of resource types
+ * @param[in] cb The callback function to get data
+ * @param[in] user_data The user data to pass to the function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @post iotcon_resource_types_foreach() will be called for each type.
+ *
+ * @see iotcon_resource_types_foreach_cb()
+ */
+int iotcon_resource_types_foreach(iotcon_resource_types_h types,
+ iotcon_resource_types_foreach_cb cb, void *user_data);
+
+/**
+ * @brief Clones the resource types handle.
+ * @details Makes a deep copy of a source list of resource types.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] src The origin handle of the resource types
+ * @param[out] dest Clone of a source list of resource types
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see iotcon_resource_types_create()
+ * @see iotcon_resource_types_destroy()
+ * @see iotcon_resource_types_add()
+ * @see iotcon_resource_types_remove()
+ */
+int iotcon_resource_types_clone(iotcon_resource_types_h src,
+ iotcon_resource_types_h *dest);
+
+
+
+/**
* @brief The handle of options
* @details iotcon_options_h is an opaque data structure to have attribute value map
* which consists of a key and a value.\n
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_options_destroy()
- * @see iotcon_options_insert()
- * @see iotcon_options_delete()
+ * @see iotcon_options_add()
+ * @see iotcon_options_remove()
* @see iotcon_options_lookup()
*/
int iotcon_options_create(iotcon_options_h *options);
* @return void
*
* @see iotcon_options_create()
- * @see iotcon_options_insert()
- * @see iotcon_options_delete()
+ * @see iotcon_options_add()
+ * @see iotcon_options_remove()
* @see iotcon_options_lookup()
*/
void iotcon_options_destroy(iotcon_options_h options);
*
* @see iotcon_options_create()
* @see iotcon_options_destroy()
- * @see iotcon_options_delete()
+ * @see iotcon_options_remove()
* @see iotcon_options_lookup()
*/
-int iotcon_options_insert(iotcon_options_h options, unsigned short id,
+int iotcon_options_add(iotcon_options_h options, unsigned short id,
const char *data);
/**
*
* @see iotcon_options_create()
* @see iotcon_options_destroy()
- * @see iotcon_options_insert()
+ * @see iotcon_options_add()
* @see iotcon_options_lookup()
*/
-int iotcon_options_delete(iotcon_options_h options, unsigned short id);
+int iotcon_options_remove(iotcon_options_h options, unsigned short id);
/**
* @brief Looks up data at the given id from the options.
*
* @see iotcon_options_create()
* @see iotcon_options_destroy()
- * @see iotcon_options_insert()
- * @see iotcon_options_delete()
+ * @see iotcon_options_add()
+ * @see iotcon_options_remove()
*/
int iotcon_options_lookup(iotcon_options_h options, unsigned short id, char **data);
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_query_destroy()
- * @see iotcon_query_insert()
- * @see iotcon_query_delete()
+ * @see iotcon_query_add()
+ * @see iotcon_query_remove()
* @see iotcon_query_lookup()
*/
int iotcon_query_create(iotcon_query_h *query);
* @return void
*
* @see iotcon_query_create()
- * @see iotcon_query_insert()
- * @see iotcon_query_delete()
+ * @see iotcon_query_add()
+ * @see iotcon_query_remove()
* @see iotcon_query_lookup()
*/
void iotcon_query_destroy(iotcon_query_h query);
/**
- * @brief Inserts a new key and correspoding value into the query.
+ * @brief Get resource types from the query.
*
* @since_tizen 3.0
- * @remarks The full length of query should be less than or equal to 64.
+ * @remarks @a types must not be released using iotcon_resource_types_destroy().
*
* @param[in] query The handle of the query
- * @param[in] key The key of the query to insert
- * @param[in] value The string data to insert into the query
+ * @param[out] types Found resource types from query
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
*
* @see iotcon_query_create()
* @see iotcon_query_destroy()
- * @see iotcon_query_delete()
- * @see iotcon_query_lookup()
+ * @see iotcon_query_add()
+ * @see iotcon_query_remove()
+ * @see iotcon_query_set_resource_types()
*/
-int iotcon_query_insert(iotcon_query_h query, const char *key, const char *value);
+int iotcon_query_get_resource_tyeps(iotcon_query_h query, iotcon_resource_types_h *types);
/**
- * @brief Deletes the key and its associated value from the query.
+ * @brief Get resource types from the query.
+ * @details @a iface could be one of #iotcon_interface_e.
*
* @since_tizen 3.0
*
* @param[in] query The handle of the query
- * @param[in] key The key of the option to delete
+ * @param[out] iface Found interface from query
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
*
* @see iotcon_query_create()
* @see iotcon_query_destroy()
- * @see iotcon_query_insert()
- * @see iotcon_query_lookup()
+ * @see iotcon_query_add()
+ * @see iotcon_query_remove()
+ * @see iotcon_query_set_interface()
*/
-int iotcon_query_delete(iotcon_query_h query, const char *key);
+int iotcon_query_get_interface(iotcon_query_h query, int *iface);
/**
- * @brief Lookup data at the given key from the query.
+ * @brief Sets the resource types into the query.
*
* @since_tizen 3.0
*
* @param[in] query The handle of the query
- * @param[in] key The key of the query to lookup
- * @param[out] data Found data from query
+ * @param[in] value The resoure types to set into the query
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_query_create()
* @see iotcon_query_destroy()
- * @see iotcon_query_insert()
- * @see iotcon_query_delete()
- */
-int iotcon_query_lookup(iotcon_query_h query, const char *key, char **data);
-
-/**
- * @brief Specifies the type of function passed to iotcon_query_foreach()
- *
- * @since_tizen 3.0
- *
- * @param[in] key The key of the query
- * @param[in] value The value of the query
- * @param[in] user_data The user data to pass to the function
- *
- * @return #IOTCON_FUNC_CONTINUE to continue with the next function of the loop,
- * otherwise #IOTCON_FUNC_STOP to break out of the loop
- * @retval #IOTCON_FUNC_STOP stop to call next function
- * @retval #IOTCON_FUNC_CONTINUE continue to call next function
- *
- * @pre iotcon_query_foreach() will invoke this callback function.
- *
- * @see iotcon_query_foreach()
+ * @see iotcon_query_add()
+ * @see iotcon_query_remove()
+ * @see iotcon_query_lookup()
+ * @see iotcon_query_get_resource_tyeps()
*/
-typedef int (*iotcon_query_foreach_cb)(const char *key, const char *value,
- void *user_data);
+int iotcon_query_set_resource_types(iotcon_query_h query, iotcon_resource_types_h types);
/**
- * @brief Gets all datas of the query by invoking the callback function.
- * @details iotcon_query_foreach_cb() will be called for each query.\n
- * If iotcon_query_foreach_cb() returns #IOTCON_FUNC_STOP, iteration will be stop.
+ * @brief Sets the interface into the query.
*
* @since_tizen 3.0
*
* @param[in] query The handle of the query
- * @param[in] cb The callback function to get data
- * @param[in] user_data The user data to be passed to the callback function
+ * @param[in] iface The interface to add into the query
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
- * @post iotcon_query_foreach_cb() will be called for each query.
- *
- * @see iotcon_query_foreach_cb()
- */
-int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb,
- void *user_data);
-
-/**
- * @brief The handle of resource types
- * @details iotcon_resource_types_h is an opaque data structure to have list\n
- * of resource types. A resource type is datatype of string.
- *
- * @since_tizen 3.0
+ * @see iotcon_query_create()
+ * @see iotcon_query_destroy()
+ * @see iotcon_query_add()
+ * @see iotcon_query_remove()
+ * @see iotcon_query_lookup()
+ * @see iotcon_query_get_interface()
*/
-typedef struct icl_resource_types* iotcon_resource_types_h;
+int iotcon_query_set_interface(iotcon_query_h query, iotcon_interface_e iface);
/**
- * @brief Creates a new resource types handle.
+ * @brief Inserts a new key and correspoding value into the query.
*
* @since_tizen 3.0
+ * @remarks The full length of query should be less than or equal to 64.
*
- * @param[out] ret_types A newly allocated list of resource types handle
+ * @param[in] query The handle of the query
+ * @param[in] key The key of the query to insert
+ * @param[in] value The string data to insert into the query
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
- * @see iotcon_resource_types_destroy()
- * @see iotcon_resource_types_insert()
- * @see iotcon_resource_types_delete()
- * @see iotcon_resource_types_clone()
- */
-int iotcon_resource_types_create(iotcon_resource_types_h *ret_types);
-
-/**
- * @brief Free a resource types handle.
- *
- * @since_tizen 3.0
- *
- * @param[in] types The handle of the resource types
- *
- * @return void
- *
- * @see iotcon_resource_types_create()
- * @see iotcon_resource_types_insert()
- * @see iotcon_resource_types_delete()
- * @see iotcon_resource_types_clone()
+ * @see iotcon_query_create()
+ * @see iotcon_query_destroy()
+ * @see iotcon_query_remove()
+ * @see iotcon_query_lookup()
*/
-void iotcon_resource_types_destroy(iotcon_resource_types_h types);
+int iotcon_query_add(iotcon_query_h query, const char *key, const char *value);
/**
- * @brief Inserts a resource type into the list.
+ * @brief Deletes the key and its associated value from the query.
*
* @since_tizen 3.0
- * @remarks The length of resource type should be less than or equal to 61. \n
- * Duplicate strings are not allowed.
*
- * @param[in] types The handle of the resource types
- * @param[in] type The string data to insert into the resource types
+ * @param[in] query The handle of the query
+ * @param[in] key The key of the option to delete
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
- * @see iotcon_resource_types_create()
- * @see iotcon_resource_types_destroy()
- * @see iotcon_resource_types_delete()
- * @see iotcon_resource_types_clone()
+ * @see iotcon_query_create()
+ * @see iotcon_query_destroy()
+ * @see iotcon_query_add()
+ * @see iotcon_query_lookup()
*/
-int iotcon_resource_types_insert(iotcon_resource_types_h types, const char *type);
+int iotcon_query_remove(iotcon_query_h query, const char *key);
/**
- * @brief Delete a resource type form the list.
+ * @brief Lookup data at the given key from the query.
*
* @since_tizen 3.0
*
- * @param[in] types The handle of the resource types
- * @param[in] type The string data to delete from the resource types
+ * @param[in] query The handle of the query
+ * @param[in] key The key of the query to lookup
+ * @param[out] data Found data from query
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #IOTCON_ERROR_NO_DATA No data available
*
- * @see iotcon_resource_types_create()
- * @see iotcon_resource_types_destroy()
- * @see iotcon_resource_types_insert()
- * @see iotcon_resource_types_clone()
+ * @see iotcon_query_create()
+ * @see iotcon_query_destroy()
+ * @see iotcon_query_add()
+ * @see iotcon_query_remove()
*/
-int iotcon_resource_types_delete(iotcon_resource_types_h types, const char *type);
+int iotcon_query_lookup(iotcon_query_h query, const char *key, char **data);
/**
- * @brief Specifies the type of function passed to iotcon_resource_types_foreach()
+ * @brief Specifies the type of function passed to iotcon_query_foreach()
*
* @since_tizen 3.0
*
- * @param[in] type The value of the resource types
+ * @param[in] key The key of the query
+ * @param[in] value The value of the query
* @param[in] user_data The user data to pass to the function
*
* @return #IOTCON_FUNC_CONTINUE to continue with the next function of the loop,
* @retval #IOTCON_FUNC_STOP stop to call next function
* @retval #IOTCON_FUNC_CONTINUE continue to call next function
*
- * @pre iotcon_resource_types_foreach() will invoke this callback function.
+ * @pre iotcon_query_foreach() will invoke this callback function.
*
- * @see iotcon_resource_types_foreach()
+ * @see iotcon_query_foreach()
*/
-typedef int (*iotcon_resource_types_foreach_cb)(const char *type, void *user_data);
+typedef int (*iotcon_query_foreach_cb)(const char *key, const char *value,
+ void *user_data);
/**
- * @brief Gets all of the resource types of the list by invoking the callback function.
- * @details iotcon_resource_types_foreach_cb() will be called for each type.\n
- * If iotcon_resource_types_foreach_cb() returns #IOTCON_FUNC_STOP, iteration will be stop.
+ * @brief Gets all datas of the query by invoking the callback function.
+ * @details iotcon_query_foreach_cb() will be called for each query.\n
+ * If iotcon_query_foreach_cb() returns #IOTCON_FUNC_STOP, iteration will be stop.
*
* @since_tizen 3.0
*
- * @param[in] types The handle of resource types
+ * @param[in] query The handle of the query
* @param[in] cb The callback function to get data
- * @param[in] user_data The user data to pass to the function
+ * @param[in] user_data The user data to be passed to the callback function
*
* @return 0 on success, otherwise a negative error value.
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
- * @post iotcon_resource_types_foreach() will be called for each type.
- *
- * @see iotcon_resource_types_foreach_cb()
- */
-int iotcon_resource_types_foreach(iotcon_resource_types_h types,
- iotcon_resource_types_foreach_cb cb, void *user_data);
-
-/**
- * @brief Clones the resource types handle.
- * @details Makes a deep copy of a source list of resource types.
- *
- * @since_tizen 3.0
- *
- * @param[in] src The origin handle of the resource types
- * @param[out] dest Clone of a source list of resource types
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_ERROR_NONE Successful
- * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post iotcon_query_foreach_cb() will be called for each query.
*
- * @see iotcon_resource_types_create()
- * @see iotcon_resource_types_destroy()
- * @see iotcon_resource_types_insert()
- * @see iotcon_resource_types_delete()
+ * @see iotcon_query_foreach_cb()
*/
-int iotcon_resource_types_clone(iotcon_resource_types_h src,
- iotcon_resource_types_h *dest);
+int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb,
+ void *user_data);
/**
* @brief The handle of observers.
* @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
*
* @see iotcon_observers_destroy()
- * @see iotcon_observers_insert()
- * @see iotcon_observers_delete()
+ * @see iotcon_observers_add()
+ * @see iotcon_observers_remove()
*/
int iotcon_observers_create(iotcon_observers_h *ret_observers);
* @return void
*
* @see iotcon_observers_create()
- * @see iotcon_observers_insert()
- * @see iotcon_observers_delete()
+ * @see iotcon_observers_add()
+ * @see iotcon_observers_remove()
*/
void iotcon_observers_destroy(iotcon_observers_h observers);
*
* @see iotcon_observers_create()
* @see iotcon_observers_destroy()
- * @see iotcon_observers_delete()
+ * @see iotcon_observers_remove()
*/
-int iotcon_observers_insert(iotcon_observers_h observers, int obs_id);
+int iotcon_observers_add(iotcon_observers_h observers, int obs_id);
/**
* @brief Remove id from the observers.
*
* @see iotcon_observers_create()
* @see iotcon_observers_destroy()
- * @see iotcon_observers_insert()
+ * @see iotcon_observers_add()
*/
-int iotcon_observers_delete(iotcon_observers_h observers, int obs_id);
+int iotcon_observers_remove(iotcon_observers_h observers, int obs_id);
/**
* @brief The handle of resource.
* @see iotcon_notimsg_destroy()
* @see iotcon_observers_create()
* @see iotcon_observers_destroy()
- * @see iotcon_observers_insert()
- * @see iotcon_observers_delete()
+ * @see iotcon_observers_add()
+ * @see iotcon_observers_remove()
*/
int iotcon_resource_notify(iotcon_resource_h resource, iotcon_notimsg_h msg,
iotcon_observers_h observers);
return;
}
- ret = iotcon_query_insert(query, "query_key", "query_value");
+ ret = iotcon_query_add(query, "query_key", "query_value");
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_query_insert() Fail(%d)", ret);
+ ERR("iotcon_query_add() Fail(%d)", ret);
iotcon_query_destroy(query);
device_id_list = g_list_remove(device_id_list, door_resource_device_id);
free(door_resource_device_id);
return NULL;
}
- ret = iotcon_resource_types_insert(resource_types, type);
+ ret = iotcon_resource_types_add(resource_types, type);
if (IOTCON_ERROR_NONE != ret) {
iotcon_resource_types_destroy(resource_types);
- ERR("iotcon_resource_types_insert() Fail(%d)", ret);
+ ERR("iotcon_resource_types_add() Fail(%d)", ret);
return NULL;
}
ERR("iotcon_request_get_observer_id() Fail(%d)", ret);
return;
}
- ret = iotcon_observers_insert(door->observers, observer_id);
+ ret = iotcon_observers_add(door->observers, observer_id);
} else if (IOTCON_OBSERVE_DEREGISTER == observer_action) {
ret = iotcon_request_get_observer_id(request, &observer_id);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_request_get_observer_id() Fail(%d)", ret);
return;
}
- ret = iotcon_observers_delete(door->observers, observer_id);
+ ret = iotcon_observers_remove(door->observers, observer_id);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_observers_remove() Fail(%d)", ret);
return;
return;
}
- ret = iotcon_query_insert(query_params, "if", "oic.if.b");
+ ret = iotcon_query_add(query_params, "if", "oic.if.b");
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_query_insert() Fail(%d)", ret);
+ ERR("iotcon_query_add() Fail(%d)", ret);
iotcon_query_destroy(query_params);
return;
}
return;
}
- ret = iotcon_list_insert_int(temperature_list, 22, -1);
+ ret = iotcon_list_add_int(temperature_list, 22, -1);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_list_insert_int() Fail(%d)", ret);
+ ERR("iotcon_list_add_int() Fail(%d)", ret);
iotcon_state_destroy(room_state);
iotcon_representation_destroy(room_repr);
return;
}
- ret = iotcon_list_insert_int(temperature_list, 23, -1);
+ ret = iotcon_list_add_int(temperature_list, 23, -1);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_list_insert_int() Fail(%d)", ret);
+ ERR("iotcon_list_add_int() Fail(%d)", ret);
iotcon_state_destroy(room_state);
iotcon_representation_destroy(room_repr);
return;
}
- ret = iotcon_list_insert_int(temperature_list, 24, -1);
+ ret = iotcon_list_add_int(temperature_list, 24, -1);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_list_insert_int() Fail(%d)", ret);
+ ERR("iotcon_list_add_int() Fail(%d)", ret);
iotcon_state_destroy(room_state);
iotcon_representation_destroy(room_repr);
return;
}
- ret = iotcon_list_insert_int(temperature_list, 25, -1);
+ ret = iotcon_list_add_int(temperature_list, 25, -1);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_list_insert_int() Fail(%d)", ret);
+ ERR("iotcon_list_add_int() Fail(%d)", ret);
iotcon_state_destroy(room_state);
iotcon_representation_destroy(room_repr);
return;
}
- ret = iotcon_list_insert_int(temperature_list, 26, -1);
+ ret = iotcon_list_add_int(temperature_list, 26, -1);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_list_insert_int() Fail(%d)", ret);
+ ERR("iotcon_list_add_int() Fail(%d)", ret);
iotcon_state_destroy(room_state);
iotcon_representation_destroy(room_repr);
return;
iotcon_close();
return -1;
}
- ret = iotcon_resource_types_insert(room_rtypes, "core.room");
+ ret = iotcon_resource_types_add(room_rtypes, "core.room");
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_resource_types_insert(%s) Fail(%d)", "core.room", ret);
+ ERR("iotcon_resource_types_add(%s) Fail(%d)", "core.room", ret);
iotcon_resource_types_destroy(room_rtypes);
iotcon_close();
return -1;
iotcon_close();
return -1;
}
- ret = iotcon_resource_types_insert(light_rtypes, "core.light");
+ ret = iotcon_resource_types_add(light_rtypes, "core.light");
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_resource_types_insert(%s) Fail(%d)", "core.light", ret);
+ ERR("iotcon_resource_types_add(%s) Fail(%d)", "core.light", ret);
iotcon_resource_types_destroy(light_rtypes);
iotcon_resource_destroy(room_handle);
iotcon_close();