Merge branch 'notification-service'
[platform/upstream/iotivity.git] / service / notification / include / NSProviderInterface.h
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 /**\r
22  * @file\r
23  *\r
24  * This file provides APIs of Notification Service for Provider.\r
25  */\r
26 \r
27 #ifndef _NS_PROVIDER_INTERFACE_H_\r
28 #define _NS_PROVIDER_INTERFACE_H_\r
29 \r
30 #ifdef __cplusplus\r
31 extern "C"\r
32 {\r
33 #endif // __cplusplus\r
34 \r
35 #include "NSCommon.h"\r
36 #include <stdbool.h>\r
37 #include <stdint.h>\r
38 \r
39 /**\r
40  * Provider uses this callback function to receive subscription request of consumer\r
41  * @param[in] consumer        Consumer who subscribes the resource\r
42  */\r
43 typedef void (*NSSubscribeRequestCallback)(NSConsumer *);\r
44 \r
45 /**\r
46  * Provider use this callback function to receive the status of the message\r
47  * synchronization\r
48  * @param[in] sync        Synchronization information of the notification message\r
49  */\r
50 typedef void (*NSProviderSyncInfoCallback)(NSSyncInfo *);\r
51 \r
52 /**\r
53  *  Set provider service with the following configuration\r
54  */\r
55 typedef struct\r
56 {\r
57     /* Invoked when the subscription request from consumer is received */\r
58     NSSubscribeRequestCallback subRequestCallback;\r
59     /* Invoked when the synchronization data, read and deleted, is sent by consumer is received */\r
60     NSProviderSyncInfoCallback syncInfoCallback;\r
61     /* Set the policy for notification servcie refering to following\r
62      * if policy is true, provider decides to allow or deny for all the subscribing consumers.\r
63      * Otherwise(policy is false) consumer decides to request subscription to discovered providers.\r
64      */\r
65     bool subControllability;\r
66     /* User Information */\r
67     char * userInfo;\r
68 \r
69 } NSProviderConfig;\r
70 \r
71 /**\r
72  * Initialize notification service for provider service\r
73  * @param[in]  config   Refer to NSProviderConfig\r
74  * @return ::NS_OK or result code of NSResult\r
75  */\r
76 NSResult NSStartProvider(NSProviderConfig config);\r
77 \r
78 /**\r
79  * Terminate notification service for provider\r
80  * @return ::NS_OK or result code of NSResult\r
81  */\r
82 NSResult NSStopProvider();\r
83 \r
84 /**\r
85  * Request to publish resource to cloud server\r
86  * @param[in]  server address combined with IP address and port number using delimiter :\r
87  * @return ::NS_OK or result code of NSResult\r
88  */\r
89 NSResult NSProviderEnableRemoteService(char * serverAddress);\r
90 \r
91 /**\r
92  * Request to cancel remote service using cloud server\r
93  * @param[in]  server address combined with IP address and port number using delimiter :\r
94  * @return ::NS_OK or result code of NSResult\r
95  */\r
96 NSResult NSProviderDisableRemoteService(char * serverAddress);\r
97 \r
98 /**\r
99  * Send notification message to all subscribers\r
100  * @param[in]  message  Notification message including id, title, contentText\r
101  * @return ::NS_OK or result code of NSResult\r
102  */\r
103 NSResult NSSendMessage(NSMessage * msg);\r
104 \r
105 /**\r
106  * Send acceptance to consumer who subscribes the resource of notification message\r
107  * @param[in]  consumer  Consumer who subscribes the resource\r
108  * @param[in]  accepted  the result of acceptance; Allow or Deny\r
109  * @return ::NS_OK or result code of NSResult\r
110  */\r
111 NSResult NSAcceptSubscription(const char * consumerId, bool accepted);\r
112 \r
113 /**\r
114  * Get consumer list that is stored in the cache of notification service\r
115  * @param[in]  list  Consumer list\r
116  * @param[in]  size  the number of consumers stored in the cache\r
117  * @return ::NS_OK or result code of NSResult\r
118  */\r
119 //TODO will use Function.\r
120 // NSResult NSGetConsumerList(uint8_t *list, uint32_t size);\r
121 \r
122 /**\r
123  * Send read-check to provider in order to synchronize notification status with other consumers\r
124  * @param[in]  message  Notification message to synchronize the status\r
125  * @return ::NS_OK or result code of NSResult\r
126  */\r
127 NSResult NSProviderSendSyncInfo(uint64_t messageId, NSSyncType type);\r
128 \r
129 /**\r
130  * Initialize NSMessage struct, our service set message id and provider(device) id\r
131  * @return ::NSMessage *\r
132  */\r
133 NSMessage * NSCreateMessage();\r
134 \r
135 /**\r
136  * Add topic to topic list which is located in provider service storage\r
137  * @param[in]  topicName Topic name to add\r
138  * @return ::NS_OK or result code of NSResult\r
139  */\r
140 NSResult NSProviderRegisterTopic(const char * topicName);\r
141 \r
142 /**\r
143  * Delete topic from topic list\r
144  * @param[in]  topicName Topic name to delete\r
145  * @return ::NS_OK or result code of NSResult\r
146  */\r
147 NSResult NSProviderUnregisterTopic(const char * topicName);\r
148 \r
149 /**\r
150  * Select a topic name for a consumer\r
151  * @param[in]  consumerId  consumer id for which the user on provider selects a topic\r
152  * @param[in]  topicName Topic name to select\r
153  * @return ::NS_OK or result code of NSResult\r
154  */\r
155 NSResult NSProviderSetConsumerTopic(const char * consumerId, const char * topicName);\r
156 \r
157 /**\r
158  * Unselect a topic from the topic list for consumer\r
159  * @param[in]  consumerId  consumer id for which the user on provider unselects a topic\r
160  * @param[in]  topicName Topic name to unselect\r
161  * @return ::NS_OK or result code of NSResult\r
162  */\r
163 NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topicName);\r
164 \r
165 /**\r
166  * Request topic list with selection state for the consumer\r
167  * @param[in] consumerid  the id of consumer which topic list is subscribed for\r
168  * @return :: Topic list\r
169  */\r
170 NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId);\r
171 \r
172 /**\r
173  * Request topics list already registered by provider user\r
174  * @return :: Topic list\r
175  */\r
176 NSTopicLL * NSProviderGetTopics();\r
177 \r
178 #ifdef __cplusplus\r
179 }\r
180 #endif // __cplusplus\r
181 \r
182 #endif /* _NS_PROVIDER_INTERFACE_H_ */\r
183 \r