<arg type="i" name="ret" direction="out"/>
</method>
<method name="get">
- <arg type="(ssba(qs)i)" name="client" direction="in"/>
+ <arg type="(ssba(qs)i)" name="remote_resource" direction="in"/>
<arg type="a(ss)" name="query" direction="in"/>
<arg type="(a(qs)vi)" name="ret" direction="out"/>
</method>
<method name="put">
- <arg type="(ssba(qs)i)" name="client" direction="in"/>
+ <arg type="(ssba(qs)i)" name="remote_resource" direction="in"/>
<arg type="(siasa{sv}av)" name="repr" direction="in"/>
<arg type="a(ss)" name="query" direction="in"/>
<arg type="(a(qs)vi)" name="ret" direction="out"/>
</method>
<method name="post">
- <arg type="(ssba(qs)i)" name="client" direction="in"/>
+ <arg type="(ssba(qs)i)" name="remote_resource" direction="in"/>
<arg type="(siasa{sv}av)" name="repr" direction="in"/>
<arg type="a(ss)" name="query" direction="in"/>
<arg type="(a(qs)vi)" name="ret" direction="out"/>
</method>
<method name="delete">
- <arg type="(ssba(qs)i)" name="client" direction="in"/>
+ <arg type="(ssba(qs)i)" name="remote_resource" direction="in"/>
<arg type="(a(qs)i)" name="ret" direction="out"/>
</method>
<method name="observerStart">
- <arg type="(ssba(qs)i)" name="client" direction="in"/>
+ <arg type="(ssba(qs)i)" name="remote_resource" direction="in"/>
<arg type="i" name="observe_type" direction="in"/>
<arg type="a(ss)" name="query" direction="in"/>
<arg type="u" name="signal_number" direction="in"/>
static gboolean _dbus_handle_observer_start(icDbus *object,
GDBusMethodInvocation *invocation,
- GVariant *client,
+ GVariant *resource,
gint observe_type,
GVariant *query,
guint signal_number)
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");
* 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
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);
// 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;
}
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);
}
...
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);
* @code
#include <iotcon.h>
...
-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)
...
{
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;
}
* <td><b>Client</b></td>
* </tr>
* <tr>
- * <td>iotcon_register_resource</td>
+ * <td>iotcon_resource_create</td>
* <td>iotcon_get_device_info</td>
* </tr>
* <tr>
- * <td>iotcon_unregister_resource</td>
+ * <td>iotcon_resource_destroy</td>
* <td>iotcon_subscribe_presence</td>
* </tr>
* <tr>
* </tr>
* <tr>
* <td>iotcon_resource_bind_request_handler</td>
- * <td>iotcon_observer_start</td>
+ * <td>iotcon_remote_resource_observer_start</td>
* </tr>
* <tr>
* <td>iotcon_resource_bind_child_resource</td>
- * <td>iotcon_observer_stop</td>
+ * <td>iotcon_remote_resource_observer_stop</td>
* </tr>
* <tr>
* <td>iotcon_resource_unbind_child_resource</td>
- * <td>iotcon_get</td>
+ * <td>iotcon_remote_resource_get</td>
* </tr>
* <tr>
* <td>iotcon_register_device_info</td>
- * <td>iotcon_put</td>
+ * <td>iotcon_remote_resource_put</td>
* </tr>
* <tr>
* <td>iotcon_start_presence</td>
- * <td>iotcon_post</td>
+ * <td>iotcon_remote_resource_post</td>
* </tr>
* <tr>
* <td>iotcon_stop_presence</td>
- * <td>iotcon_delete</td>
+ * <td>iotcon_remote_resource_delete</td>
* </tr>
* <tr>
* <td>iotcon_response_send</td>
#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"
}
-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;
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);
info = calloc(1, sizeof(iotcon_platform_info_s));
if (NULL == info) {
- ERR("calloc(client) Fail(%d)", errno);
+ ERR("calloc(info) Fail(%d)", errno);
return;
}
#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;
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);
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;
}
if (header_options)
iotcon_options_destroy(header_options);
- iotcon_client_destroy(cb_container->resource);
+ iotcon_remote_resource_destroy(cb_container->resource);
free(cb_container);
}
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;
}
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;
}
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;
}
}
-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);
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;
}
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;
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;
}
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);
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;
}
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;
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;
}
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;
}
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);
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;
}
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;
}
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);
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;
}
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;
}
{
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;
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;
}
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;
}
_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;
}
}
-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;
#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"
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,
{
FN_CALL;
int conn_type;
- iotcon_client_h client;
+ iotcon_remote_resource_h resource;
GVariant *payload;
icl_found_resource_s *cb_container = user_data;
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?
/* 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) {
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);
}
-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);
/* 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);
/* 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);
/* 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);
}
/* 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);
}
-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);
}
-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);
/* 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);
}
-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) {
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;
}
/* 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,
}
-API int iotcon_unregister_resource(iotcon_resource_h resource)
+API int iotcon_resource_destroy(iotcon_resource_h resource)
{
FN_CALL;
int ret;
}
-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);
/**
* @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
/**
* @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
*/
/**
* @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
*/
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
*
* @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
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
* @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
* @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.
*
* @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,
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
* @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
* @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()
* @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()
* @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);
/**
* @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()
*/
* @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()
*/
*
* @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.
* @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.
*
* @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.
* @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
* @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,
/**
* @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
* @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
* @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.
* @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()
*/
* @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()
*/
* @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
* @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
* @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
* @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
* @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
* @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
* @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);
/**
* @}
#include <iotcon.h>
#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,
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,
/* 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,
}
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;
}
/* 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;
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);
}
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;
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)
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;
}
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;
}
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;
}
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)
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();
}
/* 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;
}
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;
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);
#include <iotcon.h>
#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";
}
}
-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;
}
/* 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;
}
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)
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)
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)
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();
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;
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;
}
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;
}
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;
}
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();