From 63e80d97ebb2660611d4e55af51203088a808a3a Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Wed, 24 May 2017 08:14:00 +0200 Subject: [PATCH] [Iotcon] fix for iotcon, pass information about representation [verification] Code compiles without error Passrate 1 run 1 block, second run 100% Change-Id: I2cfc09dd6244a2664dc901ba6ecc3bd151574f60 Signed-off-by: Lukasz Bardeli --- src/iotcon/iotcon_api.js | 4 ++++ src/iotcon/iotcon_server_manager.cc | 9 +++++++-- src/iotcon/iotcon_server_manager.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/iotcon/iotcon_api.js b/src/iotcon/iotcon_api.js index 9290d322..bd3f32db 100644 --- a/src/iotcon/iotcon_api.js +++ b/src/iotcon/iotcon_api.js @@ -464,7 +464,11 @@ var _setRequestListener = function(id, args_listener) { callArgs.id = id; var listener = function(result) { + if(!result.data.request.representation && result.data.uriPath) { + result.data.request.representation = new tizen.Representation(result.data.uriPath); + } var request = new Request(result.data.id, result.data.request); + switch (converter.toString(result.data.type, false)) { case RequestType.GET: native.callIfPossible(args_listener.onget, request); diff --git a/src/iotcon/iotcon_server_manager.cc b/src/iotcon/iotcon_server_manager.cc index be41a71a..107343a4 100644 --- a/src/iotcon/iotcon_server_manager.cc +++ b/src/iotcon/iotcon_server_manager.cc @@ -114,7 +114,11 @@ void IotconServerManager::RequestHandler(iotcon_resource_h resource, } obj.insert(std::make_pair(kRequest, request_val)); - + std::map::iterator it; + it = that->uri_map_.find(resource); + if (it != that->uri_map_.end()) { + obj.insert(std::make_pair(kUriPath, picojson::value(it->second.c_str()))); + } // create response iotcon_response_h response = nullptr; result = IotconUtils::ConvertIotconError(iotcon_response_create(request, &response)); @@ -177,6 +181,7 @@ TizenResult IotconServerManager::CreateResource(const std::string& uri_path, // storing ResourceInfo into map res_pointer->id = GetNextId(); resource_map_.insert(std::make_pair(res_pointer->id, res_pointer)); + uri_map_.insert(std::make_pair(res_pointer->handle, uri_path)); return TizenSuccess(); } @@ -214,7 +219,7 @@ common::TizenResult IotconServerManager::DestroyResource(long long id) { } resource_map_.erase(id); - + uri_map_.erase(resource->handle); return TizenSuccess(); } diff --git a/src/iotcon/iotcon_server_manager.h b/src/iotcon/iotcon_server_manager.h index 7b9d347c..f800e0ab 100644 --- a/src/iotcon/iotcon_server_manager.h +++ b/src/iotcon/iotcon_server_manager.h @@ -56,6 +56,7 @@ class IotconServerManager { iotcon_request_h request, void *user_data); ResourceInfoMap resource_map_; + std::map uri_map_; }; } // namespace iotcon -- 2.34.1