Fix Consumer's bug & support to non topic scenario 69/10669/2
authorYounghyunJoo <yh_.joo@samsung.com>
Fri, 19 Aug 2016 08:50:47 +0000 (17:50 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 19 Aug 2016 15:17:16 +0000 (15:17 +0000)
Change-Id: Iaf704defc826147d85762095ebb0981398e77cac
Signed-off-by: YounghyunJoo <yh_.joo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10669
Reviewed-by: Chihyun Cho <ch79.cho@samsung.com>
Reviewed-by: jaesick shin <jaesick.shin@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
service/notification/examples/linux/notificationconsumer.c
service/notification/src/consumer/NSConsumerCommon.c
service/notification/src/consumer/NSConsumerCommunication.c
service/notification/src/consumer/NSConsumerDiscovery.c

index 6a64ce3..f715eac 100644 (file)
@@ -105,7 +105,7 @@ void onNotificationPosted(NSMessage * notification)
     printf("title : %s\n", notification->title);
     printf("content : %s\n", notification->contentText);
     printf("source : %s\n", notification->sourceName);
-    if (notification->topic)
+    if (notification->topic && strlen(notification->topic) > 0)
     {
         printf("topic : %s\n", notification->topic);
     }
index 93ced34..3b71550 100644 (file)
@@ -1,4 +1,3 @@
-
 //******************************************************************
 //
 // Copyright 2016 Samsung Electronics All Rights Reserved.
@@ -134,10 +133,7 @@ void NSDiscoveredProvider(NSProvider * provider)
 {
     NS_VERIFY_NOT_NULL_V(provider);
 
-    NSProvider * retProvider = (NSProvider *)NSCopyProvider_internal((NSProvider_internal *)provider);
-    NS_VERIFY_NOT_NULL_V(retProvider);
-
-    NSConsumerThread * thread = NSThreadInit(NSDiscoveredProviderFunc, (void *) retProvider);
+    NSConsumerThread * thread = NSThreadInit(NSDiscoveredProviderFunc, (void *) provider);
     NS_VERIFY_NOT_NULL_V(thread);
 }
 
@@ -249,6 +245,11 @@ NSMessage * NSCopyMessage(NSMessage * msg)
     newMsg->sourceName = OICStrdup(msg->sourceName);
     newMsg->dateTime = OICStrdup(msg->dateTime);
     newMsg->type = msg->type;
+    newMsg->topic = NULL;
+    if (msg->topic && strlen(msg->topic) > 0)
+    {
+        newMsg->topic = OICStrdup(msg->topic);
+    }
 
     // TODO change to copy function.
     newMsg->mediaContents = msg->mediaContents;
@@ -264,6 +265,7 @@ void NSRemoveMessage(NSMessage * msg)
     NSOICFree(msg->contentText);
     NSOICFree(msg->sourceName);
     NSOICFree(msg->dateTime);
+    NSOICFree(msg->topic);
 
     // TODO change to remove function.
     NSOICFree(msg->mediaContents);
index a21741b..ef63b4b 100644 (file)
@@ -557,7 +557,7 @@ NSTopicLL * NSGetTopicLL(OCClientResponse * clientResponse)
     NS_VERIFY_NOT_NULL(payloadValue, NULL);
 
     size_t dimensionSize = calcDimTotal(payloadValue->arr.dimensions);
-    NS_LOG_V(DEBUG, "DimensionSize: %d", dimensionSize);
+    NS_LOG_V(DEBUG, "DimensionSize: %d", (int)dimensionSize);
 
     if (dimensionSize == 0 || payloadValue->type == OCREP_PROP_NULL ||
             payloadValue->arr.objArray == NULL)
@@ -589,7 +589,7 @@ NSTopicLL * NSGetTopicLL(OCClientResponse * clientResponse)
         NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(getResult == true ? (void *) 1 : NULL,
                 NULL, NSRemoveTopicLL(topicLL));
         NS_LOG_V(DEBUG, "topic name: %s", topicName);
-        NS_LOG_V(DEBUG, "topic selection: %d", state);
+        NS_LOG_V(DEBUG, "topic selection: %d", (int)state);
 
         topicNode->topicName = topicName;
         topicNode->state = state;
index 4277591..96ec822 100644 (file)
@@ -222,8 +222,6 @@ NSProvider_internal * NSGetProvider(OCClientResponse * clientResponse)
 
     NS_LOG(DEBUG, "get topic URI");
     getResult = OCRepPayloadGetPropString(payload, NS_ATTRIBUTE_TOPIC, & topicUri);
-    NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(getResult == true ? (void *) 1 : NULL, NULL,
-            NSGetProviderPostClean(providerId, messageUri, syncUri, topicUri, connection));
 
     NS_LOG(DEBUG, "get provider connection information");
     NS_VERIFY_NOT_NULL(clientResponse->addr, NULL);
@@ -239,7 +237,11 @@ NSProvider_internal * NSGetProvider(OCClientResponse * clientResponse)
     NSOICFree(providerId);
     newProvider->messageUri = messageUri;
     newProvider->syncUri = syncUri;
-    newProvider->topicUri = topicUri;
+    newProvider->topicUri = NULL;
+    if (topicUri && strlen(topicUri) > 0)
+    {
+        newProvider->topicUri = topicUri;
+    }
     newProvider->accessPolicy = (NSSelector)accepter;
     newProvider->connection = connection;
     newProvider->topicLL = NULL;