Modify Callback function.
[platform/upstream/iotivity.git] / service / notification / include / NSConsumerInterface.h
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /**
22  * @file
23  *
24  * This file provides APIs of Notification Service for Consumer.
25  */
26
27 #ifndef _NS_CONSUMER_INTERFACE_H_
28 #define _NS_CONSUMER_INTERFACE_H_
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif // __cplusplus
34
35 #include "NSCommon.h"
36
37 /**
38  * Invoked when the discovered provider is received
39  * @param[in] provider  Provider who has the notification resource
40  */
41 typedef void (* NSProviderDiscoveredCallback)(NSProvider *);
42
43 /**
44  * Invoked when the provider state is changed
45  * @param[in] provider  Provider which has the notification resource
46  * @param[in] response  Response which has the provider state
47  */
48 typedef void (* NSProviderChangedCallback)(NSProvider *, NSResponse);
49
50 /**
51  * Invoked when the notification message from provider is received
52  * synchronization
53  * @param[in] message  Notification message
54  */
55 typedef void (* NSMessageReceivedCallback)(NSMessage *);
56
57 /**
58  * Invoked when the synchronization data which has notification message
59  * read/delete event from provider/consumer is received
60  * synchronization
61  * @param[in] syncInfo  Synchronization information of the notification message
62  */
63 typedef void (* NSSyncInfoReceivedCallback)(NSSyncInfo *);
64
65 typedef struct
66 {
67     NSProviderDiscoveredCallback discoverCb;
68     NSProviderChangedCallback changedCb;
69     NSMessageReceivedCallback messageCb;
70     NSSyncInfoReceivedCallback syncInfoCb;
71
72 } NSConsumerConfig;
73
74 /**
75  * Initialize notification service for consumer
76  * @param[in]  config  NSConsumerconfig structure of callback functions
77  * @return ::NS_OK or result code of NSResult
78  */
79 NSResult NSStartConsumer(NSConsumerConfig config);
80
81 /**
82  * Terminate notification service for consumer
83  * @return ::NS_OK or result code of NSResult
84  */
85 NSResult NSStopConsumer();
86
87 /**
88  * Request to discover to remote address as parameter.
89  * @param[in]  server address combined with IP address and port number using delimiter :
90  * @return ::NS_OK or result code of NSResult
91  */
92 NSResult NSConsumerEnableRemoteService(char *serverAddress);
93
94 /**
95  * Request discovery manually
96  * @return ::NS_OK or result code of NSResult
97  */
98 NSResult NSRescanProvider();
99
100 /**
101  * Request to subscribe notification message resource of provider
102  * @param[in]  provider  Provider who send the notification message
103  * @return ::NS_OK or result code of NSResult
104  */
105 NSResult NSSubscribe(NSProvider *provider);
106
107 /**
108  * Request to unsubscribe in order not to receive notification message from provider
109  * @param[in]  provider  Provider who send the notification message
110  * @return ::NS_OK or result code of NSResult
111  */
112 NSResult NSUnsubscribe(NSProvider *provider);
113
114 /**
115  * Send sync type to provider in order to synchronize notification status with other consumers
116  * when consumer consumes the notification such as READ, DELETE
117  * @param[in]  providerId  Provider id of the Notification message
118  * @param[in]  messageId  Notification message id to synchronize the status
119  * @param[in]  type  changed notification status from NSSyncType
120  * @return ::NS_OK or result code of NSResult
121  */
122 NSResult NSConsumerSendSyncInfo(
123         const char * providerId, uint64_t messageId, NSSyncType type);
124
125 /**
126  * Request NSProvider that is matched by provider id
127  * @param[in]  providerId  the id of provider that user wants to get
128  * @return NSProvider
129  */
130 NSProvider * NSConsumerGetProvider(const char * providerId);
131
132 /**
133  * Request NSMessage that is matched by message id
134  * @param[in]  messageId  the id of message that user wants to get
135  * @return NSMessage
136  */
137 NSMessage * NSConsumerGetMessage(uint64_t messageId);
138
139 /**
140  * Request NSTopicList that is subscribed from provider
141  * @param[in]  provider  the provider that user wants to get
142  * @return NSResult
143  */
144 NSResult NSConsumerGetInterestTopics(NSProvider * provider);
145
146 /**
147  * Select Topics that is wanted to subscribe from provider
148  * @param[in]  provider  the provider that user wants to set
149  * @return NSResult
150  */
151 NSResult NSConsumerSelectInterestTopics(NSProvider * provider);
152
153 #ifdef __cplusplus
154 }
155 #endif // __cplusplus
156
157 #endif // _NS_CONSUMER_INTERFACE_H_