Commit 0c69809f authored by Jihun Ha's avatar Jihun Ha Committed by Madan Lanka

Fix a logic to copy userdata in ESReadUserdataCb

userdata parameter should be passed as double pointer type variable in
ESReadUserdataCb function so that user can assign a memory to the
variable and copy an user data to it inside the function.

Change-Id: Ic005d83c07256b83d8547069e908cbea11d54bec
Signed-off-by: default avatarJihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9985Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarMadan Lanka <lanka.madan@samsung.com>
parent 24866974
......@@ -54,7 +54,7 @@ typedef void (*ESWriteUserdataCb)(OCRepPayload* payload, char* resourceType);
* @param userdata User-specific data you want to deliver to desired users, i.e. application.
* The user should know a data structure of passed userdata.
*/
typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void* userdata);
typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void** userdata);
/**
* This function Initializes the EasySetup. This API must be called prior to invoking any other API
......
......@@ -306,7 +306,7 @@ void updateWiFiResource(OCRepPayload* input)
if(gReadUserdataCb)
{
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_WIFI, wiFiData->userdata);
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_WIFI, &wiFiData->userdata);
}
if(ssid || cred || authType!= -1 || encType != -1)
......@@ -362,7 +362,7 @@ void updateCloudResource(OCRepPayload* input)
if(gReadUserdataCb)
{
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER, cloudData->userdata);
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER, &cloudData->userdata);
}
if(authCode || authProvider || ciServer)
......@@ -410,7 +410,7 @@ void updateDevConfResource(OCRepPayload* input)
if(gReadUserdataCb)
{
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_DEVCONF, devConfData->userdata);
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_DEVCONF, &devConfData->userdata);
}
if(country || language)
......@@ -479,7 +479,9 @@ OCRepPayload* constructResponseOfCloud()
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CISERVER, gCloudResource.ciServer);
if(gWriteUserdataCb)
{
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_CLOUDSERVER);
}
return payload;
}
......
......@@ -39,7 +39,7 @@ typedef void (*ESCloudCB) (ESResult, ESCloudProvData *);
typedef void (*ESDevConfCB) (ESResult, ESDevConfProvData *);
typedef void (*ESWriteUserdataCb)(OCRepPayload* payload, char* resourceType);
typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void* userdata);
typedef void (*ESReadUserdataCb)(OCRepPayload* payload, char* resourceType, void** userdata);
/* Structure to represent a Light resource */
typedef struct PROVRESOURCE
......
......@@ -41,7 +41,7 @@ void SetUserProperties(const UserProperties *prop)
}
}
void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void* userdata)
void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void** userdata)
{
OIC_LOG(DEBUG, ESX_ENROLLEE_TAG, "ReadUserdataCb IN");
......@@ -52,11 +52,11 @@ void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void* userdata)
int64_t value = -1;
if (OCRepPayloadGetPropInt(payload, USERPROPERTY_KEY_INT, &value))
{
if(userdata != NULL)
userdata = (void*)OICMalloc(sizeof(UserProperties));
if(*userdata != NULL)
*userdata = (void*)OICMalloc(sizeof(UserProperties));
OIC_LOG_V(INFO, ESX_ENROLLEE_TAG, "[User specific property] %s : %ld",
USERPROPERTY_KEY_INT, value);
((UserProperties*)userdata)->userValue_int = value;
((UserProperties*)(*userdata))->userValue_int = value;
g_userProperties.userValue_int = value;
}
}
......
......@@ -35,7 +35,7 @@ typedef struct UserProperties_t
#define USERPROPERTY_KEY_INT "x.user.property.int"
#define USERPROPERTY_KEY_STR "x.user.property.str"
void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void* userdata);
void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void** userdata);
void WriteUserdataCb(OCRepPayload* payload, char* resourceType);
void SetUserProperties(const UserProperties *prop);
......
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