Commit d0a9a6c5 authored by Mushfiqul Islam Antu's avatar Mushfiqul Islam Antu Committed by Mushfiqul Islam

[IOT-3121] Fix rts values of Collection Resource

For baseline response of collection, value of rt & rts
are same for current implementation, which is wrong.
rts should reflect the resource types of the chlidren
of the collection.

Change-Id: Ib4e768c7401247dc9dd4917ff5a611396e8e07a2
Signed-off-by: default avatarMushfiqul Islam Antu <i.mushfiq@samsung.com>
parent 62dc2adb
......@@ -37,24 +37,21 @@
#include "cainterface.h"
#define TAG "OIC_RI_COLLECTION"
static bool AddRTSBaselinePayload(OCRepPayload **linkArray, int size, OCRepPayload **colPayload)
static bool AddRTSBaselinePayload(const OCResource* collResource, OCRepPayload **colPayload)
{
size_t arraySize = 0;
for (int j = 0; j < size; j++)
for (OCChildResource *tempChildResource = collResource->rsrcChildResourcesHead;
tempChildResource; tempChildResource = tempChildResource->next)
{
size_t rtDim[MAX_REP_ARRAY_DEPTH] = {0};
char **rt = NULL;
OCRepPayloadGetStringArray(linkArray[j], OC_RSRVD_RESOURCE_TYPE, &rt, rtDim);
arraySize += rtDim[0];
for (size_t l = 0; l < rtDim[0]; l++)
OCResource* currentResource = tempChildResource->rsrcResource;
OCResourceType* currentType = currentResource->rsrcType;
while(currentType)
{
OICFree(rt[l]);
arraySize++;
currentType = currentType->next;
}
OICFree(rt);
}
for (OCStringLL *rsrcType = (*colPayload)->types; rsrcType; rsrcType = rsrcType->next, arraySize++);
OIC_LOG_V(DEBUG, TAG, "Number of RTS elements : %zd", arraySize);
size_t dim[MAX_REP_ARRAY_DEPTH] = {arraySize, 0, 0};
char **rts = (char **)OICMalloc(sizeof(char *) * arraySize);
......@@ -64,21 +61,16 @@ static bool AddRTSBaselinePayload(OCRepPayload **linkArray, int size, OCRepPaylo
return OC_STACK_NO_MEMORY;
}
int k = 0;
for (int j = 0; j < size; j++)
for (OCChildResource *tempChildResource = collResource->rsrcChildResourcesHead;
tempChildResource; tempChildResource = tempChildResource->next)
{
size_t rtDim[MAX_REP_ARRAY_DEPTH] = {0};
char **rt = NULL;
OCRepPayloadGetStringArray(linkArray[j], OC_RSRVD_RESOURCE_TYPE, &rt, rtDim);
for (size_t l = 0; l < rtDim[0]; l++)
OCResource* currentResource = tempChildResource->rsrcResource;
OCResourceType* currentType = currentResource->rsrcType;
while(currentType)
{
rts[k++] = OICStrdup(rt[l]);
OICFree(rt[l]);
}
OICFree(rt);
rts[k++] = OICStrdup(currentType->resourcetypename);
currentType = currentType->next;
}
for (OCStringLL *rsrcType = (*colPayload)->types; rsrcType; rsrcType = rsrcType->next, size++)
{
rts[k++] = OICStrdup(rsrcType->value);
}
bool b = OCRepPayloadSetStringArrayAsOwner(*colPayload, OC_RSRVD_RTS, rts, dim);
......@@ -184,7 +176,7 @@ static OCStackResult HandleLinkedListInterface(OCEntityHandlerRequest *ehRequest
{
OCRepPayloadAddInterface(colPayload, itf->name);
}
AddRTSBaselinePayload(linkArr, size, &colPayload);
AddRTSBaselinePayload(collResource, &colPayload);
}
OCRepPayloadSetPropObjectArrayAsOwner(colPayload, OC_RSRVD_LINKS, linkArr, dim);
ret = OC_STACK_OK;
......
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