c028820d024d8cf73a4242d309676ffb4e17b5d1
[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  * Consumer uses this callback function to receive the discovered providers
39  * @param[in] provider        Provider who has the notification resource
40  */
41 typedef void (* NSProviderDiscoveredCallback)(NSProvider *);
42
43 typedef void (* NSSubscriptionAcceptedCallback)(NSProvider *);
44
45 /**
46  * Consumer use this callback function to receive notification message from provider
47  * synchronization
48  * @param[in] provider    Provider who sends notification message
49  * @param[in] message     Notification message
50  */
51 typedef void (* NSMessageReceivedCallback)(NSMessage *);
52
53 /**
54  * Provider and consumer use this callback function to receive the status of the message
55  * synchronization
56  * @param[in] provider    Provider who requests synchronization with the status
57  * @param[in] sync        Synchronization information of the notification message
58  */
59 typedef void (* NSSyncInfoReceivedCallback)(NSSyncInfo *);
60
61 typedef struct
62 {
63     NSProviderDiscoveredCallback discoverCb;
64     NSSubscriptionAcceptedCallback acceptedCb;
65     NSMessageReceivedCallback messageCb;
66     NSSyncInfoReceivedCallback syncInfoCb;
67
68 } NSConsumerConfig;
69
70 /**
71  * Initialize notification service for consumer
72  * @param[in]  providerDiscoveredCallback   Callback function to discover notification providers
73  * @param[in]  notificationReceivedCallback   Callback function to receive notification messages
74  * @param[in]  syncCallback   Callback function to receive synchronization status of notification
75  * @return ::NS_OK or result code of NSResult
76  */
77 NSResult NSStartConsumer(NSConsumerConfig config);
78
79 /**
80  * Terminate notification service for consumer
81  * @return ::NS_OK or result code of NSResult
82  */
83 NSResult NSStopConsumer();
84
85 /**
86  * Request discovery manually
87  * @return ::NS_OK or result code of NSResult
88  */
89 NSResult NSRescanProvider();
90
91 /**
92  * Request to subscribe notification message resource of provider
93  * @param[in]  provider  Provider who send the notification message
94  * @return ::NS_OK or result code of NSResult
95  */
96 NSResult NSSubscribe(NSProvider *provider);
97
98 /**
99  * Request to unsubscribe in order not to receive notification message from provider
100  * @param[in]  provider  Provider who send the notification message
101  * @return ::NS_OK or result code of NSResult
102  */
103 NSResult NSUnsubscribe(NSProvider *provider);
104
105 NSResult NSConsumerSendSyncInfo(
106         const char * providerId, uint64_t messageId, NSSyncType type);
107
108 NSProvider * NSConsumerGetProvider(const char * providerId);
109
110 NSMessage * NSConsumerGetMessage(uint64_t messageId);
111
112 #ifdef __cplusplus
113 }
114 #endif // __cplusplus
115
116 #endif // _NS_CONSUMER_INTERFACE_H_