From e4e2889e6b04941fdb20f763833dac57491e0f6b Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Fri, 12 Feb 2016 11:40:14 +0100 Subject: [PATCH] [Iotcon] Added mechanism for storing handles [Verification] Code compiles. Change-Id: I41ddc1d2d81e546f65cd8c05d7692b74b19e94d3 Signed-off-by: Piotr Kosko --- src/iotcon/iotcon_api.js | 63 +++++++++++++------ src/iotcon/iotcon_client_manager.cc | 53 ++++++++++++++++ src/iotcon/iotcon_client_manager.h | 5 ++ src/iotcon/iotcon_instance.cc | 66 +++++--------------- src/iotcon/iotcon_utils.cc | 96 +++++++++++++++++++++++++++++ src/iotcon/iotcon_utils.h | 26 ++++++++ 6 files changed, 240 insertions(+), 69 deletions(-) diff --git a/src/iotcon/iotcon_api.js b/src/iotcon/iotcon_api.js index 2e20b6c8..a97da630 100644 --- a/src/iotcon/iotcon_api.js +++ b/src/iotcon/iotcon_api.js @@ -557,6 +557,39 @@ function State(key, state) { }); } +function prepareResourceInfo(that){ + var callArgs = {}; + callArgs.id = that[kIdKey]; + if (!callArgs.id) { + console.log("RemoteResource is not already stored in C++ layer, adding all members"); + callArgs.hostAddress = that.hostAddress; + callArgs.connectivityType = that.connectivityType; + callArgs.uriPath = that.uriPath; + //properties flags + callArgs.isObservable = that.isObservable; + callArgs.isDiscoverable = that.isDiscoverable; + callArgs.isActive = that.isActive; + callArgs.isSlow = that.isSlow; + callArgs.isSecure = that.isSecure; + callArgs.isExplicitDiscoverable = that.isExplicitDiscoverable; + callArgs.resourceTypes = that.resourceTypes; + callArgs.resourceInterfaces = that.resourceInterfaces; + } else { + console.log("Already stored in C++, all needed info is id"); + } + return callArgs; +} + +function manageId(that, result) { + if (result.keepId) { + that[kIdKey] = result.id; + console.log("Keep id of resource: " + that[kIdKey]); + } else { + console.log("Clear id of resource"); + delete that[kIdKey]; + } +} + function RemoteResource(data) { Object.defineProperties(this, { cachedRepresentation: { @@ -598,8 +631,7 @@ RemoteResource.prototype.methodGet = function() { nullable: true }]); - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); callArgs.query = args.query; var callback = function(result) { @@ -636,8 +668,7 @@ RemoteResource.prototype.methodPut = function() { nullable: true }]); - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); callArgs.representation = args.representation; callArgs.query = args.query; @@ -675,8 +706,7 @@ RemoteResource.prototype.methodPost = function() { nullable: true }]); - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); callArgs.representation = args.representation; callArgs.query = args.query; @@ -707,8 +737,7 @@ RemoteResource.prototype.methodDelete = function() { nullable: true }]); - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); var callback = function(result) { if (native.isFailure(result)) { @@ -746,8 +775,7 @@ RemoteResource.prototype.setStateChangeListener = function() { nullable: true }]); - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); callArgs.query = args.query; callArgs.observePolicy = args.observePolicy; var that = this; @@ -771,8 +799,7 @@ RemoteResource.prototype.setStateChangeListener = function() { }; RemoteResource.prototype.unsetStateChangeListener = function() { - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); var result = native.callSync('IotconRemoteResource_unsetStateChangeListener', callArgs); @@ -784,8 +811,7 @@ RemoteResource.prototype.unsetStateChangeListener = function() { }; RemoteResource.prototype.startCaching = function() { - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); var result = native.callSync('IotconRemoteResource_startCaching', callArgs); @@ -795,8 +821,7 @@ RemoteResource.prototype.startCaching = function() { }; RemoteResource.prototype.stopCaching = function() { - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); var result = native.callSync('IotconRemoteResource_stopCaching', callArgs); @@ -818,8 +843,7 @@ RemoteResource.prototype.setConnectionChangeListener = function() { nullable: true }]); - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); var listener = function(result) { if (native.isFailure(result)) { @@ -839,8 +863,7 @@ RemoteResource.prototype.setConnectionChangeListener = function() { }; RemoteResource.prototype.unsetConnectionChangeListener = function() { - var callArgs = {}; - callArgs.id = this[kIdKey]; + var callArgs = prepareResourceInfo(this); var result = native.callSync('IotconRemoteResource_unsetConnectionChangeListener', callArgs); diff --git a/src/iotcon/iotcon_client_manager.cc b/src/iotcon/iotcon_client_manager.cc index fb840c3d..879ce19d 100644 --- a/src/iotcon/iotcon_client_manager.cc +++ b/src/iotcon/iotcon_client_manager.cc @@ -31,6 +31,11 @@ long long GetPresenceNextId() { return ++id; } +long long GetRemoteNextId() { + static long long id = 0; + return ++id; +} + } // namespace IotconClientManager& IotconClientManager::GetInstance() { @@ -134,5 +139,53 @@ common::TizenResult IotconClientManager::RemovePresenceEventListener(long long i return TizenSuccess(); } +picojson::value IotconClientManager::StoreRemoteResource(FoundRemoteInfoPtr ptr) { + ScopeLogger(); + if (0 == ptr->id) { + LoggerD("New remote, needed to be added to map"); + ptr->id = GetRemoteNextId(); + remotes_map_.insert(std::make_pair(ptr->id, ptr)); + } else { + LoggerD("Remote is already stored, just increase ref_count"); + ptr->ref_count++; + } + return PrepareManageIdAnswer(true, ptr->id); +} + +picojson::value IotconClientManager::RemoveRemoteResource(FoundRemoteInfoPtr ptr) { + ScopeLogger(); + ptr->ref_count--; + if (ptr->ref_count <= 0) { + LoggerD("Handle not needed anymore, removing from map"); + remotes_map_.erase(ptr->id); + return PrepareManageIdAnswer(false); + } + return PrepareManageIdAnswer(true, ptr->id); +} + +picojson::value IotconClientManager::PrepareManageIdAnswer(bool keep_id, long long id) { + picojson::value answer{picojson::object{}}; + auto& obj = answer.get(); + obj.insert(std::make_pair(kKeepId, picojson::value{keep_id})); + if (keep_id) { + obj.insert(std::make_pair(kId, picojson::value{static_cast(id)})); + } + return answer; +} + +TizenResult IotconClientManager::GetRemoteById(long long id, + FoundRemoteInfoPtr* res_pointer) const { + ScopeLogger(); + + auto it = remotes_map_.find(id); + if (it == remotes_map_.end()) { + return LogAndCreateTizenError(NotFoundError, "Resource with specified ID does not exist"); + } + *res_pointer = it->second; + + return TizenSuccess(); +} + + } // namespace iotcon } // namespace extension diff --git a/src/iotcon/iotcon_client_manager.h b/src/iotcon/iotcon_client_manager.h index 7473a43f..e57308d7 100644 --- a/src/iotcon/iotcon_client_manager.h +++ b/src/iotcon/iotcon_client_manager.h @@ -39,6 +39,9 @@ class IotconClientManager { const char* resource_type, PresenceEventPtr presence); common::TizenResult RemovePresenceEventListener(long long id); + picojson::value StoreRemoteResource(FoundRemoteInfoPtr ptr); + picojson::value RemoveRemoteResource(FoundRemoteInfoPtr ptr); + common::TizenResult GetRemoteById(long long id, FoundRemoteInfoPtr* res_pointer) const; private: IotconClientManager() = default; @@ -47,12 +50,14 @@ class IotconClientManager { IotconClientManager& operator=(const IotconClientManager&) = delete; IotconClientManager& operator=(IotconClientManager&&) = delete; + picojson::value PrepareManageIdAnswer(bool keep_id, long long id = 0); static void PresenceHandler(iotcon_presence_h resource, iotcon_error_e err, iotcon_presence_response_h response, void *user_data); PresenceMap presence_map_; + FoundRemotesMap remotes_map_; }; } // namespace iotcon diff --git a/src/iotcon/iotcon_instance.cc b/src/iotcon/iotcon_instance.cc index 3f024f64..5f18e9ba 100644 --- a/src/iotcon/iotcon_instance.cc +++ b/src/iotcon/iotcon_instance.cc @@ -36,26 +36,10 @@ typedef struct { common::PostCallback fun; } CallbackData; -#define CHECK_EXIST(args, name) \ - if (args.end() == args.find(name)) { \ - return common::TypeMismatchError(std::string(name) + " is required argument"); \ - } - long long GetId(const picojson::object& args) { return static_cast(args.find(kId)->second.get()); } -const picojson::value& GetArg(const picojson::object& args, const std::string& name) { - static const picojson::value kNull; - - auto it = args.find(name); - if (args.end() == it) { - return kNull; - } else { - return it->second; - } -} - const common::ListenerToken kResourceRequestListenerToken{"ResourceRequestListener"}; const common::ListenerToken kFindResourceListenerToken{"FindResourceListener"}; const common::ListenerToken kPresenceEventListenerToken{"PresenceEventListener"}; @@ -211,13 +195,13 @@ common::TizenResult IotconInstance::ResourceNotify(const picojson::object& args) LogAndReturnTizenError(result, ("GetResourceById() failed")); } - auto& qos = GetArg(args, kQos); + auto& qos = IotconUtils::GetArg(args, kQos); if (!qos.is()) { return common::TypeMismatchError("QOS needs to be a string"); } // create observers to notify - auto& observer_ids = GetArg(args, kObserverIds); + auto& observer_ids = IotconUtils::GetArg(args, kObserverIds); std::vector observers; @@ -257,7 +241,7 @@ common::TizenResult IotconInstance::ResourceNotify(const picojson::object& args) // create representation from resource and states iotcon_representation_h representation = nullptr; - result = IotconUtils::RepresentationFromResource(resource, GetArg(args, kStates), &representation); + result = IotconUtils::RepresentationFromResource(resource, IotconUtils::GetArg(args, kStates), &representation); if (!result) { LogAndReturnTizenError(result, ("RepresentationFromResource() failed")); } @@ -286,7 +270,7 @@ common::TizenResult IotconInstance::ResourceAddResourceType(const picojson::obje LogAndReturnTizenError(result, ("GetResourceById() failed")); } - result = IotconUtils::ConvertIotconError(iotcon_resource_bind_type(resource->handle, GetArg(args, kType).get().c_str())); + result = IotconUtils::ConvertIotconError(iotcon_resource_bind_type(resource->handle, IotconUtils::GetArg(args, kType).get().c_str())); if (!result) { LogAndReturnTizenError(result, ("iotcon_resource_bind_type() failed")); } @@ -306,7 +290,7 @@ common::TizenResult IotconInstance::ResourceAddResourceInterface(const picojson: LogAndReturnTizenError(result, ("GetResourceById() failed")); } - result = IotconUtils::ConvertIotconError(iotcon_resource_bind_interface(resource->handle, IotconUtils::ToInterface(GetArg(args, kInterface).get()))); + result = IotconUtils::ConvertIotconError(iotcon_resource_bind_interface(resource->handle, IotconUtils::ToInterface(IotconUtils::GetArg(args, kInterface).get()))); if (!result) { LogAndReturnTizenError(result, ("iotcon_resource_bind_interface() failed")); } @@ -326,7 +310,7 @@ common::TizenResult IotconInstance::ResourceAddChildResource(const picojson::obj LogAndReturnTizenError(result, ("GetResourceById() parent failed")); } - long long child_id = static_cast(GetArg(args, kChildId).get()); + long long child_id = static_cast(IotconUtils::GetArg(args, kChildId).get()); ResourceInfoPtr child; result = IotconServerManager::GetInstance().GetResourceById(child_id, &child); @@ -357,7 +341,7 @@ common::TizenResult IotconInstance::ResourceRemoveChildResource(const picojson:: LogAndReturnTizenError(result, ("GetResourceById() parent failed")); } - long long child_id = static_cast(GetArg(args, kChildId).get()); + long long child_id = static_cast(IotconUtils::GetArg(args, kChildId).get()); ResourceInfoPtr child; result = IotconServerManager::GetInstance().GetResourceById(child_id, &child); @@ -437,7 +421,7 @@ common::TizenResult IotconInstance::ResponseSend(const picojson::object& args) { } { - const auto& js_response_result = GetArg(args, kResult); + const auto& js_response_result = IotconUtils::GetArg(args, kResult); if (!js_response_result.is()) { return LogAndCreateTizenError(TypeMismatchError, "ResponseResult should be a string"); } @@ -450,7 +434,7 @@ common::TizenResult IotconInstance::ResponseSend(const picojson::object& args) { } { - const auto& js_representation = GetArg(args, kRepresentation); + const auto& js_representation = IotconUtils::GetArg(args, kRepresentation); if (!js_representation.is()) { return LogAndCreateTizenError(TypeMismatchError, "Representation should be an object"); } @@ -463,14 +447,16 @@ common::TizenResult IotconInstance::ResponseSend(const picojson::object& args) { iotcon_representation_destroy(representation); }; - result = IotconUtils::ConvertIotconError(iotcon_response_set_representation(response.get(), IotconUtils::ToInterface(GetArg(args, kInterface).get()), representation)); + result = IotconUtils::ConvertIotconError( + iotcon_response_set_representation(response.get(), IotconUtils::ToInterface( + IotconUtils::GetArg(args, kInterface).get()), representation)); if (!result) { LogAndReturnTizenError(result, ("iotcon_response_set_representation() failed")); } } { - const auto& js_options = GetArg(args, kOptions); + const auto& js_options = IotconUtils::GetArg(args, kOptions); if (js_options.is()) { iotcon_options_h options = nullptr; @@ -658,7 +644,7 @@ common::TizenResult IotconInstance::ClientAddPresenceEventListener(const picojso resource_type = const_cast(args.find(kResourceType)->second.get().c_str()); } - auto& con_type = GetArg(args, kConnectivityType); + auto& con_type = IotconUtils::GetArg(args, kConnectivityType); if (!con_type.is()) { return common::TypeMismatchError("connectivityType needs to be a string"); } @@ -794,31 +780,13 @@ common::TizenResult IotconInstance::ServerCreateResource(const picojson::object& const std::string& uri_path = args.find(kUriPath)->second.get(); - const auto& interfaces = GetArg(args, kResourceInterfaces); + const auto& interfaces = IotconUtils::GetArg(args, kResourceInterfaces); const auto& resource_interfaces = interfaces.is() ? interfaces.get() : picojson::array(); - const auto& types = GetArg(args, kResourceTypes); + const auto& types = IotconUtils::GetArg(args, kResourceTypes); const auto& resource_types = types.is() ? types.get() : picojson::array(); - int properties = IOTCON_RESOURCE_NO_PROPERTY; - - const auto& observable = GetArg(args, kIsObservable); - properties |= (observable.is() ? observable.get() : false) ? IOTCON_RESOURCE_OBSERVABLE : IOTCON_RESOURCE_NO_PROPERTY; - - const auto& discoverable = GetArg(args, kIsDiscoverable); - properties |= (discoverable.is() ? discoverable.get() : false) ? IOTCON_RESOURCE_DISCOVERABLE : IOTCON_RESOURCE_NO_PROPERTY; - - const auto& active = GetArg(args, kIsActive); - properties |= (active.is() ? active.get() : false) ? IOTCON_RESOURCE_ACTIVE : IOTCON_RESOURCE_NO_PROPERTY; - - const auto& slow = GetArg(args, kIsSlow); - properties |= (slow.is() ? slow.get() : false) ? IOTCON_RESOURCE_SLOW : IOTCON_RESOURCE_NO_PROPERTY; - - const auto& secure = GetArg(args, kIsSecure); - properties |= (secure.is() ? secure.get() : false) ? IOTCON_RESOURCE_SECURE : IOTCON_RESOURCE_NO_PROPERTY; - - const auto& explicit_discoverable = GetArg(args, kIsExplicitDiscoverable); - properties |= (explicit_discoverable.is() ? explicit_discoverable.get() : false) ? IOTCON_RESOURCE_EXPLICIT_DISCOVERABLE : IOTCON_RESOURCE_NO_PROPERTY; + int properties = IotconUtils::GetProperties(args); ResourceInfoPtr resource{new ResourceInfo()}; auto ret = IotconServerManager::GetInstance().CreateResource(uri_path, resource_interfaces, resource_types, diff --git a/src/iotcon/iotcon_utils.cc b/src/iotcon/iotcon_utils.cc index 762f2cb3..60e05fcd 100644 --- a/src/iotcon/iotcon_utils.cc +++ b/src/iotcon/iotcon_utils.cc @@ -24,6 +24,7 @@ #include "common/tools.h" #include "iotcon/iotcon_server_manager.h" +#include "iotcon/iotcon_client_manager.h" namespace extension { namespace iotcon { @@ -99,6 +100,7 @@ const std::string kResourceChildren = "resources"; const std::string kUriPath = "uriPath"; const std::string kStates = "states"; const std::string kId = "id"; +const std::string kKeepId = "keepId"; const std::string kDeviceId = "deviceId"; const std::string kHostAddress = "hostAddress"; const std::string kConnectivityType = "connectivityType"; @@ -143,6 +145,40 @@ const std::string kTriggerType = "triggerType"; using common::TizenResult; using common::TizenSuccess; +const picojson::value& IotconUtils::GetArg(const picojson::object& args, const std::string& name) { + static const picojson::value kNull; + + auto it = args.find(name); + if (args.end() == it) { + return kNull; + } else { + return it->second; + } +} + +int IotconUtils::GetProperties(const picojson::object& args) { + int properties = IOTCON_RESOURCE_NO_PROPERTY; + + const auto& observable = IotconUtils::GetArg(args, kIsObservable); + properties |= (observable.is() ? observable.get() : false) ? IOTCON_RESOURCE_OBSERVABLE : IOTCON_RESOURCE_NO_PROPERTY; + + const auto& discoverable = IotconUtils::GetArg(args, kIsDiscoverable); + properties |= (discoverable.is() ? discoverable.get() : false) ? IOTCON_RESOURCE_DISCOVERABLE : IOTCON_RESOURCE_NO_PROPERTY; + + const auto& active = IotconUtils::GetArg(args, kIsActive); + properties |= (active.is() ? active.get() : false) ? IOTCON_RESOURCE_ACTIVE : IOTCON_RESOURCE_NO_PROPERTY; + + const auto& slow = IotconUtils::GetArg(args, kIsSlow); + properties |= (slow.is() ? slow.get() : false) ? IOTCON_RESOURCE_SLOW : IOTCON_RESOURCE_NO_PROPERTY; + + const auto& secure = IotconUtils::GetArg(args, kIsSecure); + properties |= (secure.is() ? secure.get() : false) ? IOTCON_RESOURCE_SECURE : IOTCON_RESOURCE_NO_PROPERTY; + + const auto& explicit_discoverable = IotconUtils::GetArg(args, kIsExplicitDiscoverable); + properties |= (explicit_discoverable.is() ? explicit_discoverable.get() : false) ? IOTCON_RESOURCE_EXPLICIT_DISCOVERABLE : IOTCON_RESOURCE_NO_PROPERTY; + + return properties; +} void IotconUtils::PropertiesToJson(int properties, picojson::object* res) { bool value = properties & IOTCON_RESOURCE_OBSERVABLE; @@ -412,6 +448,66 @@ TizenResult IotconUtils::RemoteResourceToJson(iotcon_remote_resource_h handle, return TizenSuccess(); } +common::TizenResult IotconUtils::RemoteResourceFromJson(const picojson::object& source, + FoundRemoteInfoPtr* ptr) { + ScopeLogger(); + //checking if resource has id + long long id = 0; + if (source.find(kId)->second.is()) { + id = static_cast(source.find(kId)->second.get()); + } + if (id > 0) { + LoggerD("Resource stored, getting it from IotconClientManager"); + return IotconClientManager::GetInstance().GetRemoteById(id, ptr); + } else { + LoggerD("Id is not defined, creating handle using resource info"); + } + + (*ptr).reset(new FoundRemoteInfo{}); + CHECK_EXIST(source, kHostAddress); + char* host_address = nullptr; + if (source.find(kHostAddress)->second.is()) { + host_address = const_cast(source.find(kHostAddress)->second.get().c_str()); + } + + CHECK_EXIST(source, kConnectivityType); + iotcon_connectivity_type_e connectivity_type = IotconUtils::ToConnectivityType( + source.find(kConnectivityType)->second.get()); + + CHECK_EXIST(source, kUriPath); + char* uri_path = nullptr; + if (source.find(kUriPath)->second.is()) { + uri_path = const_cast(source.find(kUriPath)->second.get().c_str()); + } + + int properties = IotconUtils::GetProperties(source); + + CHECK_EXIST(source, kResourceTypes); + const auto& types_array = source.find(kResourceTypes)->second.get(); + iotcon_resource_types_h resource_types = nullptr; + auto res = IotconUtils::ArrayToTypes(types_array, &resource_types); + if (!res) { + return res; + } + + CHECK_EXIST(source, kResourceInterfaces); + const auto& interfaces_array = source.find(kResourceInterfaces)->second.get(); + int interfaces = IOTCON_INTERFACE_NONE; + res = IotconUtils::ArrayToInterfaces(interfaces_array, &interfaces); + if (!res) { + return res; + } + + res = IotconUtils::ConvertIotconError( + iotcon_remote_resource_create(host_address, connectivity_type, uri_path, + properties, resource_types, interfaces, &((*ptr)->handle))); + if (!res) { + LogAndReturnTizenError(res, ("creating handle failed")); + } + + return TizenSuccess(); +} + common::TizenResult IotconUtils::RequestToJson(iotcon_request_h request, picojson::object* out) { ScopeLogger(); diff --git a/src/iotcon/iotcon_utils.h b/src/iotcon/iotcon_utils.h index e171dcfe..4decbc5a 100644 --- a/src/iotcon/iotcon_utils.h +++ b/src/iotcon/iotcon_utils.h @@ -33,6 +33,11 @@ namespace extension { namespace iotcon { +#define CHECK_EXIST(args, name) \ + if (args.end() == args.find(name)) { \ + return common::TypeMismatchError(std::string(name) + " is required argument"); \ + } + extern const std::string kIsDiscoverable; extern const std::string kIsObservable; extern const std::string kIsActive; @@ -46,6 +51,7 @@ extern const std::string kResourceChildren; extern const std::string kUriPath; extern const std::string kStates; extern const std::string kId; +extern const std::string kKeepId; extern const std::string kDeviceId; extern const std::string kHostAddress; extern const std::string kConnectivityType; @@ -55,11 +61,14 @@ extern const std::string kOptions; class ResourceInfo; class PresenceEvent; +class FoundRemoteInfo; typedef std::shared_ptr ResourceInfoPtr; typedef std::map ResourceInfoMap; typedef std::shared_ptr PresenceEventPtr; typedef std::map PresenceMap; +typedef std::shared_ptr FoundRemoteInfoPtr; +typedef std::map FoundRemotesMap; using ResponsePtr = std::shared_ptr::type>; @@ -100,6 +109,19 @@ struct RemoteResourceInfo { } }; +struct FoundRemoteInfo { + long long id; + iotcon_remote_resource_h handle; + short ref_count; // counter for registered listeners for this handle + //TODO add listeners for each type + FoundRemoteInfo() : + id(0), handle(nullptr), ref_count(1) {} //initialize with 1 (struct is created, so it + //mean that some listener would be created) + ~FoundRemoteInfo() { + iotcon_remote_resource_destroy(handle); + } +}; + struct PresenceEvent { long long id; iotcon_presence_h handle; @@ -108,6 +130,8 @@ struct PresenceEvent { class IotconUtils { public: + static const picojson::value& GetArg(const picojson::object& args, const std::string& name); + static int GetProperties(const picojson::object& args); static void PropertiesToJson(int properties, picojson::object* res); static common::TizenResult ArrayToInterfaces(const picojson::array& interfaces, int* res); static picojson::array InterfacesToArray(int interfaces); @@ -122,6 +146,8 @@ class IotconUtils { static common::TizenResult ExtractFromRemoteResource(RemoteResourceInfo* resource); static common::TizenResult RemoteResourceToJson(iotcon_remote_resource_h handle, picojson::object* res); + static common::TizenResult RemoteResourceFromJson(const picojson::object& source, + FoundRemoteInfoPtr* ptr); static common::TizenResult RequestToJson(iotcon_request_h request, picojson::object* out); -- 2.34.1