2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ////////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup tag_NS_NPPService
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup tag_NS_NPPService
25 /// \brief This file contains declaration of singleton class CNotificationManager which is used
26 /// to manage notification information.
28 ////////////////////////////////////////////////////////////////////////////////////////////////////
29 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_
30 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_
32 ////////////////////////////////////////////////////////////////////////////////////////////////////
34 ////////////////////////////////////////////////////////////////////////////////////////////////////
35 #include <native_service/frameworkunified_types.h>
36 #include <native_service/ns_np_service.h>
43 /// forward declaration of class
45 class CPersistentData;
46 class CNotificationsToPersist;
47 class CStateNotification;
49 /// map of all the available notification.
50 typedef std::map<std::string, CNotification *> Notification_Type;
52 /// iterator for map of notifications.
53 typedef Notification_Type::iterator Notification_Iterator_Type;
55 /// map of all available persistent notification and its data.
56 typedef std::map<std::string, CPersistentData *> Persistent_Type;
58 /// Iterator for map of persistent notifications.
59 typedef Persistent_Type::iterator Persistent_Iterator_Type;
62 * This class is used to manage the operations related to notification
63 * on registration, subscription, publication, etc.
65 class CNotificationManager {
67 ////////////////////////////////////////////////////////////////////////////////////////////////
68 /// CNotificationManager
69 /// Constructor of CNotificationManager class
75 ////////////////////////////////////////////////////////////////////////////////////////////////
76 CNotificationManager();
78 ////////////////////////////////////////////////////////////////////////////////////////////////
79 /// ~CNotificationManager
80 /// Destructor of CNotificationManager class
86 ////////////////////////////////////////////////////////////////////////////////////////////////
87 ~CNotificationManager();
89 ////////////////////////////////////////////////////////////////////////////////////////////////
90 /// NotificationpersistentserviceServiceOnRegisterEvents
91 /// This function creates notification object depending on its type and if already created it
92 /// adds the service name to the list in the notification object.
94 /// \param [IN] f_cservicename
95 /// std::string - name of service registering for notification
97 /// \param [IN] f_cnotificationname
98 /// std::string - notification name
100 /// \param [IN] f_uimsglength
101 /// UI_32 - Maximum length of Message
103 /// \param [IN] f_enotificationtype
104 /// EFrameworkunifiedPersistentVarType - type of notification
106 /// \param [IN] f_uidelay
107 /// UI_32 - Delay time for persistence
109 /// \return EFrameworkunifiedStatus
110 // EFrameworkunifiedStatus - success or failure status
112 ////////////////////////////////////////////////////////////////////////////////////////////////
113 EFrameworkunifiedStatus NotificationpersistentserviceServiceOnRegisterEvents(const std::string &f_cservicename,
114 const std::string &f_cnotificationname,
115 const UI_32 f_uimsglength,
116 const EFrameworkunifiedNotificationType f_enotificationtype,
117 const UI_32 f_uidelay = 0);
119 ////////////////////////////////////////////////////////////////////////////////////////////////
120 /// NotificationpersistentserviceServiceOnUnRegisterEvents
121 /// This function removes the name of the service from the notification object.
123 /// \param [IN] f_cservicename
124 /// std::string - name of service unregistering from notification
126 /// \param [IN] f_cnotificationname
127 /// std::string - notification name
129 /// \return EFrameworkunifiedStatus
130 // EFrameworkunifiedStatus - success or failure status
133 ////////////////////////////////////////////////////////////////////////////////////////////////
134 EFrameworkunifiedStatus NotificationpersistentserviceServiceOnUnRegisterEvents(const std::string &f_cservicename,
135 const std::string &f_cnotificationname);
137 ////////////////////////////////////////////////////////////////////////////////////////////////
138 /// NotificationpersistentserviceServiceOnPublishEvent
139 /// This function stores the published data in the notification object in case of state and
140 /// persistent notification.
142 /// \param [IN] f_cservicename
143 /// std::string - name of service registering for notification
145 /// \param [IN] f_cnotificationname
146 /// std::string - notification name
148 /// \param [IN] f_pmessage
149 /// PVOID - pointer to message
151 /// \param f_uimsgsize
152 /// UI_32 - size of Message
154 /// \return EFrameworkunifiedStatus
155 // EFrameworkunifiedStatus - success or failure status
157 ////////////////////////////////////////////////////////////////////////////////////////////////
158 EFrameworkunifiedStatus NotificationpersistentserviceServiceOnPublishEvent(const std::string &f_cservicename,
159 const std::string &f_cnotificationname,
161 const UI_32 f_uimsgsize);
163 ////////////////////////////////////////////////////////////////////////////////////////////////
164 /// NotificationpersistentserviceServiceOnSubscribeToEvent
165 /// This function adds the name of the application to subscribers list in notification object.
167 /// \param [IN] f_csubscribername
168 /// std::string - name of application subscribing to notification
170 /// \param [IN] f_cnotificationname
171 /// std::string - notification name
173 /// \return EFrameworkunifiedStatus
174 // EFrameworkunifiedStatus - success or failure status
177 ////////////////////////////////////////////////////////////////////////////////////////////////
178 EFrameworkunifiedStatus NotificationpersistentserviceServiceOnSubscribeToEvent(const std::string &f_csubscribername,
179 const std::string &f_cnotificationname);
181 ////////////////////////////////////////////////////////////////////////////////////////////////
182 /// NotificationpersistentserviceServiceOnUnSubscribeFromEvent
183 /// This function adds the name of the application to subscribers list in notification object.
185 /// \param [IN] f_csubscribername
186 /// std::string - name of application subscribing to notification
188 /// \param [IN] f_cnotificationname
189 /// std::string - notification name
191 /// \return EFrameworkunifiedStatus
192 // EFrameworkunifiedStatus - success or failure status
195 ////////////////////////////////////////////////////////////////////////////////////////////////
196 EFrameworkunifiedStatus NotificationpersistentserviceServiceOnUnSubscribeFromEvent(const std::string &f_csubscribername,
197 const std::string &f_cnotificationname);
199 ////////////////////////////////////////////////////////////////////////////////////////////////
200 /// NPGetPersistentNotificationData
201 /// Get data for notification name
203 /// \param [IN] f_cnotificationname
204 /// std::string - name of notification
205 /// \param [OUT] f_pnotificationdata
206 /// PVOID - data corresponding to notification name
207 /// \param [IN] f_uidatasize
208 /// UI_32 - size of data
210 /// \return EFrameworkunifiedStatus
211 // EFrameworkunifiedStatus - success or failure status
214 ////////////////////////////////////////////////////////////////////////////////////////////////
215 EFrameworkunifiedStatus NPGetPersistentNotificationData(const std::string &f_cnotificationname,
216 PVOID f_pnotificationdata, const UI_32 f_uidatasize);
218 ////////////////////////////////////////////////////////////////////////////////////////////////
219 /// NotificationpersistentserviceServiceOnGetPersistentData
220 /// This function is used to get the persistent data stored related to notification.
222 /// \param [IN] f_cnotificationname
223 /// std::string - Notification Name
225 /// \param [IN] f_creceivername
226 /// std::string - Source Name
228 /// \return EFrameworkunifiedStatus
229 // EFrameworkunifiedStatus - success or failure status
231 ////////////////////////////////////////////////////////////////////////////////////////////////
232 EFrameworkunifiedStatus NotificationpersistentserviceServiceOnGetPersistentData(const std::string &f_cnotificationname,
233 const std::string &f_creceivername);
235 ////////////////////////////////////////////////////////////////////////////////////////////////
236 /// NotificationpersistentserviceGetPersistentNotificationData
237 /// This function is used to get the list of persistent notifications and the data associated
240 /// \param [OUT] f_pvpersistnotification
241 /// CNotificationsToPersist - vector containing list of persistent notifications and
242 /// data associated with it.
244 /// \param [IN] f_enotificationtype
245 /// EFrameworkunifiedNotificationType - Type of notification
247 /// \param [IN] f_uinotificationpersistentservicepersistcategoryflag
248 /// UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
249 /// 0 - persist orignal data and
250 /// 1 - persist default data
252 /// \return EFrameworkunifiedStatus
253 // EFrameworkunifiedStatus - success or failure status
255 ////////////////////////////////////////////////////////////////////////////////////////////////
256 EFrameworkunifiedStatus NotificationpersistentserviceGetPersistentNotificationData(std::vector<CNotificationsToPersist *> *f_pvpersistnotification,
257 const EFrameworkunifiedNotificationType f_enotificationtype,
258 UI_32 f_uinotificationpersistentservicepersistcategoryflag);
260 ////////////////////////////////////////////////////////////////////////////////////////////////
261 /// NotificationpersistentserviceSetPersistentNotificationData
262 /// This function is used to create the persistent notifications object and fill the data
263 /// related with it on system load.
265 /// \param [IN] f_pvpersistnotification
266 /// vector<CNotificationsToPersist> - vector containing list of notifications and data associated with it
268 /// \return EFrameworkunifiedStatus
269 // EFrameworkunifiedStatus - success or failure status
271 ////////////////////////////////////////////////////////////////////////////////////////////////
272 EFrameworkunifiedStatus NotificationpersistentserviceSetPersistentNotificationData(std::vector<CNotificationsToPersist *> *f_pvpersistnotification);
274 ////////////////////////////////////////////////////////////////////////////////////////////////
275 /// GetNotificationInfo
276 /// This function is used to get the notification information.
278 /// \param [IN] f_cnotificationname
279 /// std::string - Notification Name
281 /// \param [IN] l_pnotificationstopersist
282 /// CNotificationsToPersist - Notification info structure
284 /// \return EFrameworkunifiedStatus
285 // EFrameworkunifiedStatus - success or failure status
287 ////////////////////////////////////////////////////////////////////////////////////////////////
288 EFrameworkunifiedStatus GetNotificationInfo(const std::string &f_cnotificationname,
289 CNotificationsToPersist *&l_pnotificationstopersist); // NOLINT (runtime/references)
291 ////////////////////////////////////////////////////////////////////////////////////////////////
292 /// NotificationpersistentserviceSetDefaultPersistentNotificationData
293 /// This function is used to set the default data of persistent notification
295 /// \param [IN] f_cnotificationname
296 /// std::string - notification name
297 /// \param [IN] f_pmessage
298 /// PVOID - message data
299 /// \param [IN] f_uimsgsize
300 /// UI_32 - message size
302 /// \return EFrameworkunifiedStatus
303 // EFrameworkunifiedStatus - success or failure status
305 ////////////////////////////////////////////////////////////////////////////////////////////////
306 EFrameworkunifiedStatus NotificationpersistentserviceSetDefaultPersistentNotificationData(const std::string &f_cnotificationname,
308 const UI_32 f_uimsgsize);
310 ////////////////////////////////////////////////////////////////////////////////////////////////
311 /// NotificationpersistentserviceSetPersistentCategory
312 /// This function is used to set the persistent type of persistent notification
314 /// \param [IN] f_cnotificationname
315 /// std::string - notification name
316 /// \param [IN] f_epersistenttype
317 /// EFrameworkunifiedPersistCategory - persistent category
319 /// \return EFrameworkunifiedStatus
320 // EFrameworkunifiedStatus - success or failure status
322 ////////////////////////////////////////////////////////////////////////////////////////////////
323 EFrameworkunifiedStatus NotificationpersistentserviceSetPersistentCategory(const std::string &f_cnotificationname,
324 const EFrameworkunifiedPersistCategory f_epersistcategory);
326 ////////////////////////////////////////////////////////////////////////////////////////////////
327 /// NotificationpersistentservicePublishImmediateNotification
328 /// This function publish the immediate notification f_cnotificationname to all its subscribers.
329 /// This API is called when service updates the immediate notification data in persistent memory
330 /// using synchronous API.
332 /// \param [IN] f_cservicename
333 /// const std::string& - name of service registering for notification
335 /// \param [IN] f_cnotificationname
336 /// const std::string& - notification name
338 /// \param [IN] f_pmessage
339 /// PVOID - pointer to message
341 /// \param f_uimsgsize
342 /// UI_32 - size of Message
344 /// \return EFrameworkunifiedStatus
345 // EFrameworkunifiedStatus - eFrameworkunifiedStatusOK on success
346 /// eFrameworkunifiedStatusInvldParam - invalid parameter
347 /// eFrameworkunifiedStatusNullPointer - if notification not found
349 ////////////////////////////////////////////////////////////////////////////////////////////////
350 EFrameworkunifiedStatus NotificationpersistentservicePublishImmediateNotification(const std::string &f_cservicename,
351 const std::string &f_cnotificationname,
353 const UI_32 f_uimsgsize);
355 #ifdef NPP_PROFILEINFO_ENABLE
357 ////////////////////////////////////////////////////////////////////////////////////////////////
358 /// GetNotificationProfilingData
359 /// This function is used to get the notification profiling information.
361 /// \param [OUT] f_tNotificationProfileInfo
362 /// std::string - all the notification info of all applications concated in a string
364 /// \return EFrameworkunifiedStatus
365 // EFrameworkunifiedStatus - success or failure status
367 ////////////////////////////////////////////////////////////////////////////////////////////////
368 EFrameworkunifiedStatus GetNotificationProfilingData(std::string &f_cnotificationprofileInfo); // NOLINT (runtime/references)
373 Notification_Type *m_pmNotificationList; /// < map containing list of all notifications.
375 std::vector<std::string> *m_pvPersistentList; /// < vector containing list of all persistent notifications.
377 std::vector<std::string> *m_pvUserPersistentList; /// < vector containing list of all user persistent notifications.
379 ////////////////////////////////////////////////////////////////////////////////////////////////
380 /// CreateNotificationObject
381 /// This function is used to get notification object from map if it exists else create new
382 /// object as per type of notification.
384 /// \param [IN] f_cnotificationname
385 /// std::string - notification name
387 /// \param [IN] f_uimsglength
388 /// UI_32 - Maximum size of notification message
390 /// \param [IN] f_enotificationtype
391 /// EFrameworkunifiedPersistentVarType - Delay time for persistence
393 /// \param [IN] f_uidelay
394 /// UI_32 - Persistence Delay
396 /// \return CNotification
397 // CNotification - pointer of notification object
399 ////////////////////////////////////////////////////////////////////////////////////////////////
400 CNotification *CreateNotificationObject(const std::string &f_cnotificationname,
401 const UI_32 f_uimsglength,
402 const EFrameworkunifiedNotificationType f_enotificationtype,
403 const UI_32 f_uidelay = 0);
405 ////////////////////////////////////////////////////////////////////////////////////////////////
406 /// SearchNotification
407 /// This function is used to search whether notification object is present in map or not.
408 /// If present it sends the reference. CNotification - reference to pointer of notification object
410 /// \param [IN] f_cnotificationname
411 /// std::string - notification name
413 /// \return CNotification
414 // CNotification - pointer of notification object
416 ////////////////////////////////////////////////////////////////////////////////////////////////
417 CNotification *SearchNotification(const std::string &f_cnotificationname);
419 ////////////////////////////////////////////////////////////////////////////////////////////////
420 /// SearchPersistenceNotification
421 /// This function is used to search whether the given persistent notification object
422 /// is present in map or not.
424 /// \param [IN] f_cnotificationname
425 /// std::string - notification name
427 /// \return CStateNotification
428 // CStateNotification - pointer of notification object
430 ////////////////////////////////////////////////////////////////////////////////////////////////
431 CStateNotification *SearchPersistenceNotification(const std::string &f_cnotificationname);
433 ////////////////////////////////////////////////////////////////////////////////////////////////
434 /// CreateNotificationObjectToPersist
435 /// Creates the CNotificationsToPersist object from notification object and the persistent data.
437 /// \param [IN] f_pnotification
438 /// CStateNotification - notification object ptr
439 /// \param [IN] f_pdata
440 /// CPersistentData - persistent data
442 /// \return CNotification
443 // CNotification - pointer of notification object
445 ////////////////////////////////////////////////////////////////////////////////////////////////
446 CNotificationsToPersist *CreateNotificationObjectToPersist(CStateNotification *f_pnotification,
447 const CPersistentData *f_pdata);
449 ////////////////////////////////////////////////////////////////////////////////////////////////
450 /// RemoveUserSpecificNotificationEntry
451 /// This function is used to get the singleton instance of class.
455 /// \return EFrameworkunifiedStatus
456 /// EFrameworkunifiedStatus - success or failure status
458 ////////////////////////////////////////////////////////////////////////////////////////////////
459 EFrameworkunifiedStatus RemoveUserSpecificNotificationEntry();
461 ////////////////////////////////////////////////////////////////////////////////////////////////
462 /// ChangeNotificationType
463 /// This function creates new notification object depending on the type and replaces the old one.
464 /// The subscribers list is copied from the old notification object is copied to the new one.
466 /// \param [IN] f_pnotification
467 /// CNotification* - old notification object
469 /// \param [IN] f_cservicename
470 /// std::string - name of service registering for notification
472 /// \param [IN] f_cnotificationname
473 /// std::string - notification name
475 /// \param [IN] f_uimsglength
476 /// UI_32 - Maximum length of Message
478 /// \param [IN] f_enotificationtype
479 /// EFrameworkunifiedPersistentVarType - new type of notification
481 /// \param [IN] f_uidelay
482 /// UI_32 - Delay time for persistence
484 /// \return EFrameworkunifiedStatus
485 // EFrameworkunifiedStatus - success or failure status
487 ////////////////////////////////////////////////////////////////////////////////////////////////
488 EFrameworkunifiedStatus ChangeNotificationType(CNotification *f_pnotification,
489 const std::string &f_cservicename,
490 const std::string &f_cnotificationname,
491 const UI_32 f_uimsglength,
492 const EFrameworkunifiedNotificationType f_enotificationtype,
493 const UI_32 f_uidelay);
496 #endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_NOTIFICATION_MANAGER_H_