std::unique_ptr<CallbackData> data{new CallbackData{PostForMethodCall(token, resource)}};
+ // set options to the remote resource
+ const auto& js_options = IotconUtils::GetArg(args, kOptions);
+
+ if (js_options.is<picojson::array>()) {
+ iotcon_options_h options = nullptr;
+
+ result = IotconUtils::OptionsFromJson(js_options.get<picojson::array>(), &options);
+ if (!result) {
+ LogAndReturnTizenError(result, ("OptionsFromJson() failed"));
+ }
+ SCOPE_EXIT {
+ iotcon_options_destroy(options);
+ };
+
+ result = IotconUtils::ConvertIotconError(iotcon_remote_resource_set_options(resource->handle, options));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_response_set_options() failed"));
+ }
+ }
+
result = IotconUtils::ConvertIotconError(iotcon_remote_resource_get(resource->handle, query, RemoteResourceResponseCallback, data.get()));
if (!result) {
LogAndReturnTizenError(result, ("iotcon_remote_resource_get() failed"));
std::unique_ptr<CallbackData> data{new CallbackData{PostForMethodCall(token, resource)}};
+ // set options to the remote resource
+ const auto& js_options = IotconUtils::GetArg(args, kOptions);
+
+ if (js_options.is<picojson::array>()) {
+ iotcon_options_h options = nullptr;
+
+ result = IotconUtils::OptionsFromJson(js_options.get<picojson::array>(), &options);
+ if (!result) {
+ LogAndReturnTizenError(result, ("OptionsFromJson() failed"));
+ }
+ SCOPE_EXIT {
+ iotcon_options_destroy(options);
+ };
+
+ result = IotconUtils::ConvertIotconError(iotcon_remote_resource_set_options(resource->handle, options));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_response_set_options() failed"));
+ }
+ }
+
result = IotconUtils::ConvertIotconError(iotcon_remote_resource_put(resource->handle, representation, query, RemoteResourceResponseCallback, data.get()));
if (!result) {
LogAndReturnTizenError(result, ("iotcon_remote_resource_put() failed"));
std::unique_ptr<CallbackData> data{new CallbackData{PostForMethodCall(token, resource)}};
+ // set options to the remote resource
+ const auto& js_options = IotconUtils::GetArg(args, kOptions);
+
+ if (js_options.is<picojson::array>()) {
+ iotcon_options_h options = nullptr;
+
+ result = IotconUtils::OptionsFromJson(js_options.get<picojson::array>(), &options);
+ if (!result) {
+ LogAndReturnTizenError(result, ("OptionsFromJson() failed"));
+ }
+ SCOPE_EXIT {
+ iotcon_options_destroy(options);
+ };
+
+ result = IotconUtils::ConvertIotconError(iotcon_remote_resource_set_options(resource->handle, options));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_response_set_options() failed"));
+ }
+ }
+
result = IotconUtils::ConvertIotconError(iotcon_remote_resource_post(resource->handle, representation, query, RemoteResourceResponseCallback, data.get()));
if (!result) {
LogAndReturnTizenError(result, ("iotcon_remote_resource_post() failed"));
std::unique_ptr<CallbackData> data{new CallbackData{PostForMethodCall(token, resource)}};
+ // set options to the remote resource
+ const auto& js_options = IotconUtils::GetArg(args, kOptions);
+
+ if (js_options.is<picojson::array>()) {
+ iotcon_options_h options = nullptr;
+
+ result = IotconUtils::OptionsFromJson(js_options.get<picojson::array>(), &options);
+ if (!result) {
+ LogAndReturnTizenError(result, ("OptionsFromJson() failed"));
+ }
+ SCOPE_EXIT {
+ iotcon_options_destroy(options);
+ };
+
+ result = IotconUtils::ConvertIotconError(iotcon_remote_resource_set_options(resource->handle, options));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_response_set_options() failed"));
+ }
+ }
+
result = IotconUtils::ConvertIotconError(iotcon_remote_resource_delete(resource->handle, RemoteResourceResponseCallback, data.get()));
if (!result) {
LogAndReturnTizenError(result, ("iotcon_remote_resource_delete() failed"));
Post(kRemoteResourceStateChangeListener, common::TizenSuccess{response});
};
+ // set options to the remote resource
+ const auto& js_options = IotconUtils::GetArg(args, kOptions);
+
+ if (js_options.is<picojson::array>()) {
+ iotcon_options_h options = nullptr;
+
+ result = IotconUtils::OptionsFromJson(js_options.get<picojson::array>(), &options);
+ if (!result) {
+ LogAndReturnTizenError(result, ("OptionsFromJson() failed"));
+ }
+ SCOPE_EXIT {
+ iotcon_options_destroy(options);
+ };
+
+ result = IotconUtils::ConvertIotconError(iotcon_remote_resource_set_options(ptr->handle, options));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_response_set_options() failed"));
+ }
+ }
+
result = IotconUtils::ConvertIotconError(
iotcon_remote_resource_observe_register(ptr->handle, observe_policy, query,
ObserveCallback, ptr.get()));
if (!result) {
LogAndReturnTizenError(result, ("Failed to create remote resource handle"));
}
+
+ // set options to the remote resource
+ const auto& js_options = IotconUtils::GetArg(args, kOptions);
+
+ if (js_options.is<picojson::array>()) {
+ iotcon_options_h options = nullptr;
+
+ result = IotconUtils::OptionsFromJson(js_options.get<picojson::array>(), &options);
+ if (!result) {
+ LogAndReturnTizenError(result, ("OptionsFromJson() failed"));
+ }
+ SCOPE_EXIT {
+ iotcon_options_destroy(options);
+ };
+
+ result = IotconUtils::ConvertIotconError(iotcon_remote_resource_set_options(ptr->handle, options));
+ if (!result) {
+ LogAndReturnTizenError(result, ("iotcon_response_set_options() failed"));
+ }
+ }
+
result = IotconUtils::ConvertIotconError(iotcon_remote_resource_observe_deregister(ptr->handle));
if (!result) {
return result;
LogAndReturnTizenError(result, ("Gathering properties failed"));
}
- result = ConvertIotconError(
- iotcon_remote_resource_get_options(resource->resource, &resource->options));
- if (!result) {
- LogAndReturnTizenError(result, ("Gathering options failed"));
- }
-
result = ConvertIotconError(
iotcon_remote_resource_get_cached_representation(resource->resource, &resource->representation));
if (!result) {
IotconUtils::PropertiesToJson(remote_res.properties, res);
- if (remote_res.options) {
- picojson::value opt_json{picojson::array{}};
- result = OptionsToJson(remote_res.options, &opt_json.get<picojson::array>());
- if (!result) {
- LogAndReturnTizenError(result, ("OptionsToJson() failed"));
- }
- res->insert(std::make_pair(kOptions, opt_json));
- }
-
if (remote_res.representation) {
picojson::value repr_json{picojson::object{}};
result = RepresentationToJson(remote_res.representation, &repr_json.get<picojson::object>());
if (representation) {
{
- // hostAddress
+ // uriPath
char* uri_path = nullptr;
auto result = ConvertIotconError(iotcon_representation_get_uri_path(representation, &uri_path));
if (!result || !uri_path) {
}
{
- int children = 0;
- result = IotconUtils::ConvertIotconError(iotcon_resource_get_number_of_children(resource->handle, &children));
+ unsigned int children = 0;
+ result = IotconUtils::ConvertIotconError(iotcon_resource_get_child_count(resource->handle, &children));
if (!result) {
- LogAndReturnTizenError(result, ("iotcon_resource_get_number_of_children() failed"));
+ LogAndReturnTizenError(result, ("iotcon_resource_get_child_count() failed"));
}
- for (int i = 0; i < children; ++i) {
+ for (unsigned int i = 0; i < children; ++i) {
iotcon_resource_h child = nullptr;
result = IotconUtils::ConvertIotconError(iotcon_resource_get_nth_child(resource->handle, i, &child));
if (!result) {