Add sendMessage for NSProviderSetConsumerTopic and bug fixes for API.
authorjaesick.shin <jaesick.shin@samsung.com>
Fri, 9 Sep 2016 07:27:14 +0000 (16:27 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 12 Sep 2016 01:48:21 +0000 (01:48 +0000)
1. Add sendmessage when call NSProviderSetConsumerTopic function.
2. Add bug fixes for API ('\0' case)

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

index 0a956db..6472452 100644 (file)
@@ -263,7 +263,7 @@ NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId)
     NS_LOG(DEBUG, "NSProviderGetConsumerTopics - IN");
     pthread_mutex_lock(&nsInitMutex);
 
-    if(!consumerId)
+    if(!consumerId || consumerId[0] == '\0')
     {
         NS_LOG(DEBUG, "consumer id should be set");
         pthread_mutex_unlock(&nsInitMutex);
@@ -307,7 +307,7 @@ NSResult NSProviderRegisterTopic(const char * topicName)
     NS_LOG(DEBUG, "NSProviderAddTopics - IN");
     pthread_mutex_lock(&nsInitMutex);
 
-    if(!topicName)
+    if(!topicName || topicName == '\0')
     {
         pthread_mutex_unlock(&nsInitMutex);
         NS_LOG(DEBUG, "topic Name should be set");
@@ -326,7 +326,7 @@ NSResult NSProviderUnregisterTopic(const char * topicName)
     NS_LOG(DEBUG, "NSProviderDeleteTopics - IN");
     pthread_mutex_lock(&nsInitMutex);
 
-    if(!topicName)
+    if(!topicName || topicName[0] == '\0')
     {
         pthread_mutex_unlock(&nsInitMutex);
         NS_LOG(DEBUG, "topic Name should be set");
@@ -345,7 +345,7 @@ NSResult NSProviderSetConsumerTopic(const char * consumerId, const char * topicN
     NS_LOG(DEBUG, "NSProviderSelectTopics - IN");
     pthread_mutex_lock(&nsInitMutex);
 
-    if(!consumerId || !topicName || !NSGetPolicy())
+    if(!consumerId || consumerId[0] == '\0' || !topicName || topicName[0] == '\0' || !NSGetPolicy())
     {
         NS_LOG(DEBUG, "consumer id should be set for topic subscription or "
                 "Configuration must set to true.");
@@ -371,7 +371,7 @@ NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topi
     NS_LOG(DEBUG, "NSProviderUnselectTopics - IN");
     pthread_mutex_lock(&nsInitMutex);
 
-    if(!consumerId || !topicName || !NSGetPolicy())
+    if(!consumerId || consumerId[0] == '\0' || !topicName || topicName[0] == '\0' || !NSGetPolicy())
     {
         NS_LOG(DEBUG, "consumer id should be set for topic subscription or "
                 "Configuration must set to true.");
index 93eb541..6ba5094 100644 (file)
@@ -364,6 +364,7 @@ NSResult NSPostConsumerTopics(OCEntityHandlerRequest * entityHandlerRequest)
             NSCacheElement * newObj = (NSCacheElement *) OICMalloc(sizeof(NSCacheElement));\r
             newObj->data = (NSCacheData *) topicSubData;\r
             newObj->next = NULL;\r
+\r
             NSStorageWrite(consumerTopicList, newObj);\r
         }\r
     }\r
@@ -403,6 +404,8 @@ void * NSTopicSchedule(void * ptr)
                     newObj->data = node->taskData;\r
                     newObj->next = NULL;\r
                     NSStorageWrite(consumerTopicList, newObj);\r
+                    NSCacheTopicSubData * topicSubData = (NSCacheTopicSubData *) node->taskData;\r
+                    NSSendTopicUpdationToConsumer(topicSubData->id);\r
                     break;\r
                 case TASK_UNSUBSCRIBE_TOPIC:\r
                     NS_LOG(DEBUG, "CASE TASK_SUBSCRIBE_TOPIC : ");\r