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
77 * Constructor of NSProvider.
\r
79 * @param providerId - providerId of the Notification.
\r
81 NSProvider(const std::string &providerId) : m_providerId(providerId),
\r
82 m_topicList(new NSTopicsList()), m_state(NSProviderState::DENY),
\r
83 m_subscribedState(NSProviderSubscribedState::DENY),
\r
84 m_stateCb(NULL), m_messageCb(NULL), m_syncInfoCb(NULL) {}
\r
87 * Constructor of NSProvider.
\r
89 * @param providerId - providerId of the Notification.
\r
90 * @param topicList - NSTopicsList of interested Topics.
\r
92 NSProvider(const std::string &providerId, NSTopicsList *topicList) : m_providerId(
\r
93 providerId), m_topicList(topicList), m_state(NSProviderState::DENY),
\r
94 m_subscribedState(NSProviderSubscribedState::DENY),
\r
95 m_stateCb(NULL), m_messageCb(NULL), m_syncInfoCb(NULL) {}
\r
98 * Constructor of NSProvider.
\r
100 * @param provider - of type NSProvider.
\r
102 NSProvider(::NSProvider *provider);
\r
105 * Copy Constructor of NSProvider.
\r
107 * @param provider - NSProvider to initialize.
\r
109 NSProvider(const NSProvider &provider);
\r
112 * Copy assignment operator of NSProvider.
\r
114 * @param provider - NSProvider to initialize.
\r
115 * @return NSProvider object reference
\r
117 NSProvider &operator=(const NSProvider &provider);
\r
120 * Destructor of NSProvider.
\r
125 * This method is for getting ProviderId from the Notification service provider.
\r
127 * @return ProviderId as string.
\r
129 std::string getProviderId() const;
\r
132 * This method is for getting NSTopic List from the Notification service provider.
\r
134 * @return NSTopicsList as pointer.
\r
136 NSTopicsList *getTopicList() const;
\r
139 * Update Topic list that is wanted to be subscribed from provider
\r
141 * @param topicList - NSTopicsList of interested Topics.
\r
144 NSResult updateTopicList(NSTopicsList *topicList);
\r
147 * This method is for getting ProviderState from the Notification service provider.
\r
149 * @return ProviderState as NSProviderState.
\r
151 NSProviderState getProviderState() const;
\r
154 * This method is for getting SubscribedState from the Notification service provider.
\r
156 * @return subscribedState as NSProviderSubscribedState.
\r
158 NSProviderSubscribedState getProviderSubscribedState() const;
\r
161 * This method is for requesting subscription of Notification service.
\r
167 * This method is for requesting subscription status from Provider of Notification service.
\r
170 bool isSubscribed();
\r
173 * This method is for Sending SyncInfo of Notification service.
\r
175 * @param messageId - id of type message.
\r
176 * @param type - NSSyncType of Notification service.
\r
178 void sendSyncInfo(uint64_t messageId, NSSyncInfo::NSSyncType type);
\r
181 * This method is for registering for listeners of Notification .
\r
183 * @param stateHandle - ProviderStateCallback callback.
\r
184 * @param messageHandle - MessageReceivedCallback callback.
\r
185 * @param syncHandle - SyncInfoReceivedCallback callback
\r
187 void setListener(ProviderStateCallback stateHandle,
\r
188 MessageReceivedCallback messageHandle,
\r
189 SyncInfoReceivedCallback syncHandle);
\r
192 * This method is for getting the registered cb of Provider State received.
\r
194 * @return stateCb - ProviderStateCallback .
\r
196 ProviderStateCallback getProviderStateReceivedCb() const;
\r
199 * This method is for getting the registered cb of Notification message received.
\r
201 * @return messageCb - MessageReceivedCallback .
\r
203 MessageReceivedCallback getMessageReceivedCb() const;
\r
206 * This method is for getting the registered cb of Notification SyncInfo received.
\r
208 * @return syncInfoCb - SyncInfoReceivedCallback .
\r
210 SyncInfoReceivedCallback getSyncInfoReceivedCb() const;
\r
213 * This method is for setting NSTopic List for the Notification service provider.
\r
215 * @param topicsList as NSTopicsList pointer.
\r
217 void setTopicList(NSTopicsList *topicsList);
\r
220 * This method is for setting ProviderState for the Notification service provider.
\r
222 * @param providerState as NSProviderState.
\r
224 void setProviderState(const NSProviderState &providerState);
\r
227 * This method is for setting subscribedState for the Notification service provider.
\r
229 * @param subscribedState as NSProviderSubscribedState.
\r
231 void setProviderSubscribedState(const NSProviderSubscribedState &subscribedState);
\r
234 ::NSProvider *getNSProvider();
\r
237 std::string m_providerId;
\r
238 NSTopicsList *m_topicList;
\r
239 NSProviderState m_state;
\r
240 NSProviderSubscribedState m_subscribedState;
\r
242 ProviderStateCallback m_stateCb;
\r
243 MessageReceivedCallback m_messageCb;
\r
244 SyncInfoReceivedCallback m_syncInfoCb;
\r
248 #endif /* _NS_PROVIDER_H_ */
\r