common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / nsframework / framework_unified / client / NS_NPServiceIf / src / ns_np_service_api.c
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_NPService
19 /// \brief    APIs to be used by clients while invoking Notification Service.
20 ///
21 /// Implementation of APIs for Publishers and Subscribers of notifications.
22 ///
23 ///////////////////////////////////////////////////////////////////////////////
24
25 ///////////////////////////////////////////////////////////////////////////////
26 // Include Files
27 ///////////////////////////////////////////////////////////////////////////////
28 #include <native_service/ns_np_service.h>
29 #include <native_service/ns_np_service_protocol.h>
30 #include <native_service/ns_np_service_if.h>
31 #include <native_service/ns_message_center_if.h>
32 #include <native_service/ns_mc_system_info.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36
37 #include <limits.h>
38 #include <other_service/strlcpy.h>
39
40 // define user name as blank for global persistence file
41 #define GLOBAL_PERSISTENCE    ""
42
43 // this is the maximum number of notifications that can be registered/ unregistered at once
44 const UI_32 maxNotification = UINT_MAX / sizeof(NC_register_notif_msg);
45
46
47
48 ////////////////////////////////////////////////////////////////////////////////////////////
49 /// NPRegisterNotifications
50 /// API to send message to Notification Service to register a set of notifications
51 ///
52 /// \param [in] hNPMsgQ
53 ///         HANDLE - Handle to message queue of Notification service.
54 /// \param [in] pPublisherName
55 ///         PCSTR - Name of Publisher message queue
56 /// \param [in] numNotifications
57 ///         PCSTR - Name of Notification
58 /// \param [in] pNotificationArray
59 ///         NotificationInfo - Array of notifications
60 ///
61 /// \return status
62 ///         EFrameworkunifiedStatus - success or error
63 ////////////////////////////////////////////////////////////////////////////////////////////
64 EFrameworkunifiedStatus NPRegisterNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
65                                    NotificationInfo *pNotificationArray) {
66   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
67
68   if (maxNotification < numNotifications) {
69     return eFrameworkunifiedStatusFail;
70   }
71
72   size_t sizeOfMsg = (sizeof(NC_register_notif_msg) * numNotifications) + sizeof(UI_32);
73   if (NULL == pNotificationArray) {
74     return eFrameworkunifiedStatusInvldParam;
75   }
76
77   PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
78
79   if (NULL == pMsgBuffer) {
80     return eFrameworkunifiedStatusFail;
81   }
82
83   NC_register_multiple_notif_msg *pNotifMsg = (NC_register_multiple_notif_msg *)pMsgBuffer;
84
85   pNotifMsg->numNotifications = numNotifications;
86   memcpy(&pNotifMsg->notifierList[0], pNotificationArray, sizeof(NC_register_notif_msg) * numNotifications);
87
88   for(UI_32 i = 0; i < numNotifications; i++) {
89     // Insert \0 at the end of character (up to 64bytes) by copying with strlcpy.
90     strlcpy(pNotifMsg->notifierList[i].notificationName,
91             pNotificationArray[i].notificationName,
92             sizeof(pNotificationArray[i].notificationName));
93   }
94
95   eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_REGISTER_EV_REQ, (UI_32)sizeOfMsg, (PVOID)pNotifMsg) ;
96
97   free(pMsgBuffer);
98   pMsgBuffer = NULL;
99
100   return  eFrameworkunifiedStatus;
101 }
102
103 ////////////////////////////////////////////////////////////////////////////////////////////
104 /// \ingroup  NPUnRegisterNotifications
105 /// API to send message to Notification Service to remove a set of notifications
106 ///
107 /// \param [in] hNPMsgQ
108 ///         HANDLE - Handle to message queue of Notification service.
109 /// \param [in] pPublisherName
110 ///         PCSTR - Name of Publisher message queue
111 /// \param [in] numNotifications
112 ///         PCSTR - Name of Notification
113 /// \param [in] pNotificationArray
114 ///         NotificationInfo - Array of notifications
115 ///
116 /// \return status
117 ///         EFrameworkunifiedStatus - success or error
118 ////////////////////////////////////////////////////////////////////////////////////////////
119 EFrameworkunifiedStatus NPUnRegisterNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
120                                      NotificationInfo *pNotificationArray) {
121   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
122
123   if (maxNotification < numNotifications) {
124     return eFrameworkunifiedStatusFail;
125   }
126
127   size_t sizeOfMsg = (sizeof(NC_unregister_notif_msg) * numNotifications) + sizeof(UI_32);
128   UI_32 i = 0;
129   if (NULL == pNotificationArray) {
130     return eFrameworkunifiedStatusInvldParam;
131   }
132
133   PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
134
135   if (NULL == pMsgBuffer) {
136     return eFrameworkunifiedStatusFail;
137   }
138
139   NC_unregister_multiple_notif_msg *pNotifMsg = (NC_unregister_multiple_notif_msg *)pMsgBuffer;
140
141   pNotifMsg->numNotifications = numNotifications;
142
143   for (i = 0; i < numNotifications; ++i) {
144     strlcpy(pNotifMsg->notificationList[i].notificationName, pNotificationArray[i].notificationName,
145             sizeof(pNotifMsg->notificationList[i].notificationName));
146   }
147
148   // mb20110110 Fixed  issue 135
149   eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_UNREGISTER_EV_REQ, (UI_32)sizeOfMsg, (VOID *)pMsgBuffer) ;
150
151   free(pMsgBuffer);
152   pMsgBuffer = NULL;  // mb20110110  issue 134
153
154   return  eFrameworkunifiedStatus;
155 }
156
157 ////////////////////////////////////////////////////////////////////////////////////////////
158 /// NPRegisterNotification
159 /// API to send message to Notification Service to register a notification
160 ///
161 /// \param [in] hNPMsgQ
162 ///         HANDLE - Handle to message queue of Notification service.
163 /// \param [in] pPublisherName
164 ///         PCSTR - Name of Publisher message queue
165 /// \param [in] notif_name
166 ///         PCSTR - Name of Notification
167 /// \param [in] max_length
168 ///         const UI_32 - Max size of the notification message
169 /// \param [in] bIsPersistent
170 ///         const UI_8 - Flag to indicate if it has to be persistent
171 ///
172 /// \return status
173 ///         EFrameworkunifiedStatus - success or error
174 ////////////////////////////////////////////////////////////////////////////////////////////
175 EFrameworkunifiedStatus NPRegisterNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR notificationName,
176                                   const UI_32 maxLength, const EFrameworkunifiedNotificationType perstype)
177
178 {
179   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
180
181   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != notificationName) {
182     if (strlen(pPublisherName) && strlen(notificationName)) {
183       NotificationInfo data = {};
184       strlcpy(data.notificationName, notificationName, sizeof(data.notificationName));
185       data.persType = perstype;
186       data.maxLength = maxLength;
187
188       eFrameworkunifiedStatus = NPRegisterNotifications(hNPMsgQ, pPublisherName, 1, &data);
189     } else {
190       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
191     }
192   } else {
193     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
194   }
195
196   return eFrameworkunifiedStatus;
197 }
198
199 ////////////////////////////////////////////////////////////////////////////////////////////
200 /// NPUnRegisterNotification
201 /// API to send message to Notification Service to remove a notification
202 ///
203 /// \param [in] hNPMsgQ
204 ///         HANDLE - Handle to message queue of Notification service.
205 /// \param [in] pPublisherName
206 ///         PCSTR - Name of Publisher message queue
207 /// \param [in] pNotification
208 ///         PCSTR - Name of Notification
209 ///
210 /// \return status
211 ///         EFrameworkunifiedStatus - success or error
212 ////////////////////////////////////////////////////////////////////////////////////////////
213 EFrameworkunifiedStatus NPUnRegisterNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification) {
214
215   NotificationInfo data = {};
216   strlcpy(data.notificationName, pNotification, sizeof(data.notificationName));
217   return (NPUnRegisterNotifications(hNPMsgQ, pPublisherName, 1, &data));
218 }
219
220 ////////////////////////////////////////////////////////////////////////////////////////////
221 /// NPPublishNotification
222 /// API to send message to Notification Service to notify subscribers
223 ///
224 /// \param [in] hNPMsgQ
225 ///         HANDLE - Handle to message queue of Notification service.
226 /// \param [in] pPublisherName
227 ///         PCSTR - Name of Publisher message queue
228 /// \param [in] pNotification
229 ///         PCSTR - Name of Notification
230 /// \param [in] pData
231 ///         VOID * - Data buffer
232 /// \param [in] iLength
233 ///         const UI_32 - Size of data buffer
234 ///
235 /// \return status
236 ///         EFrameworkunifiedStatus - success or error
237 ////////////////////////////////////////////////////////////////////////////////////////////
238 EFrameworkunifiedStatus NPPublishNotification(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification,
239                                  PCVOID pData, const UI_32 iLength) {
240   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
241
242   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pNotification) {
243     if (strlen(pPublisherName) && strlen(pNotification)) {
244       if (strlen(pNotification) < MAX_STRING_SIZE_NOTIFICATION) {
245         // Insert \0 at the end of characters (up to 64bytes) by copying pNotification to local variables with strlcpy.
246         char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
247         strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
248         eFrameworkunifiedStatus =  McSendWithSysInfo(hNPMsgQ, pPublisherName, NPS_PUBLISH_EV_REQ,
249                                         tmp_notification, iLength, pData, 0);
250       } else {
251         eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
252       }
253     } else {
254       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
255     }
256   } else {
257     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
258   }
259
260   return eFrameworkunifiedStatus;
261 }
262
263 ////////////////////////////////////////////////////////////////////////////////////////////
264 /// NPSubscribeToNotification
265 /// API to send message to Notification Service to add to subscription list for
266 /// that notification
267 ///
268 /// \param [in] hNPMsgQ
269 ///         HANDLE - Handle to message queue of Notification service.
270 /// \param [in] pSubscriberName
271 ///         PCSTR - Name of subscriber message queue
272 /// \param [in] pNotification
273 ///         PCSTR - Name of Notification
274 ///
275 /// \return status
276 ///         EFrameworkunifiedStatus - success or error
277 ////////////////////////////////////////////////////////////////////////////////////////////
278 EFrameworkunifiedStatus NPSubscribeToNotification(HANDLE hNPMsgQ, PCSTR pSubscriberName, PCSTR pNotification) {
279   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
280   if (NULL != hNPMsgQ && NULL != pSubscriberName && NULL != pNotification) {
281     if (strlen(pSubscriberName) && strlen(pNotification)) {
282       NC_subscribe_msg data;
283       snprintf(data.notificationName, sizeof(data.notificationName), "%s", pNotification);
284
285       eFrameworkunifiedStatus = McSend(hNPMsgQ, pSubscriberName, NPS_SUBSCRIBE_TO_EV_REQ, sizeof(NC_subscribe_msg), (PVOID)&data);
286     } else {
287       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
288     }
289   } else {
290     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
291   }
292
293   return eFrameworkunifiedStatus;
294 }
295
296 ////////////////////////////////////////////////////////////////////////////////////////////
297 // NPSubscribeToNotifications
298 ////////////////////////////////////////////////////////////////////////////////////////////
299 EFrameworkunifiedStatus NPSubscribeToNotifications(HANDLE hNPMsgQ, PCSTR pSubscriberName, UI_32 numNotifications,
300                                       SubscribeInfo *pSubscribeInfoArray) {
301   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
302
303   if (maxNotification < numNotifications) {
304     return eFrameworkunifiedStatusFail;
305   }
306
307   size_t sizeOfMsg = (sizeof(NC_subscribe_msg) * numNotifications) + sizeof(UI_32);
308   if (NULL == pSubscribeInfoArray) {
309     return eFrameworkunifiedStatusInvldParam;
310   }
311
312   PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
313
314   if (NULL == pMsgBuffer) {
315     return eFrameworkunifiedStatusFail;
316   }
317
318   NC_subscribe_multiple_notif_msg *pSubscribeMsg = (NC_subscribe_multiple_notif_msg *)pMsgBuffer;
319
320   pSubscribeMsg->numNotifications = numNotifications;
321   memcpy(&pSubscribeMsg->notificationList[0], pSubscribeInfoArray, sizeof(NC_subscribe_msg) * numNotifications);
322
323   for(UI_32 i = 0; i < numNotifications; i++) {
324     // Insert \0 at the end of character (up to 64bytes) by copying with strlcpy.
325     strlcpy(pSubscribeMsg->notificationList[i].notificationName,
326             pSubscribeInfoArray[i].notificationName,
327             sizeof(pSubscribeInfoArray[i].notificationName));
328   }
329
330   eFrameworkunifiedStatus = McSend(hNPMsgQ, pSubscriberName, NPS_BATCH_SUBSCRIBE_TO_EV_REQ, (UI_32)sizeOfMsg, (PVOID)pSubscribeMsg) ;
331
332   free(pMsgBuffer);
333   pMsgBuffer = NULL;
334
335   return  eFrameworkunifiedStatus;
336 }
337
338 ////////////////////////////////////////////////////////////////////////////////////////////
339 /// NPUnsubscribeFromNotification
340 /// API to send message to Notification Service to remove from subscription list for
341 /// that notification
342 ///
343 /// \param [in] hNPMsgQ
344 ///         HANDLE - Handle to message queue of Notification service.
345 /// \param [in] pSubscriberName
346 ///         PCSTR - Name of subscriber message queue
347 /// \param [in] pNotification
348 ///         PCSTR - Name of Notification
349 ///
350 /// \return status
351 ///         EFrameworkunifiedStatus - success or error
352 ////////////////////////////////////////////////////////////////////////////////////////////
353 EFrameworkunifiedStatus NPUnsubscribeFromNotification(HANDLE hNPMsgQ, PCSTR pSubscriberName, PCSTR pNotification) {
354   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
355
356   if (NULL != hNPMsgQ && NULL != pSubscriberName && NULL != pNotification) {
357     if (strlen(pSubscriberName) && strlen(pNotification)) {
358       NC_unsubscribe_frm_notif_msg data;
359       snprintf(data.notificationName, sizeof(data.notificationName), "%s", pNotification);
360
361       eFrameworkunifiedStatus = McSend(hNPMsgQ, pSubscriberName, NPS_UNSUBSCRIBE_FROM_EV_REQ, sizeof(NC_unsubscribe_frm_notif_msg),
362                           (PVOID)&data);
363     } else {
364       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
365     }
366   } else {
367     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
368   }
369
370   return eFrameworkunifiedStatus;
371 }
372
373 ////////////////////////////////////////////////////////////////////////////////////////////
374 // NPUnsubscribeToNotifications
375 ////////////////////////////////////////////////////////////////////////////////////////////
376 EFrameworkunifiedStatus NPUnsubscribeFromNotifications(HANDLE hNPMsgQ, PCSTR pUnSubscriberName, UI_32 numNotifications,
377                                           SubscribeInfo *pUnSubscribeInfoArray) {
378   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
379
380   if (NULL != hNPMsgQ && NULL != pUnSubscriberName) {
381     if (strlen(pUnSubscriberName)) {
382       if (maxNotification < numNotifications) {
383         return eFrameworkunifiedStatusFail;
384       }
385
386       size_t sizeOfMsg = (sizeof(NC_subscribe_msg) * numNotifications) + sizeof(UI_32);
387       if (NULL == pUnSubscribeInfoArray) {
388         return eFrameworkunifiedStatusInvldParam;
389       }
390
391       PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
392
393       if (NULL == pMsgBuffer) {
394         return eFrameworkunifiedStatusFail;
395       }
396
397       NC_unsubscribe_multiple_notif_msg *pUnSubscribeMsg = (NC_unsubscribe_multiple_notif_msg *)pMsgBuffer;
398
399       pUnSubscribeMsg->numNotifications = numNotifications;
400       memcpy(&pUnSubscribeMsg->notificationList[0], pUnSubscribeInfoArray, sizeof(NC_subscribe_msg) * numNotifications);
401
402       for(UI_32 i = 0; i < numNotifications; i++) {
403         // Insert \0 at the end of character (up to 64bytes) by copying with strlcpy.
404         strlcpy(pUnSubscribeMsg->notificationList[i].notificationName,
405                 pUnSubscribeInfoArray[i].notificationName,
406                 sizeof(pUnSubscribeInfoArray[i].notificationName));
407       }
408
409       eFrameworkunifiedStatus = McSend(hNPMsgQ, pUnSubscriberName, NPS_BATCH_UNSUBSCRIBE_FROM_EV_REQ, (UI_32)sizeOfMsg, (PVOID)pUnSubscribeMsg) ;
410
411       free(pMsgBuffer);
412       pMsgBuffer = NULL;
413     } else {
414       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
415     }
416   } else {
417     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
418   }
419
420   return  eFrameworkunifiedStatus;
421 }
422
423 ////////////////////////////////////////////////////////////////////////////////////////////
424 /// NPReadPersistedData
425 /// API to requested the persistent data corresponding to specified notification if available
426 /// The caller recieves an acknowledgement once NPS completes data retrieval and sends it.
427 ///
428 /// \param [in] hNPMsgQ
429 ///         HANDLE - Handle to message queue of Notification service.
430 /// \param [in] pPublisherName
431 ///         PCSTR - Name of publisher message queue
432 /// \param [in] notification
433 ///         PCSTR - Name of Notification
434 ///
435 /// \return status
436 ///         EFrameworkunifiedStatus - success or error
437 ////////////////////////////////////////////////////////////////////////////////////////////
438 EFrameworkunifiedStatus NPReadPersistedData(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR notification) {
439   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
440
441   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != notification) {
442     if (strlen(pPublisherName) && strlen(notification)) {
443       NC_get_pers_data_msg msg;
444
445       snprintf(msg.notificationName, sizeof(msg.notificationName), "%s", notification);
446
447       eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_GET_PERS_DATA_REQ, sizeof(msg), (PVOID)&msg) ;
448     } else {
449       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
450     }
451   } else {
452     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
453   }
454
455   return  eFrameworkunifiedStatus;
456 }
457
458 ////////////////////////////////////////////////////////////////////////////////////////////
459 /// \ingroup  NPSavePersistentData
460 /// API to send message to Notification Service to save all persisted data that in Ram
461 /// to the filesystem via a file write.
462 ///
463 /// \param [in] hNPMsgQ
464 ///         HANDLE - Handle to message queue of Notification service.
465 /// \param [in] pPublisherName
466 ///         PCSTR - Name of publisher message queue
467 ///
468 /// \return status
469 ///         EFrameworkunifiedStatus - success or error
470 ////////////////////////////////////////////////////////////////////////////////////////////
471 EFrameworkunifiedStatus NPSavePersistentData(HANDLE hNPMsgQ, PCSTR pPublisherName) {
472   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
473
474   eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_SAVE_PERS_DATA_REQ, 0, NULL) ;
475
476   return eFrameworkunifiedStatus;
477 }
478
479 ////////////////////////////////////////////////////////////////////////////////////////////
480 /// NPRegisterPersistentFile
481 ////////////////////////////////////////////////////////////////////////////////////////////
482 EFrameworkunifiedStatus NPRegisterPersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pTag,
483                                     BOOL bIsUserFile) {  // EFrameworkunifiedRegisterType eRegisterType)
484   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
485
486   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pTag) {
487     if (strlen(pPublisherName) && strlen(pTag)) {
488       NC_RegisterPersistentFileMsg tMsg;
489
490       snprintf(tMsg.cFileTag, sizeof(tMsg.cFileTag), "%s", pTag);
491       tMsg.bIsUserFile = bIsUserFile;
492
493       eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_SET_PERSIST_FILE_PATH_REQ, sizeof(tMsg),
494                           (PVOID)&tMsg);
495     } else {
496       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
497     }
498   } else {
499     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
500   }
501
502   return eFrameworkunifiedStatus;
503 }
504
505 ////////////////////////////////////////////////////////////////////////////////////////////
506 /// NPLoadPersistentFile
507 ////////////////////////////////////////////////////////////////////////////////////////////
508 EFrameworkunifiedStatus NPLoadPersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pDstFilePath,
509                                 PCSTR pTag, HANDLE hUser) {
510   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
511
512   if (NULL != hNPMsgQ && NULL != pPublisherName &&
513       NULL != pDstFilePath && NULL != pTag) {
514     if (strlen(pPublisherName) && strlen(pDstFilePath) && strlen(pTag)) {
515       NC_LoadPersistedFileMsg tMsg = {};
516
517       snprintf(tMsg.cFilePath, sizeof(tMsg.cFilePath), "%s", pDstFilePath);
518       snprintf(tMsg.cFileTag,  sizeof(tMsg.cFileTag),  "%s", pTag);
519
520       if (hUser) {
521         NC_User *pUser = (NC_User *) hUser;
522         snprintf(tMsg.cUsername,  sizeof(tMsg.cUsername),  "%s", pUser->cUsername != 0 ? pUser->cUsername : NULL);
523       } else {
524         strlcpy(tMsg.cUsername, GLOBAL_PERSISTENCE, sizeof(tMsg.cUsername));
525       }
526
527       eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_GET_PERS_FILE_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
528     } else {
529       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
530     }
531   } else {
532     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
533   }
534
535   return eFrameworkunifiedStatus;
536 }
537
538 ////////////////////////////////////////////////////////////////////////////////////////////
539 /// NPReleasePersistentFile
540 ////////////////////////////////////////////////////////////////////////////////////////////
541 EFrameworkunifiedStatus NPReleasePersistentFile(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedReleaseType eFrameworkunifiedReleaseType, PCSTR pTag,
542                                    PCSTR pFullFilePath,  HANDLE hUser) {
543   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
544
545   if (NULL != hNPMsgQ && NULL != pPublisherName &&
546       NULL != pTag && NULL != pFullFilePath) {
547     if (strlen(pPublisherName) && strlen(pTag) && strlen(pFullFilePath)) {
548       NC_ReleasePersistentFileMsg tMsg = {eFrameworkunifiedReleaseType, {0}, {0}};
549
550       snprintf(tMsg.cFilePath, sizeof(tMsg.cFilePath), "%s", pFullFilePath);
551       snprintf(tMsg.cFileTag, sizeof(tMsg.cFileTag), "%s", pTag);
552
553       if (hUser) {
554         NC_User *pUser = (NC_User *) hUser;
555         snprintf(tMsg.cUsername,  sizeof(tMsg.cUsername),  "%s", pUser->cUsername != 0 ? pUser->cUsername : NULL);
556       } else {
557         strlcpy(tMsg.cUsername, GLOBAL_PERSISTENCE, sizeof(tMsg.cUsername));
558       }
559
560       eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_RELEASE_PERS_FILE_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
561     } else {
562       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
563     }
564   } else {
565     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
566   }
567
568   return eFrameworkunifiedStatus;
569 }
570 ////////////////////////////////////////////////////////////////////////////////////////////
571 /// NPPersistentSync
572 ////////////////////////////////////////////////////////////////////////////////////////////
573 EFrameworkunifiedStatus NPPersistentSync(PCSTR SrcName, HANDLE hNPMsgQ, UI_32 sessionid, PCSTR pPublisherName) {
574   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
575   CHAR data[4];
576   UI_32 length;
577   HANDLE hResponse;
578   char mc_invoker_name[MAX_QUEUE_NAME_SIZE];
579
580   McCreateInvokerName(SrcName, sessionid, mc_invoker_name, sizeof(mc_invoker_name));
581   hResponse = McOpenSyncReceiver(&mc_invoker_name[0]);
582   if (hResponse != NULL) {
583     eFrameworkunifiedStatus = McInvokeSync(hNPMsgQ, pPublisherName, NPS_NPP_SYNC_REQ   , sizeof(data), data, sessionid,
584                               hResponse, 0, NULL, &length);
585     McClose(hResponse);
586   } else {
587     eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
588   }
589   return eFrameworkunifiedStatus;
590 }
591 ////////////////////////////////////////////////////////////////////////////////////////////
592 /// NPSetPersonality
593 ////////////////////////////////////////////////////////////////////////////////////////////
594 EFrameworkunifiedStatus NPSetPersonality(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pUserName) {
595   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
596
597   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pUserName) {
598     if (strlen(pPublisherName) && strlen(pUserName)) {
599       // NC_SetPersonalityMsg tMsg;
600       NC_User tMsg;
601
602       snprintf(tMsg.cUsername, sizeof(tMsg.cUsername), "%s", pUserName);
603
604       // eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_SET_PERSONALITY_REQ, sizeof(tMsg), (PVOID)&tMsg ) ;
605       eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_CHANGE_PERSONALITY_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
606     } else {
607       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
608     }
609   } else {
610     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
611   }
612
613   return eFrameworkunifiedStatus;
614 }
615 ////////////////////////////////////////////////////////////////////////////////////////////
616 /// NPRegisterPersistentFolder
617 /// API to register persistence tag to folder that need to persist
618 ///
619 /// \param [in] hNPMsgQ
620 ///         HANDLE - Handle to message queue of Notification service.
621 /// \param [in] pPublisherName
622 ///         PCSTR - Name of publisher message queue
623 /// \param [in] pTag
624 ///         PCSTR - Tag associated to folder that need to persist
625 /// \param [in] bIsUserFolder
626 ///         BOOL - TRUE - user specific folder
627 ///          FALSE - global file
628 ///
629 /// \return status
630 ///         EFrameworkunifiedStatus - success or error
631 ////////////////////////////////////////////////////////////////////////////////////////////
632 EFrameworkunifiedStatus NPRegisterPersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pTag, BOOL bIsUserFolder) {
633   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
634
635   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pTag) {
636     if (strlen(pPublisherName) && strlen(pTag)) {
637       NC_RegisterPersistentFolderMsg tMsg;
638
639       snprintf(tMsg.cFolderTag, sizeof(tMsg.cFolderTag), "%s", pTag);
640       tMsg.bIsUserFolder = bIsUserFolder;
641
642       eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_SET_PERSIST_FOLDER_PATH_REQ, sizeof(tMsg),
643                           (PVOID)&tMsg);
644     } else {
645       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
646     }
647   } else {
648     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
649   }
650
651   return eFrameworkunifiedStatus;
652 }
653
654 ////////////////////////////////////////////////////////////////////////////////////////////
655 /// NPLoadPersistentFolder
656 /// API to load folder to given path and associated with given tag from persistent memory
657 ///
658 /// \param [in] hNPMsgQ
659 ///         HANDLE - Handle to message queue of Notification service.
660 /// \param [in] pPublisherName
661 ///         PCSTR - Name of publisher message queue
662 /// \param [in] pDstFolderPath
663 ///         PCSTR - Destination where folder needs to be loaded
664 /// \param [in] pTag
665 ///         PCSTR - Tag associated to folder that need to loaded from persistent memory
666 /// \param [in] hUser
667 ///         HANDLE - Handle of the user
668 ///
669 /// \return status
670 ///         EFrameworkunifiedStatus - success or error
671 ////////////////////////////////////////////////////////////////////////////////////////////
672 EFrameworkunifiedStatus NPLoadPersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pDstFolderPath,
673                                   PCSTR pTag, HANDLE hUser) {
674   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
675
676   if (NULL != hNPMsgQ && NULL != pPublisherName &&
677       NULL != pDstFolderPath && NULL != pTag) {
678     if (strlen(pPublisherName) && strlen(pDstFolderPath) && strlen(pTag)) {
679       NC_LoadPersistedFolderMsg tMsg;
680
681       snprintf(tMsg.cFolderPath, sizeof(tMsg.cFolderPath), "%s", pDstFolderPath);
682       snprintf(tMsg.cFolderTag,  sizeof(tMsg.cFolderTag),  "%s", pTag);
683
684       if (hUser) {
685         NC_User *pUser = (NC_User *) hUser;
686         snprintf(tMsg.cUsername,  sizeof(tMsg.cUsername),  "%s", pUser->cUsername != 0 ? pUser->cUsername : NULL);
687       } else {
688         strlcpy(tMsg.cUsername, GLOBAL_PERSISTENCE, sizeof(tMsg.cUsername));
689       }
690
691       eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_GET_PERS_FOLDER_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
692     } else {
693       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
694     }
695   } else {
696     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
697   }
698
699   return eFrameworkunifiedStatus;
700 }
701
702 ////////////////////////////////////////////////////////////////////////////////////////////
703 /// NPReleasePersistentFolder
704 /// API to release folder for saving with tag name to persistent memory
705 ///
706 /// \param [in] hNPMsgQ
707 ///         HANDLE - Handle to message queue of Notification service.
708 /// \param [in] pPublisherName
709 ///         PCSTR - Name of publisher message queue
710 /// \param [in] eFrameworkunifiedReleaseType
711 ///         EFrameworkunifiedReleaseType - eFrameworkunifiedNotOnRelease     :not on release
712 ///                           eFrameworkunifiedPersistOnShutdown:persist on shutdown
713 ///                           eFrameworkunifiedPersistInstantly :persist instantly
714 /// \param [in] pTag
715 ///         PCSTR - Tag associated to folder that need to persist
716 /// \param [in] pFullFolderPath
717 ///         PCSTR - full folder path of folder that need to be stored in persistent memory
718 /// \param [in] hUser
719 ///         HANDLE - Handle of the user
720 ///
721 /// \return status
722 ///         EFrameworkunifiedStatus - success or error
723 ////////////////////////////////////////////////////////////////////////////////////////////
724 EFrameworkunifiedStatus NPReleasePersistentFolder(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedReleaseType eFrameworkunifiedReleaseType,
725                                      PCSTR pTag, PCSTR pFullFolderPath, HANDLE hUser) {
726   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
727
728   if (NULL != hNPMsgQ && NULL != pPublisherName &&
729       NULL != pTag && NULL != pFullFolderPath) {
730     if (strlen(pPublisherName) && strlen(pFullFolderPath) && strlen(pTag)) {
731       NC_ReleasePersistentFolderMsg tMsg = {eFrameworkunifiedReleaseType, {0}, {0}};
732
733       snprintf(tMsg.cFolderPath, sizeof(tMsg.cFolderPath), "%s", pFullFolderPath);
734       snprintf(tMsg.cFolderTag, sizeof(tMsg.cFolderTag), "%s", pTag);
735
736       if (hUser) {
737         NC_User *pUser = (NC_User *) hUser;
738         snprintf(tMsg.cUsername,  sizeof(tMsg.cUsername),  "%s", pUser->cUsername != 0 ? pUser->cUsername : NULL);
739       } else {
740         strlcpy(tMsg.cUsername, GLOBAL_PERSISTENCE, sizeof(tMsg.cUsername));
741       }
742
743       eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_RELEASE_PERS_FOLDER_REQ, sizeof(tMsg), (PVOID)&tMsg) ;
744     } else {
745       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
746     }
747   } else {
748     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
749   }
750
751   return eFrameworkunifiedStatus;
752 }
753
754 ////////////////////////////////////////////////////////////////////////////////////////////
755 /// NPChangePersonality
756 ////////////////////////////////////////////////////////////////////////////////////////////
757 EFrameworkunifiedStatus NPChangePersonality(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pUserName) {
758   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
759
760   if (NULL != pUserName && 0 != strlen(pUserName)) {
761     eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_CHANGE_PERSONALITY_REQ, sizeof(pUserName), (PVOID)&pUserName) ;
762   } else {
763     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
764   }
765   return eFrameworkunifiedStatus;
766 }
767
768 ////////////////////////////////////////////////////////////////////////////////////////////
769 /// SendStopToNSNPP
770 ////////////////////////////////////////////////////////////////////////////////////////////
771 EFrameworkunifiedStatus SendStopToNSNPP(HANDLE hNPMsgQ, PCSTR pPublisherName, EFrameworkunifiedShutdownType eShutdownType, UI_32 uiStopMsgData) {
772   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
773
774   if (NULL != pPublisherName && 0 != strlen(pPublisherName)) {
775     NC_StopMsgData tMsg;
776     tMsg.eShutdownType = eShutdownType;
777     tMsg.uiStopMsgData = uiStopMsgData;
778
779     eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_NPP_STOP_REQ, sizeof(tMsg), (PVOID)&tMsg);
780   } else {
781     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
782   }
783   return eFrameworkunifiedStatus;
784 }
785
786 ////////////////////////////////////////////////////////////////////////////////////////////
787 /// NPGetReadyStatusOfNPP
788 ////////////////////////////////////////////////////////////////////////////////////////////
789 EFrameworkunifiedStatus NPGetReadyStatusOfNPP(HANDLE hNPMsgQ, PCSTR pRequesterName) {
790   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
791
792   if (NULL != pRequesterName && 0 != strlen(pRequesterName)) {
793     eFrameworkunifiedStatus = McSend(hNPMsgQ, pRequesterName, NPS_GET_READYSTATUS_REQ, 0, NULL);
794   } else {
795     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
796   }
797   return eFrameworkunifiedStatus;
798 }
799
800 ////////////////////////////////////////////////////////////////////////////////////////////
801 /// NPRegisterImmediateNotifications
802 /// API to send message to Notification Service to register a set of notifications
803 ///
804 /// \param [in] hNPMsgQ
805 ///         HANDLE - Handle to message queue of Notification service.
806 /// \param [in] pPublisherName
807 ///         PCSTR - Name of Publisher message queue
808 /// \param [in] numNotifications
809 ///         PCSTR - Name of Notification
810 /// \param [in] pNotificationArray
811 ///         ImmediateNotificationInfo - Array of notifications
812 ///
813 /// \return status
814 ///         EFrameworkunifiedStatus - success or error
815 ////////////////////////////////////////////////////////////////////////////////////////////
816 EFrameworkunifiedStatus NPRegisterImmediateNotifications(HANDLE hNPMsgQ, PCSTR pPublisherName, UI_32 numNotifications,
817                                             ImmediateNotificationInfo *pNotificationArray) {
818   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
819
820   if (maxNotification < numNotifications) {
821     return eFrameworkunifiedStatusFail;
822   }
823
824   size_t sizeOfMsg = (sizeof(NC_register_immediate_notif_msg) * numNotifications) + sizeof(UI_32);
825   if (NULL == pNotificationArray) {
826     return eFrameworkunifiedStatusInvldParam;
827   }
828
829   PCHAR *pMsgBuffer = (PCHAR *)malloc(sizeOfMsg);
830
831   if (NULL == pMsgBuffer) {
832     return eFrameworkunifiedStatusFail;
833   }
834
835   NC_register_multiple_immediate_notif_msg *pNotifMsg = (NC_register_multiple_immediate_notif_msg *)pMsgBuffer;
836
837   if (NULL != pNotifMsg) {
838       pNotifMsg->numNotifications = numNotifications;
839   }
840
841   memcpy(&pNotifMsg->notifierList[0], pNotificationArray, sizeof(NC_register_immediate_notif_msg) * numNotifications);
842
843   for(UI_32 i = 0; i < numNotifications; i++ ) {
844     // Insert \0 at the end of character (up to 64bytes) by copying with strlcpy.
845     strlcpy(pNotifMsg->notifierList[i].notificationName,
846             pNotificationArray[i].notificationName,
847             sizeof(pNotificationArray[i].notificationName));
848   }
849
850   eFrameworkunifiedStatus = McSend(hNPMsgQ, pPublisherName, NPS_REGISTER_NOR_EV_REQ, (UI_32)sizeOfMsg, (PVOID)pNotifMsg) ;
851
852   if (NULL != pMsgBuffer) {
853     free(pMsgBuffer);
854     pMsgBuffer = NULL;
855   }
856   return  eFrameworkunifiedStatus;
857 }
858
859 ////////////////////////////////////////////////////////////////////////////////////////////
860 /// NPClearPersistedData
861 ////////////////////////////////////////////////////////////////////////////////////////////
862 EFrameworkunifiedStatus NPClearPersistedData(HANDLE hNPMsgQ, PCSTR pRequesterName, EFrameworkunifiedClearPersistence eFrameworkunifiedClearPersistenceScope) {
863   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
864
865   if ((NULL != hNPMsgQ) && (NULL != pRequesterName) && (0 != strlen(pRequesterName))) {
866     NC_ClearPersistedDataReq tMsg = {};
867     tMsg.ePersistenceData = eFrameworkunifiedClearPersistenceScope;
868
869     eFrameworkunifiedStatus = McSend(hNPMsgQ,
870                         pRequesterName,
871                         NPS_DELETE_PERSISTED_DATA_REQ,
872                         sizeof(tMsg),
873                         &tMsg);
874   } else {
875     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
876   }
877   return eFrameworkunifiedStatus;
878 }
879
880 ////////////////////////////////////////////////////////////////////////////////////////////
881 /// NPSetPersistNotfnDefaultValue
882 ////////////////////////////////////////////////////////////////////////////////////////////
883 EFrameworkunifiedStatus NPSetPersistNotfnDefaultValue(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification, PCVOID pData,
884                                          const UI_32 iLength) {
885   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
886
887   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pNotification) {
888     if ((0 != strlen(pPublisherName)) && (0 != strlen(pNotification))) {
889
890       // Insert \0 at the end of characters (up to 64bytes) by copying pNotification to local variables with strlcpy.
891       char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
892       strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
893
894       eFrameworkunifiedStatus =  McSendWithSysInfo(hNPMsgQ,
895                                       pPublisherName,
896                                       NPS_SET_DEFAULT_PERS_DATA,
897                                       (PCHAR)tmp_notification,
898                                       iLength,
899                                       pData,
900                                       0);
901     } else {
902       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
903     }
904   } else {
905     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
906   }
907
908   return eFrameworkunifiedStatus;
909 }
910
911 ////////////////////////////////////////////////////////////////////////////////////////////
912 /// NPSetPersistentNotfnType
913 ////////////////////////////////////////////////////////////////////////////////////////////
914 EFrameworkunifiedStatus NPSetPersistentNotfnType(HANDLE hNPMsgQ, PCSTR pPublisherName, PCSTR pNotification,
915                                     EFrameworkunifiedPersistCategory ePersistCategory) {
916   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
917
918   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pNotification) {
919     if ((0 != strlen(pPublisherName)) && (0 != strlen(pNotification))) {
920
921       // Insert \0 at the end of characters (up to 64bytes) by copying pNotification to local variables with strlcpy.
922       char tmp_notification[MAX_STRING_SIZE_NOTIFICATION] = {0};
923       strlcpy(tmp_notification, pNotification, MAX_STRING_SIZE_NOTIFICATION);
924
925       eFrameworkunifiedStatus =  McSendWithSysInfo(hNPMsgQ,
926                                       pPublisherName,
927                                       NPS_SET_NOTFN_PERSISTENT_TYPE,
928                                       (PCHAR)tmp_notification,
929                                       sizeof(ePersistCategory),
930                                       &ePersistCategory,
931                                       0);
932     } else {
933       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
934     }
935   } else {
936     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
937   }
938
939   return eFrameworkunifiedStatus;
940 }
941
942 ////////////////////////////////////////////////////////////////////////////////////////////
943 /// NPSetFilePersistentType
944 ////////////////////////////////////////////////////////////////////////////////////////////
945 EFrameworkunifiedStatus NPSetFilePersistentType(HANDLE hNPMsgQ, PCSTR pPublisherName,
946                                    PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
947   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
948
949   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pTag) {
950     if ((0 != strlen(pPublisherName)) && (0 != strlen(pTag))) {
951       NC_SetFilePersistType tMsg = {};
952
953       tMsg.ePersistType = ePersistCategory;
954
955       snprintf(tMsg.cTag, sizeof(tMsg.cTag), "%s", pTag);
956
957       eFrameworkunifiedStatus = McSend(hNPMsgQ,
958                           pPublisherName,
959                           NPS_SET_FILE_PERSISTENT_TYPE,
960                           sizeof(tMsg),
961                           (PVOID)&tMsg) ;
962     } else {
963       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
964     }
965   } else {
966     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
967   }
968
969   return eFrameworkunifiedStatus;
970 }
971
972 ////////////////////////////////////////////////////////////////////////////////////////////
973 /// NPSetFolderPersistentType
974 ////////////////////////////////////////////////////////////////////////////////////////////
975 EFrameworkunifiedStatus NPSetFolderPersistentType(HANDLE hNPMsgQ, PCSTR pPublisherName,
976                                      PCSTR pTag, EFrameworkunifiedPersistCategory ePersistCategory) {
977   EFrameworkunifiedStatus eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
978
979   if (NULL != hNPMsgQ && NULL != pPublisherName && NULL != pTag) {
980     if ((0 != strlen(pPublisherName)) && (0 != strlen(pTag))) {
981       NC_SetFolderPersistType tMsg = {};
982
983       tMsg.ePersistType = ePersistCategory;
984       snprintf(tMsg.cTag, sizeof(tMsg.cTag), "%s", pTag);
985
986       eFrameworkunifiedStatus = McSend(hNPMsgQ,
987                           pPublisherName,
988                           NPS_SET_FOLDER_PERSISTENT_TYPE,
989                           sizeof(tMsg),
990                           (PVOID)&tMsg) ;
991     } else {
992       eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
993     }
994   } else {
995     eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
996   }
997
998   return eFrameworkunifiedStatus;
999 }
1000
1001 // EOF