unsubscribe signal when unregister resource and unsubscribe presence
authoryoungman <yman.jung@samsung.com>
Tue, 23 Jun 2015 06:11:06 +0000 (15:11 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:06:25 +0000 (20:06 +0900)
Change-Id: I6a09c11a87716aee0675be332f6ba8386db3d14a
Signed-off-by: youngman <yman.jung@samsung.com>
26 files changed:
daemon/icd-ioty.cpp
lib/icl-client.c
lib/icl-client.h
lib/icl-dbus-type.c
lib/icl-dbus-type.h
lib/icl-dbus.c
lib/icl-dbus.h
lib/icl-ioty.h
lib/icl-options.c
lib/icl-options.h
lib/icl-query.c
lib/icl-query.h
lib/icl-repr-list.c
lib/icl-repr-list.h
lib/icl-repr-obj.c
lib/icl-repr-value.c
lib/icl-repr-value.h
lib/icl-repr.c
lib/icl-repr.h
lib/icl-request.h
lib/icl-resource-types.c
lib/icl-resource-types.h
lib/icl-response.c
lib/icl-response.h
lib/icl.c
lib/include/iotcon-struct.h

index 64f213b78010e3b7fbe3ac7b7b8f4c3ab0a833b9..b53aa916cad43038584bc66c299dc3e2982ba413 100644 (file)
@@ -934,7 +934,7 @@ extern "C" int icd_ioty_find_resource(const char *host_address, const char *reso
        else
                resource_name << host_address << ICD_UNICAST_RESOURCE_DISCOVERY;
 
-       if (resource_type)
+       if (IC_STR_EQUAL != strcmp(resource_type, IC_STR_NULL))
                resource_name << "?rt=" << resource_type;
 
        shared_ptr<icdIotivityHandler::findObject> object
index b7e6a00836d7740cefd0827110f38fe4dbcf8cea..b6ab977c9452c996c08b68a01056917901c5f243 100644 (file)
@@ -62,7 +62,7 @@ API iotcon_client_h iotcon_client_new(const char *host, const char *uri,
        RETV_IF(NULL == uri, NULL);
        RETV_IF(NULL == resource_types, NULL);
 
-       resource = calloc(1, sizeof(struct ic_remote_resource));
+       resource = calloc(1, sizeof(struct icl_remote_resource));
        if (NULL == resource) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
index 534e19c324b004f0e1a2b4daf9531d0525911fe3..669deba2299295cda8328b7854d2f610003a86a7 100644 (file)
@@ -19,7 +19,7 @@
 #include "iotcon-struct.h"
 #include "icl-options.h"
 
-struct ic_remote_resource {
+struct icl_remote_resource {
        char *uri;
        char *host;
        bool is_observable;
index 9b11a3e5dc82486cff8d527e5137b93a8e24cb5a..270abb95d701bb6b5d64f934c00d0ad339cdb4c0 100644 (file)
@@ -51,7 +51,7 @@ const char** icl_dbus_resource_types_to_array(iotcon_resource_types_h types)
 }
 
 
-GVariant* icl_dbus_notimsg_to_gvariant(struct ic_notify_msg *msg)
+GVariant* icl_dbus_notimsg_to_gvariant(struct icl_notify_msg *msg)
 {
        char *repr_json = NULL;
        GVariant *value;
@@ -77,7 +77,7 @@ GVariant* icl_dbus_notimsg_to_gvariant(struct ic_notify_msg *msg)
 }
 
 
-GVariant* icl_dbus_response_to_gvariant(struct ic_resource_response *response)
+GVariant* icl_dbus_response_to_gvariant(struct icl_resource_response *response)
 {
        GHashTableIter iter;
        GVariantBuilder *options;
@@ -108,7 +108,7 @@ GVariant* icl_dbus_response_to_gvariant(struct ic_resource_response *response)
 }
 
 
-GVariant* icl_dbus_client_to_gvariant(struct ic_remote_resource *resource)
+GVariant* icl_dbus_client_to_gvariant(struct icl_remote_resource *resource)
 {
        FN_CALL;
        GVariant *value;
index f01d7fabf486ce2d9652d39541c2ea9047b0cdd6..9017f593f3bd450fa394e31600ec6b56b8e732db 100644 (file)
@@ -21,9 +21,9 @@
 #include "icl-resource-types.h"
 
 const char** icl_dbus_resource_types_to_array(iotcon_resource_types_h types);
-GVariant* icl_dbus_notimsg_to_gvariant(struct ic_notify_msg *msg);
-GVariant* icl_dbus_response_to_gvariant(struct ic_resource_response *response);
-GVariant* icl_dbus_client_to_gvariant(struct ic_remote_resource *resource);
+GVariant* icl_dbus_notimsg_to_gvariant(struct icl_notify_msg *msg);
+GVariant* icl_dbus_response_to_gvariant(struct icl_resource_response *response);
+GVariant* icl_dbus_client_to_gvariant(struct icl_remote_resource *resource);
 GVariant* icl_dbus_device_info_to_gvariant(iotcon_device_info_s *device_info);
 GVariant* icl_dbus_query_to_gvariant(iotcon_query_h query);
 GVariant* icl_dbus_observers_to_gvariant(iotcon_observers_h observers);
index c47b084d4fa8a3804cbc1d931ee95bc4e002cd3e..66906dcbfdcd453603925aec7cb480e6177211ff 100644 (file)
@@ -38,6 +38,7 @@ typedef struct {
        unsigned int id;
 } icl_cb_container_s;
 
+
 static inline unsigned int _icl_dbus_generate_signal_number()
 {
        static unsigned int i = 0;
@@ -74,7 +75,8 @@ static inline void _icl_dbus_unref()
 }
 
 
-int _dbus_subscribe_signal(char *sig_name, void *cb, void *user_data, void *sig_handler)
+static unsigned int _icl_dbus_subscribe_signal(char *sig_name, void *cb, void *user_data,
+               GDBusSignalCallback sig_handler)
 {
        unsigned int id;
        icl_cb_container_s *cb_container;
@@ -82,7 +84,7 @@ int _dbus_subscribe_signal(char *sig_name, void *cb, void *user_data, void *sig_
        cb_container = calloc(1, sizeof(icl_cb_container_s));
        if (NULL == cb_container) {
                ERR("calloc() Fail(%d)", errno);
-               return IOTCON_ERROR_OUT_OF_MEMORY;
+               return 0;
        }
        cb_container->cb = cb;
        cb_container->user_data = user_data;
@@ -99,12 +101,13 @@ int _dbus_subscribe_signal(char *sig_name, void *cb, void *user_data, void *sig_
                        free);
        if (0 == id) {
                ERR("g_dbus_connection_signal_subscribe() Fail");
-               return IOTCON_ERROR_DBUS;
+               free(cb_container);
+               return id;
        }
 
        cb_container->id = id;
 
-       return IOTCON_ERROR_NONE;
+       return id;
 }
 
 
@@ -130,7 +133,7 @@ static void _icl_dbus_request_handler(GDBusConnection *connection,
        char *repr_uri;
        int request_handle;
        int resource_handle;
-       struct ic_resource_request request = {0};
+       struct icl_resource_request request = {0};
        icl_cb_container_s *cb_container = user_data;
        iotcon_request_handler_cb cb = cb_container->cb;
 
@@ -197,23 +200,35 @@ static void _icl_dbus_request_handler(GDBusConnection *connection,
 }
 
 
-void* icl_dbus_register_resource(const char *uri, iotcon_resource_types_h types,
-               int ifaces, uint8_t properties, iotcon_request_handler_cb cb, void *user_data)
+icl_handle_container_s* icl_dbus_register_resource(const char *uri,
+               iotcon_resource_types_h types,
+               int ifaces,
+               uint8_t properties,
+               iotcon_request_handler_cb cb,
+               void *user_data)
 {
-       int ret;
        int signal_number;
+       unsigned int subscription_id;
        int resource_handle;
        GError *error = NULL;
        const gchar **res_types;
        char sig_name[IC_DBUS_SIGNAL_LENGTH];
+       icl_handle_container_s *handle_container;
 
        RETV_IF(NULL == icl_dbus_object, NULL);
 
        signal_number = _icl_dbus_generate_signal_number();
 
+       handle_container = calloc(1, sizeof(icl_handle_container_s));
+       if (NULL == handle_container) {
+               ERR("calloc() Fail(%d)", errno);
+               return NULL;
+       }
+
        res_types = icl_dbus_resource_types_to_array(types);
        if (NULL == res_types) {
                ERR("icl_dbus_resource_types_to_array() Fail");
+               free(handle_container);
                return NULL;
        }
 
@@ -223,25 +238,30 @@ void* icl_dbus_register_resource(const char *uri, iotcon_resource_types_h types,
                ERR("ic_dbus_call_register_resource_sync() Fail(%s)", error->message);
                g_error_free(error);
                free(res_types);
+               free(handle_container);
                return NULL;
        }
+       free(res_types);
 
        snprintf(sig_name, sizeof(sig_name), "%s_%u", IC_DBUS_SIGNAL_REQUEST_HANDLER,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(sig_name, cb, user_data, _icl_dbus_request_handler);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
-               free(res_types);
+       subscription_id = _icl_dbus_subscribe_signal(sig_name, cb, user_data,
+                       _icl_dbus_request_handler);
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
+               free(handle_container);
                return NULL;
        }
 
-       free(res_types);
-       return GINT_TO_POINTER(resource_handle);
+       handle_container->handle = resource_handle;
+       handle_container->id = subscription_id;
+
+       return handle_container;
 }
 
 
-int icl_dbus_unregister_resource(void *resource)
+int icl_dbus_unregister_resource(icl_handle_container_s *resource)
 {
        FN_CALL;
        int ret;
@@ -249,27 +269,30 @@ int icl_dbus_unregister_resource(void *resource)
 
        RETV_IF(NULL == icl_dbus_object, IOTCON_ERROR_DBUS);
 
-       ic_dbus_call_unregister_resource_sync(icl_dbus_object,
-                       GPOINTER_TO_INT(resource), &ret, NULL, &error);
+       ic_dbus_call_unregister_resource_sync(icl_dbus_object, resource->handle, &ret,
+                       NULL, &error);
        if (error) {
                ERR("ic_dbus_call_unregister_resource_sync() Fail(%s)", error->message);
                g_error_free(error);
                return IOTCON_ERROR_DBUS;
        }
 
+       g_dbus_connection_signal_unsubscribe(icl_dbus_conn, resource->id);
+       free(resource);
+
        return ret;
 }
 
 
-int icl_dbus_bind_interface(void *resource, int iface)
+int icl_dbus_bind_interface(icl_handle_container_s *resource, int iface)
 {
        int ret;
        GError *error = NULL;
 
        RETV_IF(NULL == icl_dbus_object, IOTCON_ERROR_DBUS);
 
-       ic_dbus_call_bind_interface_sync(icl_dbus_object, GPOINTER_TO_INT(resource),
-                       iface, &ret, NULL, &error);
+       ic_dbus_call_bind_interface_sync(icl_dbus_object, resource->handle, iface, &ret,
+                       NULL, &error);
        if (error) {
                ERR("ic_dbus_call_bind_interface_sync() Fail(%s)", error->message);
                g_error_free(error);
@@ -280,15 +303,15 @@ int icl_dbus_bind_interface(void *resource, int iface)
 }
 
 
-int icl_dbus_bind_type(void *resource, const char *type)
+int icl_dbus_bind_type(icl_handle_container_s *resource, const char *type)
 {
        int ret;
        GError *error = NULL;
 
        RETV_IF(NULL == icl_dbus_object, IOTCON_ERROR_DBUS);
 
-       ic_dbus_call_bind_type_sync(icl_dbus_object, GPOINTER_TO_INT(resource),
-                       type, &ret, NULL, &error);
+       ic_dbus_call_bind_type_sync(icl_dbus_object, resource->handle, type, &ret, NULL,
+                       &error);
        if (error) {
                ERR("ic_dbus_call_bind_type_sync() Fail(%s)", error->message);
                g_error_free(error);
@@ -299,15 +322,15 @@ int icl_dbus_bind_type(void *resource, const char *type)
 }
 
 
-int icl_dbus_bind_resource(void *parent, void *child)
+int icl_dbus_bind_resource(icl_handle_container_s *parent, icl_handle_container_s *child)
 {
        int ret;
        GError *error = NULL;
 
        RETV_IF(NULL == icl_dbus_object, IOTCON_ERROR_DBUS);
 
-       ic_dbus_call_bind_resource_sync(icl_dbus_object, GPOINTER_TO_INT(parent),
-                       GPOINTER_TO_INT(child), &ret, NULL, &error);
+       ic_dbus_call_bind_resource_sync(icl_dbus_object, parent->handle, child->handle,
+                       &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_bind_resource_sync() Fail(%s)", error->message);
                g_error_free(error);
@@ -318,15 +341,16 @@ int icl_dbus_bind_resource(void *parent, void *child)
 }
 
 
-int icl_dbus_unbind_resource(void *parent, void *child)
+int icl_dbus_unbind_resource(icl_handle_container_s *parent,
+               icl_handle_container_s *child)
 {
        int ret;
        GError *error = NULL;
 
        RETV_IF(NULL == icl_dbus_object, IOTCON_ERROR_DBUS);
 
-       ic_dbus_call_unbind_resource_sync(icl_dbus_object, GPOINTER_TO_INT(parent),
-                       GPOINTER_TO_INT(child), &ret, NULL, &error);
+       ic_dbus_call_unbind_resource_sync(icl_dbus_object, parent->handle, child->handle,
+                       &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_unbind_resource_sync() Fail(%s)", error->message);
                g_error_free(error);
@@ -337,8 +361,8 @@ int icl_dbus_unbind_resource(void *parent, void *child)
 }
 
 
-int icl_dbus_notify_list_of_observers(void *resource, struct ic_notify_msg *msg,
-               iotcon_observers_h observers)
+int icl_dbus_notify_list_of_observers(icl_handle_container_s *resource,
+               struct icl_notify_msg *msg, iotcon_observers_h observers)
 {
        int ret;
        GError *error = NULL;
@@ -354,7 +378,7 @@ int icl_dbus_notify_list_of_observers(void *resource, struct ic_notify_msg *msg,
        }
        obs = icl_dbus_observers_to_gvariant(observers);
 
-       ic_dbus_call_notify_list_of_observers_sync(icl_dbus_object, GPOINTER_TO_INT(resource),
+       ic_dbus_call_notify_list_of_observers_sync(icl_dbus_object, resource->handle,
                        noti_msg, obs, &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_notify_list_of_observers_sync() Fail(%s)", error->message);
@@ -368,15 +392,14 @@ int icl_dbus_notify_list_of_observers(void *resource, struct ic_notify_msg *msg,
 }
 
 
-int icl_dbus_notify_all(void *resource)
+int icl_dbus_notify_all(icl_handle_container_s *resource)
 {
        int ret;
        GError *error = NULL;
 
        RETV_IF(NULL == icl_dbus_object, IOTCON_ERROR_DBUS);
 
-       ic_dbus_call_notify_all_sync(icl_dbus_object, GPOINTER_TO_INT(resource), &ret, NULL,
-                       &error);
+       ic_dbus_call_notify_all_sync(icl_dbus_object, resource->handle, &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_notify_all_sync() Fail(%s)", error->message);
                g_error_free(error);
@@ -387,7 +410,7 @@ int icl_dbus_notify_all(void *resource)
 }
 
 
-int icl_dbus_send_response(struct ic_resource_response *response)
+int icl_dbus_send_response(struct icl_resource_response *response)
 {
        int ret;
        GError *error = NULL;
@@ -424,7 +447,7 @@ static void _icl_dbus_found_resource(GDBusConnection *connection,
        icl_cb_container_s *cb_container = user_data;
        iotcon_found_resource_cb cb = cb_container->cb;
 
-       struct ic_remote_resource resource = {0};
+       struct icl_remote_resource resource = {0};
 
        g_variant_get(parameters, "(&s&siasi)",
                        &resource.uri,
@@ -452,6 +475,7 @@ int icl_dbus_find_resource(const char *host_address, const char *resource_type,
                iotcon_found_resource_cb cb, void *user_data)
 {
        int ret;
+       unsigned int subscription_id;
        int signal_number;
        char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
        GError *error = NULL;
@@ -460,8 +484,8 @@ int icl_dbus_find_resource(const char *host_address, const char *resource_type,
 
        signal_number = _icl_dbus_generate_signal_number();
 
-       ic_dbus_call_find_resource_sync(icl_dbus_object, host_address, resource_type,
-                       signal_number, &ret, NULL, &error);
+       ic_dbus_call_find_resource_sync(icl_dbus_object, host_address,
+                       ic_utils_dbus_encode_str(resource_type), signal_number, &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_find_resource_sync() Fail(%s)", error->message);
                g_error_free(error);
@@ -471,9 +495,10 @@ int icl_dbus_find_resource(const char *host_address, const char *resource_type,
        snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_FOUND_RESOURCE,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(signal_name, cb, user_data, _icl_dbus_found_resource);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
+       subscription_id = _icl_dbus_subscribe_signal(signal_name, cb, user_data,
+                       _icl_dbus_found_resource);
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
                return IOTCON_ERROR_DBUS;
        }
 
@@ -551,6 +576,7 @@ int icl_dbus_get(iotcon_client_h resource, iotcon_query_h query,
 {
        int ret;
        GError *error = NULL;
+       unsigned int subscription_id;
        int signal_number;
        char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
        GVariant *arg_client;
@@ -575,9 +601,9 @@ int icl_dbus_get(iotcon_client_h resource, iotcon_query_h query,
        snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_GET,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(signal_name, cb, user_data, _icl_dbus_on_cru);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
+       subscription_id = _icl_dbus_subscribe_signal(signal_name, cb, user_data, _icl_dbus_on_cru);
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
                return IOTCON_ERROR_DBUS;
        }
 
@@ -590,6 +616,7 @@ int icl_dbus_put(iotcon_client_h resource, iotcon_repr_h repr,
 {
        int ret;
        GError *error = NULL;
+       unsigned int subscription_id;
        int signal_number;
        char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
        char *arg_repr;
@@ -623,9 +650,10 @@ int icl_dbus_put(iotcon_client_h resource, iotcon_repr_h repr,
        snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_PUT,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(signal_name, cb, user_data, _icl_dbus_on_cru);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
+       subscription_id = _icl_dbus_subscribe_signal(signal_name, cb, user_data,
+                       _icl_dbus_on_cru);
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
                free(arg_repr);
                return IOTCON_ERROR_DBUS;
        }
@@ -641,6 +669,7 @@ int icl_dbus_post(iotcon_client_h resource, iotcon_repr_h repr,
 {
        int ret;
        GError *error = NULL;
+       unsigned int subscription_id;
        int signal_number;
        char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
        char *arg_repr;
@@ -674,9 +703,10 @@ int icl_dbus_post(iotcon_client_h resource, iotcon_repr_h repr,
        snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_POST,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(signal_name, cb, user_data, _icl_dbus_on_cru);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
+       subscription_id = _icl_dbus_subscribe_signal(signal_name, cb, user_data,
+                       _icl_dbus_on_cru);
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
                free(arg_repr);
                return IOTCON_ERROR_DBUS;
        }
@@ -728,6 +758,7 @@ int icl_dbus_delete(iotcon_client_h resource, iotcon_on_delete_cb cb,
 {
        int ret;
        GError *error = NULL;
+       unsigned int subscription_id;
        int signal_number;
        char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
        GVariant *arg_client;
@@ -750,9 +781,10 @@ int icl_dbus_delete(iotcon_client_h resource, iotcon_on_delete_cb cb,
        snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_DELETE,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(signal_name, cb, user_data, _icl_dbus_on_delete);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
+       subscription_id = _icl_dbus_subscribe_signal(signal_name, cb, user_data,
+                       _icl_dbus_on_delete);
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
                return IOTCON_ERROR_DBUS;
        }
 
@@ -833,6 +865,7 @@ int icl_dbus_observer_start(iotcon_client_h resource,
        int ret;
        int observe_h;
        GError *error = NULL;
+       unsigned int subscription_id;
        int signal_number;
        char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
        GVariant *arg_client;
@@ -860,9 +893,10 @@ int icl_dbus_observer_start(iotcon_client_h resource,
        snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_OBSERVE,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(signal_name, cb, user_data, _icl_dbus_on_observe);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
+       subscription_id = _icl_dbus_subscribe_signal(signal_name, cb, user_data,
+                       _icl_dbus_on_observe);
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
                return IOTCON_ERROR_DBUS;
        }
 
@@ -963,6 +997,7 @@ int icl_dbus_get_device_info(const char *host_address, iotcon_device_info_cb cb,
 {
        int ret;
        GError *error = NULL;
+       unsigned int subscription_id;
        int signal_number;
        char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
 
@@ -981,10 +1016,10 @@ int icl_dbus_get_device_info(const char *host_address, iotcon_device_info_cb cb,
        snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_DEVICE,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(signal_name, cb, user_data,
+       subscription_id = _icl_dbus_subscribe_signal(signal_name, cb, user_data,
                        _icl_dbus_received_device_info);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
                return IOTCON_ERROR_DBUS;
        }
 
@@ -1051,48 +1086,61 @@ static void _icl_dbus_presence_handler(GDBusConnection *connection,
 }
 
 
-void* icl_dbus_subscribe_presence(const char *host_address,
+icl_handle_container_s* icl_dbus_subscribe_presence(const char *host_address,
                const char *type, iotcon_presence_cb cb, void *user_data)
 {
-       int ret;
        int presence_h;
        GError *error = NULL;
+       unsigned int subscription_id;
        int signal_number;
        char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
+       icl_handle_container_s *handle_container;
 
        RETV_IF(NULL == icl_dbus_object, NULL);
 
        signal_number = _icl_dbus_generate_signal_number();
 
+       handle_container = calloc(1, sizeof(icl_handle_container_s));
+       if (NULL == handle_container) {
+               ERR("calloc() Fail(%d)", errno);
+               return NULL;
+       }
+
        ic_dbus_call_subscribe_presence_sync(icl_dbus_object, host_address, type,
                        signal_number, &presence_h, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_subscribe_presence_sync() Fail(%s)", error->message);
                g_error_free(error);
+               free(handle_container);
                return NULL;
        }
 
        snprintf(signal_name, sizeof(signal_name), "%s_%u", IC_DBUS_SIGNAL_PRESENCE,
                        signal_number);
 
-       ret = _dbus_subscribe_signal(signal_name, cb, user_data, _icl_dbus_presence_handler);
-       if (IOTCON_ERROR_NONE != ret) {
-               ERR("_dbus_subscribe_signal() Fail");
+       subscription_id = _icl_dbus_subscribe_signal(signal_name, cb, user_data,
+                       _icl_dbus_presence_handler);
+       if (0 == subscription_id) {
+               ERR("_icl_dbus_subscribe_signal() Fail");
+               free(handle_container);
                return NULL;
        }
 
-       return GINT_TO_POINTER(presence_h);
+       handle_container->handle = presence_h;
+       handle_container->id = subscription_id;
+
+       return handle_container;
 }
 
 
-int icl_dbus_unsubscribe_presence(void *presence_h)
+int icl_dbus_unsubscribe_presence(icl_handle_container_s *presence_h)
 {
        int ret;
        GError *error = NULL;
 
        RETV_IF(NULL == icl_dbus_object, IOTCON_ERROR_DBUS);
 
-       ic_dbus_call_unsubscribe_presence_sync(icl_dbus_object, GPOINTER_TO_INT(presence_h),
+       ic_dbus_call_unsubscribe_presence_sync(icl_dbus_object, presence_h->handle,
                        &ret, NULL, &error);
        if (error) {
                ERR("ic_dbus_call_unsubscribe_presence_sync() Fail(%s)", error->message);
@@ -1100,9 +1148,8 @@ int icl_dbus_unsubscribe_presence(void *presence_h)
                return IOTCON_ERROR_DBUS;
        }
 
-       /* how to unsubscribe
-        * g_dbus_connection_signal_unsubscribe(icl_dbus_conn, );
-        */
+       g_dbus_connection_signal_unsubscribe(icl_dbus_conn, presence_h->id);
+       free(presence_h);
 
        return ret;
 }
index e73fcb3c6e674649f0f0721a04782fdf11ab9b32..9c9d8d9eb9da5cfe6b891fa02e609418090e5f54 100644 (file)
 #ifndef __IOT_CONNECTIVITY_MANAGER_DBUS_H__
 #define __IOT_CONNECTIVITY_MANAGER_DBUS_H__
 
+typedef struct {
+       int handle;
+       unsigned int id;
+} icl_handle_container_s;
+
 int icl_dbus_config(const char *address, unsigned short port);
-void* icl_dbus_register_resource(const char *uri, iotcon_resource_types_h types,
-               int ifaces, uint8_t properties, iotcon_request_handler_cb cb, void *user_data);
-int icl_dbus_unregister_resource(void *resource);
+icl_handle_container_s* icl_dbus_register_resource(const char *uri,
+               iotcon_resource_types_h types,
+               int ifaces,
+               uint8_t properties,
+               iotcon_request_handler_cb cb,
+               void *user_data);
+int icl_dbus_unregister_resource(icl_handle_container_s *resource);
 
-int icl_dbus_bind_interface(void *resource, int iface);
-int icl_dbus_bind_type(void *resource, const char *type);
-int icl_dbus_bind_resource(void *parent, void *child);
-int icl_dbus_unbind_resource(void *parent, void *child);
+int icl_dbus_bind_interface(icl_handle_container_s *resource, int iface);
+int icl_dbus_bind_type(icl_handle_container_s *resource, const char *type);
+int icl_dbus_bind_resource(icl_handle_container_s *parent,
+               icl_handle_container_s *child);
+int icl_dbus_unbind_resource(icl_handle_container_s *parent,
+               icl_handle_container_s *child);
 
-int icl_dbus_notify_list_of_observers(void *resource, struct ic_notify_msg *msg,
-               iotcon_observers_h observers);
-int icl_dbus_notify_all(void *resource);
-int icl_dbus_send_response(struct ic_resource_response *response);
+int icl_dbus_notify_list_of_observers(icl_handle_container_s *resource,
+               struct icl_notify_msg *msg, iotcon_observers_h observers);
+int icl_dbus_notify_all(icl_handle_container_s *resource);
+int icl_dbus_send_response(struct icl_resource_response *response);
 
 int icl_dbus_find_resource(const char *host_address, const char *resource_type,
                iotcon_found_resource_cb found_resource_cb, void *user_data);
@@ -55,9 +66,9 @@ int icl_dbus_get_device_info(const char *host_address, iotcon_device_info_cb cb,
 
 int icl_dbus_start_presence(unsigned int time_to_live);
 int icl_dbus_stop_presence();
-void* icl_dbus_subscribe_presence(const char *host_address, const char *type,
-               iotcon_presence_cb cb, void *user_data);
-int icl_dbus_unsubscribe_presence(void *presence_h);
+icl_handle_container_s* icl_dbus_subscribe_presence(const char *host_address,
+               const char *type, iotcon_presence_cb cb, void *user_data);
+int icl_dbus_unsubscribe_presence(icl_handle_container_s *presence_h);
 
 unsigned int icl_dbus_start();
 void icl_dbus_stop();
index 04a8e34a8dd3e7492cd8690c155f2f18019e1377..73d66234c11b62d051f518e840279e2debf79f77 100644 (file)
 #define __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_H__
 
 #include "iotcon.h"
+#include "icl-dbus.h"
 
-struct ic_notify_msg {
+struct icl_notify_msg {
        int error_code;
        iotcon_interface_e iface;
        iotcon_repr_h repr;
 };
 
-struct ic_resource {
+struct icl_resource {
        char *uri;
        char *host;
        bool is_observable;
        iotcon_resource_types_h types;
        int ifaces;
-       void *handle;
+       icl_handle_container_s *handle;
        iotcon_request_handler_cb cb;
        void *user_data;
        iotcon_resource_h children[IOTCON_CONTAINED_RESOURCES_MAX];
index e4e85ee3ed7b50c42adc7b9cef48ffbbf57e5eb9..df74693fea897abe0ec4f9aa58d779b79af57c2a 100644 (file)
@@ -36,7 +36,7 @@ iotcon_options_h icl_options_ref(iotcon_options_h options)
 
 API iotcon_options_h iotcon_options_new()
 {
-       iotcon_options_h options = calloc(1, sizeof(struct ic_options));
+       iotcon_options_h options = calloc(1, sizeof(struct icl_options));
        if (NULL == options) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
index 47cdfdb7247a78dc59ddcf77c16b9416b5c01cc9..8069546c97a3bf1ddceaf8889d4e66c08d7b6b82 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "iotcon-struct.h"
 
-struct ic_options {
+struct icl_options {
        int ref_count;
        GHashTable *hash;
 };
index 4eba31b0382fdb14429b9dce867c2ecfb0c9b6ed..a4f61ae28937aa3afeeafe3e60784088056f2151 100644 (file)
@@ -26,7 +26,7 @@
 
 API iotcon_query_h iotcon_query_new()
 {
-       iotcon_query_h query = calloc(1, sizeof(struct ic_query));
+       iotcon_query_h query = calloc(1, sizeof(struct icl_query));
        if (NULL == query) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
index 873c1a58a39c3c6edaed5e32fb9c81a1f0f7502c..09324d8fe095de0918535f78a63fa3a5aa81a02e 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "iotcon-struct.h"
 
-struct ic_query {
+struct icl_query {
        int len;
        GHashTable *hash;
 };
index a1ff4d5ceee36ae4f325d4bf235f3c117b76a23f..d4e299b45d838bc630ac35b33563a50d2032e402 100644 (file)
@@ -55,7 +55,7 @@ static iotcon_list_h _icl_list_new(iotcon_types_e type)
 {
        iotcon_list_h list;
 
-       list = calloc(1, sizeof(struct ic_list_s));
+       list = calloc(1, sizeof(struct icl_list_s));
        if (NULL == list) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
@@ -374,13 +374,13 @@ static int _icl_list_del_nth_value(iotcon_list_h list, int pos, iotcon_types_e v
        }
 
        if (IOTCON_TYPE_STR == value->type) {
-               ic_basic_s *real = (ic_basic_s*)value;
+               icl_basic_s *real = (icl_basic_s*)value;
                free(real->val.s);
        } else if (IOTCON_TYPE_LIST == value->type) {
-               ic_val_list_s *real = (ic_val_list_s*)value;
+               icl_val_list_s *real = (icl_val_list_s*)value;
                iotcon_list_free(real->list);
        } else if (IOTCON_TYPE_REPR == value->type) {
-               ic_val_repr_s *real = (ic_val_repr_s*)value;
+               icl_val_repr_s *real = (icl_val_repr_s*)value;
                iotcon_repr_free(real->repr);
        }
 
@@ -505,7 +505,7 @@ API int iotcon_list_foreach_int(iotcon_list_h list, iotcon_list_int_fn fn,
 {
        GList *cur;
        int index = 0;
-       ic_basic_s *real = NULL;
+       icl_basic_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)",
@@ -530,7 +530,7 @@ API int iotcon_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_fn fn,
 {
        GList *cur;
        int index = 0;
-       ic_basic_s *real = NULL;
+       icl_basic_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_TYPE,
@@ -555,7 +555,7 @@ API int iotcon_list_foreach_double(iotcon_list_h list, iotcon_list_double_fn fn,
 {
        GList *cur;
        int index = 0;
-       ic_basic_s *real = NULL;
+       icl_basic_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_TYPE,
@@ -580,7 +580,7 @@ API int iotcon_list_foreach_str(iotcon_list_h list, iotcon_list_str_fn fn,
 {
        GList *cur;
        int index = 0;
-       ic_basic_s *real = NULL;
+       icl_basic_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)",
@@ -605,7 +605,7 @@ API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_fn fn,
 {
        int index = 0;
        GList *cur = NULL;
-       ic_val_list_s *real = NULL;
+       icl_val_list_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_INVALID_TYPE,
@@ -629,7 +629,7 @@ API int iotcon_list_foreach_repr(iotcon_list_h list, iotcon_list_repr_fn fn, voi
 {
        int index = 0;
        GList *cur = NULL;
-       ic_val_repr_s *real = NULL;
+       icl_val_repr_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_INVALID_TYPE,
@@ -763,7 +763,7 @@ iotcon_list_h icl_list_from_json(JsonArray *parray)
                                return NULL;
                        }
 
-                       ic_basic_s *real = (ic_basic_s*)value;
+                       icl_basic_s *real = (icl_basic_s*)value;
                        if (IOTCON_TYPE_NONE != list->type && list->type != real->type) {
                                ERR("Type matching Fail(list:%d,value:%d)", list->type, real->type);
                                icl_value_free(value);
index 3327bc16a7ccf440f8dbb5b5455552d09c5de95a..5a877739337e530aa5f8fb252640d6b997a27278 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "iotcon-struct.h"
 
-struct ic_list_s {
+struct icl_list_s {
        int type;
        int ref_count;
        GList *list;
index f3ea1acce361caf8485234bed73e11da6e841ac5..ce2f30b1e1cc8ac7f116e17ef2babe34df682b66 100644 (file)
@@ -68,7 +68,7 @@ API int iotcon_repr_get_int(iotcon_repr_h repr, const char *key, int *val)
                return IOTCON_ERROR_NO_DATA;
        }
 
-       ic_basic_s *real = (ic_basic_s*)value;
+       icl_basic_s *real = (icl_basic_s*)value;
        if (IOTCON_TYPE_INT != real->type) {
                ERR("Invalid Type(%d)", real->type);
                return IOTCON_ERROR_INVALID_TYPE;
@@ -113,7 +113,7 @@ API int iotcon_repr_del_int(iotcon_repr_h repr, const char *key)
 
 API int iotcon_repr_get_bool(iotcon_repr_h repr, const char *key, bool *val)
 {
-       ic_basic_s *real = NULL;
+       icl_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
@@ -126,7 +126,7 @@ API int iotcon_repr_get_bool(iotcon_repr_h repr, const char *key, bool *val)
                return IOTCON_ERROR_NO_DATA;
        }
 
-       real = (ic_basic_s*)value;
+       real = (icl_basic_s*)value;
        if (IOTCON_TYPE_BOOL != real->type) {
                ERR("Invalid Type(%d)", real->type);
                return IOTCON_ERROR_INVALID_TYPE;
@@ -168,7 +168,7 @@ API int iotcon_repr_del_bool(iotcon_repr_h repr, const char *key)
 
 API int iotcon_repr_get_double(iotcon_repr_h repr, const char *key, double *val)
 {
-       ic_basic_s *real = NULL;
+       icl_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
@@ -181,7 +181,7 @@ API int iotcon_repr_get_double(iotcon_repr_h repr, const char *key, double *val)
                return IOTCON_ERROR_NO_DATA;
        }
 
-       real = (ic_basic_s*)value;
+       real = (icl_basic_s*)value;
        if (IOTCON_TYPE_DOUBLE != real->type) {
                ERR("Invalid Type(%d)", real->type);
                return IOTCON_ERROR_INVALID_TYPE;
@@ -226,7 +226,7 @@ API int iotcon_repr_del_double(iotcon_repr_h repr, const char *key)
 
 API int iotcon_repr_get_str(iotcon_repr_h repr, const char *key, char **val)
 {
-       ic_basic_s *real = NULL;
+       icl_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
@@ -239,7 +239,7 @@ API int iotcon_repr_get_str(iotcon_repr_h repr, const char *key, char **val)
                return IOTCON_ERROR_NO_DATA;
        }
 
-       real = (ic_basic_s*)value;
+       real = (icl_basic_s*)value;
        if (IOTCON_TYPE_STR != real->type) {
                ERR("Invalid Type(%d)", real->type);
                return IOTCON_ERROR_INVALID_TYPE;
@@ -285,7 +285,7 @@ API int iotcon_repr_del_str(iotcon_repr_h repr, const char *key)
 
 API bool iotcon_repr_is_null(iotcon_repr_h repr, const char *key)
 {
-       ic_basic_s *real = NULL;
+       icl_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
        RETV_IF(NULL == repr, false);
@@ -297,7 +297,7 @@ API bool iotcon_repr_is_null(iotcon_repr_h repr, const char *key)
                return false;
        }
 
-       real = (ic_basic_s*)value;
+       real = (icl_basic_s*)value;
 
        return (IOTCON_TYPE_NULL == real->type) ? true : false;
 }
@@ -337,7 +337,7 @@ API int iotcon_repr_del_null(iotcon_repr_h repr, const char *key)
 API int iotcon_repr_get_list(iotcon_repr_h repr, const char *key, iotcon_list_h *list)
 {
        iotcon_value_h value = NULL;
-       ic_val_list_s *real = NULL;
+       icl_val_list_s *real = NULL;
 
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
@@ -349,7 +349,7 @@ API int iotcon_repr_get_list(iotcon_repr_h repr, const char *key, iotcon_list_h
                return IOTCON_ERROR_NO_DATA;
        }
 
-       real = (ic_val_list_s*)value;
+       real = (icl_val_list_s*)value;
        if (IOTCON_TYPE_LIST != real->type) {
                ERR("Invalid Type(%d)", real->type);
                return IOTCON_ERROR_INVALID_TYPE;
@@ -397,7 +397,7 @@ API int iotcon_repr_del_list(iotcon_repr_h repr, const char *key)
 
 API int iotcon_repr_get_repr(iotcon_repr_h src, const char *key, iotcon_repr_h *dest)
 {
-       ic_val_repr_s *real = NULL;
+       icl_val_repr_s *real = NULL;
        iotcon_value_h value = NULL;
 
        RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
@@ -410,7 +410,7 @@ API int iotcon_repr_get_repr(iotcon_repr_h src, const char *key, iotcon_repr_h *
                return IOTCON_ERROR_NO_DATA;
        }
 
-       real = (ic_val_repr_s*)value;
+       real = (icl_val_repr_s*)value;
        if (IOTCON_TYPE_REPR != real->type) {
                ERR("Invalid Type(%d)", real->type);
                return IOTCON_ERROR_INVALID_TYPE;
index 78cfa4468f64b25c428232413abc3007de8b17ef..bb35920e3059849f56fce0eec1bf0ff6bf3896c0 100644 (file)
@@ -36,13 +36,13 @@ static iotcon_value_h _icl_value_new(int type)
        case IOTCON_TYPE_DOUBLE:
        case IOTCON_TYPE_STR:
        case IOTCON_TYPE_NULL:
-               ret_val = calloc(1, sizeof(ic_basic_s));
+               ret_val = calloc(1, sizeof(icl_basic_s));
                break;
        case IOTCON_TYPE_LIST:
-               ret_val = calloc(1, sizeof(ic_val_list_s));
+               ret_val = calloc(1, sizeof(icl_val_list_s));
                break;
        case IOTCON_TYPE_REPR:
-               ret_val = calloc(1, sizeof(ic_val_repr_s));
+               ret_val = calloc(1, sizeof(icl_val_repr_s));
                break;
        default:
                ERR("Invalid Type(%d)", type);
@@ -75,9 +75,9 @@ iotcon_value_h icl_value_new_null()
 
 iotcon_value_h icl_value_new_int(int val)
 {
-       ic_basic_s *value;
+       icl_basic_s *value;
 
-       value = (ic_basic_s*)_icl_value_new(IOTCON_TYPE_INT);
+       value = (icl_basic_s*)_icl_value_new(IOTCON_TYPE_INT);
        if (NULL == value) {
                ERR("_icl_value_new(INT:%d) Fail", val);
                return NULL;
@@ -90,9 +90,9 @@ iotcon_value_h icl_value_new_int(int val)
 
 iotcon_value_h icl_value_new_bool(bool val)
 {
-       ic_basic_s *value;
+       icl_basic_s *value;
 
-       value = (ic_basic_s*)_icl_value_new(IOTCON_TYPE_BOOL);
+       value = (icl_basic_s*)_icl_value_new(IOTCON_TYPE_BOOL);
        if (NULL == value) {
                ERR("_icl_value_new(BOOL:%d) Fail", val);
                return NULL;
@@ -105,9 +105,9 @@ iotcon_value_h icl_value_new_bool(bool val)
 
 iotcon_value_h icl_value_new_double(double val)
 {
-       ic_basic_s *value;
+       icl_basic_s *value;
 
-       value = (ic_basic_s*)_icl_value_new(IOTCON_TYPE_DOUBLE);
+       value = (icl_basic_s*)_icl_value_new(IOTCON_TYPE_DOUBLE);
        if (NULL == value) {
                ERR("_icl_value_new(DOUBLE:%f) Fail", val);
                return NULL;
@@ -120,11 +120,11 @@ iotcon_value_h icl_value_new_double(double val)
 
 iotcon_value_h icl_value_new_str(char *val)
 {
-       ic_basic_s *value;
+       icl_basic_s *value;
 
        RETV_IF(NULL == val, NULL);
 
-       value = (ic_basic_s*)_icl_value_new(IOTCON_TYPE_STR);
+       value = (icl_basic_s*)_icl_value_new(IOTCON_TYPE_STR);
        if (NULL == value) {
                ERR("_icl_value_new(STR:%s) Fail", val);
                return NULL;
@@ -138,9 +138,9 @@ iotcon_value_h icl_value_new_str(char *val)
 
 iotcon_value_h icl_value_new_list(iotcon_list_h val)
 {
-       ic_val_list_s *value;
+       icl_val_list_s *value;
 
-       value = (ic_val_list_s*)_icl_value_new(IOTCON_TYPE_LIST);
+       value = (icl_val_list_s*)_icl_value_new(IOTCON_TYPE_LIST);
        if (NULL == value) {
                ERR("_icl_value_new(LIST) Fail");
                return NULL;
@@ -153,9 +153,9 @@ iotcon_value_h icl_value_new_list(iotcon_list_h val)
 
 iotcon_value_h icl_value_new_repr(iotcon_repr_h val)
 {
-       ic_val_repr_s *value;
+       icl_val_repr_s *value;
 
-       value = (ic_val_repr_s*)_icl_value_new(IOTCON_TYPE_REPR);
+       value = (icl_val_repr_s*)_icl_value_new(IOTCON_TYPE_REPR);
        if (NULL == value) {
                ERR("_icl_value_new(REPR) Fail");
                return NULL;
@@ -168,7 +168,7 @@ iotcon_value_h icl_value_new_repr(iotcon_repr_h val)
 
 int icl_value_get_int(iotcon_value_h value, int *val)
 {
-       ic_basic_s *real = (ic_basic_s*)value;
+       icl_basic_s *real = (icl_basic_s*)value;
 
        RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_INT != real->type, IOTCON_ERROR_INVALID_PARAMETER,
@@ -181,7 +181,7 @@ int icl_value_get_int(iotcon_value_h value, int *val)
 
 int icl_value_get_bool(iotcon_value_h value, bool *val)
 {
-       ic_basic_s *real = (ic_basic_s*)value;
+       icl_basic_s *real = (icl_basic_s*)value;
 
        RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_BOOL != real->type, IOTCON_ERROR_INVALID_PARAMETER,
@@ -194,7 +194,7 @@ int icl_value_get_bool(iotcon_value_h value, bool *val)
 
 int icl_value_get_double(iotcon_value_h value, double *val)
 {
-       ic_basic_s *real = (ic_basic_s*)value;
+       icl_basic_s *real = (icl_basic_s*)value;
 
        RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_DOUBLE != real->type, IOTCON_ERROR_INVALID_PARAMETER,
@@ -207,7 +207,7 @@ int icl_value_get_double(iotcon_value_h value, double *val)
 
 int icl_value_get_str(iotcon_value_h value, const char **val)
 {
-       ic_basic_s *real = (ic_basic_s*)value;
+       icl_basic_s *real = (icl_basic_s*)value;
 
        RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_STR != real->type, IOTCON_ERROR_INVALID_PARAMETER,
@@ -221,7 +221,7 @@ int icl_value_get_str(iotcon_value_h value, const char **val)
 
 int icl_value_get_list(iotcon_value_h value, iotcon_list_h *list)
 {
-       ic_val_list_s *real = (ic_val_list_s*)value;
+       icl_val_list_s *real = (icl_val_list_s*)value;
 
        RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_LIST != real->type, IOTCON_ERROR_INVALID_PARAMETER,
@@ -234,7 +234,7 @@ int icl_value_get_list(iotcon_value_h value, iotcon_list_h *list)
 
 int icl_value_get_repr(iotcon_value_h value, iotcon_repr_h *repr)
 {
-       ic_val_repr_s *real = (ic_val_repr_s*)value;
+       icl_val_repr_s *real = (icl_val_repr_s*)value;
 
        RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_TYPE_REPR != real->type, IOTCON_ERROR_INVALID_PARAMETER,
@@ -254,7 +254,7 @@ int icl_value_get_repr(iotcon_value_h value, iotcon_repr_h *repr)
 JsonNode* icl_value_to_json(iotcon_value_h value)
 {
        JsonNode *node;
-       ic_basic_s *real = (ic_basic_s*)value;
+       icl_basic_s *real = (icl_basic_s*)value;
 
        RETV_IF(NULL == value, NULL);
 
@@ -362,7 +362,7 @@ void icl_value_free(gpointer data)
        int type = value->type;
        switch (type) {
        case IOTCON_TYPE_STR:
-               free(((ic_basic_s*)value)->val.s);
+               free(((icl_basic_s*)value)->val.s);
        case IOTCON_TYPE_INT:
        case IOTCON_TYPE_BOOL:
        case IOTCON_TYPE_DOUBLE:
@@ -397,7 +397,7 @@ void icl_value_free(gpointer data)
 iotcon_value_h icl_value_clone(iotcon_value_h src)
 {
        iotcon_value_h dest = NULL;
-       ic_basic_s *real = (ic_basic_s*)src;
+       icl_basic_s *real = (icl_basic_s*)src;
 
        RETV_IF(NULL == src, NULL);
 
index 8b34e66b4df724e30a41f6afb254a7dc225b2fff..4e18d6d20653ee943d1adb19c8c5bbf01a4916a3 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "iotcon-struct.h"
 
-struct ic_value_s {
+struct icl_value_s {
        int type;
 };
 
@@ -33,17 +33,17 @@ typedef struct {
                double d;
                char *s;
        } val;
-} ic_basic_s;
+} icl_basic_s;
 
 typedef struct {
        int type;
-       struct ic_list_s *list;
-} ic_val_list_s;
+       struct icl_list_s *list;
+} icl_val_list_s;
 
 typedef struct {
        int type;
-       struct ic_repr_s *repr;
-} ic_val_repr_s;
+       struct icl_repr_s *repr;
+} icl_val_repr_s;
 
 iotcon_value_h icl_value_new_null();
 iotcon_value_h icl_value_new_int(int val);
index 0a8ac34dd8b413dcd677249dd63916f0e88241e2..3a191bb331d5a037cafdedd829dcfcd6ce1bf6d2 100644 (file)
@@ -61,7 +61,7 @@ API iotcon_repr_h iotcon_repr_new()
        iotcon_repr_h ret_val;
        errno = 0;
 
-       ret_val = calloc(1, sizeof(struct ic_repr_s));
+       ret_val = calloc(1, sizeof(struct icl_repr_s));
        if (NULL == ret_val) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
index f88eef729b22b906471981ffacbcc55402be14b7..0a5542c30b2211c6d499dd285a5b19b5302737b9 100644 (file)
@@ -29,7 +29,7 @@
 #define IOTCON_KEY_PROPERTY "prop"
 #define IOTCON_KEY_REP "rep"
 
-struct ic_repr_s {
+struct icl_repr_s {
        char *uri;
        int ref_count;
        int interfaces;
index 51f974c3e8bca825ad882b75ea30f23ad9bd0aa1..d0cf7f91a7a17ecf04bc672675f06a80d6cae69d 100644 (file)
 typedef void* oc_request_h;
 typedef void* oc_resource_h;
 
-struct ic_observe_info {
+struct icl_observe_info {
        iotcon_observe_action_e action;
        int observer_id;
 };
 
-struct ic_resource_request {
+struct icl_resource_request {
        int types;
        char *uri;
        iotcon_options_h header_options;
        iotcon_query_h query;
-       struct ic_observe_info observation_info;
+       struct icl_observe_info observation_info;
        iotcon_repr_h repr;
        oc_request_h request_handle;
        oc_resource_h resource_handle;
index 9dad5e27a3ef14e99832a56021cad8e9b3194988..c492c41a186788326898e78578a1e1e2a685ea04 100644 (file)
@@ -37,7 +37,7 @@ iotcon_resource_types_h icl_resource_types_ref(iotcon_resource_types_h types)
 
 API iotcon_resource_types_h iotcon_resource_types_new()
 {
-       iotcon_resource_types_h types = calloc(1, sizeof(struct ic_resource_types));
+       iotcon_resource_types_h types = calloc(1, sizeof(struct icl_resource_types));
        if (NULL == types) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
@@ -165,7 +165,7 @@ API iotcon_resource_types_h iotcon_resource_types_clone(iotcon_resource_types_h
 
        RETV_IF(NULL == types, NULL);
 
-       clone = calloc(1, sizeof(struct ic_resource_types));
+       clone = calloc(1, sizeof(struct icl_resource_types));
        if (NULL == clone) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
index 453dd9e884d4ae913e1a0ae074a9424b5812bc8f..80b59f2f99f8079d2f7beb51863c02c0e1bdbc41 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "iotcon-struct.h"
 
-struct ic_resource_types {
+struct icl_resource_types {
        int ref_count;
        GList *type_list;
 };
index e136d1417f7df9c9722ca1c19b53586b3df2aa08..96875ba2b3220c5601ad83a45a4bd3698d74c58d 100644 (file)
@@ -33,7 +33,7 @@ API iotcon_response_h iotcon_response_new(iotcon_request_h request_h)
 
        RETV_IF(NULL == request_h, NULL);
 
-       iotcon_response_h resp = calloc(1, sizeof(struct ic_resource_response));
+       iotcon_response_h resp = calloc(1, sizeof(struct icl_resource_response));
        if (NULL == resp) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
index 3d436f767bd491a4359f0c090ced326d95b288da..2be4fbe4eaa46a9020f9632b9bc5e0dd31e363a4 100644 (file)
@@ -20,7 +20,7 @@
 #include "iotcon-constant.h"
 #include "icl-request.h"
 
-struct ic_resource_response {
+struct icl_resource_response {
        char *new_uri;
        int error_code;
        iotcon_options_h header_options;
index 239b6855da6683527db8494ae7617286dd9b1715..a7f075b55dd479494b68031dbf5371871a860cdb 100644 (file)
--- a/lib/icl.c
+++ b/lib/icl.c
@@ -121,7 +121,7 @@ API iotcon_resource_h iotcon_register_resource(const char *uri,
        RETV_IF(NULL == res_types, NULL);
        RETV_IF(NULL == cb, NULL);
 
-       resource = calloc(1, sizeof(struct ic_resource));
+       resource = calloc(1, sizeof(struct icl_resource));
        if (NULL == resource) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
@@ -412,7 +412,7 @@ API iotcon_notimsg_h iotcon_notimsg_new(iotcon_repr_h repr, iotcon_interface_e i
 
        RETV_IF(NULL == repr, NULL);
 
-       msg = calloc(1, sizeof(struct ic_notify_msg));
+       msg = calloc(1, sizeof(struct icl_notify_msg));
        if (NULL == msg) {
                ERR("calloc() Fail(%d)", errno);
                return NULL;
index 610f69aa2f6f849b41fedbd7221189f047695319..9c5ef6c54898ca56d84d9e04c125e1664de439f4 100644 (file)
 
 #include "iotcon-constant.h"
 
-typedef struct ic_value_s* iotcon_value_h;
-typedef struct ic_list_s* iotcon_list_h;
-typedef struct ic_repr_s* iotcon_repr_h;
+typedef struct icl_value_s* iotcon_value_h;
+typedef struct icl_list_s* iotcon_list_h;
+typedef struct icl_repr_s* iotcon_repr_h;
 
-typedef struct ic_notify_msg* iotcon_notimsg_h;
+typedef struct icl_notify_msg* iotcon_notimsg_h;
 
 typedef void* iotcon_presence_h;
 
@@ -44,7 +44,7 @@ typedef struct _device_info {
 } iotcon_device_info_s;
 
 
-typedef struct ic_options* iotcon_options_h;
+typedef struct icl_options* iotcon_options_h;
 iotcon_options_h iotcon_options_new();
 void iotcon_options_free(iotcon_options_h options);
 int iotcon_options_insert(iotcon_options_h options, unsigned short id,
@@ -57,7 +57,7 @@ int iotcon_options_foreach(iotcon_options_h options, iotcon_options_foreach_cb c
                void *user_data);
 
 
-typedef struct ic_query* iotcon_query_h;
+typedef struct icl_query* iotcon_query_h;
 iotcon_query_h iotcon_query_new();
 void iotcon_query_free(iotcon_query_h query);
 int iotcon_query_insert(iotcon_query_h query, const char *key, const char *value);
@@ -80,7 +80,7 @@ int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb,
  *
  * @return the (possibly changed) start of the list, otherwise a null pointer on failure
  */
-typedef struct ic_resource_types* iotcon_resource_types_h;
+typedef struct icl_resource_types* iotcon_resource_types_h;
 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);
@@ -96,7 +96,7 @@ void iotcon_observers_free(iotcon_observers_h observers);
 iotcon_observers_h iotcon_observers_append(iotcon_observers_h observers, int obs_id);
 iotcon_observers_h iotcon_observers_remove(iotcon_observers_h observers, int obs_id);
 
-typedef struct ic_resource* iotcon_resource_h;
+typedef struct icl_resource* iotcon_resource_h;
 int iotcon_resource_get_number_of_children(iotcon_resource_h resource, int *number);
 int iotcon_resource_get_nth_child(iotcon_resource_h parent, int index,
                iotcon_resource_h *child);
@@ -105,7 +105,7 @@ int iotcon_resource_get_types(iotcon_resource_h resource, iotcon_resource_types_
 int iotcon_resource_get_interfaces(iotcon_resource_h resource, int *ifaces);
 int iotcon_resource_is_observable(iotcon_resource_h resource, bool *observable);
 
-typedef struct ic_remote_resource* iotcon_client_h;
+typedef struct icl_remote_resource* iotcon_client_h;
 int iotcon_client_get_uri(iotcon_client_h resource, char **uri);
 int iotcon_client_get_host(iotcon_client_h resource, char **host);
 int iotcon_client_get_types(iotcon_client_h resource, iotcon_resource_types_h *types);
@@ -113,7 +113,7 @@ int iotcon_client_get_interfaces(iotcon_client_h resource, int *ifaces);
 int iotcon_client_is_observable(iotcon_client_h resource, bool *observable);
 int iotcon_client_set_options(iotcon_client_h resource, iotcon_options_h header_options);
 
-typedef struct ic_resource_request* iotcon_request_h;
+typedef struct icl_resource_request* iotcon_request_h;
 int iotcon_request_get_uri(iotcon_request_h request, char **uri);
 int iotcon_request_get_representation(iotcon_request_h request, iotcon_repr_h *repr);
 int iotcon_request_get_types(iotcon_request_h request, int *types);
@@ -123,7 +123,7 @@ int iotcon_request_get_observer_action(iotcon_request_h request,
                iotcon_observe_action_e *action);
 int iotcon_request_get_observer_id(iotcon_request_h request, int *observer_id);
 
-typedef struct ic_resource_response* iotcon_response_h;
+typedef struct icl_resource_response* iotcon_response_h;
 iotcon_response_h iotcon_response_new(iotcon_request_h request_h);
 void iotcon_response_free(iotcon_response_h resp);
 int iotcon_response_set(iotcon_response_h resp, iotcon_response_property_e prop, ...);