Commit a1b4c7db authored by lankamadan's avatar lankamadan Committed by Madan Lanka

SVACE issue fix and renaming of files as per naming standards

- Fixed SVACE analysis issues
- Renaming of files

Change-Id: Ibcc0fe8f8ec91b2d41b1199660e9bf18885342c6
Signed-off-by: default avatarlankamadan <lanka.madan@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5249Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
parent be88bce8
......@@ -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);
......
......@@ -18,11 +18,13 @@
*
******************************************************************/
#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
......
......@@ -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");
......
......@@ -19,8 +19,11 @@
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#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;
......
......@@ -18,12 +18,14 @@
*
******************************************************************/
#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
......
......@@ -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')
......
......@@ -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"
......
......@@ -26,7 +26,7 @@
#include "oic_string.h"
#include "logger.h"
#include "prov_adapter.h"
#include "provisioningapi.h"
#include "provisioning.h"
#include "escommon.h"
......
......@@ -30,7 +30,7 @@
#include <jni.h>
#include <string>
#include "esrichcommon.h"
#include "ESRichCommon.h"
#include "octypes.h"
#include "JniJvm.h"
......
......@@ -28,7 +28,7 @@
#include <jni.h>
#include "RemoteEnrollee.h"
#include "esrichcommon.h"
#include "ESRichCommon.h"
#include "JniJvm.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"
......
......@@ -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);
......
......@@ -23,7 +23,7 @@
#include <functional>
#include "esrichcommon.h"
#include "ESRichCommon.h"
#include "OCProvisioningManager.h"
namespace OIC
......
......@@ -21,7 +21,7 @@
#ifndef REMOTE_ENROLLEE_H_
#define REMOTE_ENROLLEE_H_
#include "esrichcommon.h"
#include "ESRichCommon.h"
namespace OIC
{
......
......@@ -24,7 +24,7 @@
#include <mutex>
#include <memory>
#include "esrichcommon.h"
#include "ESRichCommon.h"
#include "OCApi.h"
......
......@@ -26,7 +26,7 @@
#include <stdint.h>
#include <sstream>
#include "prov_adapter.h"
#include "provisioningapi.h"
#include "logger.h"
#define ES_MEDIATOR_TAG "easysetupsample"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment