Changed callbackwrapper visibility to private
authorYoungman <yman.jung@samsung.com>
Wed, 8 Feb 2017 00:56:26 +0000 (09:56 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Wed, 8 Mar 2017 09:21:57 +0000 (09:21 +0000)
currently callbackWrapper is public api but is used only internally, so changed its visibility to private

Change-Id: Ic39128dca13a1342103c5cfc8276abfa806f31d4
Signed-off-by: Randeep Singh <randeep.s@samsung.com>
Signed-off-by: Youngman <yman.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17091
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
resource/include/OCProvisioningManager.hpp
resource/provisioning/src/OCProvisioningManager.cpp

index 5cc8279..6124ce6 100644 (file)
@@ -148,6 +148,42 @@ namespace OC
 
     class OCSecure
     {
+        private:
+            /**
+             * Common callback wrapper, which will be called from OC-APIs.
+             */
+            static void callbackWrapper(void* ctx, size_t nOfRes,
+                                         OCProvisionResult_t *arr, bool hasError);
+
+            /**
+             * Callback function to display Verification Number.
+             *
+             * @param[in] ctx  User context returned in callback
+             * @param[in] verifNum  Array of MUTUAL_VERIF_NUM_LEN size bytes
+             *
+             * @return OC_STACK_OK in case of success and other value otherwise.
+             */
+            static OCStackResult displayNumCallbackWrapper(void* ctx,
+                    uint8_t verifNum[MUTUAL_VERIF_NUM_LEN]);
+
+            /**
+             * Callback function to get 'Num' verification result.
+             *
+             * @return OC_STACK_OK in case of success and other value otherwise.
+             */
+            static OCStackResult confirmUserCallbackWrapper(void* ctx);
+
+            /**
+             * Notifier wrapper for trustCertChain change.
+             *
+             * @param[in] ctx  User context returned in callback
+             * @param[in] credId  trustCertChain changed for this ID
+             * @param[in] trustCertChain trustcertchain binary blob
+             * @param[in] chainSize size of trustCertChain
+             */
+            static void certCallbackWrapper(void* ctx, uint16_t credId, uint8_t *trustCertChain,
+                                size_t chainSize);
+
         public:
             /**
              * The API is responsible for initialization of the provisioning manager. It will load
@@ -265,10 +301,9 @@ namespace OC
 
             /**
              * API for registering a pin input callback. Only one input pin callback is allowed
-             * to be registered at a time by setInputPinCallback and registerInputPinCallback. 
-             * Use unsetInputPinCallback to unregister a callback set by setInputPinCallback. 
+             * to be registered at a time by setInputPinCallback and registerInputPinCallback.
+             * Use unsetInputPinCallback to unregister a callback set by setInputPinCallback.
              *
-
              * @deprecated Use registerInputPinCallback instead.
              *
              * @param inputPin inputPin callback function.
@@ -288,9 +323,8 @@ namespace OC
             static OCStackResult unsetInputPinCallback();
 
             /**
-
              * API to register for a callback to input a pin. Only one input pin callback is allowed
-             * to be registered at a time by setInputPinCallback and registerInputPinCallback. Use 
+             * to be registered at a time by setInputPinCallback and registerInputPinCallback. Use
              * deregisterInputPinCallback to unregister a callback set by registerInputPinCallback.
              *
              * @param inputPinCB             Callback which is to be registered.
@@ -364,15 +398,6 @@ namespace OC
              */
             static OCStackResult deregisterDisplayPinCallback(DisplayPinCallbackHandle displayPinCallbackHandle);
 
-
-
-
-
-
-
-
-
-
             /**
              * API to get status of all the devices in current subnet. The status include endpoint
              * information and doxm information which can be extracted during owned and unowned
@@ -447,23 +472,6 @@ namespace OC
              */
             static OCStackResult setVerifyOptionMask(VerifyOptionBitmask_t optionMask);
 
-            /**
-             * Callback function to display Verification Number.
-             *
-             * @param[in] ctx  User context returned in callback
-             * @param[in] verifNum  Array of MUTUAL_VERIF_NUM_LEN size bytes
-             *
-             * @return OC_STACK_OK in case of success and other value otherwise.
-             */
-            static OCStackResult displayNumCallbackWrapper(void* ctx,
-                    uint8_t verifNum[MUTUAL_VERIF_NUM_LEN]);
-
-             /**
-             * Callback function to get 'Num' verification result.
-             *
-             * @return OC_STACK_OK in case of success and other value otherwise.
-             */
-            static OCStackResult confirmUserCallbackWrapper(void* ctx);
 
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
             /**
@@ -478,7 +486,6 @@ namespace OC
             static OCStackResult saveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
                                         OicEncodingType_t encodingType, uint16_t *credId);
 
-
             /**
              * API to read Trust certificate chain from SVR.
              * Caller must free when done using the returned trust certificate
@@ -508,17 +515,6 @@ namespace OC
             static OCStackResult removeTrustCertChangeNotifier();
 
             /**
-             * Notifier wrapper for trustCertChain change.
-             *
-             * @param[in] ctx  User context returned in callback
-             * @param[in] credId  trustCertChain changed for this ID
-             * @param[in] trustCertChain trustcertchain binary blob
-             * @param[in] chainSize size of trustCertChain
-             */
-            static void certCallbackWrapper(void* ctx, uint16_t credId, uint8_t *trustCertChain,
-                                size_t chainSize);
-
-            /**
              * Wrapper to save the seed value to generate device UUID
              *
              * @param[in] seed  buffer of seed value
@@ -534,7 +530,6 @@ namespace OC
              *@return OC_STACK_OK in case of successful configue and other value otherwise.
              */
             static OCStackResult configSelfOwnership();
-
     };
 
     /**
@@ -704,12 +699,6 @@ namespace OC
              */
             OCStackResult getOTMethod(OicSecOxm_t* oxm);
 
-            /**
-             * Common callback wrapper, which will be called from OC-APIs.
-             */
-            static void callbackWrapper(void* ctx, size_t nOfRes,
-                    OCProvisionResult_t *arr, bool hasError);
-
 #ifdef MULTIPLE_OWNER
             /**
              * API to update 'doxm.oxmsel' to resource server.
@@ -799,6 +788,12 @@ namespace OC
 #endif // MULTIPLE_OWNER
 
         private:
+            /**
+             * Common callback wrapper, which will be called from OC-APIs.
+             */
+            static void callbackWrapper(void* ctx, size_t nOfRes,
+                                           OCProvisionResult_t *arr, bool hasError);
+
             void validateSecureResource();
     };
 
