Update C API doxygen
[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  * Invoked when provider receives the subscription request of consumer.\r
41  * @param[in] consumer  Consumer who subscribes the notification message resource\r
42  */\r
43 typedef void (*NSSubscribeRequestCallback)(NSConsumer *);\r
44 \r
45 /**\r
46  * Invoked when synchronization data which has notification message\r
47  * read/deleted event from consumer is received.\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 which checks whether provider is capable of \r
62      * denying the subscription of notification message from consumer\r
63      * and getting controllabliity to set consumer topic list.\r
64      * If true, provider is able to control subscription request and consumer topic list.\r
65      * Otherwise(policy is false), consumer can do the same.\r
66      */\r
67     bool subControllability;\r
68     /* User defined information such as device friendly name */\r
69     char * userInfo;\r
70     /* Set on/off for secure resource channel setting */\r
71     bool resourceSecurity;\r
72 \r
73 } NSProviderConfig;\r
74 \r
75 /**\r
76  * Initialize notification service for provider\r
77  * @param[in]  config   Refer to NSProviderConfig\r
78  * @return ::NS_OK if the action is requested succesfully\r
79  */\r
80 NSResult NSStartProvider(NSProviderConfig config);\r
81 \r
82 /**\r
83  * Terminate notification service for provider\r
84  * @return ::NS_OK if the action is requested succesfully\r
85  */\r
86 NSResult NSStopProvider();\r
87 \r
88 /**\r
89  * Request to publish resource using remote relay server\r
90  * @param[in]  server address combined with IP address and port number using delimiter :\r
91  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
92  */\r
93 NSResult NSProviderEnableRemoteService(char * serverAddress);\r
94 \r
95 /**\r
96  * Request to terminate remote service from relay server\r
97  * @param[in]  server address combined with IP address and port number using delimiter :\r
98  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
99  */\r
100 NSResult NSProviderDisableRemoteService(char * serverAddress);\r
101 \r
102 /**\r
103  * Send notification message to all subscribers\r
104  * @param[in]  message  Notification message including id, title, contentText\r
105  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
106  */\r
107 NSResult NSSendMessage(NSMessage * msg);\r
108 \r
109 /**\r
110  * Send acceptance to consumer who subscribes the resource of notification message\r
111  * This function is valid only when subControllability is set true.\r
112  * @param[in]  consumer  Consumer who subscribes the resource\r
113  * @param[in]  accepted  the result of acceptance; ALLOW or DENY\r
114  * @return ::NS_OK if this function is requested succesfully\r
115  * or NS_FAIL if subContollability is false.\r
116  */\r
117 NSResult NSAcceptSubscription(const char * consumerId, bool accepted);\r
118 \r
119 /**\r
120  * Send synchronizad state of notificaion message to consumers\r
121  * @param[in]  messageiId  ID of notification message\r
122  * @param[in]  type  SyncType of the syncInfo message\r
123  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
124  */\r
125 NSResult NSProviderSendSyncInfo(uint64_t messageId, NSSyncType type);\r
126 \r
127 /**\r
128  * Initialize NSMessage struct.\r
129  * Service sets mandatory fields which message id and provider(device) id are filled with.\r
130  * @return ::NSMessage *\r
131  */\r
132 NSMessage * NSCreateMessage();\r
133 \r
134 /**\r
135  * Add topic to topic list which is located in provider service storage\r
136  * @param[in]  topicName Topic name to add\r
137  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
138  */\r
139 NSResult NSProviderRegisterTopic(const char * topicName);\r
140 \r
141 /**\r
142  * Delete topic from topic list\r
143  * @param[in]  topicName Topic name to delete\r
144  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
145  */\r
146 NSResult NSProviderUnregisterTopic(const char * topicName);\r
147 \r
148 /**\r
149  * Select a topic name for a consumer\r
150  * @param[in]  consumerId  consumer id for which the user on provider selects a topic\r
151  * @param[in]  topicName Topic name to select\r
152  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false\r
153  */\r
154 NSResult NSProviderSetConsumerTopic(const char * consumerId, const char * topicName);\r
155 \r
156 /**\r
157  * Unselect a topic from the topic list for consumer\r
158  * @param[in]  consumerId  consumer id for which the user on provider unselects a topic\r
159  * @param[in]  topicName Topic name to unselect\r
160  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false\r
161  */\r
162 NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topicName);\r
163 \r
164 /**\r
165  * Request topic list with selection state for the consumer\r
166  * @param[in] consumerid  the id of consumer which topic list is subscribed for\r
167  * @return :: Topic list\r
168  */\r
169 NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId);\r
170 \r
171 /**\r
172  * Request topics list already registered by provider user\r
173  * @return :: Topic list\r
174  */\r
175 NSTopicLL * NSProviderGetTopics();\r
176 \r
177 #ifdef __cplusplus\r
178 }\r
179 #endif // __cplusplus\r
180 \r
181 #endif /* _NS_PROVIDER_INTERFACE_H_ */\r
182 \r