Add logic for getTopicRequest without consumer Id and Add topic in NSSendMessage...
authorjaesick.shin <jaesick.shin@samsung.com>
Thu, 18 Aug 2016 08:12:22 +0000 (17:12 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 19 Aug 2016 04:51:11 +0000 (04:51 +0000)
1. Add exception logic of getRequest(consumer Id == NULL) for Topic case.
2. Add topic attribute for NSSendMessage Payload.

Change-Id: I7db3c6432d02cd96390b5d71677fb3f20281607d
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10599
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/notification/src/provider/NSProviderNotification.c
service/notification/src/provider/NSProviderTopic.c

index 462a656..51373cf 100644 (file)
@@ -53,6 +53,7 @@ NSResult NSSetMessagePayload(NSMessage *msg, OCRepPayload** msgPayload)
     NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_TITLE, msg->title);
     NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_TEXT, msg->contentText);
     NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_SOURCE, msg->sourceName);
+    NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_TOPIC_NAME, msg->topic);
 
     NS_LOG(DEBUG, "NSSetMessagePayload - OUT");
     return NS_OK;
index b17bbfe..e0193e1 100644 (file)
@@ -211,6 +211,12 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
         currList = consumerTopicList->head;\r
     }\r
 \r
+    if(!currList)\r
+    {\r
+        NS_LOG(DEBUG, "currList is NULL");\r
+        return NS_ERROR;\r
+    }\r
+\r
     // make response for the Get Request\r
     OCEntityHandlerResponse response;\r
     response.numSendVendorSpecificHeaderOptions = 0;\r
@@ -230,6 +236,8 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
     NSCacheElement * iter = currList;\r
     size_t dimensionSize = (size_t)NSProviderGetListSize(iter);\r
 \r
+    NS_LOG_V(DEBUG, "dimensionSize = %d", dimensionSize);\r
+\r
     if(!dimensionSize)\r
     {\r
         return NS_ERROR;\r
@@ -243,6 +251,9 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
     {\r
         NSTopicLL * topic = (NSTopicLL *) iter->data;\r
 \r
+        NS_LOG_V(DEBUG, "topicName = %s", topic->topicName);\r
+        NS_LOG_V(DEBUG, "topicState = %d",(int) topic->state);\r
+\r
         payloadTopicArray[i] = OCRepPayloadCreate();\r
         OCRepPayloadSetPropString(payloadTopicArray[i], NS_ATTRIBUTE_TOPIC_NAME, topic->topicName);\r
         OCRepPayloadSetPropInt(payloadTopicArray[i], NS_ATTRIBUTE_TOPIC_SELECTION,\r
@@ -252,7 +263,10 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
     }\r
 \r
     OCRepPayloadSetUri(payload, NS_COLLECTION_TOPIC_URI);\r
-    OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_CONSUMER_ID, id);\r
+    if(id)\r
+    {\r
+        OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_CONSUMER_ID, id);\r
+    }\r
     OCRepPayloadSetPropObjectArray(payload, NS_ATTRIBUTE_TOPIC_LIST,\r
             (const OCRepPayload**)(payloadTopicArray), dimensions);\r
 \r