1 //******************************************************************
\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\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
11 // http://www.apache.org/licenses/LICENSE-2.0
\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
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
24 * This file contains Notification service Provider representation.
\r
27 #ifndef _NS_PROVIDER_H_
\r
28 #define _NS_PROVIDER_H_
\r
32 #include "NSSyncInfo.h"
\r
33 #include "NSMessage.h"
\r
34 #include "NSUtils.h"
\r
35 #include "NSTopicsList.h"
\r
43 * @brief This class provides a set of Notification service Provider representation APIs.
\r
50 * Invoked when the provider state is changed
\r
51 * @param[in] providerState NSProviderState of the notification resource
\r
53 typedef void (* ProviderStateCallback)(NSProviderState);
\r
56 * Consumer use this callback function to receive notification message from provider
\r
58 * @param[in] message Notification message
\r
60 typedef void (*MessageReceivedCallback)(NSMessage *);
\r
63 * Provider and consumer use this callback function to receive the status of the message
\r
65 * @param[in] sync Synchronization information of the notification message
\r
67 typedef void (*SyncInfoReceivedCallback)(NSSyncInfo *);
\r
70 * Constructor of NSProvider.
\r
72 NSProvider(): m_topicList(new NSTopicsList()), m_state(NSProviderState::DENY),
\r
73 m_subscribedState(NSProviderSubscribedState::DENY),
\r
74 m_stateCb(NULL), m_messageCb(NULL), m_syncInfoCb(NULL)
\r
79 * Constructor of NSProvider.
\r
81 * @param providerId - providerId of the Notification.
\r
83 NSProvider(const std::string &providerId) : m_providerId(providerId),
\r
84 m_topicList(new NSTopicsList()), m_state(NSProviderState::DENY),
\r
85 m_subscribedState(NSProviderSubscribedState::DENY),
\r
86 m_stateCb(NULL), m_messageCb(NULL), m_syncInfoCb(NULL)
\r
91 * Constructor of NSProvider.
\r
93 * @param providerId - providerId of the Notification.
\r
94 * @param topicList - NSTopicsList of interested Topics.
\r
96 NSProvider(const std::string &providerId, NSTopicsList *topicList) : m_providerId(
\r
97 providerId), m_topicList(topicList), m_state(NSProviderState::DENY),
\r
98 m_subscribedState(NSProviderSubscribedState::DENY),
\r
99 m_stateCb(NULL), m_messageCb(NULL), m_syncInfoCb(NULL)
\r
104 * Constructor of NSProvider.
\r
106 * @param provider - of type NSProvider.
\r
108 NSProvider(::NSProvider *provider);
\r
111 * Copy Constructor of NSProvider.
\r
113 * @param provider - NSProvider to initialize.
\r
115 NSProvider(const NSProvider &provider);
\r
118 * Copy assignment operator of NSProvider.
\r
120 * @param provider - NSProvider to initialize.
\r
121 * @return NSProvider object reference
\r
123 NSProvider &operator=(const NSProvider &provider);
\r
126 * Destructor of NSProvider.
\r
131 * This method is for getting ProviderId from the Notification service provider.
\r
133 * @return ProviderId as string.
\r
135 std::string getProviderId() const;
\r
138 * This method is for getting NSTopic List from the Notification service provider.
\r
140 * @return NSTopicsList as pointer.
\r
142 NSTopicsList *getTopicList() const;
\r
145 * Update Topic list that is wanted to be subscribed from provider
\r
147 * @param topicList - NSTopicsList of interested Topics.
\r
150 NSResult updateTopicList(NSTopicsList *topicList);
\r
153 * This method is for getting ProviderState from the Notification service provider.
\r
155 * @return ProviderState as NSProviderState.
\r
157 NSProviderState getProviderState() const;
\r
160 * This method is for getting SubscribedState from the Notification service provider.
\r
162 * @return subscribedState as NSProviderSubscribedState.
\r
164 NSProviderSubscribedState getProviderSubscribedState() const;
\r
167 * This method is for requesting subscription of Notification service.
\r
173 * This method is for requesting subscription status from Provider of Notification service.
\r
176 bool isSubscribed();
\r
179 * This method is for Sending SyncInfo of Notification service.
\r
181 * @param messageId - id of type message.
\r
182 * @param type - NSSyncType of Notification service.
\r
184 void sendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type);
\r
187 * This method is for registering for listeners of Notification .
\r
189 * @param stateHandle - ProviderStateCallback callback.
\r
190 * @param messageHandle - MessageReceivedCallback callback.
\r
191 * @param syncHandle - SyncInfoReceivedCallback callback
\r
193 void setListener(ProviderStateCallback stateHandle,
\r
194 MessageReceivedCallback messageHandle,
\r
195 SyncInfoReceivedCallback syncHandle);
\r
198 * This method is for getting the registered cb of Provider State received.
\r
200 * @return stateCb - ProviderStateCallback .
\r
202 ProviderStateCallback getProviderStateReceivedCb() const;
\r
205 * This method is for getting the registered cb of Notification message received.
\r
207 * @return messageCb - MessageReceivedCallback .
\r
209 MessageReceivedCallback getMessageReceivedCb() const;
\r
212 * This method is for getting the registered cb of Notification SyncInfo received.
\r
214 * @return syncInfoCb - SyncInfoReceivedCallback .
\r
216 SyncInfoReceivedCallback getSyncInfoReceivedCb() const;
\r
219 * This method is for setting NSTopic List for the Notification service provider.
\r
221 * @param topicsList as NSTopicsList pointer.
\r
223 void setTopicList(NSTopicsList *topicsList);
\r
226 * This method is for setting ProviderState for the Notification service provider.
\r
228 * @param providerState as NSProviderState.
\r
230 void setProviderState(const NSProviderState &providerState);
\r
233 * This method is for setting subscribedState for the Notification service provider.
\r
235 * @param subscribedState as NSProviderSubscribedState.
\r
237 void setProviderSubscribedState(const NSProviderSubscribedState &subscribedState);
\r
240 ::NSProvider *getNSProvider();
\r
243 std::string m_providerId;
\r
244 NSTopicsList *m_topicList;
\r
245 NSProviderState m_state;
\r
246 NSProviderSubscribedState m_subscribedState;
\r
248 ProviderStateCallback m_stateCb;
\r
249 MessageReceivedCallback m_messageCb;
\r
250 SyncInfoReceivedCallback m_syncInfoCb;
\r
254 #endif /* _NS_PROVIDER_H_ */
\r