Remove unused directories and files in video_in_hal
[staging/basesystem.git] / nsframework / notification_persistent_service / server / include / ns_npp.h
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 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup  tag_NS_NPPService
20 /// .
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
22
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup  tag_NS_NPPService
25 /// \brief
26 ///
27 ///
28 ///
29 ////////////////////////////////////////////////////////////////////////////////////////////////////
30
31 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_
32 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_
33
34 #include <native_service/frameworkunified_sm_framework_types.h>
35 #include <native_service/frameworkunified_sm_hsm.h>
36 #include <native_service/frameworkunified_types.h>
37 #include <string>
38
39
40 class CPersistenceManager;
41 class CNotificationManager;
42 class CnotificationpersistentservicePersonalizationManager;
43
44 /**
45  *  This class act as a controller class which holds the instance of notification, personalization
46  *  and persistence manager respectively.
47  */
48 class CNSNPP: public CFrameworkunifiedHSM {
49  public:
50   ////////////////////////////////////////////////////////////////////////////////////////////////
51   /// CNSNPP
52   /// Constructor of CNSNPP class
53   ///
54   /// \param f_happ
55   ///      PVOID - application handle
56   ///
57   /// \return
58   ///
59   ////////////////////////////////////////////////////////////////////////////////////////////////
60   explicit CNSNPP(PVOID f_happ);
61
62   ////////////////////////////////////////////////////////////////////////////////////////////////
63   /// ~CNSNPP
64   /// Destructor of CNSNPP class
65   ///
66   /// \param
67   ///
68   /// \return
69   ///
70   ////////////////////////////////////////////////////////////////////////////////////////////////
71   ~CNSNPP();
72
73   ///////////////////////////////////////////////////////////////////////////////////////////
74   /// Init
75   /// This function is used to allocate dynamic memory for member variables of this class after
76   /// creation of object.
77   ///
78   /// \param f_happ
79   ///        HANDLE - Application handle
80   ///
81   /// \return EFrameworkunifiedStatus
82   ///         EFrameworkunifiedStatus - Returns status of operation
83   ///
84   ///////////////////////////////////////////////////////////////////////////////////////////
85   EFrameworkunifiedStatus Init(HANDLE f_happ);
86
87   ///////////////////////////////////////////////////////////////////////////////////////////
88   /// DeInit
89   /// This function is used to deinitialize the NPP object.
90   ///
91   /// \param f_happ
92   ///        HANDLE - Application handle
93   ///
94   /// \return VOID
95   ///         VOID - Returns status of operation
96   ///
97   ///////////////////////////////////////////////////////////////////////////////////////////
98   VOID DeInit(HANDLE f_happ);
99
100   ////////////////////////////////////////////////////////////////////////////////////////////////
101   /// FrameworkunifiedCreate
102   /// This function is pure virtual function of parent class.
103   /// In this function, states and events of StateMachine are created and connected.
104   ///
105   /// \param [in] f_peventdata
106   ///     PVOID - Event data
107   ///
108   /// \return EFrameworkunifiedStatus
109   ///         EFrameworkunifiedStatus - Returns status of operation
110   ///
111   ////////////////////////////////////////////////////////////////////////////////////////////////
112   virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_peventdata = NULL);
113
114   ////////////////////////////////////////////////////////////////////////////////////////////////
115   /// NotificationpersistentservicePersistAll
116   /// Persist all persistent state, user persistent state notification data;
117   /// and all global and user related files to permenant storage
118   ///
119   /// \param [in] f_eshutdowntype
120   ///         EFrameworkunifiedShutdownType - shutdown type i.e. normal shutdown, quick, data reset
121   ///
122   /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
123   ///     UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
124   ///     0 - persist orignal data and
125   ///     1 - persist default data
126   ///
127   /// \return EFrameworkunifiedStatus
128   ///         EFrameworkunifiedStatus - Returns status of operation
129   ///
130   ////////////////////////////////////////////////////////////////////////////////////////////////
131   EFrameworkunifiedStatus NotificationpersistentservicePersistAll(EFrameworkunifiedShutdownType f_eshutdowntype, UI_32 f_uinotificationpersistentservicepersistcategoryflag);
132
133   ////////////////////////////////////////////////////////////////////////////////////////////////
134   /// NotificationpersistentserviceSaveNotificationPersistentData
135   /// In this function, all the data related to persistent notification is retrieved from
136   /// notification manager and stored in persistent file by persistent manager.
137   ///
138   /// \param [in] f_epersistenttype
139   ///     EFrameworkunifiedPersistentVarType - Type of persistent notification
140   /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
141   ///     UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
142   ///     0 - persist orignal data and
143   ///     1 - persist default data
144   ///
145   /// \return EFrameworkunifiedStatus
146   ///         EFrameworkunifiedStatus - Returns status of operation
147   ///
148   ////////////////////////////////////////////////////////////////////////////////////////////////
149   EFrameworkunifiedStatus NotificationpersistentserviceSaveNotificationPersistentData(EFrameworkunifiedNotificationType f_epersistenttype,
150                                                UI_32 f_uinotificationpersistentservicepersistcategoryflag = 0x0);
151
152   ////////////////////////////////////////////////////////////////////////////////////////////////
153   /// NotificationpersistentserviceLoadPersistentNotificationData
154   /// In this transition, persistent file is loaded by persistent manager and
155   /// persistent notifications and its data is loaded to notification manager.
156   ///
157   /// \param [in] f_epersistenttype
158   ///     EFrameworkunifiedPersistentVarType - Type of persistent notification
159   ///
160   /// \return EFrameworkunifiedStatus
161   ///         EFrameworkunifiedStatus - Returns status of operation
162   ///
163   ////////////////////////////////////////////////////////////////////////////////////////////////
164   EFrameworkunifiedStatus NotificationpersistentserviceLoadPersistentNotificationData(EFrameworkunifiedNotificationType f_epersistenttype);
165
166   ///////////////////////////////////////////////////////////////////////////////////////////
167   /// DeletePersistedDataFolder
168   /// This function does not deletes the data instead just rename the folder which needs to
169   /// be deleted. And this data will gets deleted during next startup.
170   ///
171   /// \param f_uipersistcategoryflag
172   ///        UI_32 - Rename the persisted data folder depending on enum EFrameworkunifiedPersistCategory value
173   ///
174   /// \return EFrameworkunifiedStatus
175   ///         EFrameworkunifiedStatus - Returns status of operation
176   ///
177   ///////////////////////////////////////////////////////////////////////////////////////////
178   EFrameworkunifiedStatus DeletePersistedDataFolder(UI_32 f_uipersistcategoryflag);
179
180   ///////////////////////////////////////////////////////////////////////////////////////////
181   /// Syncfs
182   /// Syncfs is carried out.
183   ///
184   /// \param
185   ///
186   /// \return EFrameworkunifiedStatus
187   ///         EFrameworkunifiedStatus - Returns status of operation
188   ///
189   ///////////////////////////////////////////////////////////////////////////////////////////
190   EFrameworkunifiedStatus  Syncfs();
191
192   ////////////////////////////////////////////////////////////////////////////////////////////////
193   /// Singleton instance of NotificationManager
194   ////////////////////////////////////////////////////////////////////////////////////////////////
195   CNotificationManager *m_pNotificationManager;           ///< Instance of Notification Manager
196
197   ////////////////////////////////////////////////////////////////////////////////////////////////
198   /// Singleton instance of PersonalizationManager
199   ////////////////////////////////////////////////////////////////////////////////////////////////
200   CnotificationpersistentservicePersonalizationManager *m_pPersonalizationManager;  ///< Instance of Personalization Manager
201
202   ////////////////////////////////////////////////////////////////////////////////////////////////
203   /// Singleton instance of PersistenceManager
204   ////////////////////////////////////////////////////////////////////////////////////////////////
205   CPersistenceManager *m_pPersistenceManager;
206   // scheduling priority of read thread
207   static SI_32 m_siReadThreadPrio;  // NOLINT (readability/naming)
208   // scheduling priority of write thread
209   static SI_32 m_siWriteThreadPrio;  // NOLINT (readability/naming)
210   // scheduling priority of immediate persistence thread
211   static SI_32 m_siImmediatePersistenceThreadPrio;  // NOLINT (readability/naming)
212   // number of times CRC check is required. (CRC check will be done more than once only on failure)
213   static UI_16
214   m_siCRCCheckCount;  // NOLINT (readability/naming)
215
216  private:
217   ///< name of reader thread
218   const std::string m_cReadThreadName;  // NOLINT (readability/naming)
219   ///< name of writer thread
220   const std::string m_cWriteThreadName;  // NOLINT (readability/naming)
221   ///< name of immediate persistence thread
222   const std::string m_cImmediatePersistenceThreadName;  // NOLINT (readability/naming)
223
224   ///////////////////////////////////////////////////////////////////////////////////////////
225   /// CreateAndStartChildThreads
226   /// This function creates and start all child threads.
227   ///
228   /// \param f_happ
229   ///      HANDLE - Application handle
230   ///
231   /// \return EFrameworkunifiedStatus
232   ///         EFrameworkunifiedStatus - Returns status of operation
233   ///
234   ///////////////////////////////////////////////////////////////////////////////////////////
235   EFrameworkunifiedStatus CreateAndStartChildThreads(HANDLE f_happ);
236
237   ///////////////////////////////////////////////////////////////////////////////////////////
238   /// SwitchToFileStructureVersion1
239   /// Copy all the data from old persistent path to new persistent path
240   ///
241   /// \param [IN] f_uinppversion
242   ///        UI_32 - New version of NPPService
243   ///
244   /// \return EFrameworkunifiedStatus
245   ///         EFrameworkunifiedStatus - Returns status of operation
246   ///
247   ///////////////////////////////////////////////////////////////////////////////////////////
248   EFrameworkunifiedStatus SwitchToFileStructureVersion1(const UI_32 f_uinppversion);
249
250   ///////////////////////////////////////////////////////////////////////////////////////////
251   /// SwitchToFileStructureVersion2
252   /// Move immediate notification data files from IMMEDIATE_PERSISTENCE_STORAGE_V1 to
253   /// IMMEDIATE_PERSISTENCE_STORAGE_V2/AllUserAppData/UserData
254   ///
255   /// \param [IN] f_uinppversion
256   ///        UI_32 - New version of NPPService
257   ///
258   /// \return EFrameworkunifiedStatus
259   ///         EFrameworkunifiedStatus - Returns status of operation
260   ///
261   ///////////////////////////////////////////////////////////////////////////////////////////
262   EFrameworkunifiedStatus SwitchToFileStructureVersion2(const UI_32 f_uinppversion);
263
264   ///////////////////////////////////////////////////////////////////////////////////////////
265   /// GetNSNPPVersion
266   /// Get the version of NSNPP from version.txt
267   ///
268   /// \param
269   ///
270   /// \return UI_8
271   ///         UI_8 - version number
272   ///
273   ///////////////////////////////////////////////////////////////////////////////////////////
274   UI_32 GetNSNPPVersion();
275
276   ///////////////////////////////////////////////////////////////////////////////////////////
277   /// SetNSNPPVersion
278   /// Set the version of NSNPP in version.txt
279   ///
280   /// \param [IN] f_uiversion
281   ///      UI_32 - version number
282   ///
283   /// \return EFrameworkunifiedStatus
284   ///         EFrameworkunifiedStatus - Returns status of operation
285   ///
286   ///////////////////////////////////////////////////////////////////////////////////////////
287   EFrameworkunifiedStatus SetNSNPPVersion(UI_8 f_uiversion);
288
289   HANDLE m_hNSReadThread;  ///< Reader thread handle
290
291   HANDLE m_hNSWriteThread;  ///< Writer thread handle
292
293   HANDLE m_hNSImmediatePersistenceThread;  ///< immediate persistence thread handle
294 };
295
296 #endif  // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_