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
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;
#include "iotcon-struct.h"
#include "icl-options.h"
-struct ic_remote_resource {
+struct icl_remote_resource {
char *uri;
char *host;
bool is_observable;
}
-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;
}
-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;
}
-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;
#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);
unsigned int id;
} icl_cb_container_s;
+
static inline unsigned int _icl_dbus_generate_signal_number()
{
static unsigned int i = 0;
}
-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;
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;
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;
}
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;
}
-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;
}
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;
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);
}
-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);
}
-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);
}
-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);
}
-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;
}
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);
}
-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);
}
-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;
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,
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;
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);
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;
}
{
int ret;
GError *error = NULL;
+ unsigned int subscription_id;
int signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
GVariant *arg_client;
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;
}
{
int ret;
GError *error = NULL;
+ unsigned int subscription_id;
int signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
char *arg_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;
}
{
int ret;
GError *error = NULL;
+ unsigned int subscription_id;
int signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
char *arg_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;
}
{
int ret;
GError *error = NULL;
+ unsigned int subscription_id;
int signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
GVariant *arg_client;
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;
}
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;
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;
}
{
int ret;
GError *error = NULL;
+ unsigned int subscription_id;
int signal_number;
char signal_name[IC_DBUS_SIGNAL_LENGTH] = {0};
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;
}
}
-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);
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;
}
#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);
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();
#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];
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;
#include "iotcon-struct.h"
-struct ic_options {
+struct icl_options {
int ref_count;
GHashTable *hash;
};
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;
#include "iotcon-struct.h"
-struct ic_query {
+struct icl_query {
int len;
GHashTable *hash;
};
{
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;
}
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);
}
{
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)",
{
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,
{
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,
{
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)",
{
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,
{
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,
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);
#include "iotcon-struct.h"
-struct ic_list_s {
+struct icl_list_s {
int type;
int ref_count;
GList *list;
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;
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);
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;
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);
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;
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);
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;
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);
return false;
}
- real = (ic_basic_s*)value;
+ real = (icl_basic_s*)value;
return (IOTCON_TYPE_NULL == real->type) ? true : false;
}
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);
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;
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);
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;
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);
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;
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;
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;
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;
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;
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;
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,
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,
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,
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,
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,
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,
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);
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:
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);
#include "iotcon-struct.h"
-struct ic_value_s {
+struct icl_value_s {
int type;
};
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);
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;
#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;
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;
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;
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;
#include "iotcon-struct.h"
-struct ic_resource_types {
+struct icl_resource_types {
int ref_count;
GList *type_list;
};
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;
#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;
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;
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;
#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;
} 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,
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);
*
* @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);
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);
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);
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);
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, ...);