From: youngman Date: Wed, 14 Oct 2015 01:54:33 +0000 (+0900) Subject: (ACR) Modify the handle and API naming for resource and client(remote resource) X-Git-Tag: accepted/tizen/mobile/20151201.031626~82 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0302df8b3af4319e59e0657e600e95f39af9707;p=platform%2Fcore%2Fiot%2Fiotcon.git (ACR) Modify the handle and API naming for resource and client(remote resource) Change-Id: Ia26f2ed0f7c2fa47c2d7127b4198b6b6eb5ba5a5 Signed-off-by: youngman --- diff --git a/common/ic-dbus.xml b/common/ic-dbus.xml index b36c0b8..261dab9 100644 --- a/common/ic-dbus.xml +++ b/common/ic-dbus.xml @@ -52,28 +52,28 @@ - + - + - + - + - + diff --git a/daemon/icd-dbus.c b/daemon/icd-dbus.c index 50a1c8e..1092e90 100644 --- a/daemon/icd-dbus.c +++ b/daemon/icd-dbus.c @@ -514,7 +514,7 @@ static gboolean _dbus_handle_find_resource(icDbus *object, static gboolean _dbus_handle_observer_start(icDbus *object, GDBusMethodInvocation *invocation, - GVariant *client, + GVariant *resource, gint observe_type, GVariant *query, guint signal_number) @@ -523,8 +523,8 @@ static gboolean _dbus_handle_observer_start(icDbus *object, const gchar *sender; sender = g_dbus_method_invocation_get_sender(invocation); - observe_h = icd_ioty_observer_start(client, observe_type, query, signal_number, - sender); + observe_h = icd_ioty_observer_start(resource, observe_type, query, + signal_number, sender); if (NULL == observe_h) ERR("icd_ioty_observer_start() Fail"); diff --git a/doc/iotcon_doc.h b/doc/iotcon_doc.h index 4bac0fd..379109c 100644 --- a/doc/iotcon_doc.h +++ b/doc/iotcon_doc.h @@ -31,7 +31,7 @@ * RESTful API.\n\n * * @subsection CAPI_IOT_CONNECTIVITY_MODULE_RESOURCE Resource - * A Resrouce is a component in a server that can be viewed and conrolled by another client.\n + * A Resource is a component in a server that can be viewed and conrolled by another client.\n * There are different resource types, for example a temperature sensor, a light controller etc.\n\n * * @subsection CAPI_IOT_CONNECTIVITY_MODULE_RESOURCE_REGISTRATION Resource registration @@ -130,7 +130,7 @@ static void _request_handler(iotcon_request_h request, void *user_data) return; } - iotcon_resource_h handle = iotcon_register_resource(uri_path, resource_types, + iotcon_resource_h handle = iotcon_resource_create(uri_path, resource_types, interfaces, properties, _request_handler, NULL); if (NULL == handle) { iotcon_resource_types_destroy(resource_types); @@ -155,37 +155,37 @@ static void _on_get(iotcon_options_h header_options, iotcon_representation_h rec // handle get from response } ... -static void _found_resource(iotcon_client_h resource, void *user_data) +static void _found_resource(iotcon_remote_resource_h resource, void *user_data) { int ret; int resource_interfaces; char *resource_uri_path; char *resource_host; - char *resource_sid; + char *device_id; iotcon_query_h query; iotcon_resource_types_h resource_types; - ret = iotcon_client_get_uri_path(resource, &resource_uri_path); + ret = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path); if (IOTCON_ERROR_NONE != ret) { return; } - ret = iotcon_client_get_device_id(resource, &resource_sid); + ret = iotcon_remote_resource_get_device_id(resource, &device_id); if (IOTCON_ERROR_NONE != ret) { return; } - ret = iotcon_client_get_host(resource, &resource_host); + ret = iotcon_remote_resource_get_host(resource, &resource_host); if (IOTCON_ERROR_NONE != ret) { return; } - ret = iotcon_client_get_interfaces(resource, &resource_interfaces); + ret = iotcon_remote_resource_get_interfaces(resource, &resource_interfaces); if (IOTCON_ERROR_NONE != ret) { return; } - ret = iotcon_client_get_types(resource, &resource_types); + ret = iotcon_remote_resource_get_types(resource, &resource_types); if (IOTCON_ERROR_NONE != ret) { return; } @@ -197,7 +197,7 @@ static void _found_resource(iotcon_client_h resource, void *user_data) iotcon_query_insert(query, "key", "value"); - iotcon_get(resource, query, &_on_get, NULL); + iotcon_remote_resource_get(resource, query, &_on_get, NULL); iotcon_query_destroy(query); } ... @@ -291,7 +291,7 @@ static void _request_handler(iotcon_request_h request, void *user_data) return; } - ret = iotcon_register_resource(uri_path, resource_types, + ret = iotcon_resource_create(uri_path, resource_types, interfaces, properties, _request_handler, NULL, door_handle); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(resource_types); @@ -333,7 +333,7 @@ static void _request_handler(iotcon_request_h request, void *user_data) * @code #include ... -static iotcon_client_h door_resource; +static iotcon_remote_resource_h door_resource; ... static void _on_observe(iotcon_options_h header_options, iotcon_representation_h recv_repr, int response_result, int sequence_number, void *user_data) @@ -342,8 +342,8 @@ static void _on_observe(iotcon_options_h header_options, iotcon_representation_h ... { int ret; - ret = iotcon_observer_start(door_resource, IOTCON_OBSERVE_ALL, NULL, &_on_observe, NULL); - + ret = iotcon_remote_resource_observer_start(door_resource, IOTCON_OBSERVE_ALL, NULL, + &_on_observe, NULL); if (IOTCON_ERROR_NONE != ret) return; } @@ -359,11 +359,11 @@ static void _on_observe(iotcon_options_h header_options, iotcon_representation_h * Client * * - * iotcon_register_resource + * iotcon_resource_create * iotcon_get_device_info * * - * iotcon_unregister_resource + * iotcon_resource_destroy * iotcon_subscribe_presence * * @@ -376,27 +376,27 @@ static void _on_observe(iotcon_options_h header_options, iotcon_representation_h * * * iotcon_resource_bind_request_handler - * iotcon_observer_start + * iotcon_remote_resource_observer_start * * * iotcon_resource_bind_child_resource - * iotcon_observer_stop + * iotcon_remote_resource_observer_stop * * * iotcon_resource_unbind_child_resource - * iotcon_get + * iotcon_remote_resource_get * * * iotcon_register_device_info - * iotcon_put + * iotcon_remote_resource_put * * * iotcon_start_presence - * iotcon_post + * iotcon_remote_resource_post * * * iotcon_stop_presence - * iotcon_delete + * iotcon_remote_resource_delete * * * iotcon_response_send diff --git a/lib/icl-dbus-type.c b/lib/icl-dbus-type.c index 45657e8..6bebd8b 100644 --- a/lib/icl-dbus-type.c +++ b/lib/icl-dbus-type.c @@ -27,7 +27,7 @@ #include "icl-query.h" #include "icl-request.h" #include "icl-response.h" -#include "icl-client.h" +#include "icl-remote-resource.h" #include "icl-repr.h" #include "icl-payload.h" #include "icl-observation.h" @@ -114,7 +114,7 @@ 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_remote_resource_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 f8cc40c..3275ded 100644 --- a/lib/icl-dbus-type.h +++ b/lib/icl-dbus-type.h @@ -23,7 +23,7 @@ const char** icl_dbus_resource_types_to_array(iotcon_resource_types_h types); 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_remote_resource_to_gvariant(struct icl_remote_resource *resource); GVariant* icl_dbus_device_info_to_gvariant(const char *device_name); GVariant* icl_dbus_platform_info_to_gvariant(iotcon_platform_info_s *platform_info); GVariant* icl_dbus_query_to_gvariant(iotcon_query_h query); diff --git a/lib/icl-device.c b/lib/icl-device.c index 120758b..e43cf7f 100644 --- a/lib/icl-device.c +++ b/lib/icl-device.c @@ -230,7 +230,7 @@ static void _icl_platform_info_cb(GDBusConnection *connection, info = calloc(1, sizeof(iotcon_platform_info_s)); if (NULL == info) { - ERR("calloc(client) Fail(%d)", errno); + ERR("calloc(info) Fail(%d)", errno); return; } diff --git a/lib/icl-client-crud.c b/lib/icl-remote-resource-crud.c similarity index 76% rename from lib/icl-client-crud.c rename to lib/icl-remote-resource-crud.c index e91a4db..a7f8065 100644 --- a/lib/icl-client-crud.c +++ b/lib/icl-remote-resource-crud.c @@ -27,25 +27,25 @@ #include "icl-dbus.h" #include "icl-dbus-type.h" #include "icl-repr.h" -#include "icl-client.h" +#include "icl-remote-resource.h" #include "icl-payload.h" typedef struct { - iotcon_on_cru_cb cb; + iotcon_remote_resource_cru_cb cb; void *user_data; - iotcon_client_h resource; + iotcon_remote_resource_h resource; } icl_on_cru_s; typedef struct { - iotcon_on_delete_cb cb; + iotcon_remote_resource_delete_cb cb; void *user_data; - iotcon_client_h resource; + iotcon_remote_resource_h resource; } icl_on_delete_s; typedef struct { - iotcon_on_observe_cb cb; + iotcon_remote_resource_observe_cb cb; void *user_data; - iotcon_client_h resource; + iotcon_remote_resource_h resource; } icl_on_observe_s; @@ -58,7 +58,7 @@ static void _icl_on_cru_cb(GVariant *result, icl_on_cru_s *cb_container) char *option_data; GVariant *repr_gvar; iotcon_options_h header_options = NULL; - iotcon_on_cru_cb cb = cb_container->cb; + iotcon_remote_resource_cru_cb cb = cb_container->cb; g_variant_get(result, "(a(qs)vi)", &options, &repr_gvar, &res); @@ -80,7 +80,7 @@ static void _icl_on_cru_cb(GVariant *result, icl_on_cru_s *cb_container) if (header_options) iotcon_options_destroy(header_options); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return; } @@ -96,7 +96,7 @@ static void _icl_on_cru_cb(GVariant *result, icl_on_cru_s *cb_container) if (header_options) iotcon_options_destroy(header_options); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); } @@ -112,7 +112,7 @@ static void _icl_on_get_cb(GObject *object, GAsyncResult *g_async_res, if (error) { ERR("ic_dbus_call_get_finish() Fail(%s)", error->message); g_error_free(error); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return; } @@ -132,7 +132,7 @@ static void _icl_on_put_cb(GObject *object, GAsyncResult *g_async_res, if (error) { ERR("ic_dbus_call_put_finish() Fail(%s)", error->message); g_error_free(error); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return; } @@ -152,7 +152,7 @@ static void _icl_on_post_cb(GObject *object, GAsyncResult *g_async_res, if (error) { ERR("ic_dbus_call_post_finish() Fail(%s)", error->message); g_error_free(error); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return; } @@ -161,12 +161,12 @@ static void _icl_on_post_cb(GObject *object, GAsyncResult *g_async_res, } -API int iotcon_get(iotcon_client_h resource, iotcon_query_h query, iotcon_on_cru_cb cb, - void *user_data) +API int iotcon_remote_resource_get(iotcon_remote_resource_h resource, + iotcon_query_h query, iotcon_remote_resource_cru_cb cb, void *user_data) { int ret; GVariant *arg_query; - GVariant *arg_client; + GVariant *arg_remote_resource; icl_on_cru_s *cb_container; RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS); @@ -179,9 +179,9 @@ API int iotcon_get(iotcon_client_h resource, iotcon_query_h query, iotcon_on_cru return IOTCON_ERROR_OUT_OF_MEMORY; } - ret = iotcon_client_ref(resource, &cb_container->resource); + ret = iotcon_remote_resource_ref(resource, &cb_container->resource); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_ref() Fail"); + ERR("iotcon_remote_resource_ref() Fail"); free(cb_container); return IOTCON_ERROR_OUT_OF_MEMORY; } @@ -189,22 +189,25 @@ API int iotcon_get(iotcon_client_h resource, iotcon_query_h query, iotcon_on_cru cb_container->cb = cb; cb_container->user_data = user_data; - arg_client = icl_dbus_client_to_gvariant(resource); + arg_remote_resource = icl_dbus_remote_resource_to_gvariant(resource); arg_query = icl_dbus_query_to_gvariant(query); - ic_dbus_call_get(icl_dbus_get_object(), arg_client, arg_query, NULL, _icl_on_get_cb, - cb_container); + ic_dbus_call_get(icl_dbus_get_object(), arg_remote_resource, arg_query, NULL, + _icl_on_get_cb, cb_container); return IOTCON_ERROR_NONE; } -API int iotcon_put(iotcon_client_h resource, iotcon_representation_h repr, - iotcon_query_h query, iotcon_on_cru_cb cb, void *user_data) +API int iotcon_remote_resource_put(iotcon_remote_resource_h resource, + iotcon_representation_h repr, + iotcon_query_h query, + iotcon_remote_resource_cru_cb cb, + void *user_data) { int ret; GVariant *arg_repr; - GVariant *arg_client; + GVariant *arg_remote_resource; GVariant *arg_query; icl_on_cru_s *cb_container; @@ -219,9 +222,9 @@ API int iotcon_put(iotcon_client_h resource, iotcon_representation_h repr, return IOTCON_ERROR_OUT_OF_MEMORY; } - ret = iotcon_client_ref(resource, &cb_container->resource); + ret = iotcon_remote_resource_ref(resource, &cb_container->resource); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_ref() Fail"); + ERR("iotcon_remote_resource_ref() Fail"); free(cb_container); return IOTCON_ERROR_OUT_OF_MEMORY; } @@ -232,28 +235,31 @@ API int iotcon_put(iotcon_client_h resource, iotcon_representation_h repr, arg_repr = icl_representation_to_gvariant(repr); if (NULL == arg_repr) { ERR("icl_representation_to_gvariant() Fail"); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return IOTCON_ERROR_REPRESENTATION; } - arg_client = icl_dbus_client_to_gvariant(resource); + arg_remote_resource = icl_dbus_remote_resource_to_gvariant(resource); arg_query = icl_dbus_query_to_gvariant(query); - ic_dbus_call_put(icl_dbus_get_object(), arg_client, arg_repr, arg_query, + ic_dbus_call_put(icl_dbus_get_object(), arg_remote_resource, arg_repr, arg_query, NULL, _icl_on_put_cb, cb_container); return IOTCON_ERROR_NONE; } -API int iotcon_post(iotcon_client_h resource, iotcon_representation_h repr, - iotcon_query_h query, iotcon_on_cru_cb cb, void *user_data) +API int iotcon_remote_resource_post(iotcon_remote_resource_h resource, + iotcon_representation_h repr, + iotcon_query_h query, + iotcon_remote_resource_cru_cb cb, + void *user_data) { int ret; GVariant *arg_repr; GVariant *arg_query; - GVariant *arg_client; + GVariant *arg_remote_resource; icl_on_cru_s *cb_container; RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS); @@ -267,9 +273,9 @@ API int iotcon_post(iotcon_client_h resource, iotcon_representation_h repr, return IOTCON_ERROR_OUT_OF_MEMORY; } - ret = iotcon_client_ref(resource, &cb_container->resource); + ret = iotcon_remote_resource_ref(resource, &cb_container->resource); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_ref() Fail"); + ERR("iotcon_remote_resource_ref() Fail"); free(cb_container); return IOTCON_ERROR_OUT_OF_MEMORY; } @@ -280,15 +286,15 @@ API int iotcon_post(iotcon_client_h resource, iotcon_representation_h repr, arg_repr = icl_representation_to_gvariant(repr); if (NULL == arg_repr) { ERR("icl_representation_to_gvariant() Fail"); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return IOTCON_ERROR_REPRESENTATION; } - arg_client = icl_dbus_client_to_gvariant(resource); + arg_remote_resource = icl_dbus_remote_resource_to_gvariant(resource); arg_query = icl_dbus_query_to_gvariant(query); - ic_dbus_call_post(icl_dbus_get_object(), arg_client, arg_repr, arg_query, + ic_dbus_call_post(icl_dbus_get_object(), arg_remote_resource, arg_repr, arg_query, NULL, _icl_on_post_cb, cb_container); return IOTCON_ERROR_NONE; @@ -307,13 +313,13 @@ static void _icl_on_delete_cb(GObject *object, GAsyncResult *g_async_res, iotcon_options_h header_options = NULL; icl_on_delete_s *cb_container = user_data; - iotcon_on_delete_cb cb = cb_container->cb; + iotcon_remote_resource_delete_cb cb = cb_container->cb; ic_dbus_call_delete_finish(IC_DBUS(object), &result, g_async_res, &error); if (error) { ERR("ic_dbus_call_delete_finish() Fail(%s)", error->message); g_error_free(error); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return; } @@ -324,7 +330,7 @@ static void _icl_on_delete_cb(GObject *object, GAsyncResult *g_async_res, if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_options_create() Fail(%d)", ret); g_variant_iter_free(options); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return; } @@ -342,15 +348,16 @@ static void _icl_on_delete_cb(GObject *object, GAsyncResult *g_async_res, if (header_options) iotcon_options_destroy(header_options); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); } -API int iotcon_delete(iotcon_client_h resource, iotcon_on_delete_cb cb, void *user_data) +API int iotcon_remote_resource_delete(iotcon_remote_resource_h resource, + iotcon_remote_resource_delete_cb cb, void *user_data) { int ret; - GVariant *arg_client; + GVariant *arg_remote_resource; icl_on_delete_s *cb_container; RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS); @@ -363,9 +370,9 @@ API int iotcon_delete(iotcon_client_h resource, iotcon_on_delete_cb cb, void *us return IOTCON_ERROR_OUT_OF_MEMORY; } - ret = iotcon_client_ref(resource, &cb_container->resource); + ret = iotcon_remote_resource_ref(resource, &cb_container->resource); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_ref() Fail"); + ERR("iotcon_remote_resource_ref() Fail"); free(cb_container); return IOTCON_ERROR_OUT_OF_MEMORY; } @@ -373,10 +380,10 @@ API int iotcon_delete(iotcon_client_h resource, iotcon_on_delete_cb cb, void *us cb_container->cb = cb; cb_container->user_data = user_data; - arg_client = icl_dbus_client_to_gvariant(resource); + arg_remote_resource = icl_dbus_remote_resource_to_gvariant(resource); - ic_dbus_call_delete(icl_dbus_get_object(), arg_client, NULL, _icl_on_delete_cb, - cb_container); + ic_dbus_call_delete(icl_dbus_get_object(), arg_remote_resource, NULL, + _icl_on_delete_cb, cb_container); return IOTCON_ERROR_NONE; } @@ -400,7 +407,7 @@ static void _icl_on_observe_cb(GDBusConnection *connection, iotcon_options_h header_options = NULL; icl_on_observe_s *cb_container = user_data; - iotcon_on_observe_cb cb = cb_container->cb; + iotcon_remote_resource_observe_cb cb = cb_container->cb; g_variant_get(parameters, "(a(qs)vii)", &options, &repr_gvar, &res, &seq_num); @@ -410,7 +417,7 @@ static void _icl_on_observe_cb(GDBusConnection *connection, if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_options_create() Fail(%d)", ret); g_variant_iter_free(options); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return; } @@ -426,7 +433,7 @@ static void _icl_on_observe_cb(GDBusConnection *connection, if (header_options) iotcon_options_destroy(header_options); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return; } @@ -448,17 +455,20 @@ static void _icl_observe_conn_cleanup(icl_on_observe_s *cb_container) { cb_container->resource->observe_handle = 0; cb_container->resource->observe_sub_id = 0; - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); } -API int iotcon_observer_start(iotcon_client_h resource, int observe_type, - iotcon_query_h query, iotcon_on_observe_cb cb, void *user_data) +API int iotcon_remote_resource_observer_start(iotcon_remote_resource_h resource, + int observe_type, + iotcon_query_h query, + iotcon_remote_resource_observe_cb cb, + void *user_data) { GVariant *arg_query; unsigned int sub_id; - GVariant *arg_client; + GVariant *arg_remote_resource; GError *error = NULL; int64_t observe_handle; icl_on_observe_s *cb_container; @@ -471,17 +481,17 @@ API int iotcon_observer_start(iotcon_client_h resource, int observe_type, signal_number = icl_dbus_generate_signal_number(); - arg_client = icl_dbus_client_to_gvariant(resource); + arg_remote_resource = icl_dbus_remote_resource_to_gvariant(resource); arg_query = icl_dbus_query_to_gvariant(query); - ic_dbus_call_observer_start_sync(icl_dbus_get_object(), arg_client, observe_type, - arg_query, signal_number, &observe_handle, NULL, &error); + ic_dbus_call_observer_start_sync(icl_dbus_get_object(), arg_remote_resource, + observe_type, arg_query, signal_number, &observe_handle, NULL, &error); if (error) { ERR("ic_dbus_call_observer_start_sync() Fail(%s)", error->message); ret = icl_dbus_convert_dbus_error(error->code); g_error_free(error); g_variant_unref(arg_query); - g_variant_unref(arg_client); + g_variant_unref(arg_remote_resource); return ret; } @@ -499,9 +509,9 @@ API int iotcon_observer_start(iotcon_client_h resource, int observe_type, return IOTCON_ERROR_OUT_OF_MEMORY; } - ret = iotcon_client_ref(resource, &cb_container->resource); + ret = iotcon_remote_resource_ref(resource, &cb_container->resource); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_ref() Fail"); + ERR("iotcon_remote_resource_ref() Fail"); free(cb_container); return IOTCON_ERROR_OUT_OF_MEMORY; } @@ -513,7 +523,7 @@ API int iotcon_observer_start(iotcon_client_h resource, int observe_type, _icl_observe_conn_cleanup, _icl_on_observe_cb); if (0 == sub_id) { ERR("icl_dbus_subscribe_signal() Fail"); - iotcon_client_destroy(cb_container->resource); + iotcon_remote_resource_destroy(cb_container->resource); free(cb_container); return IOTCON_ERROR_DBUS; } @@ -524,7 +534,7 @@ API int iotcon_observer_start(iotcon_client_h resource, int observe_type, } -API int iotcon_observer_stop(iotcon_client_h resource) +API int iotcon_remote_resource_observer_stop(iotcon_remote_resource_h resource) { int ret; GError *error = NULL; diff --git a/lib/icl-client.c b/lib/icl-remote-resource.c similarity index 77% rename from lib/icl-client.c rename to lib/icl-remote-resource.c index 9e0c8dd..24d22c2 100644 --- a/lib/icl-client.c +++ b/lib/icl-remote-resource.c @@ -26,7 +26,7 @@ #include "icl-options.h" #include "icl-dbus.h" #include "icl-repr.h" -#include "icl-client.h" +#include "icl-remote-resource.h" #include "icl-resource-types.h" #include "icl-payload.h" @@ -36,7 +36,7 @@ typedef struct { unsigned int id; } icl_found_resource_s; -static iotcon_client_h _icl_client_from_gvariant(GVariant *payload, +static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *payload, iotcon_connectivity_type_e conn_type); static void _icl_found_resource_cb(GDBusConnection *connection, @@ -49,7 +49,7 @@ static void _icl_found_resource_cb(GDBusConnection *connection, { FN_CALL; int conn_type; - iotcon_client_h client; + iotcon_remote_resource_h resource; GVariant *payload; icl_found_resource_s *cb_container = user_data; @@ -57,16 +57,16 @@ static void _icl_found_resource_cb(GDBusConnection *connection, g_variant_get(parameters, "(vi)", &payload, &conn_type); - client = _icl_client_from_gvariant(payload, conn_type); - if (NULL == client) { - ERR("icl_client_parse_resource_object() Fail"); + resource = _icl_remote_resource_from_gvariant(payload, conn_type); + if (NULL == resource) { + ERR("icl_remote_resource_from_gvariant() Fail"); return; } if (cb) - cb(client, cb_container->user_data); + cb(resource, cb_container->user_data); - iotcon_client_destroy(client); + iotcon_remote_resource_destroy(resource); /* TODO * When is callback removed? @@ -135,20 +135,20 @@ API int iotcon_find_resource(const char *host_address, const char *resource_type /* If you know the information of resource, then you can make a proxy of the resource. */ -API int iotcon_client_create(const char *host, +API int iotcon_remote_resource_create(const char *host, const char *uri_path, bool is_observable, iotcon_resource_types_h resource_types, int resource_ifs, - iotcon_client_h *client_handle) + iotcon_remote_resource_h *resource_handle) { FN_CALL; - iotcon_client_h resource = NULL; + iotcon_remote_resource_h resource = NULL; RETV_IF(NULL == host, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == resource_types, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == client_handle, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == resource_handle, IOTCON_ERROR_INVALID_PARAMETER); resource = calloc(1, sizeof(struct icl_remote_resource)); if (NULL == resource) { @@ -164,13 +164,13 @@ API int iotcon_client_create(const char *host, resource->ref_count = 1; - *client_handle = resource; + *resource_handle = resource; return IOTCON_ERROR_NONE; } -API void iotcon_client_destroy(iotcon_client_h resource) +API void iotcon_remote_resource_destroy(iotcon_remote_resource_h resource) { RET_IF(NULL == resource); @@ -192,7 +192,7 @@ API void iotcon_client_destroy(iotcon_client_h resource) } -API int iotcon_client_ref(iotcon_client_h src, iotcon_client_h *dest) +API int iotcon_remote_resource_ref(iotcon_remote_resource_h src, iotcon_remote_resource_h *dest) { RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(src->ref_count <= 0, IOTCON_ERROR_INVALID_PARAMETER); @@ -206,7 +206,7 @@ API int iotcon_client_ref(iotcon_client_h src, iotcon_client_h *dest) /* The content of the resource should not be freed by user. */ -API int iotcon_client_get_uri_path(iotcon_client_h resource, char **uri_path) +API int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource, char **uri_path) { RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER); @@ -218,7 +218,7 @@ API int iotcon_client_get_uri_path(iotcon_client_h resource, char **uri_path) /* The content of the resource should not be freed by user. */ -API int iotcon_client_get_host(iotcon_client_h resource, char **host) +API int iotcon_remote_resource_get_host(iotcon_remote_resource_h resource, char **host) { RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == host, IOTCON_ERROR_INVALID_PARAMETER); @@ -230,7 +230,7 @@ API int iotcon_client_get_host(iotcon_client_h resource, char **host) /* The content of the resource should not be freed by user. */ -API int iotcon_client_get_device_id(iotcon_client_h resource, char **device_id) +API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource, char **device_id) { RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == device_id, IOTCON_ERROR_INVALID_PARAMETER); @@ -241,7 +241,7 @@ API int iotcon_client_get_device_id(iotcon_client_h resource, char **device_id) } /* The content of the resource should not be freed by user. */ -API int iotcon_client_get_types(iotcon_client_h resource, iotcon_resource_types_h *types) +API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource, iotcon_resource_types_h *types) { RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER); @@ -252,7 +252,7 @@ API int iotcon_client_get_types(iotcon_client_h resource, iotcon_resource_types_ } -API int iotcon_client_get_interfaces(iotcon_client_h resource, int *ifaces) +API int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource, int *ifaces) { RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER); @@ -263,7 +263,8 @@ API int iotcon_client_get_interfaces(iotcon_client_h resource, int *ifaces) } -API int iotcon_client_is_observable(iotcon_client_h resource, bool *observable) +API int iotcon_remote_resource_is_observable(iotcon_remote_resource_h resource, + bool *observable) { RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); RETV_IF(NULL == observable, IOTCON_ERROR_INVALID_PARAMETER); @@ -275,7 +276,7 @@ API int iotcon_client_is_observable(iotcon_client_h resource, bool *observable) /* if header_options is NULL, then client's header_options is unset */ -API int iotcon_client_set_options(iotcon_client_h resource, +API int iotcon_remote_resource_set_options(iotcon_remote_resource_h resource, iotcon_options_h header_options) { RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); @@ -292,18 +293,18 @@ API int iotcon_client_set_options(iotcon_client_h resource, } -static iotcon_client_h _icl_client_from_gvariant(GVariant *payload, +static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *payload, iotcon_connectivity_type_e conn_type) { int ret; - iotcon_client_h client; + iotcon_remote_resource_h resource; GVariantIter *types_iter; char host_addr[PATH_MAX] = {0}; iotcon_resource_types_h res_types; - char *uri_path, *sid, *res_type, *addr; + char *uri_path, *device_id, *res_type, *addr; int ifaces, is_observable, is_secure, port; - g_variant_get(payload, "(&s&siasib&si)", &uri_path, &sid, &ifaces, &types_iter, + g_variant_get(payload, "(&s&siasib&si)", &uri_path, &device_id, &ifaces, &types_iter, &is_observable, &is_secure, &addr, &port); switch (conn_type) { @@ -324,26 +325,26 @@ static iotcon_client_h _icl_client_from_gvariant(GVariant *payload, while (g_variant_iter_loop(types_iter, "s", &res_type)) iotcon_resource_types_insert(res_types, res_type); - ret = iotcon_client_create(host_addr, uri_path, !!is_observable, res_types, ifaces, - &client); + ret = iotcon_remote_resource_create(host_addr, uri_path, !!is_observable, res_types, ifaces, + &resource); if (res_types) iotcon_resource_types_destroy(res_types); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_create() Fail"); + ERR("iotcon_remote_resource_create() Fail"); return NULL; } - client->ref_count = 1; + resource->ref_count = 1; - client->device_id = strdup(sid); - if (NULL == client->device_id) { - ERR("strdup(sid) Fail(%d)", errno); - iotcon_client_destroy(client); + resource->device_id = strdup(device_id); + if (NULL == resource->device_id) { + ERR("strdup(device_id) Fail(%d)", errno); + iotcon_remote_resource_destroy(resource); return NULL; } - client->conn_type = conn_type; - client->is_secure = is_secure; + resource->conn_type = conn_type; + resource->is_secure = is_secure; - return client; + return resource; } diff --git a/lib/icl-client.h b/lib/icl-remote-resource.h similarity index 100% rename from lib/icl-client.h rename to lib/icl-remote-resource.h diff --git a/lib/icl-resource.c b/lib/icl-resource.c index 125f6b7..27e72ff 100644 --- a/lib/icl-resource.c +++ b/lib/icl-resource.c @@ -148,7 +148,7 @@ static void _icl_resource_conn_cleanup(iotcon_resource_h resource) /* The length of uri_path should be less than or equal to 36. */ -API int iotcon_register_resource(const char *uri_path, +API int iotcon_resource_create(const char *uri_path, iotcon_resource_types_h res_types, int ifaces, uint8_t properties, @@ -232,7 +232,7 @@ API int iotcon_register_resource(const char *uri_path, } -API int iotcon_unregister_resource(iotcon_resource_h resource) +API int iotcon_resource_destroy(iotcon_resource_h resource) { FN_CALL; int ret; @@ -334,7 +334,7 @@ API int iotcon_resource_bind_type(iotcon_resource_h resource, const char *resour } -API int iotcon_resource_bind_request_handler(iotcon_resource_h resource, +API int iotcon_resource_set_request_handler(iotcon_resource_h resource, iotcon_request_handler_cb cb) { RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER); diff --git a/lib/include/iotcon-struct.h b/lib/include/iotcon-struct.h index 904dca7..0b4050a 100644 --- a/lib/include/iotcon-struct.h +++ b/lib/include/iotcon-struct.h @@ -39,8 +39,8 @@ typedef struct icl_list_s* iotcon_list_h; /** * @ingroup CAPI_IOT_CONNECTIVITY_REPRESENTATION_MODULE * @brief The handle of representation. - * @details iotcon_representation_h is an opaque data structure to have uri_path, list of resource types - * and interfaces.\n + * @details iotcon_representation_h is an opaque data structure to have uri_path,\n + * list of resource types and interfaces.\n * It could contain other representation as children.\n * * @since_tizen 3.0 @@ -416,8 +416,8 @@ int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb, /** * @brief The handle of resource types - * @details iotcon_resource_types_h is an opaque data structure to have list of resource types.\n - * A resource type is datatype of string. + * @details iotcon_resource_types_h is an opaque data structure to have list\n + * of resource types. A resource type is datatype of string. * * @since_tizen 3.0 */ @@ -643,11 +643,11 @@ int iotcon_observers_delete(iotcon_observers_h observers, int obs_id); /** * @brief The handle of resource. - * @details iotcon_resource_h is an opaque data structure to represent registered resource by server. - * A resource has host, uri_path, resource types, interfaces and internal handle.\n - * If observable attribute of resource is true, client can observe this resource.\n - * When client request by CRUD functions, handler will be invoked if registered. - * It could contain other resource as children.\n + * @details iotcon_resource_h is an opaque data structure to represent registered\n + * resource by server. A resource has host, uri_path, resource types, interfaces\n + * and internal handle. If observable attribute of resource is true, client can observe\n + * this resource. When client request by CRUD functions, handler will be invoked\n + * if registered. It could contain other resource as children.\n * * @since_tizen 3.0 */ @@ -776,129 +776,132 @@ int iotcon_resource_get_interfaces(iotcon_resource_h resource, int *ifaces); int iotcon_resource_is_observable(iotcon_resource_h resource, bool *observable); /** - * @brief The handle of client + * @brief The handle of remote resource * @details When Client success to find out resource from remote server, - * server's resource information is reorganized as iotcon_client_h by Iotcon. + * server's resource information is reorganized as iotcon_remote_resource_h by Iotcon. * Client can request CRUD to server by using this.\n - * iotcon_client_h is an opaque data structure to have host, uri_path, resource types, interfaces, - * options and server id.\n + * iotcon_remote_resource_h is an opaque data structure to have host, uri_path,\n + * resource types, interfaces, options and device id.\n * If observable attribute is true, remote resource is observable.\n * When you observe remote resource, observe_handle will be set. * * @since_tizen 3.0 */ -typedef struct icl_remote_resource* iotcon_client_h; +typedef struct icl_remote_resource* iotcon_remote_resource_h; /** - * @brief Gets an URI path of the client + * @brief Gets an URI path of the remote resource * * @since_tizen 3.0 * @remarks @a uri_path must not be released using free(). * - * @param[in] resource The handle of the client - * @param[out] uri_path The URI path of the client + * @param[in] resource The handle of the remote resource + * @param[out] uri_path The URI path of the remote resource * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_client_get_host() - * @see iotcon_client_get_device_id() - * @see iotcon_client_get_types() - * @see iotcon_client_get_interfaces() - * @see iotcon_client_is_observable() - * @see iotcon_client_set_options() + * @see iotcon_remote_resource_get_host() + * @see iotcon_remote_resource_get_device_id() + * @see iotcon_remote_resource_get_types() + * @see iotcon_remote_resource_get_interfaces() + * @see iotcon_remote_resource_is_observable() + * @see iotcon_remote_resource_set_options() */ -int iotcon_client_get_uri_path(iotcon_client_h resource, char **uri_path); +int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource, + char **uri_path); /** - * @brief Gets an host address of the client + * @brief Gets an host address of the remote resource * * @since_tizen 3.0 * @remarks @a host must not be released using free(). * - * @param[in] resource The handle of the client - * @param[out] host The host address of the client + * @param[in] resource The handle of the remote resource + * @param[out] host The host address of the remote resource * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_client_get_uri_path() - * @see iotcon_client_get_device_id() - * @see iotcon_client_get_types() - * @see iotcon_client_get_interfaces() - * @see iotcon_client_is_observable() - * @see iotcon_client_set_options() + * @see iotcon_remote_resource_get_uri_path() + * @see iotcon_remote_resource_get_device_id() + * @see iotcon_remote_resource_get_types() + * @see iotcon_remote_resource_get_interfaces() + * @see iotcon_remote_resource_is_observable() + * @see iotcon_remote_resource_set_options() */ -int iotcon_client_get_host(iotcon_client_h resource, char **host); +int iotcon_remote_resource_get_host(iotcon_remote_resource_h resource, char **host); /** - * @brief Gets an server id of the client + * @brief Gets an device id of the remote resource * * @since_tizen 3.0 - * @remarks @a sid must not be released using free(). + * @remarks @a device_id must not be released using free(). * - * @param[in] resource The handle of the client - * @param[out] device_id The device id of the client + * @param[in] resource The handle of the remote resource + * @param[out] device_id The device id of the remote resource * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_client_get_uri_path() - * @see iotcon_client_get_host() - * @see iotcon_client_get_types() - * @see iotcon_client_get_interfaces() - * @see iotcon_client_is_observable() - * @see iotcon_client_set_options() + * @see iotcon_remote_resource_get_uri_path() + * @see iotcon_remote_resource_get_host() + * @see iotcon_remote_resource_get_types() + * @see iotcon_remote_resource_get_interfaces() + * @see iotcon_remote_resource_is_observable() + * @see iotcon_remote_resource_set_options() */ -int iotcon_client_get_device_id(iotcon_client_h resource, char **device_id); +int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource, + char **device_id); /** - * @brief Gets resource types of the client + * @brief Gets resource types of the remote resource * * @since_tizen 3.0 * - * @param[in] resource The handle of the client - * @param[out] types The resource types of the client + * @param[in] resource The handle of the remote resource + * @param[out] types The resource types of the remote resource * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_client_get_uri_path() - * @see iotcon_client_get_host() - * @see iotcon_client_get_device_id() - * @see iotcon_client_get_interfaces() - * @see iotcon_client_is_observable() - * @see iotcon_client_set_options() + * @see iotcon_remote_resource_get_uri_path() + * @see iotcon_remote_resource_get_host() + * @see iotcon_remote_resource_get_device_id() + * @see iotcon_remote_resource_get_interfaces() + * @see iotcon_remote_resource_is_observable() + * @see iotcon_remote_resource_set_options() */ -int iotcon_client_get_types(iotcon_client_h resource, iotcon_resource_types_h *types); +int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource, + iotcon_resource_types_h *types); /** - * @brief Gets resource interfaces of the client + * @brief Gets resource interfaces of the remote resource * * @since_tizen 3.0 * - * @param[in] resource The handle of the client - * @param[out] ifaces The resource interfaces of the client + * @param[in] resource The handle of the remote resource + * @param[out] ifaces The resource interfaces of the remote resource * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_client_get_uri_path() - * @see iotcon_client_get_host() - * @see iotcon_client_get_device_id() - * @see iotcon_client_get_types() - * @see iotcon_client_is_observable() - * @see iotcon_client_set_options() + * @see iotcon_remote_resource_get_uri_path() + * @see iotcon_remote_resource_get_host() + * @see iotcon_remote_resource_get_device_id() + * @see iotcon_remote_resource_get_types() + * @see iotcon_remote_resource_is_observable() + * @see iotcon_remote_resource_set_options() */ -int iotcon_client_get_interfaces(iotcon_client_h resource, int *ifaces); +int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource, int *ifaces); /** - * @brief Checks whether the client is observable or not. + * @brief Checks whether the remote resource is observable or not. * * @since_tizen 3.0 * @@ -909,35 +912,37 @@ int iotcon_client_get_interfaces(iotcon_client_h resource, int *ifaces); * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_client_get_uri_path() - * @see iotcon_client_get_host() - * @see iotcon_client_get_device_id() - * @see iotcon_client_get_types() - * @see iotcon_client_get_interfaces() - * @see iotcon_client_set_options() + * @see iotcon_remote_resource_get_uri_path() + * @see iotcon_remote_resource_get_host() + * @see iotcon_remote_resource_get_device_id() + * @see iotcon_remote_resource_get_types() + * @see iotcon_remote_resource_get_interfaces() + * @see iotcon_remote_resource_set_options() */ -int iotcon_client_is_observable(iotcon_client_h resource, bool *observable); +int iotcon_remote_resource_is_observable(iotcon_remote_resource_h resource, + bool *observable); /** - * @brief Sets options into the client + * @brief Sets options into the remote resource * * @since_tizen 3.0 * - * @param[in] resource The handle of the client + * @param[in] resource The handle of the remote resource * @param[in] options The handle of the header options * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_client_get_uri_path() - * @see iotcon_client_get_host() - * @see iotcon_client_get_device_id() - * @see iotcon_client_get_types() - * @see iotcon_client_get_interfaces() - * @see iotcon_client_is_observable() + * @see iotcon_remote_resource_get_uri_path() + * @see iotcon_remote_resource_get_host() + * @see iotcon_remote_resource_get_device_id() + * @see iotcon_remote_resource_get_types() + * @see iotcon_remote_resource_get_interfaces() + * @see iotcon_remote_resource_is_observable() */ -int iotcon_client_set_options(iotcon_client_h resource, iotcon_options_h options); +int iotcon_remote_resource_set_options(iotcon_remote_resource_h resource, + iotcon_options_h options); /** * @brief The handle of request diff --git a/lib/include/iotcon.h b/lib/include/iotcon.h index 7dd0b49..673b55d 100644 --- a/lib/include/iotcon.h +++ b/lib/include/iotcon.h @@ -126,8 +126,8 @@ int iotcon_add_connection_changed_cb(iotcon_connection_changed_cb cb, void *user int iotcon_remove_connection_changed_cb(iotcon_connection_changed_cb cb, void *user_data); /** - * @brief Specifies the type of function passed to iotcon_register_resource() and - * iotcon_resource_bind_request_handler() + * @brief Specifies the type of function passed to iotcon_resource_create() and + * iotcon_resource_set_request_handler() * @details Called when server receive request from the client. * * @since_tizen 3.0 @@ -136,16 +136,16 @@ int iotcon_remove_connection_changed_cb(iotcon_connection_changed_cb cb, void *u * @param[in] request The request from client * @param[in] user_data The user data to pass to the function * - * @pre The callback must be registered using iotcon_register_resource() + * @pre The callback must be registered using iotcon_resource_create() * - * @see iotcon_register_resource() - * @see iotcon_resource_bind_request_handler() + * @see iotcon_resource_create() + * @see iotcon_resource_set_request_handler() */ typedef void (*iotcon_request_handler_cb)(iotcon_resource_h resource, iotcon_request_h request, void *user_data); /** - * @brief Registers a resource in server + * @brief Create a resource handle and registers the resource in server * @details Registers a resource specified by @a uri_path, @a res_types, @a ifaces which have * @a properties in Iotcon server.\n * When client find the registered resource, iotcon_request_handler_cb() will be called automatically.\n @@ -164,7 +164,7 @@ typedef void (*iotcon_request_handler_cb)(iotcon_resource_h resource, * @privilege %http://tizen.org/privilege/internet * * @remarks @a uri_path length must be less than or equal 36.\n - * You must unregister resource by calling iotcon_unregister_resource() + * You must unregister resource by calling iotcon_resource_destroy() * if resource is no longer needed. * * @param[in] uri_path The URI path of the resource. @@ -185,15 +185,15 @@ typedef void (*iotcon_request_handler_cb)(iotcon_resource_h resource, * * @post When the resource receive CRUD request, iotcon_request_handler_cb() will be called. * - * @see iotcon_unregister_resource() + * @see iotcon_resource_destroy() * @see iotcon_resource_bind_interface() * @see iotcon_resource_bind_type() - * @see iotcon_resource_bind_request_handler() + * @see iotcon_resource_set_request_handler() * @see iotcon_resource_bind_child_resource() * @see iotcon_resource_unbind_child_resource() * @see iotcon_request_handler_cb() */ -int iotcon_register_resource(const char *uri_path, +int iotcon_resource_create(const char *uri_path, iotcon_resource_types_h res_types, int ifaces, uint8_t properties, @@ -202,7 +202,7 @@ int iotcon_register_resource(const char *uri_path, iotcon_resource_h *resource_handle); /** - * @brief Unregisters a resource and releases its data. + * @brief Destroy the resource and releases its data. * * @since_tizen 3.0 * @privlevel public @@ -220,15 +220,15 @@ int iotcon_register_resource(const char *uri_path, * @retval #IOTCON_ERROR_DBUS Dbus error * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @see iotcon_register_resource() + * @see iotcon_resource_create() * @see iotcon_resource_bind_interface() * @see iotcon_resource_bind_type() - * @see iotcon_resource_bind_request_handler() + * @see iotcon_resource_set_request_handler() * @see iotcon_resource_bind_child_resource() * @see iotcon_resource_unbind_child_resource() * @see iotcon_request_handler_cb() */ -int iotcon_unregister_resource(iotcon_resource_h resource_handle); +int iotcon_resource_destroy(iotcon_resource_h resource_handle); /** * @brief Binds an interface to the resource @@ -250,10 +250,10 @@ int iotcon_unregister_resource(iotcon_resource_h resource_handle); * @retval #IOTCON_ERROR_SYSTEM System error * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @see iotcon_register_resource() - * @see iotcon_unregister_resource() + * @see iotcon_resource_create() + * @see iotcon_resource_destroy() * @see iotcon_resource_bind_type() - * @see iotcon_resource_bind_request_handler() + * @see iotcon_resource_set_request_handler() * @see iotcon_resource_bind_child_resource() * @see iotcon_resource_unbind_child_resource() * @see iotcon_request_handler_cb() @@ -277,10 +277,10 @@ int iotcon_resource_bind_interface(iotcon_resource_h resource, int iface); * @retval #IOTCON_ERROR_SYSTEM System error * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @see iotcon_register_resource() - * @see iotcon_unregister_resource() + * @see iotcon_resource_create() + * @see iotcon_resource_destroy() * @see iotcon_resource_bind_interface() - * @see iotcon_resource_bind_request_handler() + * @see iotcon_resource_set_request_handler() * @see iotcon_resource_bind_child_resource() * @see iotcon_resource_unbind_child_resource() * @see iotcon_request_handler_cb() @@ -304,15 +304,15 @@ int iotcon_resource_bind_type(iotcon_resource_h resource_handle, * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_register_resource() - * @see iotcon_unregister_resource() + * @see iotcon_resource_create() + * @see iotcon_resource_destroy() * @see iotcon_resource_bind_interface() * @see iotcon_resource_bind_type() * @see iotcon_resource_bind_child_resource() * @see iotcon_resource_unbind_child_resource() * @see iotcon_request_handler_cb() */ -int iotcon_resource_bind_request_handler(iotcon_resource_h resource, +int iotcon_resource_set_request_handler(iotcon_resource_h resource, iotcon_request_handler_cb cb); /** @@ -333,11 +333,11 @@ int iotcon_resource_bind_request_handler(iotcon_resource_h resource, * @retval #IOTCON_ERROR_SYSTEM System error * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @see iotcon_register_resource() - * @see iotcon_unregister_resource() + * @see iotcon_resource_create() + * @see iotcon_resource_destroy() * @see iotcon_resource_bind_interface() * @see iotcon_resource_bind_type() - * @see iotcon_resource_bind_request_handler() + * @see iotcon_resource_set_request_handler() * @see iotcon_resource_unbind_child_resource() * @see iotcon_request_handler_cb() */ @@ -361,11 +361,11 @@ int iotcon_resource_bind_child_resource(iotcon_resource_h parent, * @retval #IOTCON_ERROR_SYSTEM System error * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @see iotcon_register_resource() - * @see iotcon_unregister_resource() + * @see iotcon_resource_create() + * @see iotcon_resource_destroy() * @see iotcon_resource_bind_interface() * @see iotcon_resource_bind_type() - * @see iotcon_resource_bind_request_handler() + * @see iotcon_resource_set_request_handler() * @see iotcon_resource_bind_child_resource() * @see iotcon_request_handler_cb() */ @@ -625,7 +625,7 @@ int iotcon_unsubscribe_presence(iotcon_presence_h presence_handle); * * @see iotcon_find_resource() */ -typedef void (*iotcon_found_resource_cb)(iotcon_client_h resource, void *user_data); +typedef void (*iotcon_found_resource_cb)(iotcon_remote_resource_h resource, void *user_data); /** * @brief Finds resources. @@ -680,15 +680,15 @@ int iotcon_find_resource(const char *host_address, const char *resource_type, * @retval #IOTCON_ERROR_DBUS Dbus errors * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * - * @see iotcon_client_destroy() - * @see iotcon_client_ref() + * @see iotcon_remote_resource_destroy() + * @see iotcon_remote_resource_ref() */ -int iotcon_client_create(const char *host, +int iotcon_remote_resource_create(const char *host, const char *uri_path, bool is_observable, iotcon_resource_types_h resource_types, int resource_ifs, - iotcon_client_h *client_handle); + iotcon_remote_resource_h *client_handle); /** * @brief Releases a resource handle. @@ -701,10 +701,10 @@ int iotcon_client_create(const char *host, * * @return void * - * @see iotcon_client_create() - * @see iotcon_client_ref() + * @see iotcon_remote_resource_create() + * @see iotcon_remote_resource_ref() */ -void iotcon_client_destroy(iotcon_client_h resource); +void iotcon_remote_resource_destroy(iotcon_remote_resource_h resource); /** * @brief Increments reference count of the source resource. @@ -718,13 +718,13 @@ void iotcon_client_destroy(iotcon_client_h resource); * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * - * @see iotcon_client_create() - * @see iotcon_client_destroy() + * @see iotcon_remote_resource_create() + * @see iotcon_remote_resource_destroy() */ -int iotcon_client_ref(iotcon_client_h src, iotcon_client_h *dest); +int iotcon_remote_resource_ref(iotcon_remote_resource_h src, iotcon_remote_resource_h *dest); /** - * @brief Specifies the type of function passed to iotcon_observer_start(). + * @brief Specifies the type of function passed to iotcon_remote_resource_observer_start(). * @details Called when a client receive notifications from a server. The @a response_result could be one of #iotcon_response_result_e. * * @since_tizen 3.0 @@ -736,11 +736,11 @@ int iotcon_client_ref(iotcon_client_h src, iotcon_client_h *dest); * @param[in] sequence_number The sequence of notifications from server. * @param[in] user_data The user data passed from the callback registration function * - * @pre The callback must be registered using iotcon_observer_start() + * @pre The callback must be registered using iotcon_remote_resource_observer_start() * - * @see iotcon_observer_start() + * @see iotcon_remote_resource_observer_start() */ -typedef void (*iotcon_on_observe_cb)(iotcon_client_h resource, +typedef void (*iotcon_remote_resource_observe_cb)(iotcon_remote_resource_h resource, iotcon_representation_h repr, iotcon_options_h options, int response_result, @@ -749,7 +749,7 @@ typedef void (*iotcon_on_observe_cb)(iotcon_client_h resource, /** * @brief Sets observation on the resource - * @details When server sends notification message, iotcon_on_observe_cb() will be called. + * @details When server sends notification message, iotcon_remote_resource_observe_cb() will be called. * The @a observe_type could be one of #iotcon_observe_type_e. * * @since_tizen 3.0 @@ -770,16 +770,19 @@ typedef void (*iotcon_on_observe_cb)(iotcon_client_h resource, * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @post When the @a resource receive notification message, iotcon_on_observe_cb() will be called. + * @post When the @a resource receive notification message, iotcon_remote_resource_observe_cb() will be called. * - * @see iotcon_on_observe_cb() - * @see iotcon_observer_stop() + * @see iotcon_remote_resource_observe_cb() + * @see iotcon_remote_resource_observer_stop() * @see iotcon_notimsg_create() * @see iotcon_notify_list_of_observers() * @see iotcon_resource_notify_all() */ -int iotcon_observer_start(iotcon_client_h resource, int observe_type, - iotcon_query_h query, iotcon_on_observe_cb cb, void *user_data); +int iotcon_remote_resource_observer_start(iotcon_remote_resource_h resource, + int observe_type, + iotcon_query_h query, + iotcon_remote_resource_observe_cb cb, + void *user_data); /** * @brief Cancels the observation on the resource @@ -797,13 +800,13 @@ int iotcon_observer_start(iotcon_client_h resource, int observe_type, * @retval #IOTCON_ERROR_SYSTEM System error * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @see iotcon_on_observe_cb() - * @see iotcon_observer_start() + * @see iotcon_remote_resource_observe_cb() + * @see iotcon_remote_resource_observer_start() * @see iotcon_notimsg_create() * @see iotcon_notify_list_of_observers() * @see iotcon_resource_notify_all() */ -int iotcon_observer_stop(iotcon_client_h resource); +int iotcon_remote_resource_observer_stop(iotcon_remote_resource_h resource); /** * @brief Send response for incoming request. @@ -838,9 +841,9 @@ int iotcon_response_send(iotcon_response_h resp); * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * - * @see iotcon_on_observe_cb() - * @see iotcon_observer_start() - * @see iotcon_observer_stop() + * @see iotcon_remote_resource_observe_cb() + * @see iotcon_remote_resource_observer_start() + * @see iotcon_remote_resource_observer_stop() * @see iotcon_notify_list_of_observers() * @see iotcon_resource_notify_all() */ @@ -879,9 +882,9 @@ void iotcon_notimsg_destroy(iotcon_notimsg_h msg); * @retval #IOTCON_ERROR_SYSTEM System error * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @see iotcon_on_observe_cb() - * @see iotcon_observer_start() - * @see iotcon_observer_stop() + * @see iotcon_remote_resource_observe_cb() + * @see iotcon_remote_resource_observer_start() + * @see iotcon_remote_resource_observer_stop() * @see iotcon_notimsg_create() * @see iotcon_resource_notify_all() */ @@ -904,16 +907,16 @@ int iotcon_notify_list_of_observers(iotcon_resource_h resource, iotcon_notimsg_h * @retval #IOTCON_ERROR_SYSTEM System error * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @see iotcon_on_observe_cb() - * @see iotcon_observer_start() - * @see iotcon_observer_stop() + * @see iotcon_remote_resource_observe_cb() + * @see iotcon_remote_resource_observer_start() + * @see iotcon_remote_resource_observer_stop() * @see iotcon_notimsg_create() * @see iotcon_notify_list_of_observers() */ int iotcon_resource_notify_all(iotcon_resource_h resource); /** - * @brief Specifies the type of function passed to iotcon_get(), iotcon_put(), iotcon_post() + * @brief Specifies the type of function passed to iotcon_remote_resource_get(), iotcon_remote_resource_put(), iotcon_remote_resource_post() * @details The @a response_result could be one of #iotcon_response_result_e. * * @since_tizen 3.0 @@ -924,18 +927,21 @@ int iotcon_resource_notify_all(iotcon_resource_h resource); * @param[in] response_result The response result code * @param[in] user_data The user data to pass to the function * - * @pre The callback must be registered using iotcon_get(), iotcon_put(), iotcon_post() + * @pre The callback must be registered using iotcon_remote_resource_get(), iotcon_remote_resource_put(), iotcon_remote_resource_post() * - * @see iotcon_get() - * @see iotcon_put() - * @see iotcon_post() + * @see iotcon_remote_resource_get() + * @see iotcon_remote_resource_put() + * @see iotcon_remote_resource_post() */ -typedef void (*iotcon_on_cru_cb)(iotcon_client_h resource, iotcon_representation_h repr, - iotcon_options_h options, int response_result, void *user_data); +typedef void (*iotcon_remote_resource_cru_cb)(iotcon_remote_resource_h resource, + iotcon_representation_h repr, + iotcon_options_h options, + int response_result, + void *user_data); /** * @brief Gets the attributes of a resource. - * @details When server sends response on get request, iotcon_on_cru_cb() will be called. + * @details When server sends response on get request, iotcon_remote_resource_cru_cb() will be called. * * @since_tizen 3.0 * @privlevel public @@ -953,18 +959,18 @@ typedef void (*iotcon_on_cru_cb)(iotcon_client_h resource, iotcon_representation * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @post When the client receive get response, iotcon_on_cru_cb() will be called. + * @post When the client receive get response, iotcon_remote_resource_cru_cb() will be called. * - * @see iotcon_on_cru_cb() - * @see iotcon_put() - * @see iotcon_post() + * @see iotcon_remote_resource_cru_cb() + * @see iotcon_remote_resource_put() + * @see iotcon_remote_resource_post() */ -int iotcon_get(iotcon_client_h resource, iotcon_query_h query, - iotcon_on_cru_cb cb, void *user_data); +int iotcon_remote_resource_get(iotcon_remote_resource_h resource, iotcon_query_h query, + iotcon_remote_resource_cru_cb cb, void *user_data); /** * @brief Sets the representation of a resource (via PUT) - * @details When server sends response on put request, iotcon_on_cru_cb() will be called. + * @details When server sends response on put request, iotcon_remote_resource_cru_cb() will be called. * * @since_tizen 3.0 * @privlevel public @@ -983,18 +989,21 @@ int iotcon_get(iotcon_client_h resource, iotcon_query_h query, * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @post When the client receive put response, iotcon_on_cru_cb() will be called. + * @post When the client receive put response, iotcon_remote_resource_cru_cb() will be called. * - * @see iotcon_on_cru_cb() - * @see iotcon_get() - * @see iotcon_post() + * @see iotcon_remote_resource_cru_cb() + * @see iotcon_remote_resource_get() + * @see iotcon_remote_resource_post() */ -int iotcon_put(iotcon_client_h resource, iotcon_representation_h repr, - iotcon_query_h query, iotcon_on_cru_cb cb, void *user_data); +int iotcon_remote_resource_put(iotcon_remote_resource_h resource, + iotcon_representation_h repr, + iotcon_query_h query, + iotcon_remote_resource_cru_cb cb, + void *user_data); /** * @brief Posts on a resource - * @details When server sends response on post request, iotcon_on_cru_cb() will be called. + * @details When server sends response on post request, iotcon_remote_resource_cru_cb() will be called. * * @since_tizen 3.0 * @privlevel public @@ -1013,17 +1022,20 @@ int iotcon_put(iotcon_client_h resource, iotcon_representation_h repr, * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @post When the client receive post response, iotcon_on_cru_cb() will be called. + * @post When the client receive post response, iotcon_remote_resource_cru_cb() will be called. * - * @see iotcon_on_cru_cb() - * @see iotcon_get() - * @see iotcon_put() + * @see iotcon_remote_resource_cru_cb() + * @see iotcon_remote_resource_get() + * @see iotcon_remote_resource_put() */ -int iotcon_post(iotcon_client_h resource, iotcon_representation_h repr, - iotcon_query_h query, iotcon_on_cru_cb cb, void *user_data); +int iotcon_remote_resource_post(iotcon_remote_resource_h resource, + iotcon_representation_h repr, + iotcon_query_h query, + iotcon_remote_resource_cru_cb cb, + void *user_data); /** - * @brief Specifies the type of function passed to iotcon_delete() + * @brief Specifies the type of function passed to iotcon_remote_resource_delete() * @details The @a response_result could be one of #iotcon_response_result_e. * * @since_tizen 3.0 @@ -1033,16 +1045,18 @@ int iotcon_post(iotcon_client_h resource, iotcon_representation_h repr, * @param[in] response_result The response result code * @param[in] user_data The user data to pass to the function * - * @pre The callback must be registered using iotcon_delete() + * @pre The callback must be registered using iotcon_remote_resource_delete() * - * @see iotcon_delete() + * @see iotcon_remote_resource_delete() */ -typedef void (*iotcon_on_delete_cb)(iotcon_client_h resource, iotcon_options_h options, - int response_result, void *user_data); +typedef void (*iotcon_remote_resource_delete_cb)(iotcon_remote_resource_h resource, + iotcon_options_h options, + int response_result, + void *user_data); /** * @brief Deletes a resource. - * @details When server sends response on delete request, iotcon_on_delete_cb() will be called. + * @details When server sends response on delete request, iotcon_remote_resource_delete_cb() will be called. * * @since_tizen 3.0 * @privlevel public @@ -1059,12 +1073,12 @@ typedef void (*iotcon_on_delete_cb)(iotcon_client_h resource, iotcon_options_h o * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory * @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied * - * @post When the client receive delete response, iotcon_on_delete_cb() will be called. + * @post When the client receive delete response, iotcon_remote_resource_delete_cb() will be called. * - * @see iotcon_on_delete_cb() + * @see iotcon_remote_resource_delete_cb() */ -int iotcon_delete(iotcon_client_h resource, iotcon_on_delete_cb cb, void *user_data); - +int iotcon_remote_resource_delete(iotcon_remote_resource_h resource, + iotcon_remote_resource_delete_cb cb, void *user_data); /** * @} diff --git a/test/crud-test-client.c b/test/crud-test-client.c index bab0a08..c06c3e2 100644 --- a/test/crud-test-client.c +++ b/test/crud-test-client.c @@ -20,12 +20,12 @@ #include #include "test.h" -static char *door_resource_sid; -static GList *resource_sid_list; +static char *door_resource_device_id; +static GList *device_id_list; static const char* const door_uri_path = "/a/door"; -static void _on_observe(iotcon_client_h resource, +static void _on_observe(iotcon_remote_resource_h resource, iotcon_representation_h recv_repr, iotcon_options_h header_options, int response_result, @@ -38,14 +38,14 @@ static void _on_observe(iotcon_client_h resource, i++; if (2 == i) - iotcon_observer_stop(resource); + iotcon_remote_resource_observer_stop(resource); } -static void _on_delete(iotcon_client_h resource, iotcon_options_h header_options, +static void _on_delete(iotcon_remote_resource_h resource, iotcon_options_h header_options, int response_result, void *user_data) { int ret; - iotcon_client_h door_resource = user_data; + iotcon_remote_resource_h door_resource = user_data; RETM_IF(IOTCON_RESPONSE_RESULT_OK != response_result && IOTCON_RESPONSE_RESULT_RESOURCE_DELETED != response_result, @@ -54,22 +54,22 @@ static void _on_delete(iotcon_client_h resource, iotcon_options_h header_options /* delete callback operations */ - ret = iotcon_observer_start(door_resource, IOTCON_OBSERVE_ALL, NULL, _on_observe, - NULL); + ret = iotcon_remote_resource_observer_start(door_resource, IOTCON_OBSERVE_ALL, NULL, + _on_observe, NULL); if (IOTCON_ERROR_NONE != ret) - ERR("iotcon_observer_start() Fail(%d)", ret); + ERR("iotcon_remote_resource_observer_start() Fail(%d)", ret); - iotcon_client_destroy(door_resource); + iotcon_remote_resource_destroy(door_resource); } -static void _on_post(iotcon_client_h resource, iotcon_representation_h recv_repr, +static void _on_post(iotcon_remote_resource_h resource, iotcon_representation_h recv_repr, iotcon_options_h header_options, int response_result, void *user_data) { int ret, ifaces = 0; iotcon_state_h recv_state; char *host, *created_uri_path; iotcon_resource_types_h types = NULL; - iotcon_client_h new_door_resource, door_resource; + iotcon_remote_resource_h new_door_resource, door_resource; RETM_IF(IOTCON_RESPONSE_RESULT_OK != response_result && IOTCON_RESPONSE_RESULT_RESOURCE_CREATED != response_result, @@ -89,50 +89,50 @@ static void _on_post(iotcon_client_h resource, iotcon_representation_h recv_repr } DBG("New resource created : %s", created_uri_path); - ret = iotcon_client_get_host(resource, &host); + ret = iotcon_remote_resource_get_host(resource, &host); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_host() Fail(%d)", ret); + ERR("iotcon_remote_resource_get_host() Fail(%d)", ret); return; } - ret = iotcon_client_get_types(resource, &types); + ret = iotcon_remote_resource_get_types(resource, &types); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_types() Fail(%d)", ret); + ERR("iotcon_remote_resource_get_types() Fail(%d)", ret); return; } - ret = iotcon_client_get_interfaces(resource, &ifaces); + ret = iotcon_remote_resource_get_interfaces(resource, &ifaces); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_ifaces() Fail(%d)", ret); + ERR("iotcon_remote_resource_get_interfaces() Fail(%d)", ret); return; } - ret = iotcon_client_create(host, created_uri_path, true, types, ifaces, + ret = iotcon_remote_resource_create(host, created_uri_path, true, types, ifaces, &new_door_resource); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_create() Fail(%d)", ret); + ERR("iotcon_remote_resource_create() Fail(%d)", ret); return; } - ret = iotcon_client_ref(resource, &door_resource); + ret = iotcon_remote_resource_ref(resource, &door_resource); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_ref() Fail(%d)", ret); - iotcon_client_destroy(new_door_resource); + ERR("iotcon_remote_resource_ref() Fail(%d)", ret); + iotcon_remote_resource_destroy(new_door_resource); return; } - ret = iotcon_delete(new_door_resource, _on_delete, door_resource); + ret = iotcon_remote_resource_delete(new_door_resource, _on_delete, door_resource); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_delete() Fail(%d)", ret); - iotcon_client_destroy(door_resource); - iotcon_client_destroy(new_door_resource); + ERR("iotcon_remote_resource_delete() Fail(%d)", ret); + iotcon_remote_resource_destroy(door_resource); + iotcon_remote_resource_destroy(new_door_resource); return; } - iotcon_client_destroy(new_door_resource); + iotcon_remote_resource_destroy(new_door_resource); } -static void _on_put(iotcon_client_h resource, iotcon_representation_h recv_repr, +static void _on_put(iotcon_remote_resource_h resource, iotcon_representation_h recv_repr, iotcon_options_h header_options, int response_result, void *user_data) { int ret; @@ -149,14 +149,14 @@ static void _on_put(iotcon_client_h resource, iotcon_representation_h recv_repr, } /* send POST request */ - ret = iotcon_post(resource, send_repr, NULL, _on_post, NULL); + ret = iotcon_remote_resource_post(resource, send_repr, NULL, _on_post, NULL); if (IOTCON_ERROR_NONE != ret) - ERR("iotcon_post() Fail(%d)", ret); + ERR("iotcon_remote_resource_post() Fail(%d)", ret); iotcon_representation_destroy(send_repr); } -static void _on_get(iotcon_client_h resource, iotcon_representation_h recv_repr, +static void _on_get(iotcon_remote_resource_h resource, iotcon_representation_h recv_repr, iotcon_options_h header_options, int response_result, void *user_data) { int ret; @@ -213,9 +213,9 @@ static void _on_get(iotcon_client_h resource, iotcon_representation_h recv_repr, iotcon_state_destroy(send_state); /* send PUT request */ - ret = iotcon_put(resource, send_repr, NULL, _on_put, NULL); + ret = iotcon_remote_resource_put(resource, send_repr, NULL, _on_put, NULL); if (IOTCON_ERROR_NONE != ret) - ERR("iotcon_put() Fail(%d)", ret); + ERR("iotcon_remote_resource_put() Fail(%d)", ret); iotcon_representation_destroy(send_repr); } @@ -238,19 +238,18 @@ static void _presence_handler(int result, unsigned int nonce, INFO("host_address : %s", host_address); } -static int _sid_compare(const void *a, const void *b) +static int _device_id_compare(const void *a, const void *b) { return strcmp(a, b); } -static void _found_resource(iotcon_client_h resource, void *user_data) +static void _found_resource(iotcon_remote_resource_h resource, void *user_data) { - int ret; GList *node; - char *resource_sid; char *resource_host; char *resource_uri_path; - int resource_interfaces; + char *resource_device_id; + int ret, resource_interfaces; iotcon_presence_h presence_handle; iotcon_resource_types_h resource_types; @@ -260,52 +259,52 @@ static void _found_resource(iotcon_client_h resource, void *user_data) INFO("===== resource found ====="); /* get the resource URI */ - ret = iotcon_client_get_uri_path(resource, &resource_uri_path); + ret = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_uri_path() Fail(%d)", ret); + ERR("iotcon_remote_resource_get_uri_path() Fail(%d)", ret); return; } - /* get the resource unique id. + /* get the device unique id. * this is unique per-server independent on how it was discovered. */ - ret = iotcon_client_get_device_id(resource, &resource_sid); + ret = iotcon_remote_resource_get_device_id(resource, &resource_device_id); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_device_id() Fail(%d)", ret); + ERR("iotcon_remote_resource_get_device_id() Fail(%d)", ret); return; } - DBG("[%s] resource server id : %s", resource_uri_path, resource_sid); + DBG("[%s] resource device id : %s", resource_uri_path, resource_device_id); - node = g_list_find_custom(resource_sid_list, resource_sid, _sid_compare); + node = g_list_find_custom(device_id_list, resource_device_id, _device_id_compare); if (node && TEST_STR_EQUAL == strcmp(door_uri_path, resource_uri_path)) { DBG("uri_path \"%s\" already found. skip !", resource_uri_path); return; } - door_resource_sid = strdup(resource_sid); - if (NULL == door_resource_sid) { - ERR("strdup(door_resource_sid) Fail"); + door_resource_device_id = strdup(resource_device_id); + if (NULL == door_resource_device_id) { + ERR("strdup(door_resource_device_id) Fail"); return; } - resource_sid_list = g_list_append(resource_sid_list, door_resource_sid); + device_id_list = g_list_append(device_id_list, door_resource_device_id); /* get the resource host address */ - ret = iotcon_client_get_host(resource, &resource_host); + ret = iotcon_remote_resource_get_host(resource, &resource_host); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_host() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, door_resource_sid); - free(door_resource_sid); + ERR("iotcon_remote_resource_get_host() Fail(%d)", ret); + device_id_list = g_list_remove(device_id_list, door_resource_device_id); + free(door_resource_device_id); return; } DBG("[%s] resource host : %s", resource_uri_path, resource_host); /* get the resource interfaces */ - ret = iotcon_client_get_interfaces(resource, &resource_interfaces); + ret = iotcon_remote_resource_get_interfaces(resource, &resource_interfaces); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_interfaces() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, door_resource_sid); - free(door_resource_sid); + ERR("iotcon_remote_resource_get_interfaces() Fail(%d)", ret); + device_id_list = g_list_remove(device_id_list, door_resource_device_id); + free(door_resource_device_id); return; } if (IOTCON_INTERFACE_DEFAULT & resource_interfaces) @@ -318,11 +317,11 @@ static void _found_resource(iotcon_client_h resource, void *user_data) DBG("[%s] resource interface : GROUP_INTERFACE", resource_uri_path); /* get the resource types */ - ret = iotcon_client_get_types(resource, &resource_types); + ret = iotcon_remote_resource_get_types(resource, &resource_types); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_types() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, door_resource_sid); - free(door_resource_sid); + ERR("iotcon_remote_resource_get_types() Fail(%d)", ret); + device_id_list = g_list_remove(device_id_list, door_resource_device_id); + free(door_resource_device_id); return; } @@ -330,8 +329,8 @@ static void _found_resource(iotcon_client_h resource, void *user_data) resource_uri_path); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_resource_types_foreach() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, door_resource_sid); - free(door_resource_sid); + device_id_list = g_list_remove(device_id_list, door_resource_device_id); + free(door_resource_device_id); return; } @@ -344,8 +343,8 @@ static void _found_resource(iotcon_client_h resource, void *user_data) ret = iotcon_query_create(&query); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_query_create() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, door_resource_sid); - free(door_resource_sid); + device_id_list = g_list_remove(device_id_list, door_resource_device_id); + free(door_resource_device_id); return; } @@ -353,21 +352,21 @@ static void _found_resource(iotcon_client_h resource, void *user_data) if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_query_insert() Fail(%d)", ret); iotcon_query_destroy(query); - resource_sid_list = g_list_remove(resource_sid_list, door_resource_sid); - free(door_resource_sid); + device_id_list = g_list_remove(device_id_list, door_resource_device_id); + free(door_resource_device_id); return; } /* send GET Request */ - ret = iotcon_get(resource, query, _on_get, NULL); + ret = iotcon_remote_resource_get(resource, query, _on_get, NULL); if (IOTCON_ERROR_NONE != ret) - ERR("iotcon_get() Fail(%d)", ret); + ERR("iotcon_remote_resource_get() Fail(%d)", ret); iotcon_query_destroy(query); } - resource_sid_list = g_list_remove(resource_sid_list, door_resource_sid); - free(door_resource_sid); + device_id_list = g_list_remove(device_id_list, door_resource_device_id); + free(door_resource_device_id); } int main(int argc, char **argv) @@ -397,7 +396,7 @@ int main(int argc, char **argv) g_main_loop_run(loop); g_main_loop_unref(loop); - g_list_free_full(resource_sid_list, free); + g_list_free_full(device_id_list, free); /* iotcon close */ iotcon_close(); diff --git a/test/crud-test-server.c b/test/crud-test-server.c index 3b35b16..0a37ee0 100644 --- a/test/crud-test-server.c +++ b/test/crud-test-server.c @@ -107,11 +107,11 @@ static iotcon_resource_h _create_door_resource(char *uri_path, char *type, int i } /* register door resource */ - ret = iotcon_register_resource(uri_path, resource_types, ifaces, properties, + ret = iotcon_resource_create(uri_path, resource_types, ifaces, properties, _request_handler, user_data, &handle); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(resource_types); - ERR("iotcon_register_resource() Fail"); + ERR("iotcon_resource_create() Fail"); return NULL; } @@ -393,7 +393,7 @@ static void _request_handler_delete(iotcon_resource_h resource, iotcon_response_result_e result = IOTCON_RESPONSE_RESULT_OK; INFO("DELETE request"); - ret = iotcon_unregister_resource(resource); + ret = iotcon_resource_destroy(resource); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_unregiser_resource() Fail(%d)", ret); return; @@ -557,7 +557,7 @@ int main(int argc, char **argv) g_main_loop_run(loop); g_main_loop_unref(loop); - iotcon_unregister_resource(my_door.handle); + iotcon_resource_destroy(my_door.handle); _free_door_resource(&my_door); diff --git a/test/repr-test-client.c b/test/repr-test-client.c index 198894a..4616a7a 100644 --- a/test/repr-test-client.c +++ b/test/repr-test-client.c @@ -19,8 +19,8 @@ #include #include "test.h" -static char *room_resource_sid; -static GList *resource_sid_list; +static char *room_resource_device_id; +static GList *device_id_list; static const char* const room_uri_path = "/a/room"; @@ -157,14 +157,20 @@ static void _on_get(iotcon_representation_h recv_repr, int response_result) } } -static void _on_get_2nd(iotcon_client_h resource, iotcon_representation_h recv_repr, - iotcon_options_h header_options, int response_result, void *user_data) +static void _on_get_2nd(iotcon_remote_resource_h resource, + iotcon_representation_h recv_repr, + iotcon_options_h header_options, + int response_result, + void *user_data) { _on_get(recv_repr, response_result); } -static void _on_get_1st(iotcon_client_h resource, iotcon_representation_h recv_repr, - iotcon_options_h header_options, int response_result, void *user_data) +static void _on_get_1st(iotcon_remote_resource_h resource, + iotcon_representation_h recv_repr, + iotcon_options_h header_options, + int response_result, + void *user_data) { int ret; iotcon_query_h query_params; @@ -185,9 +191,9 @@ static void _on_get_1st(iotcon_client_h resource, iotcon_representation_h recv_r } /* send GET request again with BATCH interface */ - ret = iotcon_get(resource, query_params, _on_get_2nd, NULL); + ret = iotcon_remote_resource_get(resource, query_params, _on_get_2nd, NULL); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_get() Fail(%d)", ret); + ERR("iotcon_remote_resource_get() Fail(%d)", ret); iotcon_query_destroy(query_params); return; } @@ -204,19 +210,18 @@ static int _get_res_type_fn(const char *string, void *user_data) return IOTCON_FUNC_CONTINUE; } -static int _sid_compare(const void *a, const void *b) +static int _device_id_compare(const void *a, const void *b) { return strcmp(a, b); } -static void _found_resource(iotcon_client_h resource, void *user_data) +static void _found_resource(iotcon_remote_resource_h resource, void *user_data) { - int ret; GList *node; - char *resource_sid; char *resource_host; char *resource_uri_path; - int resource_interfaces; + char *resource_device_id; + int ret, resource_interfaces; iotcon_resource_types_h resource_types; if (NULL == resource) @@ -225,51 +230,51 @@ static void _found_resource(iotcon_client_h resource, void *user_data) INFO("===== resource found ====="); /* get the resource URI */ - ret = iotcon_client_get_uri_path(resource, &resource_uri_path); + ret = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_uri_path() Fail(%d)", ret); + ERR("iotcon_remote_resource_get_uri_path() Fail(%d)", ret); return; } - /* get the resource server id */ - ret = iotcon_client_get_device_id(resource, &resource_sid); + /* get the resource device id */ + ret = iotcon_remote_resource_get_device_id(resource, &resource_device_id); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_device_id() Fail(%d)", ret); + ERR("iotcon_remote_resource_get_device_id() Fail(%d)", ret); return; } - DBG("[%s] resource server id : %s", resource_uri_path, resource_sid); + DBG("[%s] resource device id : %s", resource_uri_path, resource_device_id); - node = g_list_find_custom(resource_sid_list, resource_sid, _sid_compare); + node = g_list_find_custom(device_id_list, resource_device_id, _device_id_compare); if (node && TEST_STR_EQUAL == strcmp(room_uri_path, resource_uri_path)) { DBG("uri_path \"%s\" already found. skip !", resource_uri_path); return; } - room_resource_sid = strdup(resource_sid); - if (NULL == room_resource_sid) { - ERR("strdup(room_resource_sid) Fail"); + room_resource_device_id = strdup(resource_device_id); + if (NULL == room_resource_device_id) { + ERR("strdup(room_resource_device_id) Fail"); return; } - resource_sid_list = g_list_append(resource_sid_list, room_resource_sid); + device_id_list = g_list_append(device_id_list, room_resource_device_id); /* get the resource host address */ - ret = iotcon_client_get_host(resource, &resource_host); + ret = iotcon_remote_resource_get_host(resource, &resource_host); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_host() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, room_resource_sid); - free(room_resource_sid); + ERR("iotcon_remote_resource_get_host() Fail(%d)", ret); + device_id_list = g_list_remove(device_id_list, room_resource_device_id); + free(room_resource_device_id); return; } DBG("[%s] resource host : %s", resource_uri_path, resource_host); /* get the resource interfaces */ - ret = iotcon_client_get_interfaces(resource, &resource_interfaces); + ret = iotcon_remote_resource_get_interfaces(resource, &resource_interfaces); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_interfaces() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, room_resource_sid); - free(room_resource_sid); + ERR("iotcon_remote_resource_get_interfaces() Fail(%d)", ret); + device_id_list = g_list_remove(device_id_list, room_resource_device_id); + free(room_resource_device_id); return; } if (IOTCON_INTERFACE_DEFAULT & resource_interfaces) @@ -282,31 +287,31 @@ static void _found_resource(iotcon_client_h resource, void *user_data) DBG("[%s] resource interface : GROUP_INTERFACE", resource_uri_path); /* get the resource types */ - ret = iotcon_client_get_types(resource, &resource_types); + ret = iotcon_remote_resource_get_types(resource, &resource_types); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_client_get_types() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, room_resource_sid); - free(room_resource_sid); + ERR("iotcon_remote_resource_get_types() Fail(%d)", ret); + device_id_list = g_list_remove(device_id_list, room_resource_device_id); + free(room_resource_device_id); return; } ret = iotcon_resource_types_foreach(resource_types, _get_res_type_fn, resource_uri_path); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_resource_types_foreach() Fail(%d)", ret); - resource_sid_list = g_list_remove(resource_sid_list, room_resource_sid); - free(room_resource_sid); + device_id_list = g_list_remove(device_id_list, room_resource_device_id); + free(room_resource_device_id); return; } if (TEST_STR_EQUAL == strcmp(room_uri_path, resource_uri_path)) { /* send GET request */ - ret = iotcon_get(resource, NULL, _on_get_1st, NULL); + ret = iotcon_remote_resource_get(resource, NULL, _on_get_1st, NULL); if (IOTCON_ERROR_NONE != ret) - ERR("iotcon_get() Fail(%d)", ret); + ERR("iotcon_remote_resource_get() Fail(%d)", ret); } - resource_sid_list = g_list_remove(resource_sid_list, room_resource_sid); - free(room_resource_sid); + device_id_list = g_list_remove(device_id_list, room_resource_device_id); + free(room_resource_device_id); } int main(int argc, char **argv) @@ -336,7 +341,7 @@ int main(int argc, char **argv) g_main_loop_run(loop); g_main_loop_unref(loop); - g_list_free_full(resource_sid_list, free); + g_list_free_full(device_id_list, free); /* iotcon close */ iotcon_close(); diff --git a/test/repr-test-server.c b/test/repr-test-server.c index f7d6090..1f9d951 100644 --- a/test/repr-test-server.c +++ b/test/repr-test-server.c @@ -512,12 +512,12 @@ int main(int argc, char **argv) return -1; } - ret = iotcon_register_resource("/a/room", room_rtypes, + ret = iotcon_resource_create("/a/room", room_rtypes, (IOTCON_INTERFACE_DEFAULT | IOTCON_INTERFACE_BATCH), (IOTCON_DISCOVERABLE | IOTCON_OBSERVABLE), _room_request_handler, NULL, &room_handle); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_register_resource() Fail(%d)", ret); + ERR("iotcon_resource_create() Fail(%d)", ret); iotcon_resource_types_destroy(room_rtypes); iotcon_close(); return -1; @@ -528,7 +528,7 @@ int main(int argc, char **argv) ret = iotcon_resource_types_create(&light_rtypes); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_resource_types_create() Fail(%d)", ret); - iotcon_unregister_resource(room_handle); + iotcon_resource_destroy(room_handle); iotcon_close(); return -1; } @@ -536,19 +536,19 @@ int main(int argc, char **argv) if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_resource_types_insert(%s) Fail(%d)", "core.light", ret); iotcon_resource_types_destroy(light_rtypes); - iotcon_unregister_resource(room_handle); + iotcon_resource_destroy(room_handle); iotcon_close(); return -1; } - ret = iotcon_register_resource("/a/light", light_rtypes, + ret = iotcon_resource_create("/a/light", light_rtypes, (IOTCON_INTERFACE_DEFAULT | IOTCON_INTERFACE_BATCH), (IOTCON_DISCOVERABLE | IOTCON_OBSERVABLE), _light_request_handler, NULL, &light_handle); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_register_resource() Fail"); + ERR("iotcon_resource_create() Fail"); iotcon_resource_types_destroy(light_rtypes); - iotcon_unregister_resource(room_handle); + iotcon_resource_destroy(room_handle); iotcon_close(); return -1; } @@ -557,8 +557,8 @@ int main(int argc, char **argv) ret = iotcon_resource_bind_child_resource(room_handle, light_handle); if (IOTCON_ERROR_NONE != ret) { ERR("iotcon_resource_bind_child_resource() Fail"); - iotcon_unregister_resource(light_handle); - iotcon_unregister_resource(room_handle); + iotcon_resource_destroy(light_handle); + iotcon_resource_destroy(room_handle); iotcon_close(); return -1; } @@ -566,8 +566,8 @@ int main(int argc, char **argv) g_main_loop_run(loop); g_main_loop_unref(loop); - iotcon_unregister_resource(light_handle); - iotcon_unregister_resource(room_handle); + iotcon_resource_destroy(light_handle); + iotcon_resource_destroy(room_handle); /* iotcon close */ iotcon_close();