Move the removeDeviceWithUuid method to OCSecure class as static method.
authorChul Lee <chuls.lee@samsung.com>
Fri, 5 Aug 2016 01:15:12 +0000 (10:15 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Thu, 11 Aug 2016 06:00:20 +0000 (06:00 +0000)
Change-Id: Ic8a9904990b3bbd27c82e43f1b1105aa60b00087
Signed-off-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10059
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/include/OCProvisioningManager.h
resource/provisioning/examples/provisioningclient.cpp
resource/provisioning/src/OCProvisioningManager.cpp

index 0638d99..3602cd8 100644 (file)
@@ -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();
     };
 
index 163a769..ec57563 100644 (file)
@@ -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)
index ed34574..cb13e67 100644 (file)
@@ -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<std::recursive_mutex> lock(*cLock);
+
+            OicUuid_t targetDev;
+            result = ConvertStrToUuid(uuid.c_str(), &targetDev);
+            if(OC_STACK_OK == result)
+            {
+                result = OCRemoveDeviceWithUuid(static_cast<void*>(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<std::recursive_mutex> lock(*cLock);
-
-            OicUuid_t targetDev;
-            result = ConvertStrToUuid(uuid.c_str(), &targetDev);
-            if(OC_STACK_OK == result)
-            {
-                result = OCRemoveDeviceWithUuid(static_cast<void*>(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;