<arg type="i" name="ret" direction="out"/>
</method>
<method name="sendResponse">
- <arg type="(sia(qs)ivxx)" name="response" direction="in"/>
+ <arg type="(ia(qs)ivxx)" name="response" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="findResource">
return ret;
}
-
static int _ocprocess_parse_oic_result(OCStackResult result)
{
int res;
int icd_ioty_send_response(GVariant *resp)
{
- char *new_uri_path;
GVariant *repr_gvar;
GVariantIter *options;
OCStackResult ret;
int result, error_code, options_size;
int64_t request_handle, resource_handle;
- g_variant_get(resp, "(&sia(qs)ivxx)",
- &new_uri_path,
+ g_variant_get(resp, "(ia(qs)ivxx)",
&error_code,
&options,
&result,
response.resourceHandle = ICD_INT64_TO_POINTER(resource_handle);
response.ehResult = (OCEntityHandlerResult)result;
- if (OC_EH_RESOURCE_CREATED == response.ehResult)
- snprintf(response.resourceUri, sizeof(response.resourceUri), "%s", new_uri_path);
-
options_size = g_variant_iter_n_children(options);
response.numSendVendorSpecificHeaderOptions = options_size;
case ICD_TIZEN_INFO:
ic_dbus_complete_get_tizen_info(icd_dbus_get_object(), invocation, value);
break;
+ default:
+ INFO("Invalid type(%d)", type);
}
}
cur->next = icd_payload_representation_from_gvariant(child);
cur = cur->next;
}
-
return repr;
}
* Example :
* @code
#include <iotcon.h>
-static void _on_get(iotcon_options_h header_options, iotcon_representation_h recv_repr,
- int response_result, void *user_data)
+static void _on_get(iotcon_remote_resource_h resource, iotcon_error_e err,
+ iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
{
// handle get from response
}
...
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)
+static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err,
+ iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
{
}
...
return NULL;
}
- value = g_variant_new("(sia(qs)ivxx)",
- ic_utils_dbus_encode_str(response->new_uri_path),
+ value = g_variant_new("(ia(qs)ivxx)",
response->error_code,
&options,
response->result,
}
static void _caching_get_cb(iotcon_remote_resource_h resource,
- iotcon_representation_h repr,
- iotcon_options_h options,
- int response_result,
+ iotcon_error_e err,
+ iotcon_request_type_e request_type,
+ iotcon_response_h resp,
void *user_data)
{
int ret;
+ int result;
+ iotcon_representation_h repr = NULL;
iotcon_representation_h cloned_repr;
RET_IF(NULL == resource);
RET_IF(NULL == resource->caching_handle);
- RET_IF(IOTCON_RESPONSE_RESULT_OK != response_result);
+ RETM_IF(IOTCON_ERROR_NONE != err, "_caching_get Fail(%d)", err);
+
+ ret = iotcon_response_get_result(resp, &result);
+ if (IOTCON_ERROR_NONE != ret || IOTCON_RESPONSE_RESULT_OK != result) {
+ ERR("Invalid result (%d)", result);
+ return;
+ }
+
+ ret = iotcon_response_get_representation(resp, &repr);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_representation() Fail(%d)", ret);
+ return;
+ }
ret = _caching_compare_repr(resource->caching_handle->repr, repr);
if (IC_EQUAL == ret) { /* same */
#include "icl-dbus.h"
#include "icl-dbus-type.h"
#include "icl-repr.h"
+#include "icl-response.h"
#include "icl-remote-resource.h"
#include "icl-payload.h"
typedef struct {
- iotcon_remote_resource_cru_cb cb;
+ iotcon_remote_resource_response_cb cb;
void *user_data;
iotcon_remote_resource_h resource;
-} icl_on_cru_s;
+} icl_on_response_s;
-typedef struct {
- iotcon_remote_resource_delete_cb cb;
- void *user_data;
- iotcon_remote_resource_h resource;
-} icl_on_delete_s;
-
-typedef struct {
- iotcon_remote_resource_observe_cb cb;
- void *user_data;
- iotcon_remote_resource_h resource;
-} icl_on_observe_s;
-
-static GList *icl_cru_cb_list = NULL;
-static GList *icl_delete_cb_list = NULL;
+static GList *icl_crud_cb_list = NULL;
void icl_remote_resource_crud_stop(iotcon_remote_resource_h resource)
{
GList *c;
- for (c = icl_cru_cb_list; c; c = c->next) {
- icl_on_cru_s *cb_container = c->data;
- if (NULL == cb_container) {
- ERR("cb_container is NULL");
- continue;
- }
- if (cb_container->resource == resource)
- cb_container->cb = NULL;
- }
-
- for (c = icl_delete_cb_list; c; c = c->next) {
- icl_on_delete_s *cb_container = c->data;
+ for (c = icl_crud_cb_list; c; c = c->next) {
+ icl_on_response_s *cb_container = c->data;
if (NULL == cb_container) {
ERR("cb_container is NULL");
continue;
}
}
-
-static void _icl_on_cru_cb(GVariant *result, icl_on_cru_s *cb_container)
+static int _icl_parse_crud_gvariant(iotcon_request_type_e request_type,
+ GVariant *gvar, iotcon_response_h *response)
{
- int res, ret;
- iotcon_representation_h repr;
- GVariantIter *options;
- unsigned short option_id;
- char *option_data;
- GVariant *repr_gvar;
- iotcon_options_h header_options = NULL;
- iotcon_remote_resource_cru_cb cb = cb_container->cb;
-
- g_variant_get(result, "(a(qs)vi)", &options, &repr_gvar, &res);
-
- icl_cru_cb_list = g_list_remove(icl_cru_cb_list, cb_container);
-
- if (IOTCON_ERROR_NONE == res && g_variant_iter_n_children(options)) {
- ret = iotcon_options_create(&header_options);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_options_create() Fail(%d)", ret);
- free(cb_container);
- return;
+ int res;
+ int ret;
+ int seq_number = -1;
+ GVariantIter *options_iter = NULL;
+ GVariant *repr_gvar = NULL;
+ iotcon_response_h resp = NULL;
+ iotcon_options_h options = NULL;
+ iotcon_representation_h repr = NULL;
+
+ if (IOTCON_REQUEST_OBSERVE == request_type)
+ g_variant_get(gvar, "(a(qs)vii)", &options_iter, &repr_gvar, &res, &seq_number);
+ else if (IOTCON_REQUEST_DELETE == request_type)
+ g_variant_get(gvar, "(a(qs)i)", &options_iter, &res);
+ else
+ g_variant_get(gvar, "(a(qs)vi)", &options_iter, &repr_gvar, &res);
+
+ if (options_iter) {
+ if (g_variant_iter_n_children(options_iter)) {
+ unsigned short option_id;
+ char *option_data;
+
+ ret = iotcon_options_create(&options);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_options_create() Fail(%d)", ret);
+ return ret;
+ }
+ while (g_variant_iter_loop(options_iter, "(q&s)", &option_id, &option_data))
+ iotcon_options_add(options, option_id, option_data);
}
-
- while (g_variant_iter_loop(options, "(q&s)", &option_id, &option_data))
- iotcon_options_add(header_options, option_id, option_data);
+ g_variant_iter_free(options_iter);
}
- g_variant_iter_free(options);
- repr = icl_representation_from_gvariant(repr_gvar);
- if (NULL == repr) {
- ERR("icl_representation_from_gvariant() Fail");
- if (header_options)
- iotcon_options_destroy(header_options);
- free(cb_container);
- return;
+ if (repr_gvar) {
+ repr = icl_representation_from_gvariant(repr_gvar);
+ if (NULL == repr) {
+ ERR("icl_representation_from_gvariant() Fail");
+ if (options)
+ iotcon_options_destroy(options);
+ return IOTCON_ERROR_SYSTEM;
+ }
}
res = icl_dbus_convert_daemon_error(res);
- if (cb)
- cb(cb_container->resource, repr, header_options, res,
- cb_container->user_data);
+ resp = calloc(1, sizeof(struct icl_resource_response));
+ if (NULL == resp) {
+ ERR("calloc() Fail(%d)", errno);
+ if (repr)
+ iotcon_representation_destroy(repr);
+ if (options)
+ iotcon_options_destroy(options);
+ return IOTCON_ERROR_OUT_OF_MEMORY;
+ }
+ resp->result = res;
+ resp->repr = repr;
+ resp->header_options = options;
+ resp->seq_number = seq_number;
- if (repr)
- iotcon_representation_destroy(repr);
- if (header_options)
- iotcon_options_destroy(header_options);
+ *response = resp;
- free(cb_container);
+ return IOTCON_ERROR_NONE;
}
-
-static void _icl_on_get_cb(GObject *object, GAsyncResult *g_async_res,
- gpointer user_data)
+static void _icl_on_crud_cb(iotcon_request_type_e request_type,
+ GObject *object, GAsyncResult *g_async_res, icl_on_response_s *cb_container)
{
+ int ret;
+ iotcon_response_h response = NULL;
GVariant *result;
GError *error = NULL;
- icl_on_cru_s *cb_container = user_data;
- ic_dbus_call_get_finish(IC_DBUS(object), &result, g_async_res, &error);
+ RET_IF(NULL == cb_container);
+
+ icl_crud_cb_list = g_list_remove(icl_crud_cb_list, cb_container);
+
+ switch (request_type) {
+ case IOTCON_REQUEST_GET:
+ ic_dbus_call_get_finish(IC_DBUS(object), &result, g_async_res, &error);
+ break;
+ case IOTCON_REQUEST_PUT:
+ ic_dbus_call_put_finish(IC_DBUS(object), &result, g_async_res, &error);
+ break;
+ case IOTCON_REQUEST_POST:
+ ic_dbus_call_post_finish(IC_DBUS(object), &result, g_async_res, &error);
+ break;
+ case IOTCON_REQUEST_DELETE:
+ ic_dbus_call_delete_finish(IC_DBUS(object), &result, g_async_res, &error);
+ break;
+ default:
+ ERR("Invalid type(%d)", request_type);
+ return;
+ }
+
if (error) {
- ERR("ic_dbus_call_get_finish() Fail(%s)", error->message);
+ ERR("ic_dbus_call_finish() Fail(%d, %s)", request_type, error->message);
if (cb_container->cb) {
int ret = icl_dbus_convert_dbus_error(error->code);
- cb_container->cb(cb_container->resource, NULL, NULL, ret,
+ cb_container->cb(cb_container->resource, ret, request_type, NULL,
cb_container->user_data);
}
g_error_free(error);
return;
}
- _icl_on_cru_cb(result, cb_container);
-}
-
-
-static void _icl_on_put_cb(GObject *object, GAsyncResult *g_async_res,
- gpointer user_data)
-{
- GVariant *result;
- GError *error = NULL;
- icl_on_cru_s *cb_container = user_data;
-
- ic_dbus_call_put_finish(IC_DBUS(object), &result, g_async_res, &error);
- if (error) {
- ERR("ic_dbus_call_put_finish() Fail(%s)", error->message);
+ ret = _icl_parse_crud_gvariant(request_type, result, &response);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("_icl_parse_crud_gvariant() Fail(%s)", ret);
if (cb_container->cb) {
- int ret = icl_dbus_convert_dbus_error(error->code);
- cb_container->cb(cb_container->resource, NULL, NULL, ret,
+ cb_container->cb(cb_container->resource, ret, request_type, NULL,
cb_container->user_data);
}
- g_error_free(error);
free(cb_container);
return;
}
+ if (cb_container->cb)
+ cb_container->cb(cb_container->resource, IOTCON_ERROR_NONE, request_type,
+ response, cb_container->user_data);
- _icl_on_cru_cb(result, cb_container);
+ if (response)
+ iotcon_response_destroy(response);
+
+ free(cb_container);
}
-static void _icl_on_post_cb(GObject *object, GAsyncResult *g_async_res,
+static void _icl_on_get_cb(GObject *object, GAsyncResult *g_async_res,
gpointer user_data)
{
- GVariant *result;
- GError *error = NULL;
- icl_on_cru_s *cb_container = user_data;
+ _icl_on_crud_cb(IOTCON_REQUEST_GET, object, g_async_res, user_data);
+}
- ic_dbus_call_post_finish(IC_DBUS(object), &result, g_async_res, &error);
- if (error) {
- ERR("ic_dbus_call_post_finish() Fail(%s)", error->message);
- if (cb_container->cb) {
- int ret = icl_dbus_convert_dbus_error(error->code);
- cb_container->cb(cb_container->resource, NULL, NULL, ret,
- cb_container->user_data);
- }
- g_error_free(error);
- free(cb_container);
- return;
- }
- _icl_on_cru_cb(result, cb_container);
+static void _icl_on_put_cb(GObject *object, GAsyncResult *g_async_res,
+ gpointer user_data)
+{
+ _icl_on_crud_cb(IOTCON_REQUEST_PUT, object, g_async_res, user_data);
+}
+
+
+static void _icl_on_post_cb(GObject *object, GAsyncResult *g_async_res,
+ gpointer user_data)
+{
+ _icl_on_crud_cb(IOTCON_REQUEST_POST, object, g_async_res, 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)
+ iotcon_query_h query, iotcon_remote_resource_response_cb cb, void *user_data)
{
GVariant *arg_query;
GVariant *arg_remote_resource;
- icl_on_cru_s *cb_container;
+ icl_on_response_s *cb_container;
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
- cb_container = calloc(1, sizeof(icl_on_cru_s));
+ cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
return IOTCON_ERROR_OUT_OF_MEMORY;
ic_dbus_call_get(icl_dbus_get_object(), arg_remote_resource, arg_query, NULL,
_icl_on_get_cb, cb_container);
- icl_cru_cb_list = g_list_append(icl_cru_cb_list, cb_container);
+ icl_crud_cb_list = g_list_append(icl_crud_cb_list, cb_container);
return IOTCON_ERROR_NONE;
}
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,
+ iotcon_remote_resource_response_cb cb,
void *user_data)
{
GVariant *arg_repr;
GVariant *arg_remote_resource;
GVariant *arg_query;
- icl_on_cru_s *cb_container;
+ icl_on_response_s *cb_container;
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
- cb_container = calloc(1, sizeof(icl_on_cru_s));
+ cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
return IOTCON_ERROR_OUT_OF_MEMORY;
ic_dbus_call_put(icl_dbus_get_object(), arg_remote_resource, arg_repr, arg_query,
NULL, _icl_on_put_cb, cb_container);
- icl_cru_cb_list = g_list_append(icl_cru_cb_list, cb_container);
+ icl_crud_cb_list = g_list_append(icl_crud_cb_list, cb_container);
return IOTCON_ERROR_NONE;
}
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,
+ iotcon_remote_resource_response_cb cb,
void *user_data)
{
GVariant *arg_repr;
GVariant *arg_query;
GVariant *arg_remote_resource;
- icl_on_cru_s *cb_container;
+ icl_on_response_s *cb_container;
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
- cb_container = calloc(1, sizeof(icl_on_cru_s));
+ cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
return IOTCON_ERROR_OUT_OF_MEMORY;
ic_dbus_call_post(icl_dbus_get_object(), arg_remote_resource, arg_repr, arg_query,
NULL, _icl_on_post_cb, cb_container);
- icl_cru_cb_list = g_list_append(icl_cru_cb_list, cb_container);
+ icl_crud_cb_list = g_list_append(icl_crud_cb_list, cb_container);
return IOTCON_ERROR_NONE;
}
static void _icl_on_delete_cb(GObject *object, GAsyncResult *g_async_res,
gpointer user_data)
{
- int res, ret;
- GVariant *result;
- char *option_data;
- GError *error = NULL;
- GVariantIter *options;
- unsigned short option_id;
- iotcon_options_h header_options = NULL;
-
- icl_on_delete_s *cb_container = user_data;
- iotcon_remote_resource_delete_cb cb = cb_container->cb;
-
- icl_delete_cb_list = g_list_remove(icl_delete_cb_list, cb_container);
-
- 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);
- if (cb_container->cb) {
- ret = icl_dbus_convert_dbus_error(error->code);
- cb_container->cb(cb_container->resource, NULL, ret, cb_container->user_data);
- }
- g_error_free(error);
- free(cb_container);
- return;
- }
- g_variant_get(result, "(a(qs)i)", &options, &res);
-
- if (IOTCON_ERROR_NONE == res && g_variant_iter_n_children(options)) {
- ret = iotcon_options_create(&header_options);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_options_create() Fail(%d)", ret);
- g_variant_iter_free(options);
- free(cb_container);
- return;
- }
-
- while (g_variant_iter_loop(options, "(q&s)", &option_id, &option_data))
- iotcon_options_add(header_options, option_id, option_data);
- }
- g_variant_iter_free(options);
-
- res = icl_dbus_convert_daemon_error(res);
-
- if (cb)
- cb(cb_container->resource, header_options, res, cb_container->user_data);
-
- if (header_options)
- iotcon_options_destroy(header_options);
-
- free(cb_container);
+ _icl_on_crud_cb(IOTCON_REQUEST_DELETE, object, g_async_res, user_data);
}
API int iotcon_remote_resource_delete(iotcon_remote_resource_h resource,
- iotcon_remote_resource_delete_cb cb, void *user_data)
+ iotcon_remote_resource_response_cb cb, void *user_data)
{
GVariant *arg_remote_resource;
- icl_on_delete_s *cb_container;
+ icl_on_response_s *cb_container;
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
- cb_container = calloc(1, sizeof(icl_on_delete_s));
+ cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
return IOTCON_ERROR_OUT_OF_MEMORY;
ic_dbus_call_delete(icl_dbus_get_object(), arg_remote_resource, NULL,
_icl_on_delete_cb, cb_container);
- icl_delete_cb_list = g_list_append(icl_delete_cb_list, cb_container);
+ icl_crud_cb_list = g_list_append(icl_crud_cb_list, cb_container);
return IOTCON_ERROR_NONE;
}
-
static void _icl_on_observe_cb(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
GVariant *parameters,
gpointer user_data)
{
- int res, ret;
- int seq_num;
- iotcon_representation_h repr;
- GVariantIter *options;
- unsigned short option_id;
- char *option_data;
- GVariant *repr_gvar;
- iotcon_options_h header_options = NULL;
-
- icl_on_observe_s *cb_container = user_data;
- 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 == res && g_variant_iter_n_children(options)) {
- ret = iotcon_options_create(&header_options);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_options_create() Fail(%d)", ret);
- g_variant_iter_free(options);
- free(cb_container);
- return;
- }
-
- while (g_variant_iter_loop(options, "(q&s)", &option_id, &option_data))
- iotcon_options_add(header_options, option_id, option_data);
- }
- g_variant_iter_free(options);
+ int ret;
+ iotcon_response_h response = NULL;
+ icl_on_response_s *cb_container = user_data;
- repr = icl_representation_from_gvariant(repr_gvar);
- if (NULL == repr) {
- ERR("icl_representation_from_gvariant() Fail");
- if (header_options)
- iotcon_options_destroy(header_options);
+ RET_IF(NULL == cb_container);
- free(cb_container);
+ ret = _icl_parse_crud_gvariant(IOTCON_REQUEST_OBSERVE, parameters, &response);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("_icl_parse_crud_gvariant() Fail(%d)", ret);
+ if (cb_container->cb) {
+ cb_container->cb(cb_container->resource, ret, IOTCON_REQUEST_OBSERVE, NULL,
+ cb_container->user_data);
+ }
return;
}
- res = icl_dbus_convert_daemon_error(res);
-
- if (cb)
- cb(cb_container->resource, repr, header_options, res, seq_num,
- cb_container->user_data);
+ if (cb_container->cb)
+ cb_container->cb(cb_container->resource, IOTCON_ERROR_NONE, IOTCON_REQUEST_OBSERVE,
+ response, cb_container->user_data);
- if (repr)
- iotcon_representation_destroy(repr);
- if (header_options)
- iotcon_options_destroy(header_options);
+ if (response)
+ iotcon_response_destroy(response);
}
-static void _icl_observe_conn_cleanup(icl_on_observe_s *cb_container)
+static void _icl_observe_conn_cleanup(icl_on_response_s *cb_container)
{
cb_container->resource->observe_handle = 0;
cb_container->resource->observe_sub_id = 0;
API int iotcon_remote_resource_start_observing(iotcon_remote_resource_h resource,
iotcon_observe_type_e observe_type,
iotcon_query_h query,
- iotcon_remote_resource_observe_cb cb,
+ iotcon_remote_resource_response_cb cb,
void *user_data)
{
int ret;
unsigned int sub_id;
int64_t observe_handle;
- icl_on_observe_s *cb_container;
+ icl_on_response_s *cb_container;
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(resource->observe_handle || resource->observe_sub_id, IOTCON_ERROR_ALREADY);
- cb_container = calloc(1, sizeof(icl_on_observe_s));
+ cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
return IOTCON_ERROR_OUT_OF_MEMORY;
#include "icl-remote-resource.h"
static void _monitoring_get_cb(iotcon_remote_resource_h resource,
- iotcon_representation_h repr,
- iotcon_options_h options,
- int response_result,
+ iotcon_error_e err,
+ iotcon_request_type_e request_type,
+ iotcon_response_h response,
void *user_data)
{
+ int ret;
+ int response_result;
iotcon_remote_resource_state_e resource_state;
RET_IF(NULL == resource);
RET_IF(NULL == resource->monitoring_handle);
+ RETM_IF(IOTCON_ERROR_NONE != err, "_monitoring_get Fail(%d)", err);
+
+ ret = iotcon_response_get_result(response, &response_result);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_result() Fail(%d)", ret);
+ return;
+ }
if (IOTCON_RESPONSE_RESULT_OK <= response_result)
resource_state = IOTCON_REMOTE_RESOURCE_STATE_ALIVE;
if (resp->repr)
iotcon_representation_destroy(resp->repr);
- if (resp->new_uri_path)
- free(resp->new_uri_path);
if (resp->header_options)
iotcon_options_destroy(resp->header_options);
free(resp);
}
+API int iotcon_response_get_options(iotcon_response_h resp,
+ iotcon_options_h *options)
+{
+ RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == resp->header_options, IOTCON_ERROR_NO_DATA);
-API int iotcon_response_set_new_uri_path(iotcon_response_h resp, char *new_uri_path)
+ *options = resp->header_options;
+
+ return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_response_get_representation(iotcon_response_h resp,
+ iotcon_representation_h *repr)
{
RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == resp->repr, IOTCON_ERROR_NO_DATA);
- if (resp->new_uri_path)
- free(resp->new_uri_path);
-
- if (new_uri_path) {
- resp->new_uri_path = strdup(new_uri_path);
- if (NULL == resp->new_uri_path) {
- ERR("strdup() Fail(%d)", errno);
- return IOTCON_ERROR_OUT_OF_MEMORY;
- }
- } else {
- resp->new_uri_path = NULL;
- }
+ *repr = resp->repr;
return IOTCON_ERROR_NONE;
+
}
+API int iotcon_response_get_result(iotcon_response_h resp, int *result)
+{
+ RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+
+ *result = resp->result;
+
+ return IOTCON_ERROR_NONE;
+}
API int iotcon_response_set_result(iotcon_response_h resp,
iotcon_response_result_e result)
struct icl_resource_response {
- char *new_uri_path;
int error_code;
+ int seq_number;
iotcon_options_h header_options;
iotcon_interface_e iface;
- iotcon_response_result_e result;
+ int result;
iotcon_representation_h repr;
int64_t oic_request_h;
int64_t oic_resource_h;
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
*
- * @see iotcon_remote_resource_observe_cb()
+ * @see iotcon_remote_resource_response_cb()
* @see iotcon_remote_resource_start_observing()
* @see iotcon_remote_resource_observer_stop()
* @see iotcon_resource_notify()
*/
int iotcon_remote_resource_clone(iotcon_remote_resource_h src, iotcon_remote_resource_h *dest);
+
/**
- * @brief Specifies the type of function passed to iotcon_remote_resource_start_observing().
- * @details Called when a client receive notifications from a server. The @a response_result could be one of #iotcon_response_result_e.
+ * @brief Specifies the type of function passed to iotcon_remote_resource_start_observing(),
+ * iotcon_remote_resource_get(), iotcon_remote_resource_put(), iotcon_remote_resource_post(),
+ * iotcon_remote_resource_delete().
+ * @details The @a err could be one of #iotcon_error_e.
+ * The @a request_type could be one of #iotcon_request_type_e.
*
* @since_tizen 3.0
*
* @param[in] resource The handle of the resource
- * @param[in] repr The handle of the representation
- * @param[in] options The handle of the header options
- * @param[in] response_result The response result code
- * @param[in] sequence_number The sequence of notifications from server.
+ * @param[in] err The error code
+ * @param[in] request_type The request type
+ * @param[in] response The handle of the response
* @param[in] user_data The user data passed from the callback registration function
*
- * @pre The callback must be registered using iotcon_remote_resource_start_observing()
+ * @pre The callback must be registered using iotcon_remote_resource_start_observing(),
+ * iotcon_remote_resource_get(), iotcon_remote_resource_put(), iotcon_remote_resource_post(),
+ * iotcon_remote_resource_delete()
*
* @see iotcon_remote_resource_start_observing()
*/
-typedef void (*iotcon_remote_resource_observe_cb)(iotcon_remote_resource_h resource,
- iotcon_representation_h repr,
- iotcon_options_h options,
- int response_result,
- int sequence_number,
+typedef void (*iotcon_remote_resource_response_cb)(iotcon_remote_resource_h resource,
+ iotcon_error_e err,
+ iotcon_request_type_e request_type,
+ iotcon_response_h response,
void *user_data);
/**
* @brief Sets observation on the resource
- * @details When server sends notification message, iotcon_remote_resource_observe_cb() will be called.
+ * @details When server sends notification message, iotcon_remote_resource_response_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_remote_resource_observe_cb() will be called.
+ * @post When the @a resource receive notification message, iotcon_remote_resource_response_cb() will be called.
*
- * @see iotcon_remote_resource_observe_cb()
+ * @see iotcon_remote_resource_response_cb()
* @see iotcon_remote_resource_observer_stop()
* @see iotcon_notimsg_create()
* @see iotcon_resource_notify()
int iotcon_remote_resource_start_observing(iotcon_remote_resource_h resource,
iotcon_observe_type_e observe_type,
iotcon_query_h query,
- iotcon_remote_resource_observe_cb cb,
+ iotcon_remote_resource_response_cb cb,
void *user_data);
/**
* @retval #IOTCON_ERROR_SYSTEM System error
* @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied
*
- * @see iotcon_remote_resource_observe_cb()
+ * @see iotcon_remote_resource_response_cb()
* @see iotcon_remote_resource_start_observing()
* @see iotcon_notimsg_create()
* @see iotcon_resource_notify()
int iotcon_remote_resource_observer_stop(iotcon_remote_resource_h resource);
/**
- * @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] resource The handle of the resource
- * @param[in] repr The handle of the representation
- * @param[in] options The handle of the header options
- * @param[in] response_result The response result code (Lesser than 0 on fail, otherwise a response result value)
- * @param[in] user_data The user data to pass to the function
- *
- * @pre The callback must be registered using iotcon_remote_resource_get(), iotcon_remote_resource_put(), iotcon_remote_resource_post()
- *
- * @see iotcon_remote_resource_get()
- * @see iotcon_remote_resource_put()
- * @see iotcon_remote_resource_post()
- */
-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_remote_resource_cru_cb() will be called.
+ * @details When server sends response on get request, iotcon_remote_resource_response_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_remote_resource_cru_cb() will be called.
+ * @post When the client receive get response, iotcon_remote_resource_response_cb() will be called.
*
- * @see iotcon_remote_resource_cru_cb()
+ * @see iotcon_remote_resource_response_cb()
* @see iotcon_remote_resource_put()
* @see iotcon_remote_resource_post()
*/
int iotcon_remote_resource_get(iotcon_remote_resource_h resource, iotcon_query_h query,
- iotcon_remote_resource_cru_cb cb, void *user_data);
+ iotcon_remote_resource_response_cb cb, void *user_data);
/**
* @brief Sets the representation of a resource (via PUT)
- * @details When server sends response on put request, iotcon_remote_resource_cru_cb() will be called.
+ * @details When server sends response on put request, iotcon_remote_resource_response_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_remote_resource_cru_cb() will be called.
+ * @post When the client receive put response, iotcon_remote_resource_response_cb() will be called.
*
- * @see iotcon_remote_resource_cru_cb()
+ * @see iotcon_remote_resource_response_cb()
* @see iotcon_remote_resource_get()
* @see iotcon_remote_resource_post()
*/
int iotcon_remote_resource_put(iotcon_remote_resource_h resource,
iotcon_representation_h repr,
iotcon_query_h query,
- iotcon_remote_resource_cru_cb cb,
+ iotcon_remote_resource_response_cb cb,
void *user_data);
/**
* @brief Posts on a resource
- * @details When server sends response on post request, iotcon_remote_resource_cru_cb() will be called.
+ * @details When server sends response on post request, iotcon_remote_resource_response_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_remote_resource_cru_cb() will be called.
+ * @post When the client receive post response, iotcon_remote_resource_response_cb() will be called.
*
- * @see iotcon_remote_resource_cru_cb()
+ * @see iotcon_remote_resource_response_cb()
* @see iotcon_remote_resource_get()
* @see iotcon_remote_resource_put()
*/
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_remote_resource_delete()
- * @details The @a response_result could be one of #iotcon_response_result_e.
- *
- * @since_tizen 3.0
- *
- * @param[in] resource The handle of the resource
- * @param[in] options The handle of the header options
- * @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_remote_resource_delete()
- *
- * @see iotcon_remote_resource_delete()
- */
-typedef void (*iotcon_remote_resource_delete_cb)(iotcon_remote_resource_h resource,
- iotcon_options_h options,
- int response_result,
+ iotcon_remote_resource_response_cb cb,
void *user_data);
/**
* @brief Deletes a resource.
- * @details When server sends response on delete request, iotcon_remote_resource_delete_cb() will be called.
+ * @details When server sends response on delete request, iotcon_remote_resource_response_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_remote_resource_delete_cb() will be called.
+ * @post When the client receive delete response, iotcon_remote_resource_response_cb() will be called.
*
- * @see iotcon_remote_resource_delete_cb()
+ * @see iotcon_remote_resource_response_cb()
*/
int iotcon_remote_resource_delete(iotcon_remote_resource_h resource,
- iotcon_remote_resource_delete_cb cb, void *user_data);
+ iotcon_remote_resource_response_cb cb, void *user_data);
/**
* @brief Specifies the type of function passed to iotcon_remote_resource_start_caching().
* @retval #IOTCON_ERROR_SYSTEM System error
* @retval #IOTCON_ERROR_PERMISSION_DENIED Permission denied
*
- * @see iotcon_remote_resource_observe_cb()
+ * @see iotcon_remote_resource_response_cb()
* @see iotcon_remote_resource_start_observing()
* @see iotcon_remote_resource_observer_stop()
* @see iotcon_notimsg_create()
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef __IOT_CONNECTIVITY_MANAGER_SERVER_RESPONSE_H__
-#define __IOT_CONNECTIVITY_MANAGER_SERVER_RESPONSE_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_COMMON_RESPONSE_H__
+#define __IOT_CONNECTIVITY_MANAGER_COMMON_RESPONSE_H__
#include <iotcon-constant.h>
*/
/**
- * @ingroup CAPI_IOT_CONNECTIVITY_SERVER_MODULE
- * @defgroup CAPI_IOT_CONNECTIVITY_SERVER_RESPONSE_MODULE Response
+ * @ingroup CAPI_IOT_CONNECTIVITY_COMMON_MODULE
+ * @defgroup CAPI_IOT_CONNECTIVITY_COMMON_RESPONSE_MODULE Response
*
* @brief Iotcon Response provides API to manage response.
*
*/
void iotcon_response_destroy(iotcon_response_h resp);
+
/**
- * @brief Sets new uri path into the response
+ * @brief Gets header options of the response
*
* @since_tizen 3.0
*
* @param[in] resp The handle of the response
- * @param[in] new_uri_path New uri path to set
+ * @param[out] 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
- * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #IOTCON_ERROR_NO_DATA No data
*
- * @see iotcon_response_create()
- * @see iotcon_response_destroy()
+ * @see iotcon_response_get_representation()
+ * @see iotcon_response_get_result()
*/
-int iotcon_response_set_new_uri_path(iotcon_response_h resp, char *new_uri_path);
+int iotcon_response_get_options(iotcon_response_h resp, iotcon_options_h *options);
+
+/**
+ * @brief Gets representation of the response
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] resp The handle of the response
+ * @param[out] repr The handle of the representation
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data
+ *
+ * @see iotcon_response_get_options()
+ * @see iotcon_response_get_result()
+ */
+int iotcon_response_get_representation(iotcon_response_h resp, iotcon_representation_h *repr);
+
+/**
+ * @brief Gets result of the response
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] resp The handle of the response
+ * @param[out] result The result of the response
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see iotcon_response_get_options()
+ * @see iotcon_response_get_representation()
+ */
+int iotcon_response_get_result(iotcon_response_h resp, int *result);
+
/**
* @brief Sets result into the response
* @}
*/
-#endif /* __IOT_CONNECTIVITY_MANAGER_SERVER_RESPONSE_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_COMMON_RESPONSE_H__ */
static const char* const door_uri_path = "/a/door";
-static void _on_observe(iotcon_remote_resource_h resource,
- iotcon_representation_h recv_repr,
- iotcon_options_h header_options,
- int response_result,
- int sequence_number,
- void *user_data)
+static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err,
+ iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
{
INFO("_on_observe");
}
}
-static void _on_delete(iotcon_remote_resource_h resource, iotcon_options_h header_options,
- int response_result, void *user_data)
+static void _on_delete(iotcon_remote_resource_h resource, iotcon_error_e err,
+ iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
{
- int ret;
+ int ret, response_result;
iotcon_remote_resource_h door_resource = user_data;
- RETM_IF(IOTCON_RESPONSE_RESULT_OK != response_result
- && IOTCON_RESPONSE_RESULT_RESOURCE_DELETED != response_result,
- "_on_delete Response error(%d)", response_result);
+ RETM_IF(IOTCON_ERROR_NONE != err, "_on_delete error(%d)", err);
+
+ ret = iotcon_response_get_result(response, &response_result);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_result() Fail(%d)", ret);
+ return;
+ }
+
+ if (IOTCON_RESPONSE_RESULT_OK != response_result
+ && IOTCON_RESPONSE_RESULT_RESOURCE_DELETED != response_result) {
+ ERR("_on_delete Response error(%d)", response_result);
+ return;
+ }
INFO("DELETE request was successful");
/* delete callback operations */
iotcon_remote_resource_destroy(resource);
}
-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)
+static void _on_post(iotcon_remote_resource_h resource, iotcon_error_e err,
+ iotcon_request_type_e type, iotcon_response_h response, void *user_data)
{
iotcon_state_h recv_state;
char *host, *created_uri_path;
- int ret, connectivity_type, ifaces = 0;
+ int ret, connectivity_type, response_result, ifaces = 0;
iotcon_resource_types_h types = NULL;
iotcon_remote_resource_h new_door_resource, door_resource;
+ iotcon_representation_h recv_repr = NULL;
+
+ RETM_IF(IOTCON_ERROR_NONE != err, "_on_post error(%d)", err);
+
+ ret = iotcon_response_get_result(response, &response_result);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_result() Fail(%d)", ret);
+ return;
+ }
- RETM_IF(IOTCON_RESPONSE_RESULT_OK != response_result
- && IOTCON_RESPONSE_RESULT_RESOURCE_CREATED != response_result,
- "_on_post Response error(%d)", response_result);
+ if (IOTCON_RESPONSE_RESULT_OK != response_result
+ && IOTCON_RESPONSE_RESULT_RESOURCE_CREATED != response_result) {
+ ERR("_on_post Response error(%d)", response_result);
+ return;
+ }
INFO("POST request was successful");
+ ret = iotcon_response_get_representation(response, &recv_repr);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_representation() Fail(%d)", ret);
+ return;
+ }
+
ret = iotcon_representation_get_state(recv_repr, &recv_state);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_representation_get_state() Fail(%d)", ret);
iotcon_remote_resource_destroy(resource);
}
-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)
+static void _on_put(iotcon_remote_resource_h resource, iotcon_error_e err,
+ iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
{
int ret;
+ int response_result;
iotcon_representation_h send_repr;
- RETM_IF(IOTCON_RESPONSE_RESULT_OK != response_result, "_on_put Response error(%d)",
- response_result);
+ RETM_IF(IOTCON_ERROR_NONE != err, "_on_put error(%d)", err);
+
+ ret = iotcon_response_get_result(response, &response_result);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_result() Fail(%d)", ret);
+ return;
+ }
+
+ if (IOTCON_RESPONSE_RESULT_OK != response_result) {
+ ERR("_on_put Response error(%d)", response_result);
+ return;
+ }
INFO("PUT request was successful");
ret = iotcon_representation_create(&send_repr);
iotcon_representation_destroy(send_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)
+static void _on_get(iotcon_remote_resource_h resource,
+ iotcon_error_e err,
+ iotcon_request_type_e request_type,
+ iotcon_response_h response,
+ void *user_data)
{
int ret;
+ int response_result;
bool opened = true;
iotcon_representation_h send_repr;
+ iotcon_representation_h recv_repr;
iotcon_state_h send_state;
iotcon_state_h recv_state = NULL;
- RETM_IF(IOTCON_RESPONSE_RESULT_OK != response_result, "_on_get Response error(%d)",
- response_result);
+ RETM_IF(IOTCON_ERROR_NONE != err, "_on_get error(%d)", err);
INFO("GET request was successful");
+ ret = iotcon_response_get_result(response, &response_result);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_result() Fail(%d)", ret);
+ return;
+ }
+
+ if (IOTCON_RESPONSE_RESULT_OK != response_result) {
+ ERR("_on_get Response error(%d)", response_result);
+ return;
+ }
+
+ /* get the resource host address */
+ char *resource_host = NULL;
+ iotcon_remote_resource_get_host_address(resource, &resource_host);
+ INFO("resource host : %s", resource_host);
+
+ ret = iotcon_response_get_representation(response, &recv_repr);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_representation() Fail(%d)", ret);
+ return;
+ }
+
ret = iotcon_representation_get_state(recv_repr, &recv_state);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_representation_get_state() Fail(%d)", ret);
return;
}
+
+ /* get the resource host address */
+ iotcon_remote_resource_get_host_address(resource_clone, &resource_host);
+ INFO("[%s] resource host : %s", resource_uri_path, resource_host);
+
+
/* send GET Request */
ret = iotcon_remote_resource_get(resource_clone, query, _on_get, NULL);
if (IOTCON_ERROR_NONE != ret)
}
static void _on_get_2nd(iotcon_remote_resource_h resource,
- iotcon_representation_h recv_repr,
- iotcon_options_h header_options,
- int response_result,
+ iotcon_error_e err,
+ iotcon_request_type_e request_type,
+ iotcon_response_h response,
void *user_data)
{
- _on_get(recv_repr, response_result);
+ int ret;
+ int response_result;
+ iotcon_representation_h recv_repr = NULL;
+
+ RETM_IF(IOTCON_ERROR_NONE != err, "Invalid err(%d)", err);
+
+ ret = iotcon_response_get_result(response, &response_result);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_result() Fail(%d)", ret);
+ return;
+ }
+
+ ret = iotcon_response_get_representation(response, &recv_repr);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_representation() Fail(%d)", ret);
+ return;
+ }
+ _on_get(recv_repr, response_result);
iotcon_remote_resource_destroy(resource);
}
static void _on_get_1st(iotcon_remote_resource_h resource,
- iotcon_representation_h recv_repr,
- iotcon_options_h header_options,
- int response_result,
+ iotcon_error_e err,
+ iotcon_request_type_e request_type,
+ iotcon_response_h response,
void *user_data)
{
int ret;
+ int response_result;
iotcon_query_h query_params;
+ iotcon_representation_h recv_repr = NULL;
+
+ RETM_IF(IOTCON_ERROR_NONE != err, "Invalid err(%d)", err);
+
+ ret = iotcon_response_get_result(response, &response_result);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_result() Fail(%d)", ret);
+ return;
+ }
+
+ ret = iotcon_response_get_representation(response, &recv_repr);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_response_get_representation() Fail(%d)", ret);
+ return;
+ }
_on_get(recv_repr, response_result);