SVACE issue fix and renaming of files as per naming standards
authorlankamadan <lanka.madan@samsung.com>
Mon, 29 Feb 2016 02:03:50 +0000 (11:03 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 29 Feb 2016 04:52:49 +0000 (04:52 +0000)
- Fixed SVACE analysis issues
- Renaming of files

Change-Id: Ibcc0fe8f8ec91b2d41b1199660e9bf18885342c6
Signed-off-by: lankamadan <lanka.madan@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5249
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
20 files changed:
service/easy-setup/enrollee/inc/resourcehandler.h
service/easy-setup/enrollee/linux/wifi/networkhandler.cpp
service/easy-setup/enrollee/src/easysetup.cpp
service/easy-setup/enrollee/src/resourcehandler.cpp
service/easy-setup/enrollee/tizen/wifi/networkhandler.cpp
service/easy-setup/mediator/csdk/SConscript
service/easy-setup/mediator/csdk/inc/provisioningapi.h [moved from service/easy-setup/mediator/csdk/inc/prov_adapter.h with 100% similarity]
service/easy-setup/mediator/csdk/src/provisioning.cpp
service/easy-setup/mediator/csdk/src/provisioningapi.cpp [moved from service/easy-setup/mediator/csdk/src/prov_adapter.cpp with 99% similarity]
service/easy-setup/mediator/csdk/src/wifiprovisioning.cpp [moved from service/easy-setup/mediator/csdk/src/wifi_provisioning.cpp with 100% similarity]
service/easy-setup/mediator/csdk/unittests/MediatorCSDKTest.cpp
service/easy-setup/mediator/richsdk/android/jni/JniEsUtils.h
service/easy-setup/mediator/richsdk/android/jni/JniProvisioningStatusListener.h
service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h
service/easy-setup/mediator/richsdk/inc/ESRichCommon.h [moved from service/easy-setup/mediator/richsdk/inc/esrichcommon.h with 100% similarity, mode: 0644]
service/easy-setup/mediator/richsdk/inc/EasySetup.h
service/easy-setup/mediator/richsdk/inc/EnrolleeSecurity.h
service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h
service/easy-setup/mediator/richsdk/inc/RemoteEnrolleeResource.h
service/easy-setup/sampleapp/mediator/linux/csdk_sample/mediator.cpp

index 51938f1..a927892 100755 (executable)
@@ -54,12 +54,6 @@ typedef struct NETRESOURCE
 
 OCStackResult CreateProvisioningResource(bool isSecured);
 OCStackResult DeleteProvisioningResource();
-OCStackResult DeleteNetworkResource();
-
-//created only for in case of wifi
-#ifdef ESWIFI
-OCStackResult CreateNetworkResource();
-#endif
 
 void GetTargetNetworkInfoFromProvResource(char *, char *);
 void RegisterResourceEventCallBack(ResourceEventCallback);
index 90b4f3c..0aa74b5 100644 (file)
  *
  ******************************************************************/
 
+#include "networkhandler.h"
+
 #include <unistd.h>
 
 #include "logger.h"
 #include "easysetup.h"
-#include "networkhandler.h"
+#include "oic_string.h"
 
 #define LOG_TAG "TIZEN ES"
 
@@ -30,8 +32,11 @@ const char *gSsid = "DLNA_LISMORE1";
 const char *gPass = "dlna@010203";
 char *gIpAddress;
 NetworkEventCallback gNetworkEventCb;
-static void ESActivateWifi();
 
+/*
+ * All the functions defined in this file are stub functions to be implemented by the end user of
+ * Easysetup Enrollee applications.
+ */
 static void ESActivateWifi()
 {
 
@@ -60,7 +65,7 @@ ESResult getCurrentNetworkInfo(OCConnectivityType targetType, NetworkInfo *info)
         info->ipaddr = gIpAddress;
         if (strlen(gSsid) <= MAXSSIDLEN)
         {
-            strcpy(info->ssid, gSsid);
+            OICStrcpy(info->ssid, sizeof(info->ssid), gSsid);
             return ES_OK;
         }
         else
index f6ebc4b..f06b683 100644 (file)
@@ -174,15 +174,6 @@ ESResult TerminateEasySetup()
         return ES_ERROR;
     }
 
-    //Delete Prov resource
-#ifdef ESWIFI
-    if (DeleteNetworkResource() != OC_STACK_OK)
-    {
-        OIC_LOG(ERROR, ES_ENROLLEE_TAG, "Deleting prov resource error!!");
-        return ES_ERROR;
-    }
-#endif
-
     OIC_LOG(ERROR, ES_ENROLLEE_TAG, "TerminateEasySetup success");
     return ES_OK;
 }
