Send topic notification
[platform/upstream/iotivity.git] / service / notification / src / provider / NSProviderTopic.c
1 //******************************************************************\r
2 //\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.\r
4 //\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
6 //\r
7 // Licensed under the Apache License, Version 2.0 (the "License");\r
8 // you may not use this file except in compliance with the License.\r
9 // You may obtain a copy of the License at\r
10 //\r
11 //      http://www.apache.org/licenses/LICENSE-2.0\r
12 //\r
13 // Unless required by applicable law or agreed to in writing, software\r
14 // distributed under the License is distributed on an "AS IS" BASIS,\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16 // See the License for the specific language governing permissions and\r
17 // limitations under the License.\r
18 //\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
20 \r
21 #include "NSProviderTopic.h"\r
22 \r
23 NSTopicList * NSGetTopics(char *consumerId)\r
24 {\r
25     NS_LOG(DEBUG, "NSGetTopics()");\r
26 \r
27     NSTopicList  * topicList;\r
28 \r
29     if(consumerId == NULL)\r
30     {\r
31         NS_LOG(DEBUG, "All registered topic list");\r
32     }\r
33     else\r
34     {\r
35         NS_LOG_V(DEBUG, "Subscribed topic list for consumerId(%s)", consumerId);\r
36     }\r
37 \r
38     NS_LOG(DEBUG, "NSGetTopics() NS_OK");\r
39     return topicList;\r
40 }\r
41 \r
42 bool NSIsTopicSubscribed(char * consumerId, char * topic)\r
43 {\r
44     //TODO: implement function\r
45     return true;\r
46 }\r
47 \r
48 void * NSTopicSchedule(void * ptr)\r
49 {\r
50     if (ptr == NULL)\r
51     {\r
52         NS_LOG(DEBUG, "Create NSTopicSchedule");\r
53     }\r
54 \r
55     while (NSIsRunning[TOPIC_SCHEDULER])\r
56     {\r
57         sem_wait(&NSSemaphore[TOPIC_SCHEDULER]);\r
58         pthread_mutex_lock(&NSMutex[TOPIC_SCHEDULER]);\r
59 \r
60         if (NSHeadMsg[TOPIC_SCHEDULER] != NULL)\r
61         {\r
62             NSTask *node = NSHeadMsg[TOPIC_SCHEDULER];\r
63             NSHeadMsg[TOPIC_SCHEDULER] = node->nextTask;\r
64 \r
65             switch (node->taskType)\r
66             {\r
67                 case TASK_SEND_TOPICS:\r
68                     NS_LOG(DEBUG, "CASE TASK_SEND_TOPICS : ");\r
69                     break;\r
70                 case TASK_SUBSCRIBE_TOPICS:\r
71                     NS_LOG(DEBUG, "CASE TASK_SUBSCRIBE_TOPICS : ");\r
72                     break;\r
73                 case TASK_REGISTER_TOPICS:\r
74                     NS_LOG(DEBUG, "CASE TASK_REGISTER_TOPICS : ");\r
75                     break;\r
76                 default:\r
77                     break;\r
78             }\r
79 \r
80             OICFree(node);\r
81         }\r
82 \r
83         pthread_mutex_unlock(&NSMutex[TOPIC_SCHEDULER]);\r
84     }\r
85 \r
86     NS_LOG(DEBUG, "Destroy NSTopicSchedule");\r
87     return NULL;\r
88 }\r