index 5590065..ccf1d68 100644 (file)
@@ -39,6 +39,31 @@ namespace OC
      */
     bool g_displayPinCallbackRegistered = false;
 
+    static void callbackWrapperImpl(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
+    {
+        PMResultList_t *results = nullptr;
+        ProvisionContext* context = static_cast<ProvisionContext*>(ctx);
+
+        try
+        {
+            results = new PMResultList_t;
+        }
+        catch (std::bad_alloc& e)
+        {
+            oclog() <<"Bad alloc exception";
+            return;
+        }
+
+        for (size_t i = 0; i < nOfRes; i++)
+        {
+            results->push_back(arr[i]);
+        }
+
+        std::thread exec(context->callback, results, hasError);
+        exec.detach();
+
+        delete context;
+    }
     OCStackResult OCSecure::provisionInit(const std::string& dbPath)
     {
         OCStackResult result;
@@ -382,7 +407,7 @@ namespace OC
 
         return result;
     }
-    
+
     static void inputPinCallbackWrapper(OicUuid_t deviceId, char* pinBuffer, size_t pinBufferSize, void* context)
     {
         (static_cast<InputPinContext*>(context))->callback(deviceId, pinBuffer, pinBufferSize);
@@ -694,7 +719,7 @@ namespace OC
             if(OC_STACK_OK == result)
             {
                 result = OCRemoveDeviceWithUuid(static_cast<void*>(context), waitTimeForOwnedDeviceDiscovery,
-                        &targetDev, &OCSecureResource::callbackWrapper);
+                        &targetDev, &OCSecure::callbackWrapper);
             }
             else
             {
@@ -1044,30 +1069,14 @@ namespace OC
     }
 #endif // __WITH_DTLS__ || __WITH_TLS__
 
-    void OCSecureResource::callbackWrapper(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
+    void OCSecure::callbackWrapper(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
     {
-        PMResultList_t *results = nullptr;
-        ProvisionContext* context = static_cast<ProvisionContext*>(ctx);
-
-        try
-        {
-            results = new PMResultList_t;
-        }
-        catch (std::bad_alloc& e)
-        {
-            oclog() <<"Bad alloc exception";
-            return;
-        }
-
-        for (size_t i = 0; i < nOfRes; i++)
-        {
-            results->push_back(arr[i]);
-        }
-
-        std::thread exec(context->callback, results, hasError);
-        exec.detach();
+        callbackWrapperImpl(ctx, nOfRes, arr, hasError);
+    }
 
-        delete context;
+    void OCSecureResource::callbackWrapper(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
+    {
+        callbackWrapperImpl(ctx, nOfRes, arr, hasError);
     }
 
     OCSecureResource::OCSecureResource(): m_csdkLock(std::weak_ptr<std::recursive_mutex>()),