@@ -197,14 +188,6 @@ ESResult InitProvisioning()
         return ES_ERROR;
     }
 
-#ifdef ESWIFI
-    if (CreateNetworkResource() != OC_STACK_OK)
-    {
-        OIC_LOG(ERROR, ES_ENROLLEE_TAG, "CreateNetworkResource error");
-        return ES_ERROR;
-    }
-#endif
-
     RegisterResourceEventCallBack(ProvisioningCallback);
 
     OIC_LOG(INFO, ES_ENROLLEE_TAG, "InitProvisioning OUT");
index 6eca772..dc9f1f2 100644 (file)
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 #include "resourcehandler.h"
-#include "ocpayload.h"
 
+#include <stdio.h>
+
+#include "ocpayload.h"
+#include "oic_string.h"
 
 /**
  * @var ES_RH_TAG
@@ -78,8 +81,8 @@ void GetTargetNetworkInfoFromProvResource(char *name, char *pass)
 {
     if (name != NULL && pass != NULL)
     {
-        sprintf(name, "%s", gProvResource.tnn);
-        sprintf(pass, "%s", gProvResource.cd);
+        OICStrcpy(name, sizeof(name), gProvResource.tnn);
+        OICStrcpy(pass, sizeof(pass), gProvResource.cd);
     }
 }
 
@@ -88,8 +91,8 @@ OCStackResult CreateProvisioningResource(bool isSecured)
     gProvResource.ps = ES_PS_NEED_PROVISIONING;
 
     gProvResource.tnt = CT_ADAPTER_IP;
-    sprintf(gProvResource.tnn, "Unknown");
-    sprintf(gProvResource.cd, "Unknown");
+    OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn),"Unknown");
+    OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), "Unknown");
 
     OCStackResult res = OC_STACK_ERROR;
     if (isSecured)
@@ -126,55 +129,6 @@ OCStackResult DeleteProvisioningResource()
     return res;
 }
 
-#ifdef ESWIFI
-OCStackResult CreateNetworkResource()
-{
-    NetworkInfo netInfo;
-
-    if (getCurrentNetworkInfo(CT_ADAPTER_IP, &netInfo) != ES_OK)
-    {
-        return OC_STACK_ERROR;
-    }
-
-    if (netInfo.type != CT_ADAPTER_IP)
-    {
-        return OC_STACK_ERROR;
-    }
-
-    gNetResource.cnt = (int) netInfo.type;
-    gNetResource.ant[0] = (int) CT_ADAPTER_IP;
-
-    if(netInfo.ipaddr != NULL)
-    {
-        sprintf(gNetResource.ipaddr, "%d.%d.%d.%d", netInfo.ipaddr[0], netInfo.ipaddr[1],
-                                            netInfo.ipaddr[2], netInfo.ipaddr[3]);
-    }
-    sprintf(gNetResource.cnn, "%s", netInfo.ssid);
-
-    OIC_LOG_V(INFO, ES_RH_TAG, "SSID: %s", gNetResource.cnn);
-    OIC_LOG_V(INFO, ES_RH_TAG, "IP Address: %s", gNetResource.ipaddr);
-
-    OCStackResult res = OCCreateResource(&gNetResource.handle, "oic.r.net", OC_RSRVD_INTERFACE_DEFAULT,
-            OC_RSRVD_ES_URI_NET, OCEntityHandlerCb,NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
-
-    OIC_LOG_V(INFO, ES_RH_TAG, "Created Net resource with result: %s", getResult(res));
-
-    return res;
-}
-
-OCStackResult DeleteNetworkResource()
-{
-    OCStackResult res = OCDeleteResource(gNetResource.handle);
-    if (res != OC_STACK_OK)
-    {
-        OIC_LOG_V(INFO, ES_RH_TAG, "Deleting Network resource error with result: %s",
-                                                                            getResult(res));
-    }
-
-    return res;
-}
-#endif
-
 OCEntityHandlerResult ProcessGetRequest(OCEntityHandlerRequest *ehRequest,
                                                 OCRepPayload **payload)
 {
@@ -235,24 +189,24 @@ OCEntityHandlerResult ProcessPutRequest(OCEntityHandlerRequest *ehRequest,
     // PUT request is appropriate for provisioning information to the enrollee.
     // When an enrollee receives the put request, the entire resource information should
     // be overwritten.
-    sprintf(gProvResource.tnn, "%s", "");
-    sprintf(gProvResource.tnn, "%s", "");
+    OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), "");
+    OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), "");
 
     char* tnn;
     if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
     {
-        sprintf(gProvResource.tnn, "%s", tnn);
+        OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
         OIC_LOG(INFO, ES_RH_TAG, "got ssid");
     }
 
-       OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
+    OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
     char* cd;
     if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
     {
-        sprintf(gProvResource.cd, "%s", cd);
+        OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
         OIC_LOG(INFO, ES_RH_TAG, "got password");
     }
-       OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
+    OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
     gProvResource.ps = 2;
     OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %d", gProvResource.ps);
     g_flag = 1;
index ac6f205..3bafded 100644 (file)
  *
  ******************************************************************/
 
