Added deprecated method for backward compatibility
authorRandeep Singh <randeep.s@samsung.com>
Mon, 6 Feb 2017 09:07:17 +0000 (14:37 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Wed, 8 Mar 2017 09:22:15 +0000 (09:22 +0000)
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 <randeep.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17065
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Youngman Jung <yman.jung@samsung.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
resource/include/OCProvisioningManager.hpp
resource/provisioning/src/OCProvisioningManager.cpp

index 6124ce6..0f1ab4d 100644 (file)
@@ -236,6 +236,19 @@ namespace OC
                     std::shared_ptr<OCSecureResource> &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.
              *
index ccf1d68..73e0b3c 100644 (file)
@@ -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<std::recursive_mutex> 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,