fix an error code in iotcon_initialize()
authoryoungman <yman.jung@samsung.com>
Tue, 7 Jul 2015 07:35:30 +0000 (16:35 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:06:25 +0000 (20:06 +0900)
 and a bug that user_data is always NULL

Change-Id: I36d6c1747b309649eb24e606445413b9bb48cbab
Signed-off-by: youngman <yman.jung@samsung.com>
lib/icl-options.c
lib/icl-query.c
lib/icl-repr.c
lib/icl-resource-types.c
lib/icl.c
lib/include/iotcon-representation.h
lib/include/iotcon-struct.h
test/crud-test-server.c
test/repr-test-server.c

index df74693..64ea20f 100644 (file)
@@ -119,17 +119,17 @@ API const char* iotcon_options_lookup(iotcon_options_h options, unsigned short i
 
 
 API int iotcon_options_foreach(iotcon_options_h options,
-               iotcon_options_foreach_cb cb, void *user_data)
+               iotcon_options_foreach_fn fn, void *user_data)
 {
        GHashTableIter iter;
        gpointer key, value;
 
        RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        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 (false == fn(GPOINTER_TO_UINT(key), value, user_data))
                        break;
        }
 
index a4f61ae..1a66532 100644 (file)
@@ -112,18 +112,18 @@ API const char* iotcon_query_lookup(iotcon_query_h query, const char *key)
        return ret;
 }
 
-API int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb,
+API int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_fn fn,
                void *user_data)
 {
        GHashTableIter iter;
        gpointer key, value;
 
        RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        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 (false == fn(key, value, user_data))
                        break;
        }
 