+#include "networkhandler.h"
+
 #include <wifi.h>
 #include <unistd.h>
 
 #include "logger.h"
 #include "easysetup.h"
-#include "networkhandler.h"
+#include "oic_string.h"
 
 #define LOG_TAG "TIZEN ES"
 
@@ -167,7 +169,7 @@ ESResult getCurrentNetworkInfo(OCConnectivityType targetType, NetworkInfo *info)
         info->ipaddr = gIpAddress;
         if (strlen(gSsid) <= MAXSSIDLEN)
         {
-            strcpy(info->ssid, gSsid);
+            OICStrcpy(info->ssid, sizeof(info->ssid), gSsid);
             return ES_OK;
         }
         else
index d1163eb..e68538f 100644 (file)
@@ -106,15 +106,15 @@ if target_os in ['android','linux']:
 
 if target_os == 'android':
        es_m_csdk_static = easy_setup_env.StaticLibrary('libESMediatorCSDK',
-                                       ['src/prov_adapter.cpp',
-                                       'src/wifi_provisioning.cpp',
+                                       ['src/provisioningapi.cpp',
+                                       'src/wifiprovisioning.cpp',
                     'src/provisioning.cpp'])
        easy_setup_env.InstallTarget(es_m_csdk_static, 'libESMediatorCSDK')
 
 if target_os == 'linux':
        es_m_csdk_shared = easy_setup_env.SharedLibrary('ESMediatorCSDK',
-                                       ['src/prov_adapter.cpp',
-                                       'src/wifi_provisioning.cpp',
+                                       ['src/provisioningapi.cpp',
+                                       'src/wifiprovisioning.cpp',
                     'src/provisioning.cpp'])
        easy_setup_env.InstallTarget(es_m_csdk_shared, 'libESMediatorCSDK')
 
index 7b0abff..c71fd7a 100644 (file)
@@ -149,10 +149,12 @@ OCStackApplicationResult ProvisionEnrolleeResponse(void* /*ctx*/, OCDoHandle /*h
             if (!strcmp(tnn, gProvConfig->provData.WIFI.ssid)) {
                 OIC_LOG_V(DEBUG, ES_PROV_TAG, "SSID is proper");
                 input = input->next;
+                OICFree(tnn);
                 continue;
             }
             else {
                 OIC_LOG_V(DEBUG, ES_PROV_TAG, "SSID is NOT proper");
+                OICFree(tnn);
                 goto Error;
             }
         }
@@ -161,10 +163,12 @@ OCStackApplicationResult ProvisionEnrolleeResponse(void* /*ctx*/, OCDoHandle /*h
             if (!strcmp(cd, gProvConfig->provData.WIFI.pwd)) {
                 OIC_LOG_V(DEBUG, ES_PROV_TAG, "Password is proper");
                 input = input->next;
+                OICFree(cd);
                 continue;
             }
             else {
                 OIC_LOG_V(DEBUG, ES_PROV_TAG, "Password is NOT proper");
+                OICFree(cd);
                 goto Error;
             }
         }
@@ -172,22 +176,14 @@ OCStackApplicationResult ProvisionEnrolleeResponse(void* /*ctx*/, OCDoHandle /*h
         LogProvisioningResponse(input->values);
 
         input = input->next;
-
-        OICFree(tnn);
-        OICFree(cd);
     }
 
     SuccessCallback(clientResponse);
-
     return OC_STACK_KEEP_TRANSACTION;
 
     Error:
     {
-        OICFree(tnn);
-        OICFree(cd);
-
         ErrorCallback(DEVICE_NOT_PROVISIONED);
-
         return OC_STACK_DELETE_TRANSACTION;
     }
 
@@ -25,7 +25,7 @@
 #include <stdint.h>
 #include <sstream>
 
-#include "prov_adapter.h"
+#include "provisioningapi.h"
 #include "oic_string.h"
 
 
index 57b6e63..65606d8 100644 (file)
@@ -26,7 +26,7 @@
 #include "oic_string.h"
 #include "logger.h"
 
-#include "prov_adapter.h"
+#include "provisioningapi.h"
 #include "provisioning.h"
 #include "escommon.h"
 
index ac66e23..f65a68c 100644 (file)
@@ -30,7 +30,7 @@
 #include <jni.h>
 #include <string>
 
-#include "esrichcommon.h"
+#include "ESRichCommon.h"
 #include "octypes.h"
 
 #include "JniJvm.h"
index 1a07d4c..de1f297 100644 (file)
@@ -28,7 +28,7 @@
 #define __JNI_ES_REMOTEENROLLEE_H
 
 #include "RemoteEnrollee.h"
-#include "esrichcommon.h"
+#include "ESRichCommon.h"
 #include "ESException.h"
 
 #include "JniJvm.h"
index 1b5bd89..9cc10d7 100644 (file)
@@ -24,7 +24,7 @@
 #include <memory>
 #include <vector>
 
-#include "esrichcommon.h"
+#include "ESRichCommon.h"
 #include "RemoteEnrollee.h"
 
 namespace OIC
@@ -59,13 +59,15 @@ namespace OIC
              * @return Pointer to RemoteEnrollee instance.
              */
             std::shared_ptr<RemoteEnrollee> createEnrolleeDevice (
-                         const ProvConfig& enrolleeNWProvInfo, const WiFiOnboadingConnection& wifiOnboardingconn);
+                         const ProvConfig& enrolleeNWProvInfo,
+                         const WiFiOnboadingConnection& wifiOnboardingconn);
         private:
             EasySetup();
             ~EasySetup();
 
             RemoteEnrollee::shared_ptr findDeviceInProvisioningList(
-                                const ProvConfig& enrolleeNWProvInfo, const WiFiOnboadingConnection& wifiOnboardingconn);
+                                const ProvConfig& enrolleeNWProvInfo,
+                                const WiFiOnboadingConnection& wifiOnboardingconn);
             bool addDeviceToProvisioningList(const RemoteEnrollee::shared_ptr remoteEnrollee);
             bool deleteDeviceFromProvisioningList (const ProvConfig& enrolleeNWProvInfo);
 
index 9d280a9..5308b0b 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include <functional>
 
-#include "esrichcommon.h"
+#include "ESRichCommon.h"
 #include "OCProvisioningManager.h"
 
 namespace OIC
index eb462aa..1fb83b3 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef REMOTE_ENROLLEE_H_
 #define REMOTE_ENROLLEE_H_
 
-#include "esrichcommon.h"
+#include "ESRichCommon.h"
 
 namespace OIC
 {
index 4a03d17..27678dd 100644 (file)
@@ -26,7 +26,7 @@
 #include <stdint.h>
 #include <sstream>
 
-#include "prov_adapter.h"
+#include "provisioningapi.h"
 #include "logger.h"
 
 #define ES_MEDIATOR_TAG "easysetupsample"