From 9411bf94b79318794acdac218a8f0c72866bf5ce Mon Sep 17 00:00:00 2001 From: youngman Date: Tue, 23 Jun 2015 15:11:06 +0900 Subject: [PATCH] unsubscribe signal when unregister resource and unsubscribe presence Change-Id: I6a09c11a87716aee0675be332f6ba8386db3d14a Signed-off-by: youngman --- daemon/icd-ioty.cpp | 2 +- lib/icl-client.c | 2 +- lib/icl-client.h | 2 +- lib/icl-dbus-type.c | 6 +- lib/icl-dbus-type.h | 6 +- lib/icl-dbus.c | 189 +++++++++++++++++++++++++++----------------- lib/icl-dbus.h | 39 +++++---- lib/icl-ioty.h | 7 +- lib/icl-options.c | 2 +- lib/icl-options.h | 2 +- lib/icl-query.c | 2 +- lib/icl-query.h | 2 +- lib/icl-repr-list.c | 22 +++--- lib/icl-repr-list.h | 2 +- lib/icl-repr-obj.c | 26 +++--- lib/icl-repr-value.c | 48 +++++------ lib/icl-repr-value.h | 12 +-- lib/icl-repr.c | 2 +- lib/icl-repr.h | 2 +- lib/icl-request.h | 6 +- lib/icl-resource-types.c | 4 +- lib/icl-resource-types.h | 2 +- lib/icl-response.c | 2 +- lib/icl-response.h | 2 +- lib/icl.c | 4 +- lib/include/iotcon-struct.h | 22 +++--- 26 files changed, 238 insertions(+), 179 deletions(-) diff --git a/daemon/icd-ioty.cpp b/daemon/icd-ioty.cpp index 64f213b..b53aa91 100644 --- a/daemon/icd-ioty.cpp +++ b/daemon/icd-ioty.cpp @@ -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 object diff --git a/lib/icl-client.c b/lib/icl-client.c index b7e6a00..b6ab977 100644 --- a/lib/icl-client.c +++ b/lib/icl-client.c @@ -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; diff --git a/lib/icl-client.h b/lib/icl-client.h index 534e19c..669deba 100644 --- a/lib/icl-client.h +++ b/lib/icl-client.h @@ -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; diff --git a/lib/icl-dbus-type.c b/lib/icl-dbus-type.c index 9b11a3e..270abb9 100644 --- a/lib/icl-dbus-type.c +++ b/lib/icl-dbus-type.c @@ -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; diff --git a/lib/icl-dbus-type.h b/lib/icl-dbus-type.h index f01d7fa..9017f59 100644 --- a/lib/icl-dbus-type.h +++ b/lib/icl-dbus-type.h @@ -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); diff --git a/lib/icl-dbus.c b/lib/icl-dbus.c index c47b084..66906dc 100644 --- a/lib/icl-dbus.c +++ b/lib/icl-dbus.c @@ -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; } diff --git a/lib/icl-dbus.h b/lib/icl-dbus.h index e73fcb3..9c9d8d9 100644 --- a/lib/icl-dbus.h +++ b/lib/icl-dbus.h @@ -16,20 +16,31 @@ #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(); diff --git a/lib/icl-ioty.h b/lib/icl-ioty.h index 04a8e34..73d6623 100644 --- a/lib/icl-ioty.h +++ b/lib/icl-ioty.h @@ -17,20 +17,21 @@ #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]; diff --git a/lib/icl-options.c b/lib/icl-options.c index e4e85ee..df74693 100644 --- a/lib/icl-options.c +++ b/lib/icl-options.c @@ -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; diff --git a/lib/icl-options.h b/lib/icl-options.h index 47cdfdb..8069546 100644 --- a/lib/icl-options.h +++ b/lib/icl-options.h @@ -18,7 +18,7 @@ #include "iotcon-struct.h" -struct ic_options { +struct icl_options { int ref_count; GHashTable *hash; }; diff --git a/lib/icl-query.c b/lib/icl-query.c index 4eba31b..a4f61ae 100644 --- a/lib/icl-query.c +++ b/lib/icl-query.c @@ -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; diff --git a/lib/icl-query.h b/lib/icl-query.h index 873c1a5..09324d8 100644 --- a/lib/icl-query.h +++ b/lib/icl-query.h @@ -18,7 +18,7 @@ #include "iotcon-struct.h" -struct ic_query { +struct icl_query { int len; GHashTable *hash; }; diff --git a/lib/icl-repr-list.c b/lib/icl-repr-list.c index a1ff4d5..d4e299b 100644 --- a/lib/icl-repr-list.c +++ b/lib/icl-repr-list.c @@ -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); diff --git a/lib/icl-repr-list.h b/lib/icl-repr-list.h index 3327bc1..5a87773 100644 --- a/lib/icl-repr-list.h +++ b/lib/icl-repr-list.h @@ -21,7 +21,7 @@ #include "iotcon-struct.h" -struct ic_list_s { +struct icl_list_s { int type; int ref_count; GList *list; diff --git a/lib/icl-repr-obj.c b/lib/icl-repr-obj.c index f3ea1ac..ce2f30b 100644 --- a/lib/icl-repr-obj.c +++ b/lib/icl-repr-obj.c @@ -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; diff --git a/lib/icl-repr-value.c b/lib/icl-repr-value.c index 78cfa44..bb35920 100644 --- a/lib/icl-repr-value.c +++ b/lib/icl-repr-value.c @@ -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); diff --git a/lib/icl-repr-value.h b/lib/icl-repr-value.h index 8b34e66..4e18d6d 100644 --- a/lib/icl-repr-value.h +++ b/lib/icl-repr-value.h @@ -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); diff --git a/lib/icl-repr.c b/lib/icl-repr.c index 0a8ac34..3a191bb 100644 --- a/lib/icl-repr.c +++ b/lib/icl-repr.c @@ -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; diff --git a/lib/icl-repr.h b/lib/icl-repr.h index f88eef7..0a5542c 100644 --- a/lib/icl-repr.h +++ b/lib/icl-repr.h @@ -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; diff --git a/lib/icl-request.h b/lib/icl-request.h index 51f974c..d0cf7f9 100644 --- a/lib/icl-request.h +++ b/lib/icl-request.h @@ -22,17 +22,17 @@ 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; diff --git a/lib/icl-resource-types.c b/lib/icl-resource-types.c index 9dad5e2..c492c41 100644 --- a/lib/icl-resource-types.c +++ b/lib/icl-resource-types.c @@ -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; diff --git a/lib/icl-resource-types.h b/lib/icl-resource-types.h index 453dd9e..80b59f2 100644 --- a/lib/icl-resource-types.h +++ b/lib/icl-resource-types.h @@ -18,7 +18,7 @@ #include "iotcon-struct.h" -struct ic_resource_types { +struct icl_resource_types { int ref_count; GList *type_list; }; diff --git a/lib/icl-response.c b/lib/icl-response.c index e136d14..96875ba 100644 --- a/lib/icl-response.c +++ b/lib/icl-response.c @@ -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; diff --git a/lib/icl-response.h b/lib/icl-response.h index 3d436f7..2be4fbe 100644 --- a/lib/icl-response.h +++ b/lib/icl-response.h @@ -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; diff --git a/lib/icl.c b/lib/icl.c index 239b685..a7f075b 100644 --- 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; diff --git a/lib/include/iotcon-struct.h b/lib/include/iotcon-struct.h index 610f69a..9c5ef6c 100644 --- a/lib/include/iotcon-struct.h +++ b/lib/include/iotcon-struct.h @@ -20,11 +20,11 @@ #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, ...); -- 2.7.4