From 067ef0c2a218b8b9168ae342bee969cf9693fcd5 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 11 Nov 2015 18:05:27 +0100 Subject: [PATCH] resource-container: add make it possible to specify OIC interface name Without this the interface name of a bridged device is hard coded to "oic.if.baseline" with this patch it is possible to change it to something else if needed. Change-Id: If593ed43c6deb1787f689ef1be928a0aee66bb24 Signed-off-by: Hauke Mehrtens Reviewed-on: https://gerrit.iotivity.org/gerrit/4149 Tested-by: jenkins-iotivity Reviewed-by: Markus Jung Reviewed-by: Madan Lanka --- .../resource-container/bundle-api/include/BundleResource.h | 2 +- service/resource-container/src/ResourceContainerImpl.cpp | 11 ++++++++--- service/resource-container/src/ResourceContainerImpl.h | 2 +- .../resource-container/unittests/ResourceContainerTest.cpp | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/service/resource-container/bundle-api/include/BundleResource.h b/service/resource-container/bundle-api/include/BundleResource.h index 80414c5..8b3dbe5 100644 --- a/service/resource-container/bundle-api/include/BundleResource.h +++ b/service/resource-container/bundle-api/include/BundleResource.h @@ -174,7 +174,7 @@ namespace OIC public: std::string m_bundleId; - std::string m_name, m_uri, m_resourceType, m_address; + std::string m_name, m_uri, m_resourceType, m_interface, m_address; std::map< std::string, std::vector< std::map< std::string, std::string > > > m_mapResourceProperty; diff --git a/service/resource-container/src/ResourceContainerImpl.cpp b/service/resource-container/src/ResourceContainerImpl.cpp index b75f7cc..9607622 100644 --- a/service/resource-container/src/ResourceContainerImpl.cpp +++ b/service/resource-container/src/ResourceContainerImpl.cpp @@ -262,6 +262,7 @@ namespace OIC { string strUri = resource->m_uri; string strResourceType = resource->m_resourceType; + string strInterface = resource->m_interface; RCSResourceObject::Ptr server = nullptr; int ret = EINVAL; @@ -271,7 +272,11 @@ namespace OIC registrationLock.lock(); if (m_mapResources.find(strUri) == m_mapResources.end()) { - server = buildResourceObject(strUri, strResourceType); + if (strInterface.empty()) { + strInterface = "oic.if.baseline"; + } + + server = buildResourceObject(strUri, strResourceType, strInterface); if (server != nullptr) { @@ -431,10 +436,10 @@ namespace OIC } RCSResourceObject::Ptr ResourceContainerImpl::buildResourceObject(const std::string &strUri, - const std::string &strResourceType) + const std::string &strResourceType, const std::string &strInterface) { return RCSResourceObject::Builder(strUri, strResourceType, - "oic.if.baseline").setObservable( + strInterface).setObservable( true).setDiscoverable(true).build(); } diff --git a/service/resource-container/src/ResourceContainerImpl.h b/service/resource-container/src/ResourceContainerImpl.h index 6ae4a62..f798fac 100644 --- a/service/resource-container/src/ResourceContainerImpl.h +++ b/service/resource-container/src/ResourceContainerImpl.h @@ -81,7 +81,7 @@ namespace OIC static ResourceContainerImpl *getImplInstance(); static RCSResourceObject::Ptr buildResourceObject(const std::string &strUri, - const std::string &strResourceType); + const std::string &strResourceType, const std::string &strInterface); void startBundle(const std::string &bundleId); void stopBundle(const std::string &bundleId); diff --git a/service/resource-container/unittests/ResourceContainerTest.cpp b/service/resource-container/unittests/ResourceContainerTest.cpp index 9cc1127..98a146b 100644 --- a/service/resource-container/unittests/ResourceContainerTest.cpp +++ b/service/resource-container/unittests/ResourceContainerTest.cpp @@ -317,7 +317,7 @@ TEST_F(ResourceContainerBundleAPITest, ResourceServerCreatedWhenRegisterResource m_pBundleResource->m_resourceType = "container.test"; mocks.ExpectCallFunc(ResourceContainerImpl::buildResourceObject).With(m_pBundleResource->m_uri, - m_pBundleResource->m_resourceType).Return(nullptr); + m_pBundleResource->m_resourceType, m_pBundleResource->m_interface).Return(nullptr); m_pResourceContainer->registerResource(m_pBundleResource); } -- 2.7.4