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 implementation of singleton class CNotificationManager.
27 ////////////////////////////////////////////////////////////////////////////////////////////////////
29 ////////////////////////////////////////////////////////////////////////////////////////////////////
31 ////////////////////////////////////////////////////////////////////////////////////////////////////
33 #include <native_service/ns_np_service.h>
34 #include <native_service/ns_message_center_if.h>
35 #include <native_service/ns_np_service_protocol.h>
40 #include "ns_npp_types.h"
41 #include "ns_npp_notificationpersistentservicelog.h"
42 #include "ns_npp_threads.h"
43 #include "ns_npp_notification.h"
44 #include "ns_npp_persistent_data.h"
45 #include "ns_npp_state_notification.h"
46 #include "ns_npp_regular_notification.h"
47 #include "ns_npp_notification_manager.h"
48 #include "ns_npp_state_persistence_notification.h"
49 #include "ns_npp_state_nor_persistence_notification.h"
50 #include "ns_npp_state_persistence_user_notification.h"
52 #ifdef NPP_PROFILEINFO_ENABLE
56 ////////////////////////////////////////////////////////////////////////////////////////////////////
57 /// CNotificationManager
58 /// Constructor of CNotificationManager class
59 ////////////////////////////////////////////////////////////////////////////////////////////////////
60 CNotificationManager::CNotificationManager() {
61 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
63 m_pmNotificationList = new(std::nothrow) Notification_Type(); // LCOV_EXCL_BR_LINE 11: unexpected branch
65 m_pvPersistentList = new(std::nothrow) std::vector<std::string>(); // LCOV_EXCL_BR_LINE 11: unexpected branch
67 m_pvUserPersistentList = new(std::nothrow) std::vector<std::string>(); // LCOV_EXCL_BR_LINE 11: unexpected branch
69 if (NULL == CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) { // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
70 CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread =
71 McOpenSender(NS_NPP_IMMEDIATE_PERSIST_THREAD_NAME);
74 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
77 ////////////////////////////////////////////////////////////////////////////////////////////////////
78 /// ~CNotificationManager
79 /// Destructor of CNotificationManager class
80 ////////////////////////////////////////////////////////////////////////////////////////////////////
81 CNotificationManager::~CNotificationManager() { // LCOV_EXCL_START 14: Resident process, global instance not released
82 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
83 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
85 // iterator to find notification from map of notifications
86 Notification_Iterator_Type l_itNotification;
88 CNotification *l_pNotification = NULL;
90 // delete the members in map of Notification
91 if (NULL != m_pmNotificationList) {
92 if (!m_pmNotificationList->empty()) {
93 for (l_itNotification = m_pmNotificationList->begin();
94 l_itNotification != m_pmNotificationList->end();
96 l_pNotification = (*l_itNotification).second;
98 if (NULL != l_pNotification) {
99 delete l_pNotification;
100 l_pNotification = NULL;
105 m_pmNotificationList->clear();
108 delete m_pmNotificationList;
109 m_pmNotificationList = NULL;
112 // delete the members in vector of persistent notification
113 if (NULL != m_pvPersistentList) {
114 if (!m_pvPersistentList->empty()) {
116 m_pvPersistentList->clear();
119 delete m_pvPersistentList;
120 m_pvPersistentList = NULL;
123 // delete the members in vector of user persistent notification
124 if (NULL != m_pvUserPersistentList) {
125 if (!m_pvUserPersistentList->empty()) {
127 m_pvUserPersistentList->clear();
130 delete m_pvUserPersistentList;
131 m_pvUserPersistentList = NULL;
134 if (NULL != CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) {
135 McClose(CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread);
136 CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread = NULL;
139 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
143 ////////////////////////////////////////////////////////////////////////////////////////////////////
144 /// CreateNotificationObject
145 /// This function is used to get notification object from map. If doesn't exists, it create new
146 /// object as per type of notification.
147 ////////////////////////////////////////////////////////////////////////////////////////////////////
148 CNotification *CNotificationManager::CreateNotificationObject(const std::string &f_cnotificationname,
149 const UI_32 f_uimsglength,
150 const EFrameworkunifiedNotificationType f_enotificationtype,
151 const UI_32 f_uidelay) {
152 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
154 // pointer of notification object
155 CNotification *l_pNotification = NULL;
157 // iterator to find notification from map of CNotification
158 Notification_Iterator_Type l_itNotification;
160 if (NULL == m_pmNotificationList || NULL == m_pvPersistentList || NULL == m_pvUserPersistentList) { // LCOV_EXCL_START 6: double check, m_pmNotificationList, m_pvPersistentList, m_pvUserPersistentList can't be NULL // NOLINT[whitespace/line_length]
161 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
162 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map/vector object is NULL"); // LCOV_EXCL_LINE 6: m_pmNotificationList, m_pvPersistentList, m_pvUserPersistentList can't be NULL // NOLINT[whitespace/line_length]
167 // check if notification already exists
168 l_itNotification = m_pmNotificationList->find(f_cnotificationname);
170 // if exists remove previous entry
171 if (m_pmNotificationList->end() != l_itNotification) {
172 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Removing previous entry of notification %s from map", f_cnotificationname.c_str());
173 m_pmNotificationList->erase(l_itNotification);
176 switch (f_enotificationtype) {
177 // if notification is regular notification
178 case eFrameworkunifiedNotificationVar: {
179 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Regular Notification :: %s", f_cnotificationname.c_str());
180 l_pNotification = new(std::nothrow) CRegularNotification(f_cnotificationname,
181 f_uimsglength); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
185 // if notification is state notification
186 case eFrameworkunifiedStateVar: {
187 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "State Notification :: %s", f_cnotificationname.c_str());
188 l_pNotification = new(std::nothrow) CStateNotification(f_cnotificationname,
189 f_uimsglength); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
193 // if notification is persistence notification
194 case eFrameworkunifiedPersistedStateVar: {
195 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "PersistedState Notification :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
196 l_pNotification = new(std::nothrow) CStatePersistenceNotification(f_cnotificationname,
197 f_uimsglength); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
199 if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
200 // insert notification in persistent notification vector
201 m_pvPersistentList->push_back(f_cnotificationname);
203 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
204 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory not allocated"); // LCOV_EXCL_LINE 5: It's impossible to mock new() function // NOLINT[whitespace/line_length]
210 // if notification is user persistence notification
211 case eFrameworkunifiedPersistedStateUserVar: {
212 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "PersistedStateUser Notification :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
213 l_pNotification = new(std::nothrow) CStatePersistenceUserNotification(f_cnotificationname,
214 f_uimsglength); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
216 if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
217 // insert notification in user persistent notification vector
218 m_pvUserPersistentList->push_back(f_cnotificationname);
220 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
221 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NULL pointer error"); // LCOV_EXCL_LINE 5: It's impossible to mock new() function // NOLINT[whitespace/line_length]
227 // if notification is immediate persistence notification
228 case eFrameworkunifiedImmediatePersistedStateVar: {
229 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Immediate PersistedState Notification :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
230 l_pNotification = new(std::nothrow) CStateNorPersistenceNotification(f_cnotificationname,
232 f_uidelay); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
240 if (NULL != l_pNotification) {
241 // insert notification in notification map
242 m_pmNotificationList->insert(make_pair(f_cnotificationname, l_pNotification));
244 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification object creation failed for %s.", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
247 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
248 return l_pNotification;
251 ////////////////////////////////////////////////////////////////////////////////////////////////////
252 /// SearchNotification
253 /// This function is used to search whether notification object is present in map or not.
254 /// If present it sends the reference.
255 ////////////////////////////////////////////////////////////////////////////////////////////////////
256 CNotification *CNotificationManager::SearchNotification(const std::string &f_cnotificationname) {
257 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
259 CNotification *l_pNotification = NULL;
261 // iterator to find notification from map of notifications
262 Notification_Iterator_Type l_itNotification;
264 if (NULL == m_pmNotificationList || f_cnotificationname.empty()) { // LCOV_EXCL_BR_LINE 6: double check, m_pmNotificationList can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
265 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
266 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map pointer is NULL"); // LCOV_EXCL_LINE 6: m_pmNotificationList can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
268 // check if this notification's object present in map
269 l_itNotification = m_pmNotificationList->find(f_cnotificationname);
271 // if notification found in map
272 if (m_pmNotificationList->end() != l_itNotification) {
273 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Notification found in map :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
275 // get the notification object pointer from map
276 l_pNotification = (*l_itNotification).second;
278 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Notification not found :: %s", f_cnotificationname.c_str());
282 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
283 return l_pNotification;
286 ////////////////////////////////////////////////////////////////////////////////////////////////////
287 /// SearchPersistenceNotification
288 /// This function is used to search for the given persistent notification in map.
289 ////////////////////////////////////////////////////////////////////////////////////////////////////
290 CStateNotification *CNotificationManager::SearchPersistenceNotification(const std::string &f_cnotificationname) {
291 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
293 // pointer of notification object
294 CNotification *l_pNotification = NULL;
295 CStateNotification *l_pStateNotification = NULL;
297 // search the notification in the map
298 l_pNotification = SearchNotification(f_cnotificationname);
300 if (NULL != l_pNotification) {
301 if (eFrameworkunifiedPersistedStateVar == l_pNotification->GetNotificationType() ||
302 eFrameworkunifiedPersistedStateUserVar == l_pNotification->GetNotificationType() ||
303 eFrameworkunifiedImmediatePersistedStateVar == l_pNotification->GetNotificationType()) {
304 l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
307 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "There is no persistence notification registered with name :: %s",
308 f_cnotificationname.c_str());
311 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
312 return l_pStateNotification;
315 ////////////////////////////////////////////////////////////////////////////////////////////////////
316 /// NotificationpersistentserviceServiceOnRegisterEvents
317 /// This function creates notification object depending on its type and if already created it adds
318 /// the service name to the list in the notification object.
319 ////////////////////////////////////////////////////////////////////////////////////////////////////
320 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnRegisterEvents(const std::string &f_cservicename,
321 const std::string &f_cnotificationname,
322 const UI_32 f_uimsglength,
323 const EFrameworkunifiedNotificationType f_enotificationtype,
324 const UI_32 f_uidelay) {
325 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
326 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
328 CNotification *l_pNotification = NULL;
330 if (f_cservicename.empty() || f_cnotificationname.empty()) {
331 l_estatus = eFrameworkunifiedStatusInvldParam;
333 // get the notification object from map or create new object
334 l_pNotification = SearchNotification(f_cnotificationname);
336 // if new notification is registered
337 if (NULL == l_pNotification) {
338 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Create new notification object :: %s", f_cnotificationname.c_str());
340 // create the new notification object depending on type and insert in map and vector
341 l_pNotification = CreateNotificationObject(f_cnotificationname,
346 if (NULL != l_pNotification) {
347 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Set Notification publisher %s for notification %s", f_cservicename.c_str(),
348 f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
350 // set publisher name
351 l_estatus = l_pNotification->SetEventPublisher(f_cservicename);
353 } else { // if notification object already exists
354 EFrameworkunifiedNotificationType l_eNotificationType = l_pNotification->GetNotificationType();
356 // <<notification type is eFrameworkunifiedUnknown
357 // if some service had already subscribed to the notification before registering it.>>
358 if (eFrameworkunifiedUnknown == l_eNotificationType) {
359 // creates new notification object depending on the type and insert it in notification map
360 l_estatus = ChangeNotificationType(l_pNotification, f_cservicename, f_cnotificationname, f_uimsglength,
361 f_enotificationtype, f_uidelay);
363 // delete the old notification object
364 delete l_pNotification; // LCOV_EXCL_BR_LINE 11: unexpected branch
365 l_pNotification = NULL;
366 } else { // notification is already registered by some service
367 // update the notification property, if re-registered by the same publisher
368 if (f_cservicename == l_pNotification->GetPublisherName() || // if re-register by service
369 "" == l_pNotification->GetPublisherName()) { // if previously unregistered by service
370 // if type is same just update the length of notification data
371 if (l_eNotificationType == f_enotificationtype) {
372 if (l_pNotification->GetMaxMessageSize() != f_uimsglength) {
373 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
374 "Updating max size of notification %s to %d from %d", f_cnotificationname.c_str(),
375 f_uimsglength, l_pNotification->GetMaxMessageSize());
376 l_estatus = l_pNotification->ResetMaxMessageSize(f_uimsglength);
379 if ("" == l_pNotification->GetPublisherName()) {
380 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
381 "Updating publisher name of notification %s to %s from %s", f_cservicename.c_str(),
382 f_cnotificationname.c_str(), l_pNotification->GetPublisherName().c_str());
383 l_pNotification->SetEventPublisher(f_cservicename);
385 } else if (eFrameworkunifiedImmediatePersistedStateVar != l_eNotificationType &&
386 eFrameworkunifiedImmediatePersistedStateVar != f_enotificationtype) {
387 // else create new notification object depending on the type and delete the old one
388 // note: do not change immediate notification type
389 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Changing type of notfn %s from %d to %d", f_cnotificationname.c_str(),
390 l_eNotificationType, f_enotificationtype);
392 std::vector<std::string>::iterator l_itNotificationName;
394 // remove the notification name from the persistent list of notification(if any)
395 if (eFrameworkunifiedPersistedStateVar == l_eNotificationType) {
396 l_itNotificationName = find(m_pvPersistentList->begin(), m_pvPersistentList->end(), f_cnotificationname);
398 if (m_pvPersistentList->end() != l_itNotificationName) {
399 m_pvPersistentList->erase(l_itNotificationName);
401 } else if (eFrameworkunifiedPersistedStateUserVar == l_eNotificationType) {
402 l_itNotificationName = find(m_pvUserPersistentList->begin(),
403 m_pvUserPersistentList->end(),
404 f_cnotificationname);
406 if (m_pvUserPersistentList->end() != l_itNotificationName) {
407 m_pvUserPersistentList->erase(l_itNotificationName);
413 // creates new notification object depending on the new type and insert it in map and delete the old one
414 l_estatus = ChangeNotificationType(l_pNotification, f_cservicename, f_cnotificationname, f_uimsglength,
415 f_enotificationtype, f_uidelay);
417 // delete the old notification object
418 delete l_pNotification;
419 l_pNotification = NULL;
424 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notfn: %s already registered by %s, skipping register request by %s",
425 f_cnotificationname.c_str(), l_pNotification->GetPublisherName().c_str(), f_cservicename.c_str());
427 l_estatus = eFrameworkunifiedStatusFail;
433 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
437 ////////////////////////////////////////////////////////////////////////////////////////////////
438 /// ChangeNotificationType
439 /// This function creates new notification object depending on the type and replaces the old one.
440 ////////////////////////////////////////////////////////////////////////////////////////////////
441 EFrameworkunifiedStatus CNotificationManager::ChangeNotificationType(CNotification *f_pnotification,
442 const std::string &f_cservicename,
443 const std::string &f_cnotificationname,
444 const UI_32 f_uimsglength,
445 const EFrameworkunifiedNotificationType f_enotificationtype,
446 const UI_32 f_uidelay) {
447 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
448 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
450 CNotification *l_pNewNotification = NULL;
452 if (NULL != f_pnotification) { // LCOV_EXCL_BR_LINE 6: f_pnotification can't be NULL
453 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Create New Notification :: %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
455 // create new notification object as per notification type
456 l_pNewNotification = CreateNotificationObject(f_cnotificationname, f_uimsglength, f_enotificationtype, f_uidelay);
458 if (NULL != l_pNewNotification) {
459 l_estatus = l_pNewNotification->SetEventPublisher(f_cservicename);
461 // assign subscribers list to newly created notification
462 l_pNewNotification->SetNewSubscribersList(f_pnotification);
464 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
465 "Error creating notification object for notification:%s",
466 f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h"
467 l_estatus = eFrameworkunifiedStatusNullPointer;
470 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
471 l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 6: f_pnotification can't be NULL
474 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
478 ////////////////////////////////////////////////////////////////////////////////////////////////////
479 /// NotificationpersistentserviceServiceOnUnRegisterEvents
480 /// This function removes the name of the service from the notification object.
481 ////////////////////////////////////////////////////////////////////////////////////////////////////
482 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnUnRegisterEvents(const std::string &f_cservicename,
483 const std::string &f_cnotificationname) {
484 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
485 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
487 CNotification *l_pNotification = NULL;
488 std::vector<std::string> *l_pvPersistentList = NULL;
490 // iterator to find notification from map of notifications
491 Notification_Iterator_Type l_itNotification;
493 if (f_cservicename.empty() || f_cnotificationname.empty()) {
494 l_estatus = eFrameworkunifiedStatusInvldParam;
496 // check if this notification's object present in map
497 l_itNotification = m_pmNotificationList->find(f_cnotificationname);
499 // if notification found in map
500 if (m_pmNotificationList->end() != l_itNotification) {
501 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Notification found in map"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
503 // get the notification object pointer from map
504 l_pNotification = (*l_itNotification).second;
506 if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: f_pnotification can't be NULL
507 if (eFrameworkunifiedPersistedStateUserVar == l_pNotification->GetNotificationType()) {
508 l_pvPersistentList = m_pvUserPersistentList;
509 } else if (eFrameworkunifiedPersistedStateVar == l_pNotification->GetNotificationType()) {
510 l_pvPersistentList = m_pvPersistentList;
513 // reset the publisher name
514 l_estatus = l_pNotification->ResetEventPublisher(f_cservicename);
516 if (eFrameworkunifiedStatusOK == l_estatus) {
517 // if no other service is subscribed to this notification and no service is registered
518 // to this notification remove the notification object from map
519 if (!l_pNotification->IsServiceRegistered() &&
520 l_pNotification->IsSubscribersListEmpty()) {
521 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Deleting Notification Object"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
523 // delete the notification
524 delete l_pNotification; // LCOV_EXCL_BR_LINE 11: unexpected branch
525 l_pNotification = NULL;
527 m_pmNotificationList->erase(l_itNotification);
529 if (l_pvPersistentList) {
530 // find the notification in vector
531 std::vector<std::string>::iterator l_itNotificationName;
533 l_itNotificationName = find(l_pvPersistentList->begin(),
534 l_pvPersistentList->end(),
535 f_cnotificationname);
537 if (l_pvPersistentList->end() != l_itNotificationName) {
538 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification name from vector");
539 l_pvPersistentList->erase(l_itNotificationName);
542 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Persistent list empty"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
545 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Services still registered or subscriber list empty"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
548 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s is not registered by service %s",
549 f_cnotificationname.c_str(), f_cservicename.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
552 // LCOV_EXCL_START 6: f_pnotification can't be NULL
553 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
554 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not registered", f_cnotificationname.c_str());
556 l_estatus = eFrameworkunifiedStatusNullPointer;
560 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not found.", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
562 l_estatus = eFrameworkunifiedStatusFail;
566 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
570 ////////////////////////////////////////////////////////////////////////////////////////////////////
571 /// NotificationpersistentserviceServiceOnPublishEvent
572 /// This function stores the published data in the notification object in case of state and
573 /// persistent notification.
574 ////////////////////////////////////////////////////////////////////////////////////////////////////
575 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnPublishEvent(const std::string &f_cservicename,
576 const std::string &f_cnotificationname,
578 const UI_32 f_uimsgsize) {
579 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
580 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
582 CNotification *l_pNotification = NULL;
584 if (f_cservicename.empty() || f_cnotificationname.empty()) { // LCOV_EXCL_BR_LINE 6: f_cservicename and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
585 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
586 l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: f_cservicename and f_cnotificationname can't be empty
588 // get the notification object from map
589 l_pNotification = SearchNotification(f_cnotificationname);
591 if (NULL != l_pNotification) {
592 // publish the notification
593 if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotification->Publish(f_cservicename,
596 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error publishing notification %s published by %s, status: %d",
597 f_cnotificationname.c_str(), f_cservicename.c_str(), l_estatus); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
600 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification not registered"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
602 l_estatus = eFrameworkunifiedStatusNullPointer;
607 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
611 ////////////////////////////////////////////////////////////////////////////////////////////////////
612 /// NotificationpersistentserviceServiceOnSubscribeToEvent
613 /// This function adds the name of the application to subscribers list in notification object.
614 ////////////////////////////////////////////////////////////////////////////////////////////////////
615 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnSubscribeToEvent(const std::string &f_csubscribername,
616 const std::string &f_cnotificationname) {
617 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
618 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
620 // iterator to find notification from map of notifications
621 Notification_Iterator_Type l_itNotification;
623 CNotification *l_pNotification = NULL;
625 if (f_cnotificationname.empty() || f_csubscribername.empty()) {
626 l_estatus = eFrameworkunifiedStatusInvldParam;
627 } else if (NULL == m_pmNotificationList) { // LCOV_EXCL_BR_LINE 6 m_pmNotificationList can't be NULL
628 // LCOV_EXCL_START 6: m_pmNotificationList can't be NULL
629 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
630 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "map pointer is NULL");
631 l_estatus = eFrameworkunifiedStatusNullPointer;
634 // get the notification object from map or create new object
635 l_pNotification = SearchNotification(f_cnotificationname);
637 if (NULL == l_pNotification) {
638 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "CNotification object created for %s", f_cnotificationname.c_str());
640 l_pNotification = new(std::nothrow) CNotification(f_cnotificationname, 0); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
642 m_pmNotificationList->insert(make_pair(f_cnotificationname, l_pNotification));
645 if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: double check, l_pNotification can't be NULL
646 // add subscribers name in subscribers list of notification
647 l_estatus = l_pNotification->AddEventReciever(f_csubscribername);
649 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
650 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory not allocated for l_pNotification"); // LCOV_EXCL_LINE 6: double check, l_pNotification can't be NULL // NOLINT[whitespace/line_length]
654 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
658 ////////////////////////////////////////////////////////////////////////////////////////////////////
659 /// NotificationpersistentserviceServiceOnUnSubscribeFromEvent
660 /// This function removes the name of the application from the subscribers list in notification object.
661 ////////////////////////////////////////////////////////////////////////////////////////////////////
662 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnUnSubscribeFromEvent(const std::string &f_csubscribername,
663 const std::string &f_cnotificationname) {
664 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
665 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
667 CNotification *l_pNotification = NULL;
669 // iterator to find notification from map of notifications
670 Notification_Iterator_Type l_itNotificationType;
672 std::vector<std::string> *l_pvPersistentList = NULL;
674 if (f_cnotificationname.empty() || f_csubscribername.empty()) {
675 l_estatus = eFrameworkunifiedStatusInvldParam;
676 } else if (NULL == m_pmNotificationList) { // LCOV_EXCL_BR_LINE 6: m_pmNotificationList can't be NULL
677 // LCOV_EXCL_START 6: m_pmNotificationList can't be NULL
678 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
679 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification list pointer is NULL");
680 l_estatus = eFrameworkunifiedStatusNullPointer;
683 // check if this notification's object present in map
684 l_itNotificationType = m_pmNotificationList->find(f_cnotificationname);
686 // if notification found in map
687 if (m_pmNotificationList->end() != l_itNotificationType) {
688 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Notification %s found in map", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
690 l_pNotification = (*l_itNotificationType).second;
692 if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: l_pNotification can't be NULL
693 if (eFrameworkunifiedPersistedStateUserVar == l_pNotification->GetNotificationType()) {
694 l_pvPersistentList = m_pvUserPersistentList;
695 } else if (eFrameworkunifiedPersistedStateVar == l_pNotification->GetNotificationType()) {
696 l_pvPersistentList = m_pvPersistentList;
699 // removes the subscribers name from subscribers list of notification
700 l_estatus = l_pNotification->DeleteEventReciever(f_csubscribername);
702 // if no other service is subscribed to this notification and no service is registered
703 // to this notification remove the notification object from map
704 if (!l_pNotification->IsServiceRegistered() &&
705 l_pNotification->IsSubscribersListEmpty()) {
706 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification Object from map"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
708 // delete notification object from map
709 delete l_pNotification; // LCOV_EXCL_BR_LINE 11: unexpected branch
710 l_pNotification = NULL;
712 m_pmNotificationList->erase(l_itNotificationType);
714 if (l_pvPersistentList) {
715 // find notification in vector
716 std::vector<std::string>::iterator l_itNotificationName;
717 l_itNotificationName = find(l_pvPersistentList->begin(),
718 l_pvPersistentList->end(),
719 f_cnotificationname);
721 if (l_pvPersistentList->end() != l_itNotificationName) {
722 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification from vector"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
723 l_pvPersistentList->erase(l_itNotificationName);
726 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Persistent list Empty."); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
730 // LCOV_EXCL_START 6: l_pNotification can't be NULL
731 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
732 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Notification %s not registered", f_cnotificationname.c_str());
733 l_estatus = eFrameworkunifiedStatusNullPointer;
738 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Notification %s not found.", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
739 l_estatus = eFrameworkunifiedStatusFail;
743 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
747 ////////////////////////////////////////////////////////////////////////////////////////////////////
748 /// NPGetPersistentNotificationData
750 ////////////////////////////////////////////////////////////////////////////////////////////////////
751 EFrameworkunifiedStatus CNotificationManager::NPGetPersistentNotificationData(const std::string &f_cnotificationname,
752 PVOID f_pnotificationdata,
753 const UI_32 f_uidatasize) {
754 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
755 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
757 CNotification *l_pNotification = NULL;
758 CStateNotification *l_pStateNotification = NULL;
759 const CPersistentData *l_pPersistentData = NULL;
761 if (f_cnotificationname.empty() || NULL == f_pnotificationdata) { // LCOV_EXCL_BR_LINE 6: f_pnotificationdata can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
762 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
763 l_estatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: f_pnotificationdata can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
765 l_pNotification = SearchNotification(f_cnotificationname);
767 if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 200: f_cnotificationname must be NTFY_NPPService_UserChange, NTFY_NPPService_UserChange must be registered in FrameworkunifiedOnEntry() by itself. // NOLINT[whitespace/line_length]
768 const EFrameworkunifiedNotificationType l_eNotificationType = l_pNotification->GetNotificationType();
770 if (eFrameworkunifiedStateVar == l_eNotificationType ||
771 eFrameworkunifiedPersistedStateVar == l_eNotificationType ||
772 eFrameworkunifiedPersistedStateUserVar == l_eNotificationType ||
773 eFrameworkunifiedImmediatePersistedStateVar == l_eNotificationType) { // LCOV_EXCL_BR_LINE 200: NTFY_NPPService_UserChange's type is eFrameworkunifiedPersistedStateVar. // NOLINT[whitespace/line_length]
774 l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
776 l_pPersistentData = l_pStateNotification->GetPersistentData();
778 if (NULL != l_pPersistentData) {
779 if (f_uidatasize >= l_pPersistentData->m_uiMsgSize) {
780 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Sending Data Size %d", l_pPersistentData->m_uiMsgSize);
782 if (NULL != l_pPersistentData->m_pMessage) {
783 std::memcpy(f_pnotificationdata, l_pPersistentData->m_pMessage, l_pPersistentData->m_uiMsgSize);
785 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification data is NULL");
788 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
789 "Smaller buffer size %d is received for notification data of size %d", f_uidatasize,
790 l_pPersistentData->m_uiMsgSize);
793 l_estatus = eFrameworkunifiedStatusFail;
794 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
795 "Persistent data object is NULL for notification %s", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
798 // LCOV_EXCL_START 200: NTFY_NPPService_UserChange's type is eFrameworkunifiedPersistedStateVar.
799 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
800 l_estatus = eFrameworkunifiedStatusFail;
801 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Get notification data failed, Notification %s is registered as type %d",
802 f_cnotificationname.c_str(), l_eNotificationType);
806 // LCOV_EXCL_START 200: f_cnotificationname must be NTFY_NPPService_UserChange, NTFY_NPPService_UserChange must be registered in FrameworkunifiedOnEntry() by itself. // NOLINT[whitespace/line_length]
807 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
808 l_estatus = eFrameworkunifiedStatusFail;
809 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not found.", f_cnotificationname.c_str());
814 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
818 ////////////////////////////////////////////////////////////////////////////////////////////////////
819 /// NotificationpersistentserviceServiceOnGetPersistentData
820 /// This function is used to get the persistent data stored related to notification.
821 ////////////////////////////////////////////////////////////////////////////////////////////////////
822 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceServiceOnGetPersistentData(const std::string &f_cnotificationname,
823 const std::string &f_creceivername) {
824 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
825 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
827 CNotification *l_pNotification = NULL;
828 CStateNotification *l_pStateNotification = NULL;
829 const CPersistentData *l_pPersistentData = NULL;
831 if (f_cnotificationname.empty() || f_creceivername.empty()) { // LCOV_EXCL_BR_LINE 6: f_creceivername can't be NULL and f_cnotificationname can't be empty // NOLINT[whitespace/line_length]
832 // LCOV_EXCL_START 6: f_creceivername can't be NULL and f_cnotificationname can't be empty
833 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
834 l_estatus = eFrameworkunifiedStatusInvldParam;
837 // open the receiver message queue
838 HANDLE l_hReceiverMq = McOpenSender(f_creceivername.c_str());
840 if (NULL == l_hReceiverMq) { // LCOV_EXCL_BR_LINE 4: NSFW error case
841 // LCOV_EXCL_START 4: NSFW error case.
842 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
843 // catastrophic failure!
844 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to open MessageQ %s ", f_creceivername.c_str());
845 l_estatus = eFrameworkunifiedStatusFail;
848 // get the notification object from map or create new object
849 l_pNotification = SearchNotification(f_cnotificationname);
851 if (NULL != l_pNotification) {
852 l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
854 if (NULL != l_pStateNotification) { // LCOV_EXCL_BR_LINE 5: fail safe for static_cast<CStateNotification *>
855 l_pPersistentData = l_pStateNotification->GetPersistentData();
857 if (NULL != l_pPersistentData) {
858 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Sending Data Size %d", l_pPersistentData->m_uiMsgSize);
860 if (NULL == l_pPersistentData->m_pMessage) {
861 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Sending Data is NULL");
864 // sent the notification data to requester
865 l_estatus = McSend(l_hReceiverMq,
867 NPS_GET_PERS_DATA_ACK,
868 l_pPersistentData->m_uiMsgSize,
869 l_pPersistentData->m_pMessage);
870 FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Persistent data found for notification %s. "
871 "Sent NPS_GET_PERS_DATA_ACK to %s. Status: %d."
872 , f_cnotificationname.c_str(), f_creceivername.c_str(), l_estatus);
873 } else { // In case of failure, we send back a failure ACK
874 l_estatus = eFrameworkunifiedStatusFail;
875 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "No persistent data found for notification %s. "
876 , f_cnotificationname.c_str());
880 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not found", f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
881 l_estatus = eFrameworkunifiedStatusInvldParam;
883 // Close the mq handle
884 McClose(l_hReceiverMq);
885 l_hReceiverMq = NULL;
889 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
893 ////////////////////////////////////////////////////////////////////////////////////////////////////
894 /// NotificationpersistentserviceGetPersistentNotificationData
895 /// This function is used to get the list of persistent notifications and data associated with it.
896 ////////////////////////////////////////////////////////////////////////////////////////////////////
897 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceGetPersistentNotificationData(std::vector<CNotificationsToPersist *>
898 *f_pvpersistnotification,
899 const EFrameworkunifiedNotificationType f_enotificationtype,
900 UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
901 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
902 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
904 CNotification *l_pNotification = NULL;
905 CStateNotification *l_pStateNotification = NULL;
906 CStatePersistenceNotification *l_pStatePersistenceNotification = NULL;
908 std::string l_cNotificationName = "";
909 CNotificationsToPersist *l_pNotificationsToPersist = NULL;
910 const CPersistentData *l_pPData = NULL;
912 std::vector<std::string> *l_pvPersistentList = NULL;
914 // iterator for retrieving notifications from map of notifications
915 Notification_Iterator_Type l_itNotification;
917 if (eFrameworkunifiedPersistedStateUserVar == f_enotificationtype) {
918 l_pvPersistentList = m_pvUserPersistentList;
919 } else if (eFrameworkunifiedPersistedStateVar == f_enotificationtype) { // LCOV_EXCL_BR_LINE 6: f_enotificationtype must be eFrameworkunifiedPersistedStateUserVar or eFrameworkunifiedPersistedStateVar // NOLINT[whitespace/line_length]
920 l_pvPersistentList = m_pvPersistentList;
923 // copy all the notification data in map to received vector
924 if (NULL != f_pvpersistnotification && NULL != l_pvPersistentList) { // LCOV_EXCL_BR_LINE 6: f_pvpersistnotification and l_pvPersistentList can't be null // NOLINT[whitespace/line_length]
925 for (UI_32 l_uiCount = 0;
926 l_uiCount < l_pvPersistentList->size();
928 // get the persistent notification name from vector
929 l_cNotificationName = l_pvPersistentList->at(l_uiCount);
931 // search for notification in map
932 l_itNotification = m_pmNotificationList->find(l_cNotificationName);
934 // notification found in map
935 if (m_pmNotificationList->end() != l_itNotification) {
936 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Persistent Notification: %s", l_cNotificationName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
938 // get notification object from map
939 l_pNotification = (*l_itNotification).second;
941 if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: l_pNotification can't be NULL
942 if (eFrameworkunifiedPersistedStateVar == f_enotificationtype) {
943 l_pStatePersistenceNotification = static_cast<CStatePersistenceNotification *>(l_pNotification);
945 // get the notification's default data
946 if ((eFrameworkunifiedUserData == l_pStatePersistenceNotification->GetPersistentCategory() &&
947 (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedUserData)) ||
948 (eFrameworkunifiedFactoryData == l_pStatePersistenceNotification->GetPersistentCategory() &&
949 (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedFactoryData)) ||
950 (eFrameworkunifiedFactoryCustomerData == l_pStatePersistenceNotification->GetPersistentCategory() &&
951 (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedFactoryCustomerData)) ||
952 (eFrameworkunifiedDealerData == l_pStatePersistenceNotification->GetPersistentCategory() &&
953 (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedDealerData))) {
954 l_pPData = l_pStatePersistenceNotification->GetDefaultPersistentData();
956 l_pStateNotification = l_pStatePersistenceNotification;
958 // get the published notification data
959 if (l_pStateNotification->IsPublished()) {
960 l_pPData = l_pStateNotification->GetPersistentData();
962 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification not published");
966 l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
968 // if not to reset userdata
969 if (0 == (f_uinotificationpersistentservicepersistcategoryflag & eFrameworkunifiedUserData)) {
970 if (l_pStateNotification->IsPublished()) {
971 l_pPData = l_pStateNotification->GetPersistentData();
973 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification not published");
978 if ((NULL != l_pStateNotification) && (NULL != l_pPData)) {
979 l_pNotificationsToPersist = CreateNotificationObjectToPersist(l_pStateNotification, l_pPData); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
981 // insert the persistent data in map
982 f_pvpersistnotification->push_back(l_pNotificationsToPersist); // LCOV_EXCL_BR_LINE 11: unexpected branch
986 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "no data is stored in notification %s", l_cNotificationName.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
989 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
990 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification object is NULL for %s", l_cNotificationName.c_str()); // LCOV_EXCL_LINE 6: l_pNotification can't be NULL // NOLINT[whitespace/line_length]
993 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Non Persistent Notification: %s", l_cNotificationName.c_str());
997 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
998 l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 6: f_pvpersistnotification and l_pvPersistentList can't be null // NOLINT[whitespace/line_length]
1001 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1005 ////////////////////////////////////////////////////////////////////////////////////////////////////
1006 /// CreateNotificationObjectToPersist
1007 /// Creates the CNotificationsToPersist object from notification object and the persistent data.
1008 ////////////////////////////////////////////////////////////////////////////////////////////////////
1009 CNotificationsToPersist *CNotificationManager::CreateNotificationObjectToPersist(CStateNotification
1010 *f_pStateNotification,
1011 const CPersistentData *f_pdata) {
1012 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1014 CNotificationsToPersist *l_pNotificationsToPersist = NULL;
1015 CPersistentData *l_pData = NULL;
1017 if (NULL != f_pStateNotification && NULL != f_pdata) { // LCOV_EXCL_BR_LINE 6: f_pStateNotification and f_pdata can't be NULL // NOLINT[whitespace/line_length]
1018 if (f_pStateNotification->GetMaxMessageSize() >= f_pdata->m_uiMsgSize) {
1019 l_pNotificationsToPersist = new(std::nothrow) CNotificationsToPersist(); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
1021 if (NULL != l_pNotificationsToPersist) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
1022 l_pNotificationsToPersist->m_pPersistentData = new(std::nothrow) CPersistentData(); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
1023 l_pData = l_pNotificationsToPersist->m_pPersistentData;
1025 if (NULL != l_pData) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
1026 l_pNotificationsToPersist->m_cNotificationName = f_pStateNotification->GetNotificationName();
1027 l_pNotificationsToPersist->m_uiMaxMsgLength = f_pStateNotification->GetMaxMessageSize();
1028 l_pNotificationsToPersist->m_ePersistentType = f_pStateNotification->GetNotificationType();
1030 if (eFrameworkunifiedPersistedStateVar == l_pNotificationsToPersist->m_ePersistentType) {
1031 l_pNotificationsToPersist->m_ePersistCategory = (static_cast<CStatePersistenceNotification *>
1032 (f_pStateNotification))->GetPersistentCategory();
1035 l_pNotificationsToPersist->m_cPublisherName = f_pStateNotification->GetPublisherName();
1037 l_pData->m_uiMsgSize = f_pdata->m_uiMsgSize;
1038 l_pData->m_pMessage = new(std::nothrow) CHAR[l_pNotificationsToPersist->m_uiMaxMsgLength];
1040 if (NULL != l_pData->m_pMessage) { // LCOV_EXCL_BR_LINE 5: It's impossible to mock new() function
1041 std::memset(l_pData->m_pMessage, 0, l_pNotificationsToPersist->m_uiMaxMsgLength);
1042 std::memcpy(l_pData->m_pMessage, f_pdata->m_pMessage, f_pdata->m_uiMsgSize);
1045 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1046 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "memory not allocated for l_pNotificationsToPersist"); // LCOV_EXCL_LINE 5: It's impossible to mock new() function // NOLINT[whitespace/line_length]
1050 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1051 "Error persisting notfn, Data size of notification %s is %d greater than max registered size %d",
1052 f_pStateNotification->GetNotificationName().c_str(),
1053 f_pdata->m_uiMsgSize, f_pStateNotification->GetMaxMessageSize());
1056 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1057 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid parameter received"); // LCOV_EXCL_LINE 6: f_pStateNotification and f_pdata can't be NULL // NOLINT[whitespace/line_length]
1060 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1061 return l_pNotificationsToPersist;
1064 ////////////////////////////////////////////////////////////////////////////////////////////////////
1065 /// NotificationpersistentserviceSetPersistentNotificationData
1066 /// This function is used to create the persistent notifications object and fill the data related
1067 /// with it on system load.
1068 ////////////////////////////////////////////////////////////////////////////////////////////////////
1069 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceSetPersistentNotificationData(std::vector<CNotificationsToPersist *>
1070 *f_pvpersistnotification) {
1071 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1072 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1074 CStateNotification *l_pNotification = NULL;
1075 CNotificationsToPersist *l_pNotificationsToPersist = NULL;
1077 std::vector<std::string> *l_pvPersistentList = NULL;
1079 Persistent_Iterator_Type l_itPersistentData;
1081 // store all the notification data received in vector to map of CNotification and to vector of
1082 // persistent notification in case of persistent and user persistent notification
1083 if (NULL != f_pvpersistnotification) { // LCOV_EXCL_BR_LINE 6: double check, f_pvpersistnotification can't be NULL
1084 for (UI_32 l_uiCount = 0;
1085 l_uiCount < f_pvpersistnotification->size();
1087 // get the persistent data object
1088 l_pNotificationsToPersist = f_pvpersistnotification->at(l_uiCount);
1090 if (NULL != l_pNotificationsToPersist) { // LCOV_EXCL_BR_LINE 6: double check, l_pNotificationsToPersist can't be NULL // NOLINT[whitespace/line_length]
1091 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Persistent Type %d", l_pNotificationsToPersist->m_ePersistentType);
1093 if (eFrameworkunifiedPersistedStateVar == l_pNotificationsToPersist->m_ePersistentType) {
1094 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "PersistentState Notification");
1096 l_pNotification = new(std::nothrow) CStatePersistenceNotification(
1097 l_pNotificationsToPersist->m_cNotificationName,
1098 l_pNotificationsToPersist->m_uiMaxMsgLength,
1099 l_pNotificationsToPersist->m_ePersistCategory);
1101 l_pvPersistentList = m_pvPersistentList;
1102 } else if (eFrameworkunifiedPersistedStateUserVar == l_pNotificationsToPersist->m_ePersistentType) {
1103 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "PersistentStateUser Notification");
1105 l_pNotification = new(std::nothrow) CStatePersistenceUserNotification(
1106 l_pNotificationsToPersist->m_cNotificationName,
1107 l_pNotificationsToPersist->m_uiMaxMsgLength);
1109 l_pvPersistentList = m_pvUserPersistentList;
1110 } else if (eFrameworkunifiedImmediatePersistedStateVar == l_pNotificationsToPersist->m_ePersistentType) { // LCOV_EXCL_BR_LINE 6: l_pNotificationsToPersist->m_ePersistentType must be eFrameworkunifiedPersistedStateVar, eFrameworkunifiedPersistedStateUserVar, eFrameworkunifiedImmediatePersistedStateVar // NOLINT[whitespace/line_length]
1111 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "PersistentStateUser Notification");
1113 l_pNotification = new(std::nothrow) CStateNorPersistenceNotification(
1114 l_pNotificationsToPersist->m_cNotificationName,
1115 l_pNotificationsToPersist->m_uiMaxMsgLength,
1116 l_pNotificationsToPersist->m_uiDelay,
1117 l_pNotificationsToPersist->m_ePersistCategory);
1120 if (NULL != l_pNotification) { // LCOV_EXCL_BR_LINE 6: l_pNotification can't be NULL
1121 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Insert persistent notification object in map");
1123 l_pNotification->SetPersistentData(l_pNotificationsToPersist->m_pPersistentData->m_pMessage,
1124 l_pNotificationsToPersist->m_pPersistentData->m_uiMsgSize);
1126 l_pNotification->SetEventPublisher(l_pNotificationsToPersist->m_cPublisherName);
1128 if (NULL != m_pmNotificationList) { // LCOV_EXCL_BR_LINE 6: double check, m_pmNotificationList can't be NULL
1129 m_pmNotificationList->insert(make_pair(l_pNotificationsToPersist->m_cNotificationName, l_pNotification));
1131 if (NULL != l_pvPersistentList) {
1132 l_pvPersistentList->push_back(l_pNotificationsToPersist->m_cNotificationName);
1133 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Inserted persistent notification object in map");
1135 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Inserted persistent notification object in vector");
1137 // LCOV_EXCL_START 6: double check, m_pmNotificationList can't be NULL
1138 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1139 delete l_pNotification;
1140 l_pNotification = NULL;
1141 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification object not inserted in map/vector");
1145 // LCOV_EXCL_START 6: l_pNotification can't be NULL
1146 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1147 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "notification object is NULL");
1149 l_estatus = eFrameworkunifiedStatusNullPointer;
1153 // LCOV_EXCL_START 6: double check, l_pNotificationsToPersist can't be NULL
1154 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1155 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationsToPersist is NULL");
1156 l_estatus = eFrameworkunifiedStatusNullPointer;
1161 // LCOV_EXCL_START 6: double check, f_pvpersistnotification can't be NULL
1162 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1163 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistent data pointer is NULL");
1165 l_estatus = eFrameworkunifiedStatusNullPointer;
1169 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1173 ////////////////////////////////////////////////////////////////////////////////////////////////////
1174 /// RemoveUserSpecificNotificationEntry
1175 /// This function is used to remove the user persistent notifications entry
1176 ////////////////////////////////////////////////////////////////////////////////////////////////////
1177 EFrameworkunifiedStatus CNotificationManager::RemoveUserSpecificNotificationEntry() { // LCOV_EXCL_START 100: never be used
1178 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1179 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1180 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1182 std::string l_cNotificationName;
1184 std::vector<std::string>::iterator l_itNotificationName;
1186 // iterator to find notification from map of notifications
1187 Notification_Iterator_Type l_itNotification;
1189 CNotification *l_pNotification = NULL;
1191 for (l_itNotificationName = m_pvUserPersistentList->begin() ; l_itNotificationName < m_pvUserPersistentList->end() ;
1192 l_itNotificationName++) {
1193 l_cNotificationName = *(l_itNotificationName);
1195 // check if this notification's object present in map
1196 l_itNotification = m_pmNotificationList->find(l_cNotificationName);
1198 if (m_pmNotificationList->end() != l_itNotification) {
1199 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification found in map");
1201 // get the notification object pointer from map
1202 l_pNotification = (*l_itNotification).second;
1204 if (NULL != l_pNotification) {
1205 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification Object");
1207 // delete the notification
1208 delete l_pNotification;
1209 l_pNotification = NULL;
1211 m_pmNotificationList->erase(l_itNotification);
1213 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Deleting Notification name from vector");
1214 m_pvUserPersistentList->erase(l_itNotificationName);
1216 l_itNotificationName = m_pvUserPersistentList->begin();
1219 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification not found.");
1221 l_estatus = eFrameworkunifiedStatusFail;
1224 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1229 EFrameworkunifiedStatus CNotificationManager::GetNotificationInfo(const std::string &f_cnotificationname, // LCOV_EXCL_START 100: never be used // NOLINT[whitespace/line_length]
1230 CNotificationsToPersist *&f_pnotificationstopersist) {
1231 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1232 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1233 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1235 CNotification *l_pNotification = NULL;
1236 CStateNotification *l_pStateNotification = NULL;
1237 const CPersistentData *l_pPData = NULL;
1239 l_pNotification = SearchNotification(f_cnotificationname);
1240 l_pStateNotification = static_cast<CStateNotification *>(l_pNotification);
1242 if (NULL != l_pStateNotification) {
1243 if (l_pStateNotification->IsPublished()) {
1244 l_pPData = l_pStateNotification->GetPersistentData();
1246 if (NULL != l_pPData) {
1247 f_pnotificationstopersist = new(std::nothrow) CNotificationsToPersist();
1249 if (NULL == f_pnotificationstopersist) {
1250 l_estatus = eFrameworkunifiedStatusNullPointer;
1251 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation error for f_pnotificationstopersist");
1254 if (eFrameworkunifiedStatusOK == l_estatus) {
1255 f_pnotificationstopersist->m_pPersistentData = new(std::nothrow) CPersistentData();
1257 if (NULL == f_pnotificationstopersist->m_pPersistentData) {
1258 l_estatus = eFrameworkunifiedStatusNullPointer;
1259 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation error for f_pnotificationstopersist->m_pPersistentData");
1263 if (eFrameworkunifiedStatusOK == l_estatus) {
1264 f_pnotificationstopersist->m_cNotificationName = l_pStateNotification->GetNotificationName();
1265 f_pnotificationstopersist->m_uiMaxMsgLength = l_pStateNotification->GetMaxMessageSize();
1266 f_pnotificationstopersist->m_cPublisherName = l_pStateNotification->GetPublisherName();
1267 f_pnotificationstopersist->m_ePersistentType = l_pStateNotification->GetNotificationType();
1269 if (eFrameworkunifiedPersistedStateVar == f_pnotificationstopersist->m_ePersistentType) {
1270 f_pnotificationstopersist->m_ePersistCategory = (static_cast<CStatePersistenceNotification *>
1271 (l_pStateNotification))->GetPersistentCategory();
1274 if (eFrameworkunifiedImmediatePersistedStateVar == f_pnotificationstopersist->m_ePersistentType) {
1275 CStateNorPersistenceNotification *l_pStateNorPersistenceNotification =
1276 static_cast<CStateNorPersistenceNotification *>(l_pStateNotification);
1277 f_pnotificationstopersist->m_uiDelay = l_pStateNorPersistenceNotification->GetPersistenceDelay();
1278 f_pnotificationstopersist->m_ePersistCategory = (static_cast<CStateNorPersistenceNotification *>
1279 (l_pStateNotification))->GetPersistentCategory();
1282 f_pnotificationstopersist->m_pPersistentData->m_pMessage = new(std::nothrow)
1283 CHAR[f_pnotificationstopersist->m_uiMaxMsgLength];
1284 std::memset(f_pnotificationstopersist->m_pPersistentData->m_pMessage, 0,
1285 f_pnotificationstopersist->m_uiMaxMsgLength);
1286 std::memcpy(f_pnotificationstopersist->m_pPersistentData->m_pMessage,
1287 l_pPData->m_pMessage, l_pPData->m_uiMsgSize);
1289 f_pnotificationstopersist->m_pPersistentData->m_uiMsgSize = l_pPData->m_uiMsgSize;
1292 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "No data is stored in notification %s", f_cnotificationname.c_str());
1295 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Notification %s not published", f_cnotificationname.c_str());
1298 l_estatus = eFrameworkunifiedStatusNullPointer;
1301 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1306 ////////////////////////////////////////////////////////////////////////////////////////////////////
1307 /// NotificationpersistentserviceSetDefaultPersistentNotificationData
1308 /// This function is used to set the default data of persistent notification
1309 ////////////////////////////////////////////////////////////////////////////////////////////////////
1310 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceSetDefaultPersistentNotificationData(const std::string &f_cnotificationname,
1312 const UI_32 f_uimsgsize) {
1313 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1314 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1316 // pointer of notification object
1317 CStateNotification *l_pStateNotification = SearchPersistenceNotification(f_cnotificationname);
1319 if (NULL != l_pStateNotification) {
1320 l_estatus = l_pStateNotification->SetDefaultPersistentData(f_pmessage, f_uimsgsize);
1322 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to set default notification data for %s, notification does not exists",
1323 f_cnotificationname.c_str());
1326 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1330 ////////////////////////////////////////////////////////////////////////////////////////////////////
1331 /// NotificationpersistentserviceSetPersistentCategory
1332 /// This function is used to set the persistent type of persistent notification
1333 ////////////////////////////////////////////////////////////////////////////////////////////////////
1334 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentserviceSetPersistentCategory(const std::string &f_cnotificationname,
1335 const EFrameworkunifiedPersistCategory f_epersistcategory) {
1336 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1337 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1339 // pointer of notification object
1340 CStateNotification *l_pStateNotification = SearchPersistenceNotification(f_cnotificationname);
1342 if (NULL != l_pStateNotification) {
1343 EFrameworkunifiedNotificationType l_eNotificationType = l_pStateNotification->GetNotificationType();
1345 if (eFrameworkunifiedPersistedStateVar == l_eNotificationType) {
1346 l_estatus = (static_cast<CStatePersistenceNotification *>(l_pStateNotification))->SetPersistentCategory(
1347 f_epersistcategory);
1348 } else if (eFrameworkunifiedImmediatePersistedStateVar == l_eNotificationType) {
1349 l_estatus = (static_cast<CStateNorPersistenceNotification *>(l_pStateNotification))->SetPersistentCategory(
1350 f_epersistcategory);
1352 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Cannot set category %d for notification %s of type %d", f_epersistcategory,
1353 f_cnotificationname.c_str(), l_eNotificationType);
1356 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1357 "Cannot set category %d for %s, Either not registered or not a persistent notification",
1358 f_epersistcategory, f_cnotificationname.c_str()); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
1361 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1365 ////////////////////////////////////////////////////////////////////////////////////////////////
1366 /// NotificationpersistentservicePublishImmediateNotification
1367 /// This function publish the immediate notification f_cnotificationname to all its subscribers.
1368 /// This API is called when service updates the immediate notification data in persistent memory
1369 /// using synchronous API.
1370 ////////////////////////////////////////////////////////////////////////////////////////////////
1371 EFrameworkunifiedStatus CNotificationManager::NotificationpersistentservicePublishImmediateNotification(const std::string &f_cservicename,
1372 const std::string &f_cnotificationname,
1374 const UI_32 f_uimsgsize) {
1375 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1376 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1378 if (f_cservicename.empty() || f_cnotificationname.empty()) {
1379 l_estatus = eFrameworkunifiedStatusInvldParam;
1381 // get the notification object from map
1382 CStateNotification *l_pStateNotf = SearchPersistenceNotification(f_cnotificationname);
1384 if (NULL != l_pStateNotf) {
1385 if (eFrameworkunifiedImmediatePersistedStateVar == l_pStateNotf->GetNotificationType()) {
1386 CStateNorPersistenceNotification *l_pImmediateNotf =
1387 static_cast<CStateNorPersistenceNotification *>(l_pStateNotf);
1389 // publish the notification
1390 if (eFrameworkunifiedStatusOK != (l_estatus = l_pImmediateNotf->PublishNotification(f_cservicename,
1393 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error publishing notification %s published by %s, status: %d",
1394 f_cnotificationname.c_str(), f_cservicename.c_str(), l_estatus);
1397 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s is not registered as immediate persistence by service %s",
1398 f_cnotificationname.c_str(), f_cservicename.c_str());
1401 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification %s not registered by service %s", f_cnotificationname.c_str(),
1402 f_cservicename.c_str());
1404 l_estatus = eFrameworkunifiedStatusNullPointer;
1408 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1412 #ifdef NPP_PROFILEINFO_ENABLE
1414 EFrameworkunifiedStatus CNotificationManager::GetNotificationProfilingData(std::string &f_cnotificationprofileInfo) {
1415 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1416 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1418 Notification_Iterator_Type l_itNotification;
1419 NotifReceiver_Iterator_Type l_itNotifReceiver_Iterator;
1421 CNotification *l_pNotification = NULL;
1422 NotifReceiver_Type *l_pSubscriberList = NULL;
1424 std::stringstream ss;
1425 UI_32 l_uiSubscriberCnt = 0;
1427 std::string l_cPublisher = "";
1428 std::string l_cNotification = "";
1431 if (NULL == m_pmNotificationList) {
1432 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification List m_pmNotificationList is NULL in notification manager");
1433 l_estatus = eFrameworkunifiedStatusFail;
1436 if (eFrameworkunifiedStatusOK == l_estatus && m_pmNotificationList->empty()) {
1437 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification List m_pmNotificationList Empty in notification manager");
1438 l_estatus = eFrameworkunifiedStatusFail;
1441 if (eFrameworkunifiedStatusOK == l_estatus) {
1442 f_cnotificationprofileInfo.append("Application Name,");
1443 f_cnotificationprofileInfo.append("Notification Name,");
1444 f_cnotificationprofileInfo.append("Type,");
1445 f_cnotificationprofileInfo.append("Length,");
1446 f_cnotificationprofileInfo.append("Subscribed By,");
1447 f_cnotificationprofileInfo.append("Subscribers Count");
1449 for (l_itNotification = m_pmNotificationList->begin();
1450 l_itNotification != m_pmNotificationList->end();
1451 l_itNotification++) {
1452 l_pNotification = (*l_itNotification).second;
1453 if (NULL == l_pNotification) {
1454 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification object ptr is NULL");
1455 l_estatus = eFrameworkunifiedStatusFail;
1457 l_cPublisher = l_pNotification->GetPublisherName();
1458 if (l_cPublisher.empty()) {
1459 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Publisher name empty");
1460 l_estatus = eFrameworkunifiedStatusFail;
1463 l_cNotification = l_pNotification->GetNotificationName();
1464 if (l_cNotification.empty()) {
1465 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Notification name empty");
1466 l_estatus = eFrameworkunifiedStatusFail;
1469 l_pSubscriberList = l_pNotification->GetSubscriberList();
1470 if (NULL == l_pSubscriberList) {
1471 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Subscribers List ptr is NULL");
1472 l_estatus = eFrameworkunifiedStatusFail;
1476 if (eFrameworkunifiedStatusOK == l_estatus) {
1477 f_cnotificationprofileInfo.append("\n");
1479 f_cnotificationprofileInfo.append(l_cPublisher);
1480 f_cnotificationprofileInfo.append(",");
1482 f_cnotificationprofileInfo.append(l_cNotification);
1483 f_cnotificationprofileInfo.append(",");
1485 switch (l_pNotification->GetNotificationType()) {
1486 case eFrameworkunifiedNotificationVar : {
1487 f_cnotificationprofileInfo.append("Regular");
1491 case eFrameworkunifiedStateVar : {
1492 f_cnotificationprofileInfo.append("State");
1496 case eFrameworkunifiedPersistedStateVar : {
1497 f_cnotificationprofileInfo.append("PersistenceState");
1501 case eFrameworkunifiedPersistedStateUserVar : {
1502 f_cnotificationprofileInfo.append("UserPersistenceState");
1506 case eFrameworkunifiedImmediatePersistedStateVar : {
1507 f_cnotificationprofileInfo.append("ImmediatePersistenceState");
1511 case eFrameworkunifiedUnknown: {
1512 f_cnotificationprofileInfo.append("Unknown");
1519 f_cnotificationprofileInfo.append(",");
1521 ss << l_pNotification->GetMaxMessageSize();
1522 f_cnotificationprofileInfo.append(ss.str());
1524 f_cnotificationprofileInfo.append(",\"");
1526 l_uiSubscriberCnt = 0;
1527 for (l_itNotifReceiver_Iterator = l_pSubscriberList->begin();
1528 l_pSubscriberList->end() != l_itNotifReceiver_Iterator;) {
1529 f_cnotificationprofileInfo.append(l_itNotifReceiver_Iterator->first);
1530 ++l_uiSubscriberCnt;
1532 ++l_itNotifReceiver_Iterator;
1534 if (l_pSubscriberList->end() != l_itNotifReceiver_Iterator) {
1535 f_cnotificationprofileInfo.append(",");
1539 f_cnotificationprofileInfo.append("\",");
1541 ss << l_uiSubscriberCnt;
1542 f_cnotificationprofileInfo.append(ss.str());
1546 l_estatus = eFrameworkunifiedStatusOK;
1549 } catch (std::exception &exp) {
1550 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Exception:: %s", exp.what());
1551 l_estatus = eFrameworkunifiedStatusFail;
1554 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");