From: Chul Lee Date: Fri, 5 Aug 2016 01:15:12 +0000 (+0900) Subject: Move the removeDeviceWithUuid method to OCSecure class as static method. X-Git-Tag: 1.2.0+RC1~135 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be7243fff72bea9c777804dccabeee77c2b28542;p=platform%2Fupstream%2Fiotivity.git Move the removeDeviceWithUuid method to OCSecure class as static method. Change-Id: Ic8a9904990b3bbd27c82e43f1b1105aa60b00087 Signed-off-by: Chul Lee Reviewed-on: https://gerrit.iotivity.org/gerrit/10059 Tested-by: jenkins-iotivity Reviewed-by: Jihun Ha Reviewed-by: Randeep Singh --- diff --git a/resource/include/OCProvisioningManager.h b/resource/include/OCProvisioningManager.h index 0638d99..3602cd8 100644 --- a/resource/include/OCProvisioningManager.h +++ b/resource/include/OCProvisioningManager.h @@ -177,6 +177,21 @@ namespace OC * @return ::OC_STACK_OK in case of success and other value otherwise. */ static OCStackResult setDisplayPinCB(GeneratePinCallback displayPin); + + /** + * API to remove device credential and ACL from all devices in subnet. + * + * @param resultCallback Callback provided by API user, callback will be called when + * credential revocation is finished. + * @param uuid Device uuid to be revoked. + * @param waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device + * discovery in seconds. + * @return ::OC_STACK_OK in case of success and other value otherwise. + */ + static OCStackResult removeDeviceWithUuid(unsigned short waitTimeForOwnedDeviceDiscovery, + std::string uuid, + ResultCallBack resultCallback); + }; /** @@ -268,20 +283,6 @@ namespace OC ResultCallBack resultCallback); /** - * API to remove device credential and ACL from all devices in subnet. - * - * @param resultCallback Callback provided by API user, callback will be called when - * credential revocation is finished. - * @param uuid Device uuid to be revoked. - * @param waitTimeForOwnedDeviceDiscovery Maximum wait time for owned device - * discovery in seconds. - * @return ::OC_STACK_OK in case of success and other value otherwise. - */ - OCStackResult removeDeviceWithUuid(unsigned short waitTimeForOwnedDeviceDiscovery, - std::string uuid, - ResultCallBack resultCallback); - - /** * API to provision DirectPairing to devices. * * @param pconf pointer to PCONF (Pairing Configuration). @@ -330,13 +331,14 @@ namespace OC */ bool getOwnedStatus(); - private: + /** * Common callback wrapper, which will be called from OC-APIs. */ static void callbackWrapper(void* ctx, int nOfRes, OCProvisionResult_t *arr, bool hasError); + private: void validateSecureResource(); }; diff --git a/resource/provisioning/examples/provisioningclient.cpp b/resource/provisioning/examples/provisioningclient.cpp index 163a769..ec57563 100644 --- a/resource/provisioning/examples/provisioningclient.cpp +++ b/resource/provisioning/examples/provisioningclient.cpp @@ -1118,7 +1118,7 @@ int main(void) ask = 0; - if (pOwnedDevList[index]->removeDeviceWithUuid(DISCOVERY_TIMEOUT, + if (OCSecure::removeDeviceWithUuid(DISCOVERY_TIMEOUT, pOwnedDevList[index]->getDeviceID(), provisionCB) != OC_STACK_OK) diff --git a/resource/provisioning/src/OCProvisioningManager.cpp b/resource/provisioning/src/OCProvisioningManager.cpp index ed34574..cb13e67 100644 --- a/resource/provisioning/src/OCProvisioningManager.cpp +++ b/resource/provisioning/src/OCProvisioningManager.cpp @@ -230,6 +230,46 @@ namespace OC return result; } + OCStackResult OCSecure::removeDeviceWithUuid(unsigned short waitTimeForOwnedDeviceDiscovery, + std::string uuid, + ResultCallBack resultCallback) + { + if (!resultCallback) + { + oclog() << "Result calback can't be null"; + return OC_STACK_INVALID_CALLBACK; + } + + OCStackResult result; + auto cLock = OCPlatform_impl::Instance().csdkLock().lock(); + + if (cLock) + { + ProvisionContext* context = new ProvisionContext(resultCallback); + + std::lock_guard lock(*cLock); + + OicUuid_t targetDev; + result = ConvertStrToUuid(uuid.c_str(), &targetDev); + if(OC_STACK_OK == result) + { + result = OCRemoveDeviceWithUuid(static_cast(context), waitTimeForOwnedDeviceDiscovery, + &targetDev, &OCSecureResource::callbackWrapper); + } + else + { + oclog() <<"Can not convert struuid to uuid"; + } + } + else + { + oclog() <<"Mutex not found"; + result = OC_STACK_ERROR; + } + return result; + } + + void OCSecureResource::callbackWrapper(void* ctx, int nOfRes, OCProvisionResult_t *arr, bool hasError) { PMResultList_t *results = nullptr; @@ -458,45 +498,6 @@ namespace OC return result; } - OCStackResult OCSecureResource::removeDeviceWithUuid(unsigned short waitTimeForOwnedDeviceDiscovery, - std::string uuid, - ResultCallBack resultCallback) - { - if (!resultCallback) - { - oclog() << "Result calback can't be null"; - return OC_STACK_INVALID_CALLBACK; - } - - OCStackResult result; - auto cLock = m_csdkLock.lock(); - - if (cLock) - { - ProvisionContext* context = new ProvisionContext(resultCallback); - - std::lock_guard lock(*cLock); - - OicUuid_t targetDev; - result = ConvertStrToUuid(uuid.c_str(), &targetDev); - if(OC_STACK_OK == result) - { - result = OCRemoveDeviceWithUuid(static_cast(context), waitTimeForOwnedDeviceDiscovery, - &targetDev, &OCSecureResource::callbackWrapper); - } - else - { - oclog() <<"Can not convert struuid to uuid"; - } - } - else - { - oclog() <<"Mutex not found"; - result = OC_STACK_ERROR; - } - return result; - } - OCStackResult OCSecureResource::getLinkedDevices(UuidList_t &uuidList) { OCStackResult result;