From a1b4c7db92c466637ed1190b7d08db9a7d25527d Mon Sep 17 00:00:00 2001 From: lankamadan Date: Mon, 29 Feb 2016 11:03:50 +0900 Subject: [PATCH] SVACE issue fix and renaming of files as per naming standards - Fixed SVACE analysis issues - Renaming of files Change-Id: Ibcc0fe8f8ec91b2d41b1199660e9bf18885342c6 Signed-off-by: lankamadan Reviewed-on: https://gerrit.iotivity.org/gerrit/5249 Tested-by: jenkins-iotivity --- service/easy-setup/enrollee/inc/resourcehandler.h | 6 -- .../enrollee/linux/wifi/networkhandler.cpp | 11 +++- service/easy-setup/enrollee/src/easysetup.cpp | 17 ----- .../easy-setup/enrollee/src/resourcehandler.cpp | 74 ++++------------------ .../enrollee/tizen/wifi/networkhandler.cpp | 6 +- service/easy-setup/mediator/csdk/SConscript | 8 +-- .../csdk/inc/{prov_adapter.h => provisioningapi.h} | 0 .../easy-setup/mediator/csdk/src/provisioning.cpp | 12 ++-- .../src/{prov_adapter.cpp => provisioningapi.cpp} | 2 +- ...{wifi_provisioning.cpp => wifiprovisioning.cpp} | 0 .../mediator/csdk/unittests/MediatorCSDKTest.cpp | 2 +- .../mediator/richsdk/android/jni/JniEsUtils.h | 2 +- .../android/jni/JniProvisioningStatusListener.h | 2 +- .../richsdk/android/jni/JniRemoteEnrollee.h | 2 +- .../richsdk/inc/{esrichcommon.h => ESRichCommon.h} | 0 .../easy-setup/mediator/richsdk/inc/EasySetup.h | 8 ++- .../mediator/richsdk/inc/EnrolleeSecurity.h | 2 +- .../mediator/richsdk/inc/RemoteEnrollee.h | 2 +- .../mediator/richsdk/inc/RemoteEnrolleeResource.h | 2 +- .../mediator/linux/csdk_sample/mediator.cpp | 2 +- 20 files changed, 48 insertions(+), 112 deletions(-) rename service/easy-setup/mediator/csdk/inc/{prov_adapter.h => provisioningapi.h} (100%) rename service/easy-setup/mediator/csdk/src/{prov_adapter.cpp => provisioningapi.cpp} (99%) rename service/easy-setup/mediator/csdk/src/{wifi_provisioning.cpp => wifiprovisioning.cpp} (100%) rename service/easy-setup/mediator/richsdk/inc/{esrichcommon.h => ESRichCommon.h} (100%) mode change 100755 => 100644 diff --git a/service/easy-setup/enrollee/inc/resourcehandler.h b/service/easy-setup/enrollee/inc/resourcehandler.h index 51938f1..a927892 100755 --- a/service/easy-setup/enrollee/inc/resourcehandler.h +++ b/service/easy-setup/enrollee/inc/resourcehandler.h @@ -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); diff --git a/service/easy-setup/enrollee/linux/wifi/networkhandler.cpp b/service/easy-setup/enrollee/linux/wifi/networkhandler.cpp index 90b4f3c..0aa74b5 100644 --- a/service/easy-setup/enrollee/linux/wifi/networkhandler.cpp +++ b/service/easy-setup/enrollee/linux/wifi/networkhandler.cpp @@ -18,11 +18,13 @@ * ******************************************************************/ +#include "networkhandler.h" + #include #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 diff --git a/service/easy-setup/enrollee/src/easysetup.cpp b/service/easy-setup/enrollee/src/easysetup.cpp index f6ebc4b..f06b683 100644 --- a/service/easy-setup/enrollee/src/easysetup.cpp +++ b/service/easy-setup/enrollee/src/easysetup.cpp @@ -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"); diff --git a/service/easy-setup/enrollee/src/resourcehandler.cpp b/service/easy-setup/enrollee/src/resourcehandler.cpp index 6eca772..dc9f1f2 100644 --- a/service/easy-setup/enrollee/src/resourcehandler.cpp +++ b/service/easy-setup/enrollee/src/resourcehandler.cpp @@ -19,8 +19,11 @@ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #include "resourcehandler.h" -#include "ocpayload.h" +#include + +#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; diff --git a/service/easy-setup/enrollee/tizen/wifi/networkhandler.cpp b/service/easy-setup/enrollee/tizen/wifi/networkhandler.cpp index ac6f205..3bafded 100644 --- a/service/easy-setup/enrollee/tizen/wifi/networkhandler.cpp +++ b/service/easy-setup/enrollee/tizen/wifi/networkhandler.cpp @@ -18,12 +18,14 @@ * ******************************************************************/ +#include "networkhandler.h" + #include #include #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 diff --git a/service/easy-setup/mediator/csdk/SConscript b/service/easy-setup/mediator/csdk/SConscript index d1163eb..e68538f 100644 --- a/service/easy-setup/mediator/csdk/SConscript +++ b/service/easy-setup/mediator/csdk/SConscript @@ -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') diff --git a/service/easy-setup/mediator/csdk/inc/prov_adapter.h b/service/easy-setup/mediator/csdk/inc/provisioningapi.h similarity index 100% rename from service/easy-setup/mediator/csdk/inc/prov_adapter.h rename to service/easy-setup/mediator/csdk/inc/provisioningapi.h diff --git a/service/easy-setup/mediator/csdk/src/provisioning.cpp b/service/easy-setup/mediator/csdk/src/provisioning.cpp index 7b0abff..c71fd7a 100644 --- a/service/easy-setup/mediator/csdk/src/provisioning.cpp +++ b/service/easy-setup/mediator/csdk/src/provisioning.cpp @@ -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; } diff --git a/service/easy-setup/mediator/csdk/src/prov_adapter.cpp b/service/easy-setup/mediator/csdk/src/provisioningapi.cpp similarity index 99% rename from service/easy-setup/mediator/csdk/src/prov_adapter.cpp rename to service/easy-setup/mediator/csdk/src/provisioningapi.cpp index d2ed0f8..537f17a 100644 --- a/service/easy-setup/mediator/csdk/src/prov_adapter.cpp +++ b/service/easy-setup/mediator/csdk/src/provisioningapi.cpp @@ -25,7 +25,7 @@ #include #include -#include "prov_adapter.h" +#include "provisioningapi.h" #include "oic_string.h" diff --git a/service/easy-setup/mediator/csdk/src/wifi_provisioning.cpp b/service/easy-setup/mediator/csdk/src/wifiprovisioning.cpp similarity index 100% rename from service/easy-setup/mediator/csdk/src/wifi_provisioning.cpp rename to service/easy-setup/mediator/csdk/src/wifiprovisioning.cpp diff --git a/service/easy-setup/mediator/csdk/unittests/MediatorCSDKTest.cpp b/service/easy-setup/mediator/csdk/unittests/MediatorCSDKTest.cpp index 57b6e63..65606d8 100644 --- a/service/easy-setup/mediator/csdk/unittests/MediatorCSDKTest.cpp +++ b/service/easy-setup/mediator/csdk/unittests/MediatorCSDKTest.cpp @@ -26,7 +26,7 @@ #include "oic_string.h" #include "logger.h" -#include "prov_adapter.h" +#include "provisioningapi.h" #include "provisioning.h" #include "escommon.h" diff --git a/service/easy-setup/mediator/richsdk/android/jni/JniEsUtils.h b/service/easy-setup/mediator/richsdk/android/jni/JniEsUtils.h index ac66e23..f65a68c 100644 --- a/service/easy-setup/mediator/richsdk/android/jni/JniEsUtils.h +++ b/service/easy-setup/mediator/richsdk/android/jni/JniEsUtils.h @@ -30,7 +30,7 @@ #include #include -#include "esrichcommon.h" +#include "ESRichCommon.h" #include "octypes.h" #include "JniJvm.h" diff --git a/service/easy-setup/mediator/richsdk/android/jni/JniProvisioningStatusListener.h b/service/easy-setup/mediator/richsdk/android/jni/JniProvisioningStatusListener.h index af185b2..8b37cac 100644 --- a/service/easy-setup/mediator/richsdk/android/jni/JniProvisioningStatusListener.h +++ b/service/easy-setup/mediator/richsdk/android/jni/JniProvisioningStatusListener.h @@ -28,7 +28,7 @@ #include #include "RemoteEnrollee.h" -#include "esrichcommon.h" +#include "ESRichCommon.h" #include "JniJvm.h" diff --git a/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h b/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h index 1a07d4c..de1f297 100644 --- a/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h +++ b/service/easy-setup/mediator/richsdk/android/jni/JniRemoteEnrollee.h @@ -28,7 +28,7 @@ #define __JNI_ES_REMOTEENROLLEE_H #include "RemoteEnrollee.h" -#include "esrichcommon.h" +#include "ESRichCommon.h" #include "ESException.h" #include "JniJvm.h" diff --git a/service/easy-setup/mediator/richsdk/inc/esrichcommon.h b/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h old mode 100755 new mode 100644 similarity index 100% rename from service/easy-setup/mediator/richsdk/inc/esrichcommon.h rename to service/easy-setup/mediator/richsdk/inc/ESRichCommon.h diff --git a/service/easy-setup/mediator/richsdk/inc/EasySetup.h b/service/easy-setup/mediator/richsdk/inc/EasySetup.h index 1b5bd89..9cc10d7 100644 --- a/service/easy-setup/mediator/richsdk/inc/EasySetup.h +++ b/service/easy-setup/mediator/richsdk/inc/EasySetup.h @@ -24,7 +24,7 @@ #include #include -#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 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); diff --git a/service/easy-setup/mediator/richsdk/inc/EnrolleeSecurity.h b/service/easy-setup/mediator/richsdk/inc/EnrolleeSecurity.h index 9d280a9..5308b0b 100755 --- a/service/easy-setup/mediator/richsdk/inc/EnrolleeSecurity.h +++ b/service/easy-setup/mediator/richsdk/inc/EnrolleeSecurity.h @@ -23,7 +23,7 @@ #include -#include "esrichcommon.h" +#include "ESRichCommon.h" #include "OCProvisioningManager.h" namespace OIC diff --git a/service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h b/service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h index eb462aa..1fb83b3 100644 --- a/service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h +++ b/service/easy-setup/mediator/richsdk/inc/RemoteEnrollee.h @@ -21,7 +21,7 @@ #ifndef REMOTE_ENROLLEE_H_ #define REMOTE_ENROLLEE_H_ -#include "esrichcommon.h" +#include "ESRichCommon.h" namespace OIC { diff --git a/service/easy-setup/mediator/richsdk/inc/RemoteEnrolleeResource.h b/service/easy-setup/mediator/richsdk/inc/RemoteEnrolleeResource.h index d9014c7..62cd648 100644 --- a/service/easy-setup/mediator/richsdk/inc/RemoteEnrolleeResource.h +++ b/service/easy-setup/mediator/richsdk/inc/RemoteEnrolleeResource.h @@ -24,7 +24,7 @@ #include #include -#include "esrichcommon.h" +#include "ESRichCommon.h" #include "OCApi.h" diff --git a/service/easy-setup/sampleapp/mediator/linux/csdk_sample/mediator.cpp b/service/easy-setup/sampleapp/mediator/linux/csdk_sample/mediator.cpp index 4a03d17..27678dd 100644 --- a/service/easy-setup/sampleapp/mediator/linux/csdk_sample/mediator.cpp +++ b/service/easy-setup/sampleapp/mediator/linux/csdk_sample/mediator.cpp @@ -26,7 +26,7 @@ #include #include -#include "prov_adapter.h" +#include "provisioningapi.h" #include "logger.h" #define ES_MEDIATOR_TAG "easysetupsample" -- 2.7.4