index fc548da..f3f211e 100644 (file)
@@ -198,8 +198,7 @@ API int iotcon_repr_get_nth_child(iotcon_repr_h parent, int pos, iotcon_repr_h *
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_repr_foreach_keys(iotcon_repr_h repr, iotcon_repr_key_fn fn,
-               void *user_data)
+API int iotcon_repr_foreach(iotcon_repr_h repr, iotcon_repr_fn fn, void *user_data)
 {
        GHashTableIter iter;
        gpointer key, value;
index c492c41..e00f2d2 100644 (file)
@@ -141,15 +141,15 @@ API int iotcon_resource_types_delete(iotcon_resource_types_h types, const char *
 
 
 API int iotcon_resource_types_foreach(iotcon_resource_types_h types,
-               iotcon_resource_types_foreach_cb cb, void *user_data)
+               iotcon_resource_types_foreach_fn fn, void *user_data)
 {
        GList *node;
 
        RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        for (node = types->type_list; node; node = node->next) {
-               if (IOTCON_FUNC_STOP == cb((const char*)node->data, user_data))
+               if (IOTCON_FUNC_STOP == fn((const char*)node->data, user_data))
                        break;
        }
 
index 5f48c7d..f9d1bcf 100644 (file)
--- a/lib/icl.c
+++ b/lib/icl.c
@@ -39,7 +39,7 @@ API int iotcon_initialize()
        FN_CALL;
        int ret;
 
-       RETVM_IF(true == icl_is_init, IOTCON_ERROR_INVALID_PARAMETER,  "already initialized");
+       RETVM_IF(true == icl_is_init, IOTCON_ERROR_ALREADY,  "already initialized");
 
 #if !GLIB_CHECK_VERSION(2, 35, 0)
        g_type_init();
@@ -126,7 +126,7 @@ API iotcon_resource_h iotcon_register_resource(const char *uri,
        }
 
        resource->handle = icl_dbus_register_resource(uri, res_types, ifaces,
-                       properties, cb, NULL);
+                       properties, cb, user_data);
        if (NULL == resource->handle) {
                ERR("icl_dbus_register_resource() Fail");
                free(resource);
index 73bd17c..0218a0f 100644 (file)
@@ -108,8 +108,8 @@ int iotcon_repr_foreach_children(iotcon_repr_h parent, iotcon_children_fn fn,
 unsigned int iotcon_repr_get_children_count(iotcon_repr_h parent);
 int iotcon_repr_get_nth_child(iotcon_repr_h parent, int pos, iotcon_repr_h *child);
 
-typedef int (*iotcon_repr_key_fn)(iotcon_repr_h repr, const char *key, void *user_data);
-int iotcon_repr_foreach_keys(iotcon_repr_h repr, iotcon_repr_key_fn fn, void *user_data);
+typedef int (*iotcon_repr_fn)(const char *key, const char *value, void *user_data);
+int iotcon_repr_foreach(iotcon_repr_h repr, iotcon_repr_fn fn, void *user_data);
 unsigned int iotcon_repr_get_keys_count(iotcon_repr_h repr);
 
 char* iotcon_repr_generate_json(iotcon_repr_h repr);
index c4406e2..8ca8238 100644 (file)
@@ -67,9 +67,9 @@ int iotcon_options_insert(iotcon_options_h options, unsigned short id,
                const char *data);
 int iotcon_options_delete(iotcon_options_h options, unsigned short id);
 const char* iotcon_options_lookup(iotcon_options_h options, unsigned short id);
-typedef int (*iotcon_options_foreach_cb)(unsigned short id, const char *data,
+typedef int (*iotcon_options_foreach_fn)(unsigned short id, const char *data,
                void *user_data);
-int iotcon_options_foreach(iotcon_options_h options, iotcon_options_foreach_cb cb,
+int iotcon_options_foreach(iotcon_options_h options, iotcon_options_foreach_fn fn,
                void *user_data);
 
 
@@ -79,9 +79,9 @@ void iotcon_query_free(iotcon_query_h query);
 int iotcon_query_insert(iotcon_query_h query, const char *key, const char *value);
 int iotcon_query_delete(iotcon_query_h query, const char *key);
 const char* iotcon_query_lookup(iotcon_query_h query, const char *key);
-typedef int (*iotcon_query_foreach_cb)(const char *key, const char *value,
+typedef int (*iotcon_query_foreach_fn)(const char *key, const char *value,
                void *user_data);
-int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb,
+int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_fn fn,
                void *user_data);
 
 
@@ -101,9 +101,9 @@ iotcon_resource_types_h iotcon_resource_types_new();
 void iotcon_resource_types_free(iotcon_resource_types_h types);
 int iotcon_resource_types_insert(iotcon_resource_types_h types, const char *type);
 int iotcon_resource_types_delete(iotcon_resource_types_h types, const char *type);
-typedef int (*iotcon_resource_types_foreach_cb)(const char *type, void *user_data);
+typedef int (*iotcon_resource_types_foreach_fn)(const char *type, void *user_data);
 int iotcon_resource_types_foreach(iotcon_resource_types_h types,
-               iotcon_resource_types_foreach_cb cb, void *user_data);
+               iotcon_resource_types_foreach_fn fn, void *user_data);
 iotcon_resource_types_h iotcon_resource_types_clone(iotcon_resource_types_h types);
 
 
index 672aa59..873613a 100644 (file)
@@ -209,7 +209,7 @@ static void _request_handler_delete(iotcon_response_h response)
        iotcon_repr_free(resp_repr);
 }
 
-static int _query_cb(const char *key, const char *value, void *user_data)
+static int _query_fn(const char *key, const char *value, void *user_data)
 {
        INFO("key : %s", key);
        INFO("value : %s", value);
@@ -234,7 +234,7 @@ static void _request_handler(iotcon_request_h request, void *user_data)
                return;
        }
        if (query)
-               iotcon_query_foreach(query, _query_cb, NULL);
+               iotcon_query_foreach(query, _query_fn, NULL);
 
        ret = iotcon_request_get_types(request, &types);
        if (IOTCON_ERROR_NONE != ret) {
index fa90986..b298b76 100644 (file)
@@ -46,7 +46,7 @@ static void _light_request_handler_get(iotcon_response_h response)
        iotcon_repr_free(resp_repr);
 }
 
-static int _query_foreach_cb(const char *key, const char *value, void *user_data)
+static int _query_foreach_fn(const char *key, const char *value, void *user_data)
 {
        char **interface_str = user_data;
 
@@ -110,7 +110,7 @@ static void _room_request_handler_get(iotcon_request_h request,
                return;
        }
        if (query)
-               iotcon_query_foreach(query, _query_foreach_cb, &query_str);
+               iotcon_query_foreach(query, _query_foreach_fn, &query_str);
 
        if (query_str && (TEST_STR_EQUAL == strcmp("oc.mi.b", query_str))) {
                DBG("operation for BATCH interface");