From 7e306511d57d4ed279341f700775c4033e844c11 Mon Sep 17 00:00:00 2001 From: Randeep Singh Date: Mon, 6 Feb 2017 14:37:17 +0530 Subject: [PATCH] Added deprecated method for backward compatibility setOwnerTransferCallbackData was removed and new api setInputPinCallback was introduced. In this patch setOwnerTransferCallbackData is added as deprecated API to maintain backward compatibility. Change-Id: I0b5fffa476d466c526e2e5bf63ba9186b7dbdf9c Signed-off-by: Randeep Singh Reviewed-on: https://gerrit.iotivity.org/gerrit/17065 Tested-by: jenkins-iotivity Reviewed-by: Youngman Jung Reviewed-by: Phil Coval --- resource/include/OCProvisioningManager.hpp | 13 ++++++++ .../provisioning/src/OCProvisioningManager.cpp | 35 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/resource/include/OCProvisioningManager.hpp b/resource/include/OCProvisioningManager.hpp index 6124ce6..0f1ab4d 100644 --- a/resource/include/OCProvisioningManager.hpp +++ b/resource/include/OCProvisioningManager.hpp @@ -236,6 +236,19 @@ namespace OC std::shared_ptr &foundDevice); /** + * API for registering Ownership transfer methods for a particular transfer Type. + * @deprecated Use setInputPinCallback to set input pin callback value. + * + * @param oxm Ownership transfer method. + * @param callbackData CallbackData Methods for ownership transfer. + * @param inputPin Callback method to input pin for verification. + * @return ::OC_STACK_OK in case of success and other value otherwise. + * + */ + static OCStackResult setOwnerTransferCallbackData(OicSecOxm_t oxm, + OTMCallbackData_t* callbackData, InputPinCallback inputPin); + + /** * API is responsible for discovery of devices in specified endpoint/deviceID. * And this function will only return the specified device's response. * diff --git a/resource/provisioning/src/OCProvisioningManager.cpp b/resource/provisioning/src/OCProvisioningManager.cpp index ccf1d68..73e0b3c 100644 --- a/resource/provisioning/src/OCProvisioningManager.cpp +++ b/resource/provisioning/src/OCProvisioningManager.cpp @@ -199,6 +199,41 @@ namespace OC return result; } + OCStackResult OCSecure::setOwnerTransferCallbackData(OicSecOxm_t oxm, + OTMCallbackData_t* callbackData, InputPinCallback inputPin) + { + if (NULL == callbackData || oxm >= OIC_OXM_COUNT) + { + oclog() <<"Invalid callbackData or OXM type"; + return OC_STACK_INVALID_PARAM; + } + + if ((OIC_RANDOM_DEVICE_PIN == oxm) && !inputPin) + { + oclog() <<"for OXM type DEVICE_PIN, inputPin callback can't be null"; + return OC_STACK_INVALID_PARAM; + } + + OCStackResult result; + auto cLock = OCPlatform_impl::Instance().csdkLock().lock(); + + if (cLock) + { + std::lock_guard lock(*cLock); + result = OCSetOwnerTransferCallbackData(oxm, callbackData); + if (result == OC_STACK_OK && (OIC_RANDOM_DEVICE_PIN == oxm)) + { + SetInputPinCB(inputPin); + } + } + else + { + oclog() <<"Mutex not found"; + result = OC_STACK_ERROR; + } + return result; + } + OCStackResult OCSecure::discoverSingleDeviceInUnicast(unsigned short timeout, const OicUuid_t* deviceID, const std::string& hostAddress, -- 2.7.4