diff options
author | Senthil Kumar G S <senthil.gs@samsung.com> | 2019-11-19 11:35:11 +0530 |
---|---|---|
committer | DoHyun Pyun <dh79.pyun@samsung.com> | 2019-11-28 16:21:33 +0900 |
commit | 719f7ec27d9333259468d9067e24284d7f5b9b95 (patch) | |
tree | a32220c67d2780a381747a270f827ddcd0a9a677 | |
parent | 2e4fa3b68a8b9cfe5bc29e333ae32bdc67f74dcf (diff) | |
download | iotivity-719f7ec27d9333259468d9067e24284d7f5b9b95.tar.gz iotivity-719f7ec27d9333259468d9067e24284d7f5b9b95.tar.bz2 iotivity-719f7ec27d9333259468d9067e24284d7f5b9b95.zip |
Remove code duplication in easy-setup service.
Code duplications in easy-setup service reported by Sonarqube
has been addressed in this patch.
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/ecf2f9ec396bddceaa59aa4daa84506d6ea32e92
(cherry-picked from ecf2f9ec396bddceaa59aa4daa84506d6ea32e92)
Change-Id: Id89ba0f0ea8a712dad2c60873f4c6896491a7cb9
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
-rwxr-xr-x | service/easy-setup/enrollee/src/resourcehandler.c | 63 | ||||
-rw-r--r-- | service/easy-setup/mediator/richsdk/inc/ESSCCommon.h | 431 |
2 files changed, 108 insertions, 386 deletions
diff --git a/service/easy-setup/enrollee/src/resourcehandler.c b/service/easy-setup/enrollee/src/resourcehandler.c index 779354e5c..f33187d78 100755 --- a/service/easy-setup/enrollee/src/resourcehandler.c +++ b/service/easy-setup/enrollee/src/resourcehandler.c @@ -559,6 +559,29 @@ void updateDevConfResource(OCRepPayload* input) OICFree(devConfData); } +static OCRepPayload *constructPolicy(OCEntityHandlerRequest *ehRequest, OCResourceHandle handle) +{ + OCResourceProperty p = OCGetResourceProperties(handle); + OCRepPayload *policy = OCRepPayloadCreate(); + if (!policy) + { + OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload"); + return NULL; + } + + OCRepPayloadSetPropInt(policy, OC_RSRVD_BITMAP, + ((p & OC_DISCOVERABLE) | (p & OC_OBSERVABLE))); + if (p & OC_SECURE) + { + OCRepPayloadSetPropBool(policy, OC_RSRVD_SECURE, p & OC_SECURE); + uint16_t securePort = CAGetAssignedPortNumber(ehRequest->devAddr.adapter, + ehRequest->devAddr.flags); + OCRepPayloadSetPropInt(policy, OC_RSRVD_HOSTING_PORT, securePort); + } + + return policy; +} + OCRepPayload* constructResponseOfWiFiConf(char *interface) { OCRepPayload* payload = OCRepPayloadCreate(); @@ -865,24 +888,8 @@ OCRepPayload* constructResponseOfEasySetup(OCEntityHandlerRequest *ehRequest) OCRepPayloadSetStringArray(add, OC_RSRVD_INTERFACE, (const char **)resourceInterface, dimensions); - OCResourceProperty p = OCGetResourceProperties((OCResourceHandle *)g_ESWiFiConfResource.handle); - OCRepPayload *policy = OCRepPayloadCreate(); - if (!policy) - { - OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload"); - return NULL; - } - - OCRepPayloadSetPropInt(policy, OC_RSRVD_BITMAP, - ((p & OC_DISCOVERABLE) | (p & OC_OBSERVABLE))); - if (p & OC_SECURE) - { - OCRepPayloadSetPropBool(policy, OC_RSRVD_SECURE, p & OC_SECURE); - uint16_t securePort = CAGetAssignedPortNumber(ehRequest->devAddr.adapter, - ehRequest->devAddr.flags); - OCRepPayloadSetPropInt(policy, OC_RSRVD_HOSTING_PORT, securePort); - } - + OCRepPayload *policy = constructPolicy(ehRequest, + (OCResourceHandle *)g_ESWiFiConfResource.handle); OCRepPayloadSetPropObject(add, OC_RSRVD_POLICY, policy); arrayPayload[childResCnt++] = add; @@ -919,24 +926,8 @@ OCRepPayload* constructResponseOfEasySetup(OCEntityHandlerRequest *ehRequest) OCRepPayloadSetStringArray(add, OC_RSRVD_INTERFACE, (const char **)resourceInterface, dimensions); - OCResourceProperty p = OCGetResourceProperties((OCResourceHandle *)g_ESDevConfResource.handle); - OCRepPayload *policy = OCRepPayloadCreate(); - if (!policy) - { - OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload"); - return NULL; - } - - OCRepPayloadSetPropInt(policy, OC_RSRVD_BITMAP, - ((p & OC_DISCOVERABLE) | (p & OC_OBSERVABLE))); - if (p & OC_SECURE) - { - OCRepPayloadSetPropBool(policy, OC_RSRVD_SECURE, p & OC_SECURE); - uint16_t securePort = CAGetAssignedPortNumber(ehRequest->devAddr.adapter, - ehRequest->devAddr.flags); - OCRepPayloadSetPropInt(policy, OC_RSRVD_HOSTING_PORT, securePort); - } - + OCRepPayload *policy = constructPolicy(ehRequest, + (OCResourceHandle *)g_ESDevConfResource.handle); OCRepPayloadSetPropObject(add, OC_RSRVD_POLICY, policy); arrayPayload[childResCnt++] = add; diff --git a/service/easy-setup/mediator/richsdk/inc/ESSCCommon.h b/service/easy-setup/mediator/richsdk/inc/ESSCCommon.h index d52cd2679..65c6d4729 100644 --- a/service/easy-setup/mediator/richsdk/inc/ESSCCommon.h +++ b/service/easy-setup/mediator/richsdk/inc/ESSCCommon.h @@ -109,6 +109,68 @@ namespace OIC std::string bssid; } SCCandidateAPInfo; + static std::vector<SCCandidateAPInfo> getCandidateAPListHelper(OCRepresentation rep) + { + if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS)) + { + std::vector<OC::OCRepresentation> candidateInfo = + rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS); + std::vector<SCCandidateAPInfo> postcandidateInfo; + for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin(); + it != candidateInfo.end(); ++it) + { + OC::OCRepresentation rep = *it; + SCCandidateAPInfo candidateInfotemp; + if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID)) + { + candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID); + } + if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE)) + { + candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE); + } + if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL)) + { + candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL); + } + if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID)) + { + candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID); + } + postcandidateInfo.push_back(candidateInfotemp); + } + return postcandidateInfo; + } + return {}; + } + + static std::string getEasySetupPropHelper(OCRepresentation easySetupRep, std::string propName) + { + std::vector<OCRepresentation> children = easySetupRep.getChildren(); + for(auto child = children.begin(); child != children.end(); ++child) + { + if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) + { + OCRepresentation rep; + if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) + { + rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); + } + else + { + return std::string(""); + } + + if(rep.hasAttribute(propName)) + { + return rep.getValue<std::string>(propName); + } + } + } + return std::string(""); + } + + /** * @brief Properties of provisioning resource. It includes a provisioning status and last * error code. @@ -433,38 +495,7 @@ namespace OIC */ std::vector<SCCandidateAPInfo> getCandidateAPList() { - if (m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS)) - { - std::vector<OC::OCRepresentation> candidateInfo= - m_rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS); - std::vector<SCCandidateAPInfo> postcandidateInfo; - for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin(); - it != candidateInfo.end(); ++it) - { - OC::OCRepresentation rep = *it; - SCCandidateAPInfo candidateInfotemp; - if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID)) - { - candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID); - } - if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE)) - { - candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE); - } - if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL)) - { - candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL); - - } - if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID)) - { - candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID); - } - postcandidateInfo.push_back(candidateInfotemp); - } - return postcandidateInfo; - } - return {}; + return getCandidateAPListHelper(m_rep); } /** @@ -828,28 +859,7 @@ namespace OIC */ std::string getDeviceType() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_DEVICE_TYPE)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_DEVICE_TYPE); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_DEVICE_TYPE); } /** @@ -860,28 +870,7 @@ namespace OIC */ std::string getDeviceSubType() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE); } /** @@ -894,28 +883,7 @@ namespace OIC */ std::string getRegisterSetDevice() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV); } /** @@ -926,45 +894,19 @@ namespace OIC std::vector<SCCandidateAPInfo> getCandidateAPList() const { std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) + for (auto child = children.begin(); child != children.end(); ++child) { - if(child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos) + if (child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos) { OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) + if (child->hasAttribute(OC_RSRVD_REPRESENTATION)) { rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); } - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS)) + if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS)) { - std::vector<OC::OCRepresentation> candidateInfo=rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS); - std::vector<SCCandidateAPInfo> postcandidateInfo; - for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin(); - it != candidateInfo.end(); ++it) - { - OC::OCRepresentation rep = *it; - SCCandidateAPInfo candidateInfotemp; - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID)) - { - candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_SSID); - } - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE)) - { - candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_PASSPHRASE); - } - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL)) - { - candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL); - - } - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID)) - { - candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_CANDIDATE_BSSID); - } - postcandidateInfo.push_back(candidateInfotemp); - } - return postcandidateInfo; + return getCandidateAPListHelper(rep); } } } @@ -982,28 +924,7 @@ namespace OIC */ std::string getNetworkProvisioningInfo() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO); } /** @@ -1016,28 +937,7 @@ namespace OIC */ std::string getSSOList() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSO_LIST)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SSO_LIST); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_SSO_LIST); } /** @@ -1077,28 +977,7 @@ namespace OIC */ std::string getTCHeader() { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_HEADER)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_TC_HEADER); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_TC_HEADER); } /** @@ -1108,28 +987,7 @@ namespace OIC */ std::string getTCVersion() { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_TC_VERSION)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_TC_VERSION); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_TC_VERSION); } /** @@ -1139,28 +997,7 @@ namespace OIC */ std::string getPnpPin() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_PNP_PIN)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_PNP_PIN); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_PNP_PIN); } /** @@ -1227,28 +1064,7 @@ namespace OIC */ std::string getUTCDatetime() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_UTC_DATE_TIME); - } - } - } - return {}; + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_UTC_DATE_TIME); } /** @@ -1258,28 +1074,7 @@ namespace OIC */ std::string getRegionalDatetime() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME); - } - } - } - return {}; + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME); } /** @@ -1294,28 +1089,7 @@ namespace OIC */ std::string getESProtocolVersion() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION); } /** @@ -1326,28 +1100,7 @@ namespace OIC */ std::string getCountry() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_COUNTRY)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_COUNTRY); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_COUNTRY); } /** @@ -1357,30 +1110,8 @@ namespace OIC */ std::string getHubId() const { - std::vector<OCRepresentation> children = m_EasySetupRep.getChildren(); - for(auto child = children.begin(); child != children.end(); ++child) - { - if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OCRepresentation rep; - if(child->hasAttribute(OC_RSRVD_REPRESENTATION)) - { - rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION); - } - else - { - return std::string(""); - } - - if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_HUB_ID)) - { - return rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_HUB_ID); - } - } - } - return std::string(""); + return getEasySetupPropHelper(m_EasySetupRep, SC_RSRVD_ES_VENDOR_HUB_ID); } - }; } } |