IOT-2618 remove href prop in introspection res
authorSrikrishna Gurugubelli <srikguru@microsoft.com>
Thu, 14 Sep 2017 18:10:44 +0000 (11:10 -0700)
committerZiran Sun <ziran.sun@samsung.com>
Mon, 2 Oct 2017 12:31:25 +0000 (12:31 +0000)
Also made rt and if properties conditional based on whether the query
interface was baseline or not.

Signed-off-by: Srikrishna Gurugubelli <srikguru@microsoft.com>
Change-Id: I620d422ebc4442a34fa9de8623221de6f341a342
Bug: https://jira.iotivity.org/browse/IOT-2618

resource/csdk/stack/src/ocresource.c

index 6ed11992284dc869beda7a5e6cfec659cfd45956..99959e23d31d5c0de11506e507716623e2b72cd4 100644 (file)
@@ -1098,7 +1098,7 @@ exit:
 }
 
 OCStackResult BuildIntrospectionResponseRepresentation(const OCResource *resourcePtr,
-    OCRepPayload** payload, OCDevAddr *devAddr)
+    OCRepPayload** payload, OCDevAddr *devAddr, bool includeBaselineProps)
 {
     size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
     OCRepPayload *tempPayload = NULL;
@@ -1130,36 +1130,33 @@ OCStackResult BuildIntrospectionResponseRepresentation(const OCResource *resourc
         goto exit;
     }
 
-    if (!OCRepPayloadSetUri(tempPayload, resourcePtr->uri))
+    if(includeBaselineProps)
     {
-        OIC_LOG(ERROR, TAG, "Failed to set payload URI");
-        ret = OC_STACK_ERROR;
-        goto exit;
-    }
-
-    resType = resourcePtr->rsrcType;
-    while (resType)
-    {
-        if (!OCRepPayloadAddResourceType(tempPayload, resType->resourcetypename))
+        resType = resourcePtr->rsrcType;
+        while (resType)
         {
-            OIC_LOG(ERROR, TAG, "Failed at add resource type");
-            ret = OC_STACK_ERROR;
-            goto exit;
+            if (!OCRepPayloadAddResourceType(tempPayload, resType->resourcetypename))
+            {
+                OIC_LOG(ERROR, TAG, "Failed at add resource type");
+                ret = OC_STACK_ERROR;
+                goto exit;
+            }
+            resType = resType->next;
         }
-        resType = resType->next;
-    }
 
-    resInterface = resourcePtr->rsrcInterface;
-    while (resInterface)
-    {
-        if (!OCRepPayloadAddInterface(tempPayload, resInterface->name))
+        resInterface = resourcePtr->rsrcInterface;
+        while (resInterface)
         {
-            OIC_LOG(ERROR, TAG, "Failed to add interface");
-            ret = OC_STACK_ERROR;
-            goto exit;
+            if (!OCRepPayloadAddInterface(tempPayload, resInterface->name))
+            {
+                OIC_LOG(ERROR, TAG, "Failed to add interface");
+                ret = OC_STACK_ERROR;
+                goto exit;
+            }
+            resInterface = resInterface->next;
         }
-        resInterface = resInterface->next;
     }
+
     if (!OCRepPayloadSetPropString(tempPayload, OC_RSRVD_INTROSPECTION_NAME, OC_RSRVD_INTROSPECTION_NAME_VALUE))
     {
         OIC_LOG(ERROR, TAG, "Failed to set Name property.");
@@ -1916,8 +1913,13 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
     {
         // Received request for introspection
         OCResource *resourcePtr = FindResourceByUri(OC_RSRVD_INTROSPECTION_URI_PATH);
+        bool includeBaselineProps = interfaceQuery
+                                    && (0 == strcmp(interfaceQuery, OC_RSRVD_INTERFACE_DEFAULT));
         VERIFY_PARAM_NON_NULL(TAG, resourcePtr, "Introspection URI not found.");
-        discoveryResult = BuildIntrospectionResponseRepresentation(resourcePtr, (OCRepPayload **)&payload, &request->devAddr);
+        discoveryResult = BuildIntrospectionResponseRepresentation(resourcePtr,
+                                                                   (OCRepPayload **)&payload,
+                                                                   &request->devAddr,
+                                                                   includeBaselineProps);
         OIC_LOG(INFO, TAG, "Request is for Introspection");
     }
     else if (OC_INTROSPECTION_PAYLOAD_URI == virtualUriInRequest)