aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMushfiqul Islam Antu <i.mushfiq@samsung.com>2018-11-30 15:13:51 +0600
committerMushfiqul Islam <mmiantu@gmail.com>2018-12-04 03:55:51 +0000
commitd0a9a6c5ce59407147ef6ceeeae79623e8c732f4 (patch)
tree10a2f79da28f501c217a955493c22909d5a52cd8
parent62dc2adb4c41f64fc8d0f47c40bcb26b21acad2e (diff)
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: Mushfiqul Islam Antu <i.mushfiq@samsung.com>
-rw-r--r--resource/csdk/stack/src/occollection.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/resource/csdk/stack/src/occollection.c b/resource/csdk/stack/src/occollection.c
index 081f10c..ad1f2e4 100644
--- a/resource/csdk/stack/src/occollection.c
+++ b/resource/csdk/stack/src/occollection.c
@@ -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]);
+ rts[k++] = OICStrdup(currentType->resourcetypename);
+ currentType = currentType->next;
}
- OICFree(rt);
- }
- 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;