GVariantBuilder *options;
RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
+ RETV_IF(NULL == resp, OC_STACK_DELETE_TRANSACTION);
if (NULL == resp->payload) {
- ERR("payload is empty");
+ ERR("payload is empty(%d)", resp->result);
icd_ioty_complete_error(ICD_CRUD_GET, ctx, IOTCON_ERROR_IOTIVITY);
return OC_STACK_DELETE_TRANSACTION;
}
GVariantBuilder *options;
RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
+ RETV_IF(NULL == resp, OC_STACK_DELETE_TRANSACTION);
if (NULL == resp->payload) {
- ERR("payload is empty");
+ ERR("payload is empty(%d)", resp->result);
icd_ioty_complete_error(ICD_CRUD_PUT, ctx, IOTCON_ERROR_IOTIVITY);
return OC_STACK_DELETE_TRANSACTION;
}
GVariantBuilder *options;
RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
+ RETV_IF(NULL == resp, OC_STACK_DELETE_TRANSACTION);
if (NULL == resp->payload) {
- ERR("payload is empty");
+ ERR("payload is empty(%d)", resp->result);
icd_ioty_complete_error(ICD_CRUD_POST, ctx, IOTCON_ERROR_IOTIVITY);
return OC_STACK_DELETE_TRANSACTION;
}
GVariantBuilder *options;
RETV_IF(NULL == ctx, OC_STACK_DELETE_TRANSACTION);
+ RETV_IF(NULL == resp, OC_STACK_DELETE_TRANSACTION);
if (NULL == resp->payload) {
- ERR("payload is empty");
+ ERR("payload is empty(%d)", resp->result);
icd_ioty_complete_error(ICD_CRUD_DELETE, ctx, IOTCON_ERROR_IOTIVITY);
return OC_STACK_DELETE_TRANSACTION;
}
OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION;
if (NULL == resp->payload) {
- ERR("payload is empty");
+ ERR("payload is empty(%d)", resp->result);
_observe_cb_response_error(sig_context->bus_name, sig_context->signal_number,
IOTCON_ERROR_IOTIVITY);
return cb_result;
int ret;
icd_encap_worker_ctx_s *encap_ctx = ctx;
+ RETV_IF(NULL == ctx, OC_STACK_KEEP_TRANSACTION);
RETV_IF(NULL == resp, OC_STACK_KEEP_TRANSACTION);
if (OC_OBSERVE_DEREGISTER == resp->sequenceNumber)
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+ if (true == resource->is_found) {
+ ERR("The resource should be cloned.");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
if (0 != resource->caching_sub_id) {
ERR("Already Start Caching");
return IOTCON_ERROR_ALREADY;
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+ if (true == resource->is_found) {
+ ERR("The resource should be cloned.");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+ if (true == resource->is_found) {
+ ERR("The resource should be cloned.");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+ if (true == resource->is_found) {
+ ERR("The resource should be cloned.");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+ if (true == resource->is_found) {
+ ERR("The resource should be cloned.");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
cb_container = calloc(1, sizeof(icl_on_response_s));
if (NULL == cb_container) {
ERR("calloc() Fail(%d)", errno);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(resource->observe_handle || resource->observe_sub_id, IOTCON_ERROR_ALREADY);
+ if (true == resource->is_found) {
+ ERR("The resource should be cloned.");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
arg_remote_resource = icl_dbus_remote_resource_to_gvariant(resource);
arg_query = icl_dbus_query_to_gvariant(query);
RETV_IF(false == ic_utils_check_oic_feature_supported(), IOTCON_ERROR_NOT_SUPPORTED);
RETV_IF(NULL == icl_dbus_get_object(), IOTCON_ERROR_DBUS);
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+
+ if (true == resource->is_found) {
+ ERR("The resource should be cloned.");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
if (0 == resource->observe_handle) {
ERR("It doesn't have a observe_handle");
return IOTCON_ERROR_INVALID_PARAMETER;
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+ if (true == resource->is_found) {
+ ERR("The resource should be cloned.");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
if (0 != resource->monitoring_sub_id) {
ERR("Already Start Monitoring");
return IOTCON_ERROR_ALREADY;
return;
}
+ resource->is_found = true;
+
if (cb)
cb(resource, IOTCON_ERROR_NONE, cb_container->user_data);
static void _icl_remote_resource_destroy(iotcon_remote_resource_h resource)
{
RET_IF(NULL == resource);
- if (resource->ref_count < 0)
+ if (resource->ref_count < 0) {
ERR("Invalid ref_count (%d)", resource->ref_count);
+ return;
+ }
+ if (true == resource->is_found) {
+ ERR("It can't be destroyed by user.");
+ return;
+ }
+
free(resource->uri_path);
free(resource->host_address);
free(resource->device_id);
} icl_remote_resource_device_state_e;
struct icl_remote_resource {
+ bool is_found;
int ref_count;
char *uri_path;
char *host_address;
/**
* @brief Specifies the type of function passed to iotcon_find_resource().
- * @details Called when a resource is found from the remote server.
+ * @details Called when a resource is found from the remote server.\n
+ * The @a resource completes its life cycle in the function.
+ * If you want to send requests(GET, PUT, POST, DELETE, and OBSERVE) on the @a resource, you must clone the @a resource using iotcon_remote_resource_clone().
* The @a result could be one of #iotcon_error_e.
*
* @since_tizen 3.0
* @details Use this function to start caching the resource's attribute.\n
* Although, remote resource is not observable, it keeps the representation up-to-date.
* Because It checks whether representation is changed, periodically.\n
- * The default checking interval is 10 seconds, but it may be changed by an administrator.
+ * The default checking interval is 10 seconds, but it may be changed by an administrator.\n
+ * Also, you can get the cached representation even when the remote resource is off-line.
*
* @since_tizen 3.0
* @privlevel public