Add logic for extra Information.
[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 a consumer requests subscription.\r
41  * @param[in] consumer        Consumer who subscribes the 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 refering to following\r
62      * if true, the controllability such as subscription request and consumer topic selection\r
63      * is owned by provider user. Otherwise(policy is false), consumer user has the same.\r
64      */\r
65     bool subControllability;\r
66     /* User Information */\r
67     char * userInfo;\r
68     /* Set on/off with SECURED build option */\r
69     bool resourceSecurity;\r
70 \r
71 } NSProviderConfig;\r
72 \r
73 /**\r
74  * Initialize notification service for provider\r
75  * @param[in]  config   Refer to NSProviderConfig\r
76  * @return ::NS_OK if the action is requested succesfully\r
77  */\r
78 NSResult NSStartProvider(NSProviderConfig config);\r
79 \r
80 /**\r
81  * Terminate notification service for provider\r
82  * @return ::NS_OK if the action is requested succesfully\r
83  */\r
84 NSResult NSStopProvider();\r
85 \r
86 /**\r
87  * Request to publish resource using remote relay server\r
88  * @param[in]  server address combined with IP address and port number using delimiter :\r
89  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
90  */\r
91 NSResult NSProviderEnableRemoteService(char * serverAddress);\r
92 \r
93 /**\r
94  * Request to terminate remote service from relay server\r
95  * @param[in]  server address combined with IP address and port number using delimiter :\r
96  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
97  */\r
98 NSResult NSProviderDisableRemoteService(char * serverAddress);\r
99 \r
100 /**\r
101  * Send notification message to all subscribers\r
102  * @param[in]  message  Notification message including id, title, contentText\r
103  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
104  */\r
105 NSResult NSSendMessage(NSMessage * msg);\r
106 \r
107 /**\r
108  * Send acceptance to consumer who subscribes the resource of notification message\r
109  * @param[in]  consumer  Consumer who subscribes the resource\r
110  * @param[in]  accepted  the result of acceptance; Allow or Deny\r
111  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false.\r
112  */\r
113 NSResult NSAcceptSubscription(const char * consumerId, bool accepted);\r
114 \r
115 /**\r
116  * Get consumer list that is stored in the cache of notification service\r
117  * @param[in]  list  Consumer list\r
118  * @param[in]  size  the number of consumers stored in the cache\r
119  * @return ::NS_OK or result code of NSResult\r
120  */\r
121 //TODO will use Function.\r
122 // NSResult NSGetConsumerList(uint8_t *list, uint32_t size);\r
123 \r
124 /**\r
125  * Send synchronizad state of notificaion message to consumers\r
126  * @param[in]  message  Notification message to synchronize the status\r
127  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
128  */\r
129 NSResult NSProviderSendSyncInfo(uint64_t messageId, NSSyncType type);\r
130 \r
131 /**\r
132  * Initialize NSMessage struct, provider service sets generated message id and provider(device) id\r
133  * @return ::NSMessage *\r
134  */\r
135 NSMessage * NSCreateMessage();\r
136 \r
137 /**\r
138  * Add topic to topic list which is located in provider service storage\r
139  * @param[in]  topicName Topic name to add\r
140  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
141  */\r
142 NSResult NSProviderRegisterTopic(const char * topicName);\r
143 \r
144 /**\r
145  * Delete topic from topic list\r
146  * @param[in]  topicName Topic name to delete\r
147  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if wrong parameter is set.\r
148  */\r
149 NSResult NSProviderUnregisterTopic(const char * topicName);\r
150 \r
151 /**\r
152  * Select a topic name for a consumer\r
153  * @param[in]  consumerId  consumer id for which the user on provider selects a topic\r
154  * @param[in]  topicName Topic name to select\r
155  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false\r
156  */\r
157 NSResult NSProviderSetConsumerTopic(const char * consumerId, const char * topicName);\r
158 \r
159 /**\r
160  * Unselect a topic from the topic list for consumer\r
161  * @param[in]  consumerId  consumer id for which the user on provider unselects a topic\r
162  * @param[in]  topicName Topic name to unselect\r
163  * @return ::NS_OK if the action is requested succesfully or NS_FAIL if subContollability is false\r
164  */\r
165 NSResult NSProviderUnsetConsumerTopic(const char * consumerId, const char * topicName);\r
166 \r
167 /**\r
168  * Request topic list with selection state for the consumer\r
169  * @param[in] consumerid  the id of consumer which topic list is subscribed for\r
170  * @return :: Topic list\r
171  */\r
172 NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId);\r
173 \r
174 /**\r
175  * Request topics list already registered by provider user\r
176  * @return :: Topic list\r
177  */\r
178 NSTopicLL * NSProviderGetTopics();\r
179 \r
180 #ifdef __cplusplus\r
181 }\r
182 #endif // __cplusplus\r
183 \r
184 #endif /* _NS_PROVIDER_INTERFACE_H_ */\r
185 \r