NSTopics Sturct name change into NSTopicLL
authorjaesick.shin <jaesick.shin@samsung.com>
Thu, 18 Aug 2016 02:40:46 +0000 (11:40 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 18 Aug 2016 10:46:38 +0000 (10:46 +0000)
This patch included,
1. remove comment out for related provider in SConscript.
2. change NSTopics Sturct to NSTopicLL.
3. bug fixes for related topic logic.

Change-Id: I848b7cf2f85f4b23b8cbd51485bc6a01e4e04b4f
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10571
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/notification/SConscript
service/notification/examples/linux/notificationprovider.c
service/notification/src/provider/NSProviderInterface.c
service/notification/src/provider/NSProviderMemoryCache.c
service/notification/src/provider/NSProviderMemoryCache.h
service/notification/src/provider/NSProviderTopic.c

index 7b3b447..2257be0 100755 (executable)
@@ -88,24 +88,24 @@ notification_provider_src = [
 notification_consumer_src = [
        env.Glob('src/consumer/*.c'), env.Glob('src/common/*.c')]
 
-#providersdk = notification_env.SharedLibrary('notification_provider', notification_provider_src)
-#notification_env.InstallTarget(providersdk, 'libnotification_provider')
-#notification_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
+providersdk = notification_env.SharedLibrary('notification_provider', notification_provider_src)
+notification_env.InstallTarget(providersdk, 'libnotification_provider')
+notification_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
 
 consumersdk = notification_env.SharedLibrary('notification_consumer', notification_consumer_src)
 notification_env.InstallTarget(consumersdk, 'libnotification_consumer')
 notification_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer')
 
-#providersdk = notification_env.StaticLibrary('notification_provider', notification_provider_src)
-#notification_env.InstallTarget(providersdk, 'libnotification_provider')
-#notification_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
+providersdk = notification_env.StaticLibrary('notification_provider', notification_provider_src)
+notification_env.InstallTarget(providersdk, 'libnotification_provider')
+notification_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
 
 consumersdk = notification_env.StaticLibrary('notification_consumer', notification_consumer_src)
 notification_env.InstallTarget(consumersdk, 'libnotification_consumer')
 notification_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer')
 
-#notification_env.UserInstallTargetHeader('include/NSProviderInterface.h',\
-#      'service/notification', 'NSProviderInterface.h')
+notification_env.UserInstallTargetHeader('include/NSProviderInterface.h',\
+       'service/notification', 'NSProviderInterface.h')
 notification_env.UserInstallTargetHeader('include/NSConsumerInterface.h',\
        'service/notification', 'NSConsumerInterface.h')
 
@@ -114,7 +114,7 @@ notification_env.UserInstallTargetHeader('include/NSConsumerInterface.h',\
 # SConscript('unittest/SConscript')
 
 # Go to build sample apps
-#SConscript('examples/SConscript')
+SConscript('examples/SConscript')
 
 # Go to build jni
 #if target_os == 'android':
index 00487ce..e300564 100644 (file)
@@ -36,7 +36,7 @@
 // Input the following values to publish resource to cloud\r
 char REMOTE_SERVER_ADDRESS[50];\r
 char REMOTE_SERVER_SESSION[50];\r
-char mainConsumer[37] = '\0';\r
+char mainConsumer[37] = {'\0',};\r
 \r
 extern char *strdup(const char *s);\r
 \r
@@ -119,7 +119,7 @@ FILE* server_fopen(const char *path, const char *mode)
     return fopen("oic_ns_provider_db.dat", mode);\r
 }\r
 \r
-void printTopics(NSTopics * topics)\r
+void printTopics(NSTopicLL * topics)\r
 {\r
     if(!topics)\r
     {\r
@@ -127,7 +127,7 @@ void printTopics(NSTopics * topics)
         return;\r
     }\r
 \r
-    NSTopics * iter = topics;\r
+    NSTopicLL * iter = topics;\r
 \r
     while(iter)\r
     {\r
@@ -136,7 +136,7 @@ void printTopics(NSTopics * topics)
     }\r
 }\r
 \r
-void removeTopics(NSTopics * topics)\r
+void removeTopics(NSTopicLL * topics)\r
 {\r
     if(!topics)\r
     {\r
@@ -144,11 +144,11 @@ void removeTopics(NSTopics * topics)
         return;\r
     }\r
 \r
-    NSTopics * iter = topics;\r
+    NSTopicLL * iter = topics;\r
 \r
     while(iter)\r
     {\r
-        NSTopics * del = iter;\r
+        NSTopicLL * del = iter;\r
         if(del->topicName)\r
         {\r
             OICFree(del->topicName);\r
@@ -278,29 +278,33 @@ int main()
 \r
             case 7:\r
                 printf("NSProviderSelectTopic\n");\r
-                NSProviderSelectTopic("OCF_TOPIC1");\r
-                NSProviderSelectTopic("OCF_TOPIC2");\r
-                NSProviderSelectTopic("OCF_TOPIC3");\r
-                NSProviderSelectTopic("OCF_TOPIC4");\r
+                NSProviderSelectTopic(mainConsumer, "OCF_TOPIC1");\r
+                NSProviderSelectTopic(mainConsumer, "OCF_TOPIC2");\r
+                NSProviderSelectTopic(mainConsumer, "OCF_TOPIC3");\r
+                NSProviderSelectTopic(mainConsumer, "OCF_TOPIC4");\r
                 break;\r
 \r
             case 8:\r
                 printf("NSProviderUnSelectTopic\n");\r
-                NSProviderUnSelectTopic("OCF_TOPIC1");\r
+                NSProviderUnselectTopic(mainConsumer, "OCF_TOPIC1");\r
                 break;\r
 \r
             case 9:\r
                 printf("NSProviderGetConsumerTopics\n");\r
-                NSTopics * topics = NSProviderGetConsumerTopics(mainConsumer);\r
-                printTopics(topics);\r
-                removeTopics(topics);\r
+                {\r
+                    NSTopicLL * topics = NSProviderGetConsumerTopics(mainConsumer);\r
+                    printTopics(topics);\r
+                    removeTopics(topics);\r
+                }\r
                 break;\r
 \r
             case 10:\r
                 printf("NSProviderGetConsumerTopics\n");\r
-                NSTopics * topics = NSProviderGetTopics();\r
-                printTopics(topics);\r
-                removeTopics(topics);\r
+                {\r
+                    NSTopicLL * topics = NSProviderGetTopics();\r
+                    printTopics(topics);\r
+                    removeTopics(topics);\r
+                }\r
                 break;\r
 \r
             case 11:\r
index fe47040..e969238 100644 (file)
@@ -240,7 +240,7 @@ NSMessage * NSCreateMessage()
     return msg;\r
 }\r
 \r
-NSTopics * NSProviderGetConsumerTopics(char *consumerId)\r
+NSTopicLL * NSProviderGetConsumerTopics(char *consumerId)\r
 {\r
     NS_LOG(DEBUG, "NSProviderGetConsumerTopics - IN");\r
     pthread_mutex_lock(&nsInitMutex);\r
@@ -252,18 +252,18 @@ NSTopics * NSProviderGetConsumerTopics(char *consumerId)
         return NS_FAIL;\r
     }\r
 \r
-    NSTopics * topics = NSProviderGetConsumerTopicsCacheData(consumerTopicList, consumerId);\r
+    NSTopicLL * topics = NSProviderGetConsumerTopicsCacheData(consumerTopicList, consumerId);\r
 \r
     pthread_mutex_unlock(&nsInitMutex);\r
     return topics;\r
 }\r
 \r
-NSTopics * NSProviderGetTopics()\r
+NSTopicLL * NSProviderGetTopics()\r
 {\r
     NS_LOG(DEBUG, "NSProviderGetTopics - IN");\r
     pthread_mutex_lock(&nsInitMutex);\r
 \r
-    NSTopics * topics = NSProviderGetTopicsCacheData(registeredTopicList);\r
+    NSTopicLL * topics = NSProviderGetTopicsCacheData(registeredTopicList);\r
 \r
     pthread_mutex_unlock(&nsInitMutex);\r
     NS_LOG(DEBUG, "NSProviderGetTopics - OUT");\r
index 0771ec4..2f1df89 100644 (file)
@@ -505,7 +505,7 @@ NSResult NSStorageDelete(NSCacheList * list, const char * delId)
     return NS_FAIL;\r
 }\r
 \r
-NSTopics * NSProviderGetTopicsCacheData(NSCacheList * regTopicList)\r
+NSTopicLL * NSProviderGetTopicsCacheData(NSCacheList * regTopicList)\r
 {\r
     NS_LOG(DEBUG, "NSProviderGetTopicsCache - IN");\r
     pthread_mutex_lock(&NSCacheMutex);\r
@@ -518,15 +518,15 @@ NSTopics * NSProviderGetTopicsCacheData(NSCacheList * regTopicList)
         return NULL;\r
     }\r
 \r
-    NSTopics * iterTopic = NULL;\r
-    NSTopics * newTopic = NULL;\r
-    NSTopics * topics = NULL;\r
+    NSTopicLL * iterTopic = NULL;\r
+    NSTopicLL * newTopic = NULL;\r
+    NSTopicLL * topics = NULL;\r
 \r
     while (iter)\r
     {\r
         NSCacheTopicData * curr = (NSCacheTopicData *) iter->data;\r
 \r
-        newTopic = (NSTopics *) OICMalloc(sizeof(NSTopics));\r
+        newTopic = (NSTopicLL *) OICMalloc(sizeof(NSTopicLL));\r
         newTopic->state = curr->state;\r
         newTopic->next = NULL;\r
         newTopic->topicName = OICStrdup(curr->topicName);\r
@@ -550,12 +550,12 @@ NSTopics * NSProviderGetTopicsCacheData(NSCacheList * regTopicList)
     return topics;\r
 }\r
 \r
-NSTopics * NSProviderGetConsumerTopicsCacheData(NSCacheList * conTopicList, char *consumerId)\r
+NSTopicLL * NSProviderGetConsumerTopicsCacheData(NSCacheList * conTopicList, char *consumerId)\r
 {\r
     NS_LOG(DEBUG, "NSProviderGetConsumerTopics - IN");\r
 \r
     pthread_mutex_lock(&NSCacheMutex);\r
-    NSTopics * topics = NSProviderGetTopics();\r
+    NSTopicLL * topics = NSProviderGetTopics();\r
 \r
     if(!topics)\r
     {\r
@@ -572,7 +572,7 @@ NSTopics * NSProviderGetConsumerTopicsCacheData(NSCacheList * conTopicList, char
 \r
         if(curr && strcmp(curr->id, consumerId) == 0)\r
         {\r
-            NSTopics * topicIter = topics;\r
+            NSTopicLL * topicIter = topics;\r
             while(topicIter)\r
             {\r
                 if(strcmp(topicIter->topicName, curr->topicName) == 0)\r
index f305160..a513fb4 100644 (file)
@@ -42,9 +42,9 @@ NSResult NSCacheUpdateSubScriptionState(NSCacheList *, char *, bool);
 \r
 NSResult NSProviderDeleteSubDataFromObId(NSCacheList * list, OCObservationId id);\r
 \r
-NSTopics * NSProviderGetTopicsCacheData(NSCacheList * regTopicList);\r
+NSTopicLL * NSProviderGetTopicsCacheData(NSCacheList * regTopicList);\r
 \r
-NSTopics * NSProviderGetConsumerTopicsCacheData(NSCacheList * conTopicList, char *consumerId);\r
+NSTopicLL * NSProviderGetConsumerTopicsCacheData(NSCacheList * conTopicList, char *consumerId);\r
 \r
 size_t NSProviderGetListSize(NSCacheElement * firstElement);\r
 \r
index ddae169..e54a97b 100644 (file)
@@ -195,7 +195,7 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
     NS_LOG(DEBUG, "NSSendTopicList - IN");\r
 \r
     char * id = NSGetValueFromQuery(OICStrdup(entityHandlerRequest->query), NS_QUERY_CONSUMER_ID);\r
-    NSTopics * topics = NULL;\r
+    NSTopicLL * topics = NULL;\r
     NSCacheElement * currList = NULL;\r
 \r
     if(!id)\r
@@ -241,7 +241,7 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
     size_t dimensions[3] = {dimensionSize, 0, 0};\r
     for (int i = 0; i < (int)dimensionSize; i++)\r
     {\r
-        NSTopics * topic = (NSTopics *) iter->data;\r
+        NSTopicLL * topic = (NSTopicLL *) iter->data;\r
 \r
         payloadTopicArray[i] = OCRepPayloadCreate();\r
         OCRepPayloadSetPropString(payloadTopicArray[i], NS_ATTRIBUTE_TOPIC_NAME, topic->topicName);\r
@@ -315,11 +315,11 @@ NSResult NSPostConsumerTopics(OCEntityHandlerRequest * entityHandlerRequest)
             NSCacheTopicSubData * topicSubData =\r
             (NSCacheTopicSubData *) OICMalloc(sizeof(NSCacheTopicSubData));\r
 \r
-            OICStrcpy(topicSubData->id, consumerId, NS_UUID_STRING_SIZE);\r
+            OICStrcpy(topicSubData->id, NS_UUID_STRING_SIZE, consumerId);\r
             topicSubData->topicName = OICStrdup(topicName);\r
 \r
             NSCacheElement * newObj = (NSCacheElement *) OICMalloc(sizeof(NSCacheElement));\r
-            newObj->data = topicSubData;\r
+            newObj->data = (NSCacheData *) topicSubData;\r
             newObj->next = NULL;\r
             NSStorageWrite(consumerTopicList, newObj);\r
         }\r