Change resource type of /oic/res from string to array.
authorZiran Sun <ziran.sun@samsung.com>
Thu, 23 Jun 2016 10:18:45 +0000 (11:18 +0100)
committerZiran Sun <ziran.sun@samsung.com>
Mon, 27 Jun 2016 08:48:47 +0000 (08:48 +0000)
JIRA Issue: https://jira.iotivity.org/browse/IOT-1131

Change-Id: I91f77f806ed7feb290fea0aa1b12f76a3b119442
Signed-off-by: Ziran Sun <ziran.sun@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8921
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Reviewed-by: Mushfiqul Islam <i.mushfiq@samsung.com>
resource/csdk/stack/include/octypes.h
resource/csdk/stack/include/payload_logging.h
resource/csdk/stack/src/ocpayload.c
resource/csdk/stack/src/ocpayloadconvert.c
resource/csdk/stack/src/ocpayloadparse.c
resource/csdk/stack/src/ocresource.c

index 9ae4c5e..e96a648 100644 (file)
@@ -1198,7 +1198,7 @@ typedef struct
     char *uri;
 
     /** Resource Type */
-    char *type;
+    OCStringLL *type;
 
     /** Interface */
     OCStringLL *interface;
index 75e2b0c..c518be6 100644 (file)
@@ -189,7 +189,10 @@ static inline void OCPayloadLogDiscovery(LogLevel level, OCDiscoveryPayload* pay
     }
     if (payload->type)
     {
-        OIC_LOG_V(level, PL_TAG, "\tResource Type: %s", payload->type);
+        for (OCStringLL *strll = payload->type; strll; strll = strll->next)
+        {
+            OIC_LOG_V(level, PL_TAG, "\tResource Type: %s", strll->value);
+        }
     }
     OIC_LOG(level, PL_TAG, "\tInterface:");
     for (OCStringLL *itf = payload->interface; itf; itf = itf->next)
index 8c61027..da35c63 100644 (file)
@@ -1590,7 +1590,7 @@ void OCDiscoveryPayloadDestroy(OCDiscoveryPayload* payload)
     OICFree(payload->sid);
     OICFree(payload->baseURI);
     OICFree(payload->uri);
-    OICFree(payload->type);
+    OCFreeOCStringLL(payload->type);
     OICFree(payload->name);
     OCFreeOCStringLL(payload->interface);
     OCDiscoveryResourceDestroy(payload->resources);
index 1e3b2b2..bcaa283 100644 (file)
@@ -269,8 +269,7 @@ static int64_t OCConvertDiscoveryPayload(OCDiscoveryPayload *payload, uint8_t *o
         VERIFY_CBOR_SUCCESS(TAG, err, "Failed setting device id");
 
         // Insert Resource Type
-        err |= ConditionalAddTextStringToMap(&rootMap, OC_RSRVD_RESOURCE_TYPE,
-                sizeof(OC_RSRVD_RESOURCE_TYPE) - 1, payload->type);
+        err |= OCStringLLJoin(&rootMap, OC_RSRVD_RESOURCE_TYPE, payload->type);
         VERIFY_CBOR_SUCCESS(TAG, err, "Failed setting RT");
 
         // Insert interfaces
index bd37367..8b684a6 100755 (executable)
@@ -248,7 +248,7 @@ static OCStackResult OCParseDiscoveryPayload(OCPayload **outPayload, CborValue *
         err = cbor_value_map_find_value(&rootMap, OC_RSRVD_RESOURCE_TYPE, &curVal);
         if (cbor_value_is_valid(&curVal))
         {
-            err = cbor_value_dup_text_string(&curVal, &(out->type), &len, NULL);
+            err = OCParseStringLL(&rootMap, OC_RSRVD_RESOURCE_TYPE, &out->type);
             VERIFY_CBOR_SUCCESS(TAG, err, "to find base uri value");
         }
 
index da56c92..469ee2c 100755 (executable)
@@ -775,8 +775,10 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
                             discPayload->name = OICStrdup(savedDeviceInfo.deviceName);
                             VERIFY_NON_NULL(discPayload->name, ERROR, OC_STACK_NO_MEMORY);
                         }
-                        discPayload->type = OICStrdup(OC_RSRVD_RESOURCE_TYPE_RES);
+                        discPayload->type = (OCStringLL*)OICCalloc(1, sizeof(OCStringLL));
                         VERIFY_NON_NULL(discPayload->type, ERROR, OC_STACK_NO_MEMORY);
+                        discPayload->type->value = OICStrdup(OC_RSRVD_RESOURCE_TYPE_RES);
+                        VERIFY_NON_NULL(discPayload->type->value, ERROR, OC_STACK_NO_MEMORY);
                         OCResourcePayloadAddStringLL(&discPayload->interface, OC_RSRVD_INTERFACE_LL);
                         OCResourcePayloadAddStringLL(&discPayload->interface, OC_RSRVD_INTERFACE_DEFAULT);
                         VERIFY_NON_NULL(discPayload->interface, ERROR, OC_STACK_NO_MEMORY);