<arg type="i" name="ret" direction="out"/>
</method>
<method name="get">
- <arg type="(ssba(qs)iii)" name="client" direction="in"/>
+ <arg type="(ssa(qs)i)" name="client" direction="in"/>
<arg type="a(ss)" name="query" direction="in"/>
<arg type="(a(qs)si)" name="ret" direction="out"/>
</method>
<method name="put">
- <arg type="(ssba(qs)asii)" name="client" direction="in"/>
+ <arg type="(ssa(qs)i)" name="client" direction="in"/>
<arg type="s" name="repr" direction="in"/>
<arg type="a(ss)" name="query" direction="in"/>
<arg type="(a(qs)si)" name="ret" direction="out"/>
</method>
<method name="post">
- <arg type="(ssba(qs)asii)" name="client" direction="in"/>
+ <arg type="(ssa(qs)i)" name="client" direction="in"/>
<arg type="s" name="repr" direction="in"/>
<arg type="a(ss)" name="query" direction="in"/>
<arg type="(a(qs)si)" name="ret" direction="out"/>
</method>
<method name="delete">
- <arg type="(ssba(qs)asii)" name="client" direction="in"/>
+ <arg type="(ssa(qs)i)" name="client" direction="in"/>
<arg type="(a(qs)i)" name="ret" direction="out"/>
</method>
<method name="observerStart">
};
-struct icd_get_context {
+struct icd_crud_context {
int res;
+ int crud_type;
char *payload;
GVariantBuilder *options;
GDBusMethodInvocation *invocation;
}
-static int _worker_get_cb(void *context)
+static int _worker_crud_cb(void *context)
{
GVariant *value;
- struct icd_get_context *ctx = context;
+ struct icd_crud_context *ctx = context;
RETV_IF(NULL == ctx, IOTCON_ERROR_INVALID_PARAMETER);
- value = g_variant_new("(a(qs)si)", ctx->options, ctx->payload, ctx->res);
- icd_ioty_get_complete(ctx->invocation, value);
+ if (ICD_CRUD_DELETE == ctx->crud_type)
+ value = g_variant_new("(a(qs)i)", ctx->options, ctx->res);
+ else
+ value = g_variant_new("(a(qs)si)", ctx->options, ctx->payload, ctx->res);
+ icd_ioty_complete(ctx->crud_type, ctx->invocation, value);
- /* ctx was allocated from icd_ioty_ocprocess_get_cb() */
+ /* ctx was allocated from icd_ioty_ocprocess_xxx_cb() */
free(ctx->payload);
g_variant_builder_unref(ctx->options);
free(ctx);
}
+static int _ocprocess_worker(_ocprocess_fn fn, int type, const char *payload, int res,
+ GVariantBuilder *options, void *ctx)
+{
+ int ret;
+ struct icd_crud_context *crud_ctx;
+
+ crud_ctx = calloc(1, sizeof(struct icd_crud_context));
+ if (NULL == crud_ctx) {
+ ERR("calloc() Fail(%d)", errno);
+ return IOTCON_ERROR_OUT_OF_MEMORY;
+ }
+
+ crud_ctx->crud_type = type;
+ crud_ctx->payload = strdup(ic_utils_dbus_encode_str(payload));
+ crud_ctx->res = res;
+ crud_ctx->options = options;
+ crud_ctx->invocation = ctx;
+
+ ret = _ocprocess_worker_start(fn, crud_ctx);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("_ocprocess_worker_start() Fail(%d)", ret);
+ free(crud_ctx->payload);
+ g_variant_builder_unref(crud_ctx->options);
+ free(crud_ctx);
+ }
+
+ /* DO NOT FREE crud_ctx. It MUST be freed in the _worker_crud_cb func */
+
+ return ret;
+}
+
+
OCStackApplicationResult icd_ioty_ocprocess_get_cb(void *ctx, OCDoHandle handle,
OCClientResponse *resp)
{
int ret, res;
OCStackResult result;
GVariantBuilder *options;
- struct icd_get_context *get_ctx;
+ struct icd_crud_context *crud_ctx;
RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
if (NULL == resp->resJSONPayload || '\0' == resp->resJSONPayload[0]) {
ERR("json payload is empty");
- icd_ioty_get_complete_error(ctx, IOTCON_ERROR_IOTIVITY);
+ icd_ioty_complete_error(ICD_CRUD_GET, ctx, IOTCON_ERROR_IOTIVITY);
return OC_STACK_DELETE_TRANSACTION;
}
- get_ctx = calloc(1, sizeof(struct icd_get_context));
- if (NULL == get_ctx) {
+ crud_ctx = calloc(1, sizeof(struct icd_crud_context));
+ if (NULL == crud_ctx) {
ERR("calloc() Fail(%d)", errno);
- icd_ioty_get_complete_error(ctx, IOTCON_ERROR_OUT_OF_MEMORY);
+ icd_ioty_complete_error(ICD_CRUD_GET, ctx, IOTCON_ERROR_OUT_OF_MEMORY);
return OC_STACK_DELETE_TRANSACTION;
}
options = NULL;
}
- get_ctx->payload = strdup(resp->resJSONPayload);
- get_ctx->res = res;
- get_ctx->options = options;
- get_ctx->invocation = ctx;
+ ret = _ocprocess_worker(_worker_crud_cb, ICD_CRUD_GET, resp->resJSONPayload, res,
+ options, ctx);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("_ocprocess_worker() Fail(%d)", ret);
+ icd_ioty_complete_error(ICD_CRUD_GET, ctx, ret);
+ return OC_STACK_DELETE_TRANSACTION;
+ }
+
+ return OC_STACK_DELETE_TRANSACTION;
+}
+
+
+OCStackApplicationResult icd_ioty_ocprocess_put_cb(void *ctx, OCDoHandle handle,
+ OCClientResponse *resp)
+{
+ FN_CALL;
+ int ret, res;
+ OCStackResult result;
+ GVariantBuilder *options;
+
+ RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
+
+ if (NULL == resp->resJSONPayload || '\0' == resp->resJSONPayload[0]) {
+ ERR("json payload is empty");
+ icd_ioty_complete_error(ICD_CRUD_PUT, ctx, IOTCON_ERROR_IOTIVITY);
+ return OC_STACK_DELETE_TRANSACTION;
+ }
+
+ result = resp->result;
+ switch (result) {
+ case OC_STACK_OK:
+ res = IOTCON_RESPONSE_RESULT_OK;
+ break;
+ case OC_STACK_RESOURCE_CREATED:
+ res = IOTCON_RESPONSE_RESULT_RESOURCE_CREATED;
+ break;
+ case OC_STACK_RESOURCE_DELETED:
+ res = IOTCON_RESPONSE_RESULT_RESOURCE_DELETED;
+ break;
+ default:
+ WARN("resp error(%d)", result);
+ res = IOTCON_RESPONSE_RESULT_ERROR;
+ options = NULL;
+ }
+
+ if (IOTCON_RESPONSE_RESULT_ERROR != res) {
+ options = _ocprocess_parse_header_options(resp->rcvdVendorSpecificHeaderOptions,
+ resp->numRcvdVendorSpecificHeaderOptions);
+ }
- ret = _ocprocess_worker_start(_worker_get_cb, get_ctx);
+ ret = _ocprocess_worker(_worker_crud_cb, ICD_CRUD_PUT, resp->resJSONPayload, res,
+ options, ctx);
if (IOTCON_ERROR_NONE != ret) {
- ERR("_ocprocess_worker_start() Fail(%d)", ret);
- icd_ioty_get_complete_error(ctx, ret);
- free(get_ctx->payload);
- g_variant_builder_unref(get_ctx->options);
- free(get_ctx);
+ ERR("_ocprocess_worker() Fail(%d)", ret);
+ icd_ioty_complete_error(ICD_CRUD_PUT, ctx, ret);
+ return OC_STACK_DELETE_TRANSACTION;
+ }
+
+ return OC_STACK_DELETE_TRANSACTION;
+}
+
+
+OCStackApplicationResult icd_ioty_ocprocess_post_cb(void *ctx, OCDoHandle handle,
+ OCClientResponse *resp)
+{
+ FN_CALL;
+ int ret, res;
+ OCStackResult result;
+ GVariantBuilder *options;
+ struct icd_crud_context *crud_ctx;
+
+ RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
+
+ if (NULL == resp->resJSONPayload || '\0' == resp->resJSONPayload[0]) {
+ ERR("json payload is empty");
+ icd_ioty_complete_error(ICD_CRUD_POST, ctx, IOTCON_ERROR_IOTIVITY);
+ return OC_STACK_DELETE_TRANSACTION;
+ }
+
+ crud_ctx = calloc(1, sizeof(struct icd_crud_context));
+ if (NULL == crud_ctx) {
+ ERR("calloc() Fail(%d)", errno);
+ icd_ioty_complete_error(ICD_CRUD_POST, ctx, IOTCON_ERROR_OUT_OF_MEMORY);
+ return OC_STACK_DELETE_TRANSACTION;
+ }
+
+ result = resp->result;
+ switch (result) {
+ case OC_STACK_OK:
+ res = IOTCON_RESPONSE_RESULT_OK;
+ break;
+ case OC_STACK_RESOURCE_CREATED:
+ res = IOTCON_RESPONSE_RESULT_RESOURCE_CREATED;
+ break;
+ case OC_STACK_RESOURCE_DELETED:
+ res = IOTCON_RESPONSE_RESULT_RESOURCE_DELETED;
+ break;
+ default:
+ WARN("resp error(%d)", result);
+ res = IOTCON_RESPONSE_RESULT_ERROR;
+ options = NULL;
+ }
+
+ if (IOTCON_RESPONSE_RESULT_ERROR != res) {
+ options = _ocprocess_parse_header_options(resp->rcvdVendorSpecificHeaderOptions,
+ resp->numRcvdVendorSpecificHeaderOptions);
+ }
+
+ ret = _ocprocess_worker(_worker_crud_cb, ICD_CRUD_POST, resp->resJSONPayload, res,
+ options, ctx);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("_ocprocess_worker() Fail(%d)", ret);
+ icd_ioty_complete_error(ICD_CRUD_POST, ctx, ret);
+ return OC_STACK_DELETE_TRANSACTION;
+ }
+
+ return OC_STACK_DELETE_TRANSACTION;
+}
+
+
+OCStackApplicationResult icd_ioty_ocprocess_delete_cb(void *ctx, OCDoHandle handle,
+ OCClientResponse *resp)
+{
+ FN_CALL;
+ int ret, res;
+ OCStackResult result;
+ GVariantBuilder *options;
+ struct icd_crud_context *crud_ctx;
+
+ RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
+
+ if (NULL == resp->resJSONPayload || '\0' == resp->resJSONPayload[0]) {
+ ERR("json payload is empty");
+ icd_ioty_complete_error(ICD_CRUD_DELETE, ctx, IOTCON_ERROR_IOTIVITY);
+ return OC_STACK_DELETE_TRANSACTION;
+ }
+
+ crud_ctx = calloc(1, sizeof(struct icd_crud_context));
+ if (NULL == crud_ctx) {
+ ERR("calloc() Fail(%d)", errno);
+ icd_ioty_complete_error(ICD_CRUD_DELETE, ctx, IOTCON_ERROR_OUT_OF_MEMORY);
+ return OC_STACK_DELETE_TRANSACTION;
+ }
+
+ result = resp->result;
+ switch (result) {
+ case OC_STACK_OK:
+ res = IOTCON_RESPONSE_RESULT_OK;
+ break;
+ case OC_STACK_RESOURCE_DELETED:
+ res = IOTCON_RESPONSE_RESULT_RESOURCE_DELETED;
+ break;
+ default:
+ WARN("resp error(%d)", result);
+ res = IOTCON_RESPONSE_RESULT_ERROR;
+ options = NULL;
+ }
+
+ if (IOTCON_RESPONSE_RESULT_ERROR != res) {
+ options = _ocprocess_parse_header_options(resp->rcvdVendorSpecificHeaderOptions,
+ resp->numRcvdVendorSpecificHeaderOptions);
+ }
+
+ ret = _ocprocess_worker(_worker_crud_cb, ICD_CRUD_DELETE, NULL, res, options, ctx);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("_ocprocess_worker() Fail(%d)", ret);
+ icd_ioty_complete_error(ICD_CRUD_DELETE, ctx, ret);
return OC_STACK_DELETE_TRANSACTION;
}
- /* DO NOT FREE get_ctx. It MUST be freed in the _worker_get_cb func */
+ /* DO NOT FREE crud_ctx. It MUST be freed in the _worker_delete_cb func */
return OC_STACK_DELETE_TRANSACTION;
}
OCEntityHandlerResult icd_ioty_ocprocess_req_handler(OCEntityHandlerFlag flag,
OCEntityHandlerRequest *request);
-OCStackApplicationResult icd_ioty_ocprocess_find_cb(void* ctx, OCDoHandle handle,
+OCStackApplicationResult icd_ioty_ocprocess_find_cb(void *ctx, OCDoHandle handle,
OCClientResponse* resp);
-OCStackApplicationResult icd_ioty_ocprocess_get_cb(void* ctx, OCDoHandle handle,
+OCStackApplicationResult icd_ioty_ocprocess_get_cb(void *ctx, OCDoHandle handle,
OCClientResponse* resp);
+OCStackApplicationResult icd_ioty_ocprocess_put_cb(void *ctx, OCDoHandle handle,
+ OCClientResponse *resp);
+
+OCStackApplicationResult icd_ioty_ocprocess_post_cb(void *ctx, OCDoHandle handle,
+ OCClientResponse *resp);
+
+OCStackApplicationResult icd_ioty_ocprocess_delete_cb(void *ctx, OCDoHandle handle,
+ OCClientResponse *resp);
+
#endif /*__IOT_CONNECTIVITY_MANAGER_DAEMON_IOTIVITY_THREAD_H__*/
}
-void icd_ioty_get_complete(GDBusMethodInvocation *invocation, GVariant *value)
-{
- ic_dbus_complete_get(icd_dbus_get_object(), invocation, value);
+void icd_ioty_complete(int type, GDBusMethodInvocation *invocation, GVariant *value)
+{
+ switch(type) {
+ case ICD_CRUD_GET:
+ ic_dbus_complete_get(icd_dbus_get_object(), invocation, value);
+ break;
+ case ICD_CRUD_PUT:
+ ic_dbus_complete_put(icd_dbus_get_object(), invocation, value);
+ break;
+ case ICD_CRUD_POST:
+ ic_dbus_complete_post(icd_dbus_get_object(), invocation, value);
+ break;
+ case ICD_CRUD_DELETE:
+ ic_dbus_complete_delete(icd_dbus_get_object(), invocation, value);
+ break;
+ }
}
-void icd_ioty_get_complete_error(GDBusMethodInvocation *invocation, int ret_val)
+void icd_ioty_complete_error(int type, GDBusMethodInvocation *invocation, int ret_val)
{
GVariant *value;
- value = g_variant_new("(a(qs)si)", NULL, IC_STR_NULL, ret_val);
-
- ic_dbus_complete_get(icd_dbus_get_object(), invocation, value);
+ switch (type) {
+ case ICD_CRUD_GET:
+ value = g_variant_new("(a(qs)si)", NULL, IC_STR_NULL, ret_val);
+ ic_dbus_complete_get(icd_dbus_get_object(), invocation, value);
+ break;
+ case ICD_CRUD_PUT:
+ value = g_variant_new("(a(qs)si)", NULL, IC_STR_NULL, ret_val);
+ ic_dbus_complete_put(icd_dbus_get_object(), invocation, value);
+ break;
+ case ICD_CRUD_POST:
+ value = g_variant_new("(a(qs)si)", NULL, IC_STR_NULL, ret_val);
+ ic_dbus_complete_post(icd_dbus_get_object(), invocation, value);
+ break;
+ case ICD_CRUD_DELETE:
+ value = g_variant_new("(a(qs)i)", NULL, ret_val);
+ ic_dbus_complete_delete(icd_dbus_get_object(), invocation, value);
+ break;
+ }
}
-gboolean icd_ioty_get(icDbus *object, GDBusMethodInvocation *invocation,
- GVariant *resource, GVariant *query)
+static gboolean _icd_ioty_crud(int type, icDbus *object, GDBusMethodInvocation *invocation,
+ GVariant *resource, GVariant *query, const char *repr)
{
- FN_CALL;
+ OCMethod rest_type;
OCStackResult result;
GVariantIter *options;
OCCallbackData cbdata = {0};
int conn_type, options_size;
char *uri_path, *host, *uri;
- int is_observable, ifaces, observe_handle;
+ char uri_buf[PATH_MAX] = {0};
OCHeaderOption oic_options[MAX_HEADER_OPTIONS];
+ OCHeaderOption *oic_options_ptr = NULL;
+
+ switch (type) {
+ case ICD_CRUD_GET:
+ cbdata.cb = icd_ioty_ocprocess_get_cb;
+ rest_type = OC_REST_GET;
+ break;
+ case ICD_CRUD_PUT:
+ cbdata.cb = icd_ioty_ocprocess_put_cb;
+ rest_type = OC_REST_PUT;
+ break;
+ case ICD_CRUD_POST:
+ cbdata.cb = icd_ioty_ocprocess_post_cb;
+ rest_type = OC_REST_POST;
+ break;
+ case ICD_CRUD_DELETE:
+ cbdata.cb = icd_ioty_ocprocess_delete_cb;
+ rest_type = OC_REST_DELETE;
+ break;
+ default:
+ ERR("Invalid CRUD Type(%d)", type);
+ return FALSE;
+ }
- g_variant_get(resource, "(&s&sba(qs)iii)", &uri_path, &host, &is_observable, &options,
- &ifaces, &observe_handle, &conn_type);
+ g_variant_get(resource, "(&s&sa(qs)i)", &uri_path, &host, &options, &conn_type);
- uri = _icd_ioty_resource_generate_uri(host, uri_path, query);
- if (NULL == uri) {
- ERR("_icd_ioty_resource_generate_uri() Fail");
- g_variant_iter_free(options);
- icd_ioty_get_complete_error(invocation, IOTCON_ERROR_INVALID_PARAMETER);
- return TRUE;
+ switch (type) {
+ case ICD_CRUD_GET:
+ case ICD_CRUD_PUT:
+ case ICD_CRUD_POST:
+ uri = _icd_ioty_resource_generate_uri(host, uri_path, query);
+ if (NULL == uri) {
+ ERR("_icd_ioty_resource_generate_uri() Fail");
+ g_variant_iter_free(options);
+ icd_ioty_complete_error(type, invocation, IOTCON_ERROR_INVALID_PARAMETER);
+ return TRUE;
+ }
+ break;
+ case ICD_CRUD_DELETE:
+ snprintf(uri_buf, sizeof(uri_buf), "%s%s", host, uri_path);
+ uri = strdup(uri_buf);
+ break;
}
cbdata.context = invocation;
- cbdata.cb = icd_ioty_ocprocess_get_cb;
options_size = g_variant_iter_n_children(options);
if (0 != options_size) {
ERR("_ioty_get_header_options() Fail(%d)", ret);
free(uri);
g_variant_iter_free(options);
- icd_ioty_get_complete_error(invocation, ret);
+ icd_ioty_complete_error(type, invocation, ret);
return TRUE;
}
+ oic_options_ptr = oic_options;
}
g_variant_iter_free(options);
icd_ioty_csdk_lock();
/* TODO : QoS is come from lib. And user can set QoS to client structure. */
- result = OCDoResource(NULL, OC_REST_GET, uri, NULL, NULL, conn_type, OC_HIGH_QOS,
- &cbdata, options_size?oic_options:NULL, options_size);
+ result = OCDoResource(NULL, rest_type, uri, NULL, repr, conn_type, OC_HIGH_QOS,
+ &cbdata, oic_options_ptr, options_size);
icd_ioty_csdk_unlock();
free(uri);
if (OC_STACK_OK != result) {
ERR("OCDoResource() Fail(%d)", result);
- icd_ioty_get_complete_error(invocation, IOTCON_ERROR_IOTIVITY);
+ icd_ioty_complete_error(type, invocation, IOTCON_ERROR_IOTIVITY);
return TRUE;
}
return TRUE;
}
-
-void icd_ioty_put_complete(GDBusMethodInvocation *invocation, GVariant *value)
-{
- ic_dbus_complete_put(icd_dbus_get_object(), invocation, value);
-}
-
-
-void icd_ioty_put_complete_error(GDBusMethodInvocation *invocation, int ret_val)
+gboolean icd_ioty_get(icDbus *object, GDBusMethodInvocation *invocation,
+ GVariant *resource, GVariant *query)
{
- GVariant *value;
-
- value = g_variant_new("(a(qs)si)", NULL, IC_STR_NULL, ret_val);
-
- ic_dbus_complete_put(icd_dbus_get_object(), invocation, value);
+ FN_CALL;
+ return _icd_ioty_crud(ICD_CRUD_GET, object, invocation, resource, query, NULL);
}
gboolean icd_ioty_put(icDbus *object, GDBusMethodInvocation *invocation,
GVariant *resource, const char *repr, GVariant *query)
{
- // TODO : To be implemented
- return IOTCON_ERROR_NONE;
-}
-
-
-void icd_ioty_post_complete(GDBusMethodInvocation *invocation, GVariant *value)
-{
- ic_dbus_complete_post(icd_dbus_get_object(), invocation, value);
-}
-
-
-void icd_ioty_post_complete_error(GDBusMethodInvocation *invocation, int ret_val)
-{
- GVariant *value;
-
- value = g_variant_new("(a(qs)si)", NULL, IC_STR_NULL, ret_val);
-
- ic_dbus_complete_post(icd_dbus_get_object(), invocation, value);
+ FN_CALL;
+ return _icd_ioty_crud(ICD_CRUD_PUT, object, invocation, resource, query, repr);
}
gboolean icd_ioty_post(icDbus *object, GDBusMethodInvocation *invocation,
GVariant *resource, const char *repr, GVariant *query)
{
- // TODO : To be implemented
- return IOTCON_ERROR_NONE;
-}
-
-
-void icd_ioty_delete_complete(GDBusMethodInvocation *invocation, GVariant *value)
-{
- ic_dbus_complete_delete(icd_dbus_get_object(), invocation, value);
-}
-
-
-void icd_ioty_delete_complete_error(GDBusMethodInvocation *invocation, int ret_val)
-{
- GVariant *value;
-
- value = g_variant_new("(a(qs)i)", NULL, IC_STR_NULL, ret_val);
-
- ic_dbus_complete_delete(icd_dbus_get_object(), invocation, value);
+ FN_CALL;
+ return _icd_ioty_crud(ICD_CRUD_POST, object, invocation, resource, query, repr);
}
gboolean icd_ioty_delete(icDbus *object, GDBusMethodInvocation *invocation,
GVariant *resource)
{
- // TODO : To be implemented
- return IOTCON_ERROR_NONE;
+ FN_CALL;
+ return _icd_ioty_crud(ICD_CRUD_DELETE, object, invocation, resource, NULL, NULL);
}
char *bus_name;
} icd_sig_ctx_s;
+enum {
+ ICD_CRUD_GET,
+ ICD_CRUD_PUT,
+ ICD_CRUD_POST,
+ ICD_CRUD_DELETE
+};
void icd_ioty_csdk_lock();
int icd_ioty_find_resource(const char *host_address, const char *resource_type,
unsigned int signal_number, const char *bus_name);
-void icd_ioty_get_complete(GDBusMethodInvocation *invocation, GVariant *value);
-void icd_ioty_get_complete_error(GDBusMethodInvocation *invocation, int ret_val);
+void icd_ioty_complete(int type, GDBusMethodInvocation *invocation, GVariant *value);
+void icd_ioty_complete_error(int type, GDBusMethodInvocation *invocation, int ret_val);
+
gboolean icd_ioty_get(icDbus *object, GDBusMethodInvocation *invocation,
GVariant *resource, GVariant *query);
-void icd_ioty_put_complete(GDBusMethodInvocation *invocation, GVariant *value);
-void icd_ioty_put_complete_error(GDBusMethodInvocation *invocation, int ret_val);
gboolean icd_ioty_put(icDbus *object, GDBusMethodInvocation *invocation,
GVariant *resource, const char *repr, GVariant *query);
-void icd_ioty_post_complete(GDBusMethodInvocation *invocation, GVariant *value);
-void icd_ioty_post_complete_error(GDBusMethodInvocation *invocation, int ret_val);
gboolean icd_ioty_post(icDbus *object, GDBusMethodInvocation *invocation,
GVariant *resource, const char *repr, GVariant *query);
-void icd_ioty_delete_complete(GDBusMethodInvocation *invocation, GVariant *value);
-void icd_ioty_delete_complete_error(GDBusMethodInvocation *invocation, int ret_val);
gboolean icd_ioty_delete(icDbus *object, GDBusMethodInvocation *invocation,
GVariant *resource);
static void _icl_on_cru_cb(GVariant *result, icl_on_cru_s *cb_container)
{
+ FN_CALL;
int res;
iotcon_repr_h repr;
GVariantIter *options;
static void _icl_on_delete_cb(GObject *object, GAsyncResult *g_async_res,
gpointer user_data)
{
+ FN_CALL;
int res;
GVariant *result;
char *option_data;
}
g_variant_get(result, "(a(qs)i)", &options, &res);
- if (IOTCON_ERROR_NONE != res && g_variant_iter_n_children(options)) {
+ if (IOTCON_ERROR_NONE == res && g_variant_iter_n_children(options)) {
header_options = iotcon_options_new();
while (g_variant_iter_loop(options, "(q&s)", &option_id, &option_data))
iotcon_options_insert(header_options, option_id, option_data);
API void iotcon_client_free(iotcon_client_h resource)
{
- FN_CALL;
-
RET_IF(NULL == resource);
resource->ref_count--;
}
}
- value = g_variant_new("(ssba(qs)iii)",
- resource->uri_path,
- resource->host,
- resource->is_observable,
- &options,
- resource->ifaces,
- resource->conn_type,
- GPOINTER_TO_INT(resource->observe_handle));
+ value = g_variant_new("(ssa(qs)i)", resource->uri_path, resource->host, &options,
+ resource->conn_type);
return value;
}
void icl_value_free(gpointer data)
{
- FN_CALL;
int ret;
iotcon_value_h value;
iotcon_list_h list;
ret_val->hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, free,
icl_value_free);
icl_repr_inc_ref_count(ret_val);
+ ret_val->visibility = (ICL_VISIBILITY_REPR | ICL_VISIBILITY_PROP);
return ret_val;
}
/* representation attributes are included if interface type is one of None
* or Default Parent or Batch Child */
- if (ICL_VISIBILITY_REPR == cur_repr->visibility && 0 < iotcon_repr_get_keys_count(cur_repr)) {
+ if ((ICL_VISIBILITY_REPR & cur_repr->visibility) && 0 < iotcon_repr_get_keys_count(cur_repr)) {
repr_obj = icl_obj_to_json(cur_repr);
if (NULL == repr_obj) {
ERR("icl_obj_to_json() Fail");
/* properties such as resource types and resource interfaces are included
* if interface type is one of None or Default Child or Link Child */
- if (ICL_VISIBILITY_PROP == cur_repr->visibility) {
+ if (ICL_VISIBILITY_PROP & cur_repr->visibility) {
if (0 < rt_count || IOTCON_INTERFACE_NONE != cur_repr->interfaces) {
prop_obj = json_object_new();
json_object_set_object_member(repr_obj, IC_JSON_KEY_PROPERTY, prop_obj);
API void iotcon_repr_free(iotcon_repr_h repr)
{
- FN_CALL;
RET_IF(NULL == repr);
if (false == _icl_repr_dec_ref_count(repr))
GVariant *parameters,
gpointer user_data)
{
+ FN_CALL;
GVariantIter *options;
unsigned short option_id;
char *option_data;
API void iotcon_response_free(iotcon_response_h resp)
{
- FN_CALL;
-
RET_IF(NULL == resp);
if (resp->repr)
{
int iface = GPOINTER_TO_INT(user_data);
- if (IOTCON_INTERFACE_DEFAULT == iface)
- child->visibility = ICL_VISIBILITY_PROP;
- else if (IOTCON_INTERFACE_LINK == iface)
- child->visibility = ICL_VISIBILITY_PROP;
- else if (IOTCON_INTERFACE_BATCH == iface)
+ switch(iface) {
+ case IOTCON_INTERFACE_BATCH:
child->visibility = ICL_VISIBILITY_REPR;
- else
+ break;
+ case IOTCON_INTERFACE_NONE:
+ case IOTCON_INTERFACE_DEFAULT:
+ case IOTCON_INTERFACE_LINK:
+ case IOTCON_INTERFACE_GROUP:
child->visibility = ICL_VISIBILITY_PROP;
+ break;
+ default:
+ WARN("Invalid interface type(%d)", iface);
+ child->visibility = ICL_VISIBILITY_PROP;
+ break;
+ }
return IOTCON_FUNC_CONTINUE;
}
iotcon_repr_h first = resp->repr;
DBG("interface type of response : %d", resp->iface);
- if (IOTCON_INTERFACE_NONE == resp->iface)
- first->visibility = ICL_VISIBILITY_REPR;
- else if (IOTCON_INTERFACE_DEFAULT == resp->iface)
+
+ switch(resp->iface) {
+ case IOTCON_INTERFACE_NONE:
+ case IOTCON_INTERFACE_DEFAULT:
+ case IOTCON_INTERFACE_GROUP:
first->visibility = ICL_VISIBILITY_REPR;
- else
+ break;
+ case IOTCON_INTERFACE_LINK:
+ case IOTCON_INTERFACE_BATCH:
first->visibility = ICL_VISIBILITY_NONE;
+ break;
+ default:
+ WARN("Invalid interface type(%d)", resp->iface);
+ first->visibility = ICL_VISIBILITY_REPR;
+ break;
+ }
ret = iotcon_repr_foreach_children(first, _icl_response_repr_child_fn,
GINT_TO_POINTER(resp->iface));
typedef enum {
ICL_VISIBILITY_NONE = 0,
- ICL_VISIBILITY_REPR,
- ICL_VISIBILITY_PROP,
+ ICL_VISIBILITY_REPR = (1 << 0),
+ ICL_VISIBILITY_PROP = (1 << 1),
} icl_visibility_e;