X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Feasy-setup%2Fmediator%2Frichsdk%2Fsrc%2FEasySetup.cpp;h=ef1a06abdae1d6c97a0fa818ae5b52ad28347e6e;hb=refs%2Ftags%2Fsubmit%2Ftizen_4.0%2F20171010.021147;hp=fae946210476597aec29f9a66da104239f89fbc2;hpb=3e08f0b76cfa2aebd58a6acd4d8a6ae64c5d3cf4;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/easy-setup/mediator/richsdk/src/EasySetup.cpp b/service/easy-setup/mediator/richsdk/src/EasySetup.cpp old mode 100644 new mode 100755 index fae9462..ef1a06a --- a/service/easy-setup/mediator/richsdk/src/EasySetup.cpp +++ b/service/easy-setup/mediator/richsdk/src/EasySetup.cpp @@ -18,23 +18,25 @@ // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -#include "EasySetup.h" +#include "EasySetup.hpp" +#include "OCPlatform.h" #include "logger.h" #include "ESException.h" #include "RemoteEnrollee.h" +using namespace OC; + namespace OIC { namespace Service { - #define EASYSETUP_TAG "EASY_SETUP" + #define EASYSETUP_TAG "ES_EASY_SETUP" EasySetup * EasySetup::s_instance = nullptr; EasySetup::EasySetup() { - } EasySetup* EasySetup::getInstance () @@ -46,69 +48,37 @@ namespace OIC return s_instance; } - RemoteEnrollee::shared_ptr EasySetup::findDeviceInProvisioningList ( - const EnrolleeNWProvInfo& enrolleeNWProvInfo) + std::shared_ptr EasySetup::createRemoteEnrollee (std::shared_ptr< OC::OCResource > resource) { - OC_LOG(DEBUG,EASYSETUP_TAG,"Entered findDeviceInProvisioningList ()"); - - std::vector< std::shared_ptr< RemoteEnrollee > >::iterator it; + OIC_LOG(INFO, EASYSETUP_TAG, "createRemoteEnrollee IN"); - std::shared_ptr< RemoteEnrollee > remoteEnrollee = nullptr; - for(auto it : m_activeEnrolleeList) + if(resource) { - OC_LOG_V(DEBUG,EASYSETUP_TAG,"entered the iterator"); - - if (0 == memcmp(&it->getEnrolleeProvisioningInfo().netAddressInfo, - &enrolleeNWProvInfo.netAddressInfo, sizeof(EnrolleeNWProvInfo))) + if(resource->getResourceTypes().at(0) != OC_RSRVD_ES_RES_TYPE_EASYSETUP || + resource->connectivityType() & CT_ADAPTER_TCP) { - remoteEnrollee = it; - return remoteEnrollee; + OIC_LOG (ERROR, EASYSETUP_TAG, "Given resource is not valid due to wrong rt or conntype"); + return nullptr; } - } - - OC_LOG_V(DEBUG,EASYSETUP_TAG,"Return nullptr for findDeviceInProvisioningList call"); - return remoteEnrollee; - } - bool EasySetup::addDeviceToProvisioningList(const RemoteEnrollee::shared_ptr remoteEnrollee) - { - for (auto it : m_activeEnrolleeList) - { - if (0 == memcmp(&it->getEnrolleeProvisioningInfo().netAddressInfo, - &remoteEnrollee->getEnrolleeProvisioningInfo().netAddressInfo, - sizeof(EnrolleeNWProvInfo))) + auto interfaces = resource->getResourceInterfaces(); + for(auto interface : interfaces) { - return false; + if(interface.compare(BATCH_INTERFACE) == 0) + { + OIC_LOG (INFO, EASYSETUP_TAG, "RemoteEnrollee object is succeessfully created"); + OIC_LOG_V (INFO_PRIVATE, EASYSETUP_TAG, "HOST: %s", resource->host().c_str()); + OIC_LOG_V (INFO_PRIVATE, EASYSETUP_TAG, "URI: %s", resource->uri().c_str()); + OIC_LOG_V (INFO_PRIVATE, EASYSETUP_TAG, "SID: %s", resource->sid().c_str()); + OIC_LOG_V (INFO_PRIVATE, EASYSETUP_TAG, "CONNECTIVITY: %d", resource->connectivityType()); + return std::shared_ptr< RemoteEnrollee > (new RemoteEnrollee(resource)); + } } } - OC_LOG_V(DEBUG,EASYSETUP_TAG,"Adding new device RemoteEnrollee list"); - m_activeEnrolleeList.push_back(remoteEnrollee); - return true; + OIC_LOG (ERROR, EASYSETUP_TAG, "Given resource is NULL"); + return nullptr; } - - std::shared_ptr EasySetup::createEnrolleeDevice ( - const EnrolleeNWProvInfo& enrolleeNWProvInfo) - { - if (findDeviceInProvisioningList(enrolleeNWProvInfo) != nullptr) - { - throw ESBadRequestException { "Device already created exception" }; - } - - RemoteEnrollee::shared_ptr remoteEnrollee; - - remoteEnrollee = std::make_shared< RemoteEnrollee > (enrolleeNWProvInfo); - - - if (!addDeviceToProvisioningList (remoteEnrollee)) - { - return nullptr; - } - - return remoteEnrollee; - } - - } }