g_hash_table_iter_init(&iter, options->hash);
while (g_hash_table_iter_next(&iter, &key, &value)) {
- if (false == cb(GPOINTER_TO_UINT(key), value, user_data))
+ if (IOTCON_FUNC_STOP == cb(GPOINTER_TO_UINT(key), value, user_data))
break;
}
g_hash_table_iter_init(&iter, query->hash);
while (g_hash_table_iter_next(&iter, &key, &value)) {
- if (false == cb(key, value, user_data))
+ if (IOTCON_FUNC_STOP == cb(key, value, user_data))
break;
}
free(resource);
}
-static int _icl_remote_resource_header_foreach_cb(unsigned short id,
+static bool _icl_remote_resource_header_foreach_cb(unsigned short id,
const char *data, void *user_data)
{
int ret;
#ifndef __IOT_CONNECTIVITY_MANAGER_CONSTANT_H__
#define __IOT_CONNECTIVITY_MANAGER_CONSTANT_H__
+#include <tizen_type.h>
+
/**
* @file iotcon-constant.h
*/
*
* @since_tizen 3.0
*/
-#define IOTCON_FUNC_STOP 0
+#define IOTCON_FUNC_STOP false
/**
* @brief Use this value as the return value to continue foreach function.
*
* @since_tizen 3.0
*/
-#define IOTCON_FUNC_CONTINUE 1
+#define IOTCON_FUNC_CONTINUE true
/**
* @brief Enumeration for action of observation.
* @param[in] value The integer value
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_list_foreach_int() will invoke this callback function.
*
* @see iotcon_list_foreach_int()
*/
-typedef int (*iotcon_list_int_cb)(int pos, int value, void *user_data);
+typedef bool (*iotcon_list_int_cb)(int pos, int value, void *user_data);
/**
* @brief Gets all integer values of the given list by invoking the callback function.
* @param[in] value The boolean value
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_list_foreach_bool() will invoke this callback function.
*
* @see iotcon_list_foreach_bool()
*/
-typedef int (*iotcon_list_bool_cb)(int pos, bool value, void *user_data);
+typedef bool (*iotcon_list_bool_cb)(int pos, bool value, void *user_data);
/**
* @brief Gets all boolean values of the given list by invoking the callback function.
* @param[in] value The double value
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_list_foreach_double() will invoke this callback function.
*
* @see iotcon_list_foreach_double()
*/
-typedef int (*iotcon_list_double_cb)(int pos, double value, void *user_data);
+typedef bool (*iotcon_list_double_cb)(int pos, double value, void *user_data);
/**
* @brief Gets all double values of the given list by invoking the callback function.
* @param[in] value The string value
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_list_foreach_str() will invoke this callback function.
*
* @see iotcon_list_foreach_str()
*/
-typedef int (*iotcon_list_str_cb)(int pos, const char *value, void *user_data);
+typedef bool (*iotcon_list_str_cb)(int pos, const char *value, void *user_data);
/**
* @brief Gets all string values of the given list by invoking the callback function.
* @param[in] value The list value
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_list_foreach_list() will invoke this callback function.
*
* @see iotcon_list_foreach_list()
*/
-typedef int (*iotcon_list_list_cb)(int pos, iotcon_list_h value, void *user_data);
+typedef bool (*iotcon_list_list_cb)(int pos, iotcon_list_h value, void *user_data);
/**
* @brief Gets all sub lists of the given list by invoking the callback function.
* @param[in] value The state value
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_list_foreach_state() will invoke this callback function.
*
* @see iotcon_list_foreach_state()
*/
-typedef int (*iotcon_list_state_cb)(int pos, iotcon_state_h value, void *user_data);
+typedef bool (*iotcon_list_state_cb)(int pos, iotcon_state_h value, void *user_data);
/**
* @brief Gets all state of the given list by invoking the callback function.
#ifndef __IOT_CONNECTIVITY_MANAGER_STRUCT_OPTIONS_H__
#define __IOT_CONNECTIVITY_MANAGER_STRUCT_OPTIONS_H__
+#include <stdbool.h>
#include <iotcon-constant.h>
/**
* @param[in] data The data of the option
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_options_foreach() will invoke this callback function.
*
* @see iotcon_options_foreach()
*/
-typedef int (*iotcon_options_foreach_cb)(unsigned short id, const char *data,
+typedef bool (*iotcon_options_foreach_cb)(unsigned short id, const char *data,
void *user_data);
/**
* @brief Gets all datas of the options by invoking the callback function.
* @details iotcon_options_foreach_cb() will be called for each option.\n
- * If iotcon_options_foreach_cb() returns #IOTCON_FUNC_STOP, iteration will be stop.
+ * If iotcon_options_foreach_cb() returns false, iteration will be stop.
*
* @since_tizen 3.0
*
#ifndef __IOT_CONNECTIVITY_MANAGER_STRUCT_QUERY_H__
#define __IOT_CONNECTIVITY_MANAGER_STRUCT_QUERY_H__
+#include <stdbool.h>
#include <iotcon-constant.h>
/**
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_query_foreach() will invoke this callback function.
*
* @see iotcon_query_foreach()
*/
-typedef int (*iotcon_query_foreach_cb)(const char *key, const char *value,
+typedef bool (*iotcon_query_foreach_cb)(const char *key, const char *value,
void *user_data);
/**
* @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.
+ * If iotcon_query_foreach_cb() returns false, iteration will be stop.
*
* @since_tizen 3.0
*
* @param[in] child The child representation handle
* @param[in] user_data The user data to pass to the function
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #IOTCON_FUNC_CONTINUE Continue to iterate next child representation
- * @retval #IOTCON_FUNC_STOP Stop to iterate children representation
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_representation_foreach_children() will invoke this callback function.
*
#ifndef __IOT_CONNECTIVITY_MANAGER_STRUCT_RESOURCE_TYPES_H__
#define __IOT_CONNECTIVITY_MANAGER_STRUCT_RESOURCE_TYPES_H__
+#include <stdbool.h>
#include <iotcon-constant.h>
/**
* @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
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @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);
+typedef bool (*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.
+ * If iotcon_resource_types_foreach_cb() returns false, iteration will be stop.
*
* @since_tizen 3.0
*
* @param[in] key The key
* @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_CONTINUE Continue to iterate next key
- * @retval #IOTCON_FUNC_STOP Stop to iterate key
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
*
* @pre iotcon_state_foreach() will invoke this callback function.
*
* @see iotcon_state_foreach()
*/
-typedef int (*iotcon_state_cb)(iotcon_state_h state, const char *key, void *user_data);
+typedef bool (*iotcon_state_cb)(iotcon_state_h state, const char *key, void *user_data);
/**
* @brief Calls a function for each element of state.
iotcon_representation_destroy(send_repr);
}
-static int _get_res_type_cb(const char *string, void *user_data)
+static bool _get_res_type_cb(const char *string, void *user_data)
{
char *resource_uri_path = user_data;
iotcon_representation_destroy(resp_repr);
}
-static int _query_cb(const char *key, const char *value, void *user_data)
+static bool _query_cb(const char *key, const char *value, void *user_data)
{
INFO("key : %s, value : %s", key, value);
static char *door_resource_device_id;
static GList *device_id_list;
-static int _get_res_type_cb(const char *string, void *user_data)
+static bool _get_res_type_cb(const char *string, void *user_data)
{
char *resource_uri_path = user_data;
static const char* const room_uri_path = "/a/room";
-static int _get_int_list_cb(int pos, const int value, void *user_data)
+static bool _get_int_list_cb(int pos, const int value, void *user_data)
{
- DBG("%d°C", value);
+ DBG("%d", value);
return IOTCON_FUNC_CONTINUE;
}
iotcon_query_destroy(query_params);
}
-static int _get_res_type_fn(const char *string, void *user_data)
+static bool _get_res_type_fn(const char *string, void *user_data)
{
char *resource_uri_path = user_data;