1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file provides APIs of Notification Service for Consumer.
27 #ifndef _NS_CONSUMER_INTERFACE_H_
28 #define _NS_CONSUMER_INTERFACE_H_
38 * Invoked when the discovered provider is received
39 * @param[in] provider Provider who has the notification resource
41 typedef void (* NSProviderDiscoveredCallback)(NSProvider *);
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
48 typedef void (* NSProviderChangedCallback)(NSProvider *, NSResponse);
51 * Invoked when the notification message from provider is received
53 * @param[in] message Notification message
55 typedef void (* NSMessageReceivedCallback)(NSMessage *);
58 * Invoked when the synchronization data which has notification message
59 * read/delete event from provider/consumer is received
61 * @param[in] syncInfo Synchronization information of the notification message
63 typedef void (* NSSyncInfoReceivedCallback)(NSSyncInfo *);
67 NSProviderDiscoveredCallback discoverCb;
68 NSProviderChangedCallback changedCb;
69 NSMessageReceivedCallback messageCb;
70 NSSyncInfoReceivedCallback syncInfoCb;
75 * Initialize notification service for consumer
76 * @param[in] config NSConsumerconfig structure of callback functions
77 * @return ::NS_OK or result code of NSResult
79 NSResult NSStartConsumer(NSConsumerConfig config);
82 * Terminate notification service for consumer
83 * @return ::NS_OK or result code of NSResult
85 NSResult NSStopConsumer();
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
92 NSResult NSConsumerEnableRemoteService(char *serverAddress);
95 * Request discovery manually
96 * @return ::NS_OK or result code of NSResult
98 NSResult NSRescanProvider();
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
105 NSResult NSSubscribe(NSProvider *provider);
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
112 NSResult NSUnsubscribe(NSProvider *provider);
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
122 NSResult NSConsumerSendSyncInfo(
123 const char * providerId, uint64_t messageId, NSSyncType type);
126 * Request NSProvider that is matched by provider id
127 * @param[in] providerId the id of provider that user wants to get
130 NSProvider * NSConsumerGetProvider(const char * providerId);
133 * Request NSMessage that is matched by message id
134 * @param[in] messageId the id of message that user wants to get
137 NSMessage * NSConsumerGetMessage(uint64_t messageId);
140 * Request NSTopicList that is subscribed from provider
141 * @param[in] provider the provider that user wants to get
144 NSResult NSConsumerGetInterestTopics(NSProvider * provider);
147 * Select Topics that is wanted to subscribe from provider
148 * @param[in] provider the provider that user wants to set
151 NSResult NSConsumerSelectInterestTopics(NSProvider * provider);
155 #endif // __cplusplus
157 #endif // _NS_CONSUMER_INTERFACE_H_