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 /// \ingroup tag_NSFramework
19 /// \brief Framework wrapper over the NPService interface APIs
23 ///////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////////////
30 #include <native_service/frameworkunified_framework_types.h>
31 #include <native_service/frameworkunified_framework_if.h>
32 #include <native_service/ns_np_service_if.h>
33 #include <native_service/ns_np_service_protocol.h>
34 #include <other_service/strlcpy.h>
36 #include "frameworkunified_framework_core.h"
37 #include "ns_np_service_internal.h"
39 ////////////////////////////////////////////////////////////////////////////////////////////
40 /// FrameworkunifiedNPRegisterNotification
41 ////////////////////////////////////////////////////////////////////////////////////////////
42 EFrameworkunifiedStatus FrameworkunifiedNPRegisterNotification(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
43 const EFrameworkunifiedNotificationType persType) {
44 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
46 if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
47 if (strlen(pNotification) && strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
48 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
49 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
51 NotificationInfo notifInfo = {};
52 strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
53 notifInfo.persType = persType;
54 notifInfo.maxLength = max_length;
56 eStatus = NPRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, ¬ifInfo);
58 eStatus = eFrameworkunifiedStatusInvldParam;
61 eStatus = eFrameworkunifiedStatusInvldParam;
67 EFrameworkunifiedStatus FrameworkunifiedNPRegisterImmediatePersistNotification(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
69 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
71 if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
72 if (strlen(pNotification) && strlen(pNotification) <= MAX_STRING_SIZE_NOTIFICATION) {
73 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
74 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
76 ImmediateNotificationInfo notifInfo = {};
77 strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
78 notifInfo.persType = eFrameworkunifiedImmediatePersistedStateVar;
79 notifInfo.maxLength = max_length;
80 notifInfo.delay = delay;
82 eStatus = NPRegisterImmediateNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, ¬ifInfo);
84 eStatus = eFrameworkunifiedStatusInvldParam;
87 eStatus = eFrameworkunifiedStatusInvldParam;
93 ////////////////////////////////////////////////////////////////////////////////////////////
94 /// FrameworkunifiedNPPersistentSync
95 ////////////////////////////////////////////////////////////////////////////////////////////
96 EFrameworkunifiedStatus FrameworkunifiedNPPersistentSync(HANDLE hApp) {
97 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
98 if (frameworkunifiedCheckValidAppHandle(hApp)) {
99 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
100 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
102 eStatus = NPPersistentSync(pMqInfo->cSrcName, pMqInfo->hMsgQ, pMqInfo->sessionId, pApp->cAppName);
104 eStatus = eFrameworkunifiedStatusInvldParam;
108 ////////////////////////////////////////////////////////////////////////////////////////////
109 /// FrameworkunifiedNPRegisterNotifications
110 ////////////////////////////////////////////////////////////////////////////////////////////
111 EFrameworkunifiedStatus FrameworkunifiedNPRegisterNotifications(HANDLE hApp, const FrameworkunifiedNotificationsList *pList, UI_32 uiListLength) {
112 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
113 if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
114 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
115 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
117 if (NULL != pMqInfo) {
118 NotificationInfo *pNotificationList =
119 reinterpret_cast<NotificationInfo *>(malloc(sizeof(NotificationInfo) * uiListLength));
121 for (UI_32 i = 0; i < uiListLength; ++i) {
122 strlcpy(pNotificationList[i].notificationName, pList[i].cNotification,
123 sizeof(pNotificationList[i].notificationName));
124 pNotificationList[i].maxLength = pList[i].uiLengthData;
125 pNotificationList[i].persType = pList[i].persType;
127 eStatus = NPRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pNotificationList);
129 free(pNotificationList);
130 pNotificationList = NULL; // mb20110110 Fixed per comment 295
132 eStatus = eFrameworkunifiedStatusNullPointer;
135 eStatus = eFrameworkunifiedStatusInvldParam;
141 ////////////////////////////////////////////////////////////////////////////////////////////
142 /// FrameworkunifiedNPUnRegisterNotification
143 ////////////////////////////////////////////////////////////////////////////////////////////
144 EFrameworkunifiedStatus FrameworkunifiedNPUnRegisterNotification(HANDLE hApp, PCSTR pNotification) {
145 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
147 if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification && strlen(pNotification)) {
148 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
149 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
151 NotificationInfo notifInfo = {};
152 strlcpy(notifInfo.notificationName, pNotification, sizeof(notifInfo.notificationName));
154 eStatus = NPUnRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, 1, ¬ifInfo);
156 eStatus = eFrameworkunifiedStatusInvldParam;
162 ////////////////////////////////////////////////////////////////////////////////////////////
163 /// FrameworkunifiedNPUnRegisterNotifications
164 ////////////////////////////////////////////////////////////////////////////////////////////
165 EFrameworkunifiedStatus FrameworkunifiedNPUnRegisterNotifications(HANDLE hApp, const FrameworkunifiedNotificationsList *pList, UI_32 uiListLength) {
166 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
167 if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
168 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
169 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
170 if (NULL != pMqInfo) {
171 NotificationInfo *pNotificationList =
172 reinterpret_cast<NotificationInfo *>(malloc(sizeof(NotificationInfo) * uiListLength));
174 for (UI_32 i = 0; i < uiListLength; ++i) {
175 strlcpy(pNotificationList[i].notificationName, pList[i].cNotification,
176 sizeof(pNotificationList[i].notificationName));
177 pNotificationList[i].maxLength = pList[i].uiLengthData;
178 pNotificationList[i].persType = pList[i].persType;
180 eStatus = NPUnRegisterNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pNotificationList);
182 free(pNotificationList);
184 eStatus = eFrameworkunifiedStatusNullPointer;
187 eStatus = eFrameworkunifiedStatusInvldParam;
193 ////////////////////////////////////////////////////////////////////////////////////////////
194 /// FrameworkunifiedNPPublishNotification
195 ////////////////////////////////////////////////////////////////////////////////////////////
196 EFrameworkunifiedStatus FrameworkunifiedNPPublishNotification(HANDLE hApp, PCSTR pNotification,
197 PCVOID pData, UI_32 iLength) {
198 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
200 if (frameworkunifiedCheckValidAppHandle(hApp) && NULL != pNotification) {
201 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
202 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
204 if ((NULL != pMqInfo->hMsgQ) && (0 != std::strlen(pApp->cAppName))) {
205 eStatus = NPPublishNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification, pData, iLength);
207 eStatus = eFrameworkunifiedStatusInvldHandle;
210 eStatus = eFrameworkunifiedStatusInvldParam;
217 ////////////////////////////////////////////////////////////////////////////////////////////
218 /// FrameworkunifiedNPSubscribeToNotification
219 ////////////////////////////////////////////////////////////////////////////////////////////
220 EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotification(HANDLE hApp, PCSTR pNotification) {
221 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
223 if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
224 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
225 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
227 eStatus = NPSubscribeToNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
229 eStatus = eFrameworkunifiedStatusInvldParam;
236 EFrameworkunifiedStatus FrameworkunifiedNPSubscribeToNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList,
237 UI_32 uiListLength) {
238 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
240 if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
241 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
242 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
244 SubscribeInfo *pSubscribeList =
245 reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
247 for (UI_32 i = 0; i < uiListLength; ++i) {
248 strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
249 sizeof(pSubscribeList[i].notificationName));
251 eStatus = NPSubscribeToNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
253 free(pSubscribeList);
254 pSubscribeList = NULL; // mb20110110 Fixed per comment 307
256 eStatus = eFrameworkunifiedStatusInvldParam;
263 ////////////////////////////////////////////////////////////////////////////////////////////
264 /// FrameworkunifiedNPUnSubscribeNotifications
265 ////////////////////////////////////////////////////////////////////////////////////////////
266 EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotifications(HANDLE hApp, const FrameworkunifiedNotificationCallbackHandler *pList,
267 UI_32 uiListLength) {
268 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
270 if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
271 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
272 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
274 SubscribeInfo *pSubscribeList =
275 reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
277 for (UI_32 i = 0; i < uiListLength; ++i) {
278 strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification, MAX_STRING_SIZE_NOTIFICATION);
280 eStatus = NPUnsubscribeFromNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
282 free(pSubscribeList);
283 pSubscribeList = NULL; // mb20110110 Fixed per comment 307
285 eStatus = eFrameworkunifiedStatusInvldParam;
292 ////////////////////////////////////////////////////////////////////////////////////////////
293 /// FrameworkunifiedNPUnsubscribeFromNotification
294 ////////////////////////////////////////////////////////////////////////////////////////////
295 EFrameworkunifiedStatus FrameworkunifiedNPUnsubscribeFromNotification(HANDLE hApp, PCSTR pNotification) {
296 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
298 if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
299 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
300 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
302 eStatus = NPUnsubscribeFromNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
304 eStatus = eFrameworkunifiedStatusInvldParam;
310 ////////////////////////////////////////////////////////////////////////////////////////////
311 /// FrameworkunifiedNPReadPersistedData
312 ////////////////////////////////////////////////////////////////////////////////////////////
313 EFrameworkunifiedStatus FrameworkunifiedNPReadPersistedData(HANDLE hApp, PCSTR pNotification) {
314 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
316 if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
317 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
318 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
320 eStatus = NPReadPersistedData(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
322 eStatus = eFrameworkunifiedStatusInvldParam;
328 ////////////////////////////////////////////////////////////////////////////////////////////
329 /// FrameworkunifiedNPSavePersistentData
330 ////////////////////////////////////////////////////////////////////////////////////////////
331 // LCOV_EXCL_START 8: dead code
332 EFrameworkunifiedStatus FrameworkunifiedNPSavePersistentData(HANDLE hApp) {
333 AGL_ASSERT_NOT_TESTED();
334 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
336 if (frameworkunifiedCheckValidAppHandle(hApp)) {
337 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
338 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
340 eStatus = NPSavePersistentData(pMqInfo->hMsgQ, pApp->cAppName);
342 eStatus = eFrameworkunifiedStatusInvldParam;
350 ////////////////////////////////////////////////////////////////////////////////////////////
351 /// FrameworkunifiedNPRegisterPersistentFile
352 ////////////////////////////////////////////////////////////////////////////////////////////
353 EFrameworkunifiedStatus FrameworkunifiedNPRegisterPersistentFile(HANDLE hApp, PCSTR pTag, BOOL bIsUserFile) {
354 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
355 if (frameworkunifiedCheckValidAppHandle(hApp) && pTag) {
356 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
357 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
358 if (NULL != pMqInfo) {
359 eStatus = NPRegisterPersistentFile(pMqInfo->hMsgQ, pApp->cAppName, pTag, bIsUserFile);
361 eStatus = eFrameworkunifiedStatusNullPointer;
364 eStatus = eFrameworkunifiedStatusInvldParam;
371 ////////////////////////////////////////////////////////////////////////////////////////////
372 /// FrameworkunifiedNPLoadPersistentFile
373 ////////////////////////////////////////////////////////////////////////////////////////////
374 EFrameworkunifiedStatus FrameworkunifiedNPLoadPersistentFile(HANDLE hApp, PCSTR pDstFilePath, PCSTR pTag, HANDLE hUser) {
375 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
377 if (frameworkunifiedCheckValidAppHandle(hApp) && pDstFilePath && pTag) {
378 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
379 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
381 if (NULL != pMqInfo) {
382 eStatus = NPLoadPersistentFile(pMqInfo->hMsgQ, pApp->cAppName, pDstFilePath, pTag, hUser);
384 eStatus = eFrameworkunifiedStatusNullPointer;
387 eStatus = eFrameworkunifiedStatusInvldParam;
394 ////////////////////////////////////////////////////////////////////////////////////////////
395 /// FrameworkunifiedNPReleasePersistentFile
396 ////////////////////////////////////////////////////////////////////////////////////////////
397 EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFile(HANDLE hApp, BOOL bIsPersist, PCSTR pTag,
398 PCSTR pFullFilePath, HANDLE hUser) {
399 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
400 if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFilePath) {
401 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
402 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
404 if (NULL != pMqInfo) {
405 EFrameworkunifiedReleaseType eReleaseType = (bIsPersist == FALSE) ? eFrameworkunifiedNotOnRelease : eFrameworkunifiedPersistOnShutdown;
406 eStatus = NPReleasePersistentFile(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
407 pFullFilePath, hUser);
409 eStatus = eFrameworkunifiedStatusNullPointer;
412 eStatus = eFrameworkunifiedStatusInvldParam;
418 ////////////////////////////////////////////////////////////////////////////////////////////
419 /// FrameworkunifiedNPReleasePersistentFile
420 ////////////////////////////////////////////////////////////////////////////////////////////
421 EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFile(HANDLE hApp, EFrameworkunifiedReleaseType eReleaseType, PCSTR pTag,
422 PCSTR pFullFilePath, HANDLE hUser) {
423 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
424 if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFilePath) {
425 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
426 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
428 if (NULL != pMqInfo) {
429 eStatus = NPReleasePersistentFile(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
430 pFullFilePath, hUser);
432 eStatus = eFrameworkunifiedStatusNullPointer;
435 eStatus = eFrameworkunifiedStatusInvldParam;
441 ////////////////////////////////////////////////////////////////////////////////////////////
442 /// FrameworkunifiedNPRegisterPersistentFolder
443 ////////////////////////////////////////////////////////////////////////////////////////////
444 EFrameworkunifiedStatus FrameworkunifiedNPRegisterPersistentFolder(HANDLE hApp, PCSTR pTag, BOOL bIsUserFolder) {
445 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
446 if (frameworkunifiedCheckValidAppHandle(hApp) && pTag) {
447 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
448 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
450 if (NULL != pMqInfo) {
451 eStatus = NPRegisterPersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, pTag, bIsUserFolder);
453 eStatus = eFrameworkunifiedStatusNullPointer;
456 eStatus = eFrameworkunifiedStatusInvldParam;
463 ////////////////////////////////////////////////////////////////////////////////////////////
464 /// FrameworkunifiedNPLoadPersistentFolder
465 ////////////////////////////////////////////////////////////////////////////////////////////
466 EFrameworkunifiedStatus FrameworkunifiedNPLoadPersistentFolder(HANDLE hApp, PCSTR pDstFolderPath, PCSTR pTag, HANDLE hUser) {
467 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
468 if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pDstFolderPath) {
469 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
470 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
471 if (NULL != pMqInfo) {
472 eStatus = NPLoadPersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, pDstFolderPath, pTag, hUser);
474 eStatus = eFrameworkunifiedStatusNullPointer;
477 eStatus = eFrameworkunifiedStatusInvldParam;
484 ////////////////////////////////////////////////////////////////////////////////////////////
485 /// FrameworkunifiedNPReleasePersistentFolder
486 ////////////////////////////////////////////////////////////////////////////////////////////
487 EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFolder(HANDLE hApp, BOOL bIsPersist, PCSTR pTag, PCSTR pFullFolderPath,
489 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
490 if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFolderPath) {
491 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
492 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
493 if (NULL != pMqInfo) {
494 EFrameworkunifiedReleaseType eReleaseType = (bIsPersist == FALSE) ? eFrameworkunifiedNotOnRelease : eFrameworkunifiedPersistOnShutdown;
495 eStatus = NPReleasePersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
496 pFullFolderPath, hUser);
498 eStatus = eFrameworkunifiedStatusNullPointer;
501 eStatus = eFrameworkunifiedStatusInvldParam;
506 ////////////////////////////////////////////////////////////////////////////////////////////
507 /// FrameworkunifiedNPReleasePersistentFolder
508 ////////////////////////////////////////////////////////////////////////////////////////////
509 EFrameworkunifiedStatus FrameworkunifiedNPReleasePersistentFolder(HANDLE hApp, EFrameworkunifiedReleaseType eReleaseType, PCSTR pTag,
510 PCSTR pFullFolderPath,
512 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
513 if (frameworkunifiedCheckValidAppHandle(hApp) && pTag && pFullFolderPath) {
514 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
515 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
516 if (NULL != pMqInfo) {
517 eStatus = NPReleasePersistentFolder(pMqInfo->hMsgQ, pApp->cAppName, eReleaseType, pTag,
518 pFullFolderPath, hUser);
520 eStatus = eFrameworkunifiedStatusNullPointer;
523 eStatus = eFrameworkunifiedStatusInvldParam;
530 // defined for backward compatibility; will be removed once the persistence feature is finalized
531 EFrameworkunifiedStatus FrameworkunifiedRegisterPersistentStorage(HANDLE hApp, PCSTR pFullFilePath) {
532 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
534 if (frameworkunifiedCheckValidAppHandle(hApp) && pFullFilePath) {
535 eStatus = FrameworkunifiedNPRegisterPersistentFile(hApp, pFullFilePath);
537 eStatus = eFrameworkunifiedStatusInvldParam;
542 EFrameworkunifiedStatus FrameworkunifiedReleaseFileToPersistentStorage(HANDLE hApp, PCSTR pFullFilePath, BOOL persist) {
543 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
545 if (frameworkunifiedCheckValidAppHandle(hApp) && pFullFilePath) {
546 eStatus = FrameworkunifiedNPReleasePersistentFile(hApp, persist, pFullFilePath, pFullFilePath);
548 eStatus = eFrameworkunifiedStatusInvldParam;
554 ////////////////////////////////////////////////////////////////////////////////////////////
555 /// FrameworkunifiedNPHSMRegisterNotificationsEvents
556 /// API to send message to Notification Service to register a notification
557 ////////////////////////////////////////////////////////////////////////////////////////////
558 EFrameworkunifiedStatus FrameworkunifiedNPHSMRegisterNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationsList *pList,
559 UI_32 uiListLength) {
560 return FrameworkunifiedNPRegisterNotifications(hApp, pList, uiListLength);
563 ////////////////////////////////////////////////////////////////////////////////////////////
564 /// FrameworkunifiedNPHSMRegisterNotificatsionEvent
565 /// API to send message to Notification Service to register a notification
566 ////////////////////////////////////////////////////////////////////////////////////////////
567 EFrameworkunifiedStatus FrameworkunifiedNPHSMRegisterNotificatsionEvent(HANDLE hApp, PCSTR pNotification, const UI_32 max_length,
568 const EFrameworkunifiedNotificationType persType) {
569 return FrameworkunifiedNPRegisterNotification(hApp, pNotification, max_length, persType);
572 ////////////////////////////////////////////////////////////////////////////////////////////
573 /// FrameworkunifiedNPHSMUnRegisterNotificationEvent
574 /// API to send message to Notification Service to remove a notification
575 ////////////////////////////////////////////////////////////////////////////////////////////
576 EFrameworkunifiedStatus FrameworkunifiedNPHSMUnRegisterNotificationEvent(HANDLE hApp, PCSTR pNotification) {
577 return FrameworkunifiedNPUnRegisterNotification(hApp, pNotification);
580 ////////////////////////////////////////////////////////////////////////////////////////////
581 /// FrameworkunifiedNPHSMSubscribeToNotificationsEvents
582 /// API to send message to Notification Service to add multiple subscriptions list for
583 /// that notification
584 ////////////////////////////////////////////////////////////////////////////////////////////
585 EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationsEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
586 UI_32 uiListLength) {
587 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
589 if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
590 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
591 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
593 SubscribeInfo *pSubscribeList =
594 reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
596 for (UI_32 i = 0; i < uiListLength; ++i) {
597 strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
598 sizeof(pSubscribeList[i].notificationName));
600 eStatus = NPSubscribeToNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
602 free(pSubscribeList);
603 pSubscribeList = NULL; // mb20110110 Fixed per comment 307
605 eStatus = eFrameworkunifiedStatusInvldParam;
611 ////////////////////////////////////////////////////////////////////////////////////////////
612 /// FrameworkunifiedNPHSMSubscribeToNotificationEvent
613 /// API to send message to Notification Service to add to subscription list for
614 /// that notification
615 ////////////////////////////////////////////////////////////////////////////////////////////
616 EFrameworkunifiedStatus FrameworkunifiedNPHSMSubscribeToNotificationEvent(HANDLE hApp, PCSTR pNotification) {
617 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
619 if (frameworkunifiedCheckValidAppHandle(hApp) && pNotification) {
620 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
621 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
623 eStatus = NPSubscribeToNotification(pMqInfo->hMsgQ, pApp->cAppName, pNotification);
625 eStatus = eFrameworkunifiedStatusInvldParam;
631 ////////////////////////////////////////////////////////////////////////////////////////////
632 /// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent
633 /// API to send message to Notification Service to remove from subscription list for
634 /// that notification
635 ////////////////////////////////////////////////////////////////////////////////////////////
636 EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvent(HANDLE hApp, PCSTR pNotification) {
637 return FrameworkunifiedNPUnsubscribeFromNotification(hApp, pNotification);
640 ////////////////////////////////////////////////////////////////////////////////////////////
641 /// FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents
642 /// API to send message to Notification Service to remove from subscription list for
643 /// that notification
644 ////////////////////////////////////////////////////////////////////////////////////////////
645 EFrameworkunifiedStatus FrameworkunifiedNPHSMUnsubscribeFromNotificationEvents(HANDLE hApp, const FrameworkunifiedNotificationEvent *pList,
646 UI_32 uiListLength) {
647 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
649 if (frameworkunifiedCheckValidAppHandle(hApp) && pList) {
650 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
651 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
653 SubscribeInfo *pSubscribeList =
654 reinterpret_cast<SubscribeInfo *>(malloc(sizeof(SubscribeInfo) * uiListLength));
656 for (UI_32 i = 0; i < uiListLength; ++i) {
657 strlcpy(pSubscribeList[i].notificationName, pList[i].cNotification,
658 sizeof(pSubscribeList[i].notificationName));
660 eStatus = NPUnsubscribeFromNotifications(pMqInfo->hMsgQ, pApp->cAppName, uiListLength, pSubscribeList);
662 free(pSubscribeList);
663 pSubscribeList = NULL; // mb20110110 Fixed per comment 307
665 eStatus = eFrameworkunifiedStatusInvldParam;
671 ////////////////////////////////////////////////////////////////////////////////////////////
672 /// FrameworkunifiedNPSetPersonality
673 ////////////////////////////////////////////////////////////////////////////////////////////
674 EFrameworkunifiedStatus FrameworkunifiedNPSetPersonality(HANDLE hApp, PCSTR pUserName) {
675 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
677 if (frameworkunifiedCheckValidAppHandle(hApp) && pUserName) {
678 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
679 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
681 eStatus = NPSetPersonality(pMqInfo->hMsgQ, pApp->cAppName, pUserName);
683 eStatus = eFrameworkunifiedStatusInvldParam;
689 ////////////////////////////////////////////////////////////////////////////////////////////
690 /// FrameworkunifiedNPChangePersonality
691 ////////////////////////////////////////////////////////////////////////////////////////////
692 EFrameworkunifiedStatus FrameworkunifiedNPChangePersonality(HANDLE hApp, PCSTR pUserName) {
693 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
695 if (frameworkunifiedCheckValidAppHandle(hApp) && pUserName) {
696 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
697 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
699 eStatus = NPChangePersonality(pMqInfo->hMsgQ, pApp->cAppName, pUserName);
701 eStatus = eFrameworkunifiedStatusInvldParam;
707 ////////////////////////////////////////////////////////////////////////////////////////////
708 /// FrameworkunifiedSendStopToNSNPP
709 ////////////////////////////////////////////////////////////////////////////////////////////
710 EFrameworkunifiedStatus FrameworkunifiedSendStopToNSNPP(HANDLE hApp, EFrameworkunifiedShutdownType eShutdownType, UI_32 uiStopMsgData) {
711 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
713 if (frameworkunifiedCheckValidAppHandle(hApp)) {
714 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
715 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
717 eStatus = SendStopToNSNPP(pMqInfo->hMsgQ, pApp->cAppName, eShutdownType, uiStopMsgData);
719 eStatus = eFrameworkunifiedStatusInvldParam;
725 ////////////////////////////////////////////////////////////////////////////////////////////
726 /// FrameworkunifiedNPGetReadyStatusOfNPP
727 ////////////////////////////////////////////////////////////////////////////////////////////
728 EFrameworkunifiedStatus FrameworkunifiedNPGetReadyStatusOfNPP(HANDLE hApp) {
729 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
731 if (frameworkunifiedCheckValidAppHandle(hApp)) {
732 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
733 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
735 eStatus = NPGetReadyStatusOfNPP(pMqInfo->hMsgQ, pApp->cAppName);
737 eStatus = eFrameworkunifiedStatusInvldParam;
743 ////////////////////////////////////////////////////////////////////////////////////////////
744 /// FrameworkunifiedNPClearPersistedData
745 ////////////////////////////////////////////////////////////////////////////////////////////
746 EFrameworkunifiedStatus FrameworkunifiedNPClearPersistedData(HANDLE hApp, EFrameworkunifiedClearPersistence eFrameworkunifiedClearPersistenceScope) {
747 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
748 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
749 if (frameworkunifiedCheckValidAppHandle(hApp)) {
750 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
751 if (NULL != pMqInfo) {
752 eStatus = NPClearPersistedData(pMqInfo->hMsgQ, pApp->cAppName, eFrameworkunifiedClearPersistenceScope);
754 eStatus = eFrameworkunifiedStatusNullPointer;
757 eStatus = eFrameworkunifiedStatusNullPointer;
763 ////////////////////////////////////////////////////////////////////////////////////////////
764 /// FrameworkunifiedNPSetPersistNotfnDefaultValue
765 ////////////////////////////////////////////////////////////////////////////////////////////
766 EFrameworkunifiedStatus FrameworkunifiedNPSetPersistNotfnDefaultValue(HANDLE hApp, PCSTR pNotification, PVOID pData,
767 const UI_32 uiLength) {
768 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
770 if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pNotification)) {
771 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
773 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
775 if (NULL != pMqInfo) {
776 eStatus = NPSetPersistNotfnDefaultValue(pMqInfo->hMsgQ,
782 eStatus = eFrameworkunifiedStatusNullPointer;
785 eStatus = eFrameworkunifiedStatusInvldParam;
791 ////////////////////////////////////////////////////////////////////////////////////////////
792 /// FrameworkunifiedNPSetPersistentNotfnType
793 ////////////////////////////////////////////////////////////////////////////////////////////
794 EFrameworkunifiedStatus FrameworkunifiedNPSetPersistentNotfnType(HANDLE hApp, PCSTR pNotification, EFrameworkunifiedPersistCategory ePersistCategory) {
795 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
797 if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pNotification)) {
798 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
800 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
801 if (NULL != pMqInfo) {
802 eStatus = NPSetPersistentNotfnType(pMqInfo->hMsgQ,
807 eStatus = eFrameworkunifiedStatusNullPointer;
810 eStatus = eFrameworkunifiedStatusInvldParam;
816 ////////////////////////////////////////////////////////////////////////////////////////////
817 /// FrameworkunifiedNPSetFilePersistentType
818 ////////////////////////////////////////////////////////////////////////////////////////////
819 EFrameworkunifiedStatus FrameworkunifiedNPSetFilePersistentType(HANDLE hApp, PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
820 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
822 if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pTag)) {
823 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
825 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
827 if (NULL != pMqInfo) {
828 eStatus = NPSetFilePersistentType(pMqInfo->hMsgQ,
833 eStatus = eFrameworkunifiedStatusNullPointer;
836 eStatus = eFrameworkunifiedStatusInvldParam;
842 ////////////////////////////////////////////////////////////////////////////////////////////
843 /// FrameworkunifiedNPSetFolderPersistentType
844 ////////////////////////////////////////////////////////////////////////////////////////////
845 EFrameworkunifiedStatus FrameworkunifiedNPSetFolderPersistentType(HANDLE hApp, PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
846 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
848 if ((frameworkunifiedCheckValidAppHandle(hApp)) && (NULL != pTag)) {
849 CFrameworkunifiedFrameworkApp *pApp = static_cast<CFrameworkunifiedFrameworkApp *>(hApp);
851 MsgQInfo *pMqInfo = static_cast<MsgQInfo *>(pApp->hNPSndMsgQ);
853 if (NULL != pMqInfo) {
854 eStatus = NPSetFolderPersistentType(pMqInfo->hMsgQ,
859 eStatus = eFrameworkunifiedStatusNullPointer;
862 eStatus = eFrameworkunifiedStatusInvldParam;