Remove ESCloudProvState due to duplication 85/10685/2
authorJihun Ha <jihun.ha@samsung.com>
Sat, 20 Aug 2016 04:52:03 +0000 (13:52 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 22 Aug 2016 09:04:15 +0000 (09:04 +0000)
ESCloudProvState and ESResult can produce a similar result in easy setup.
So ESCloudProvState is decided to be merged into ESResult for consistency
with the other provisioning API like deviceProvisioning.

Change-Id: Ic937688f0f47eac9b7f4ce2b257ea7c3c6306eba
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10685
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/enrollee/unittests/ESMediatorSimulator.h
service/easy-setup/inc/escommon.h
service/easy-setup/mediator/richsdk/inc/ESRichCommon.h
service/easy-setup/mediator/richsdk/src/CloudResource.cpp
service/easy-setup/mediator/richsdk/src/EnrolleeResource.cpp
service/easy-setup/mediator/richsdk/src/RemoteEnrollee.cpp
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator_cpp.cpp

index 41a0b62..f6f8049 100755 (executable)
@@ -424,7 +424,7 @@ private:
         if(m_CloudPropProvisioningCb != NULL)
         {
             m_CloudPropProvisioningCb(cloudPropProvisioningStatus);
-            if(cloudPropProvisioningStatus->getESCloudState() == ES_CLOUD_PROVISIONING_SUCCESS)
+            if(cloudPropProvisioningStatus->getESResult() == ES_OK)
             {
                 m_CloudPropProvisioningCb = NULL;
             }
index 071944a..15933c2 100755 (executable)
@@ -120,18 +120,13 @@ typedef enum
 
 typedef enum
 {
-    ES_ERROR = -1,
     ES_OK = 0,
-    ES_NETWORKFOUND = 1,
-    ES_NETWORKCONNECTED,
-    ES_NETWORKNOTCONNECTED,
-    ES_RESOURCECREATED = 11,
-    ES_RECVREQOFPROVRES = 21,
-    ES_RECVREQOFNETRES,
-    ES_RECVUPDATEOFPROVRES,
-    ES_RECVTRIGGEROFPROVRES,
-    ES_UNAUTHORIZED = 31,
-    ES_UNSUPPORTED_OPERATION = 41
+    ES_FOUND_ENROLLEE = 1,
+    ES_NOT_FOUND_ENROLLEE = 11,
+    ES_SEC_OPERATION_IS_NOT_SUPPORTED = 20,
+    ES_UNAUTHORIZED_REQ = 21,
+    ES_SEC_PROVISION_FAILS = 22,
+    ES_ERROR = 255,
 } ESResult;
 
 /**
index 316da05..051f8ea 100755 (executable)
@@ -417,17 +417,6 @@ namespace OIC
             OCRepresentation m_rep;
         };
 
-        /**
-         * @brief Provisioning state in cloud server property provisioning.
-         */
-        typedef enum
-        {
-            ES_CLOUD_PROVISIONING_ERROR = -1,   /**< An error in cloud provisioning happens **/
-            ES_CLOUD_PROVISIONING_SUCCESS,      /**< Cloud provisioning is successfully done **/
-            ES_CLOUD_ENROLLEE_FOUND,            /**< An enrollee is found in a given network **/
-            ES_CLOUD_ENROLLEE_NOT_FOUND         /**< NO enrollee is found in a given network **/
-        }ESCloudProvState;
-
         /**
          * Security Provisioning Status
          */
@@ -706,8 +695,8 @@ namespace OIC
         class CloudPropProvisioningStatus
         {
         public:
-            CloudPropProvisioningStatus(ESResult result, ESCloudProvState state) :
-                    m_result(result), m_esCloudState(state)
+            CloudPropProvisioningStatus(ESResult result) :
+                    m_result(result)
             {
             }
 
@@ -716,14 +705,8 @@ namespace OIC
                 return m_result;
             }
 
-            ESCloudProvState getESCloudState()
-            {
-                return m_esCloudState;
-            }
-
         private:
             ESResult m_result;
-            ESCloudProvState m_esCloudState;
         };
 
         /**
index 8d47b3c..da378a5 100755 (executable)
@@ -64,27 +64,25 @@ namespace OIC
 
             if (eCode > OCStackResult::OC_STACK_RESOURCE_CHANGED)
             {
-                ESResult result  = ESResult::ES_ERROR;
+                ESResult result = ESResult::ES_ERROR;
 
                 OIC_LOG(DEBUG, ES_CLOUD_RES_TAG,"onCloudProvResponse : onCloudProvResponse is failed ");
 
                 if (eCode == OCStackResult::OC_STACK_UNAUTHORIZED_REQ)
                 {
                     OIC_LOG(DEBUG, ES_CLOUD_RES_TAG, "Mediator is unauthorized from Enrollee.");
-                    result = ESResult::ES_UNAUTHORIZED;
+                    result = ESResult::ES_UNAUTHORIZED_REQ;
                 }
 
                 std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
-                        CloudPropProvisioningStatus >(
-                        result, ESCloudProvState::ES_CLOUD_PROVISIONING_ERROR);
+                        CloudPropProvisioningStatus >(result);
                 m_cloudPropProvStatusCb(provStatus);
             }
             else
             {
                 OIC_LOG(DEBUG, ES_CLOUD_RES_TAG,"onCloudProvResponse : onCloudProvResponse is success ");
                 std::shared_ptr< CloudPropProvisioningStatus > provStatus =
-                    std::make_shared<CloudPropProvisioningStatus >(
-                    ESResult::ES_OK, ESCloudProvState::ES_CLOUD_PROVISIONING_SUCCESS);
+                    std::make_shared<CloudPropProvisioningStatus >(ESResult::ES_OK);
                 m_cloudPropProvStatusCb(provStatus);
             }
         }
index 6ad843e..ba71196 100755 (executable)
@@ -80,7 +80,7 @@ namespace OIC
                 {
                     OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                         "Mediator is unauthorized from Enrollee.");
-                    result = ESResult::ES_UNAUTHORIZED;
+                    result = ESResult::ES_UNAUTHORIZED_REQ;
                 }
 
                 EnrolleeStatus enrolleeStatus(rep);
@@ -116,7 +116,7 @@ namespace OIC
                 {
                     OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
                         "Mediator is unauthorized from Enrollee.");
-                    result = ESResult::ES_UNAUTHORIZED;
+                    result = ESResult::ES_UNAUTHORIZED_REQ;
                 }
 
                 EnrolleeConf enrolleeConf(rep);
index d8a17a7..ece4e64 100755 (executable)
@@ -224,6 +224,7 @@ namespace OIC
         void RemoteEnrollee::provisionSecurity(const SecurityProvStatusCb callback)
         {
 #ifdef __WITH_DTLS__
+            std::cout << __func__ << std::endl;
             if(!callback)
             {
                 throw ESInvalidParameterException("Callback is empty");
@@ -261,7 +262,7 @@ namespace OIC
 
             std::shared_ptr< SecProvisioningStatus > securityProvisioningStatus =
                      std::make_shared< SecProvisioningStatus >
-                                                        ("", ES_UNSUPPORTED_OPERATION);
+                                   ("", ESResult::ES_SEC_OPERATION_IS_NOT_SUPPORTED);
             m_securityProvStatusCb(securityProvisioningStatus);
 #endif
         }
@@ -362,8 +363,7 @@ namespace OIC
                     m_cloudResource = std::make_shared<CloudResource>(m_ocResource);
 
                     std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
-                        CloudPropProvisioningStatus >(ESResult::ES_OK,
-                                                        ESCloudProvState::ES_CLOUD_ENROLLEE_FOUND);
+                        CloudPropProvisioningStatus >(ESResult::ES_FOUND_ENROLLEE);
 
                     m_cloudPropProvStatusCb(provStatus);
                 }
@@ -404,8 +404,7 @@ namespace OIC
                     "Exception caught in provisionCloudProperties = %s", e.what());
 
                 std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
-                        CloudPropProvisioningStatus >(ESResult::ES_ERROR,
-                                                    ESCloudProvState::ES_CLOUD_ENROLLEE_NOT_FOUND);
+                        CloudPropProvisioningStatus >(ESResult::ES_NOT_FOUND_ENROLLEE);
                 m_cloudPropProvStatusCb(provStatus);
                 return;
             }
@@ -438,8 +437,7 @@ namespace OIC
                 m_cloudResource = nullptr;
 
                 std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
-                        CloudPropProvisioningStatus >(ESResult::ES_ERROR,
-                                                    ESCloudProvState::ES_CLOUD_PROVISIONING_ERROR);
+                        CloudPropProvisioningStatus >(ESResult::ES_ERROR);
                 m_cloudPropProvStatusCb(provStatus);
                 return;
             }
index bb0c55c..e89a344 100755 (executable)
@@ -42,8 +42,6 @@ static std::shared_ptr<OC::OCResource> curResource = nullptr;
 static std::mutex g_discoverymtx;
 static std::condition_variable g_cond;
 
-#define PROV_RESOURCE_TYPE "ocf.wk.prov"
-
 typedef void (*Runner)();
 
 Runner g_currentRun;
@@ -106,7 +104,15 @@ void provisionSecurityStatusCallback(std::shared_ptr<SecProvisioningStatus> secP
 
 void provisionSecurity()
 {
-    remoteEnrollee->provisionSecurity(provisionSecurityStatusCallback);
+    try
+    {
+        remoteEnrollee->provisionSecurity(provisionSecurityStatusCallback);
+    }
+    catch (OCException &e)
+    {
+        std::cout << "Exception during provisionSecurity call" << e.reason();
+        return;
+    }
 }
 
 void getStatusCallback(std::shared_ptr< GetEnrolleeStatus > getEnrolleeStatus)
@@ -200,7 +206,6 @@ void provisionDeviceProperty()
 
     try
     {
-        //remoteEnrollee->provisionDeviceProperties(deviceProp, deviceProvisioningStatusCallback);
         remoteEnrollee->provisionDeviceProperties(devProp, deviceProvisioningStatusCallback);
     }
     catch (OCException &e)
@@ -212,20 +217,20 @@ void provisionDeviceProperty()
 
 void cloudProvisioningStatusCallback(std::shared_ptr< CloudPropProvisioningStatus > provStatus)
 {
-    switch (provStatus->getESCloudState())
+    switch (provStatus->getESResult())
     {
-        case ES_CLOUD_PROVISIONING_ERROR:
-            cout << "Cloud Provisioning is failed." << endl;
-            break;
-        case ES_CLOUD_PROVISIONING_SUCCESS:
+        case ES_OK:
             cout << "Cloud Provisioning is success." << endl;
             break;
-        case ES_CLOUD_ENROLLEE_FOUND:
+        case ES_FOUND_ENROLLEE:
             cout << "Enrollee is found in a given network." << endl;
             break;
-        case ES_CLOUD_ENROLLEE_NOT_FOUND:
+        case ES_NOT_FOUND_ENROLLEE:
             cout << "Enrollee is not found in a given network." << endl;
             break;
+        default:
+            cout << "Cloud Provisioning is failed." << endl;
+            break;
     }
 }
 
@@ -301,7 +306,7 @@ void foundResource(std::shared_ptr<OC::OCResource> resource)
         // Do some operations with resource object.
         if(resource &&
            !curResource &&
-           resource->getResourceTypes().at(0) == PROV_RESOURCE_TYPE)
+           resource->getResourceTypes().at(0) == OC_RSRVD_ES_RES_TYPE_PROV)
         {
             std::cout<<"DISCOVERED Resource:"<<std::endl;
             // Get the resource URI
@@ -377,7 +382,7 @@ int main()
             return -1;
         }
 #endif
-        requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=" << PROV_RESOURCE_TYPE;
+        requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=" << OC_RSRVD_ES_RES_TYPE_PROV;
 
         OCPlatform::findResource("", requestURI.str(), CT_DEFAULT, &foundResource);
         std::cout<< "Finding Resource... " <<std::endl;