Create topic module running with scheduler
authorch79.cho <ch79.cho@samsung.com>
Mon, 8 Aug 2016 12:41:12 +0000 (21:41 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 9 Aug 2016 10:22:16 +0000 (10:22 +0000)
Add topic feature module that works with its scheduler.
Three tasks for topic notification are created.

Change-Id: Ie68595fe0d9a1c63a802aef64e94f61482b19286
Signed-off-by: ch79.cho <ch79.cho@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10153
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/notification/src/provider/NSProviderInterface.c
service/notification/src/provider/NSProviderTopic.c [new file with mode: 0644]

index 3b8ca0e..cc783fc 100644 (file)
@@ -249,7 +249,7 @@ NSTopicList * NSProviderGetTopics(char *consumerId)
 \r
     NSTopicList * topicList = NSInitializeTopicList();\r
     OICStrcpy(topicList->consumerId, UUID_STRING_SIZE, consumerId);\r
-    // OICStrcpy(topicList->topics, sizeof(NSTopic), NSGetTopics(consumerId));\r
+    OICStrcpy(topicList->topics, sizeof(NSTopic), NSGetTopics(consumerId));\r
 \r
     pthread_mutex_unlock(&nsInitMutex);\r
     NS_LOG(DEBUG, "NSProviderGetTopics - OUT");\r
diff --git a/service/notification/src/provider/NSProviderTopic.c b/service/notification/src/provider/NSProviderTopic.c
new file mode 100644 (file)
index 0000000..41aebb5
--- /dev/null
@@ -0,0 +1,82 @@
+//******************************************************************\r
+//\r
+// Copyright 2016 Samsung Electronics All Rights Reserved.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//      http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+\r
+#include "NSProviderTopic.h"\r
+\r
+NSTopicList * NSGetTopics(char *consumerId)\r
+{\r
+    NS_LOG(DEBUG, "NSGetTopics()");\r
+\r
+    NSTopicList  * topicList;\r
+\r
+    if(consumerId == NULL)\r
+    {\r
+        NS_LOG(DEBUG, "All registered topic list");\r
+    }\r
+    else\r
+    {\r
+        NS_LOG_V(DEBUG, "Subscribed topic list for consumerId(%s)", consumerId);\r
+    }\r
+\r
+    NS_LOG(DEBUG, "NSGetTopics() NS_OK");\r
+    return topicList;\r
+}\r
+\r
+void * NSTopicSchedule(void * ptr)\r
+{\r
+    if (ptr == NULL)\r
+    {\r
+        NS_LOG(DEBUG, "Create NSTopicSchedule");\r
+    }\r
+\r
+    while (NSIsRunning[TOPIC_SCHEDULER])\r
+    {\r
+        sem_wait(&NSSemaphore[TOPIC_SCHEDULER]);\r
+        pthread_mutex_lock(&NSMutex[TOPIC_SCHEDULER]);\r
+\r
+        if (NSHeadMsg[TOPIC_SCHEDULER] != NULL)\r
+        {\r
+            NSTask *node = NSHeadMsg[TOPIC_SCHEDULER];\r
+            NSHeadMsg[TOPIC_SCHEDULER] = node->nextTask;\r
+\r
+            switch (node->taskType)\r
+            {\r
+                case TASK_SEND_TOPICS:\r
+                    NS_LOG(DEBUG, "CASE TASK_SEND_TOPICS : ");\r
+                    break;\r
+                case TASK_SUBSCRIBE_TOPICS:\r
+                    NS_LOG(DEBUG, "CASE TASK_SUBSCRIBE_TOPICS : ");\r
+                    break;\r
+                case TASK_REGISTER_TOPICS:\r
+                    NS_LOG(DEBUG, "CASE TASK_REGISTER_TOPICS : ");\r
+                    break;\r
+                default:\r
+                    break;\r
+            }\r
+\r
+            OICFree(node);\r
+        }\r
+\r
+        pthread_mutex_unlock(&NSMutex[TOPIC_SCHEDULER]);\r
+    }\r
+\r
+    NS_LOG(DEBUG, "Destroy NSTopicSchedule");\r
+    return NULL;\r
+}\r