summaryrefslogtreecommitdiffstats
path: root/nsframework/notification_persistent_service/server/include/ns_npp.h
blob: f96dd7552084700914c706298677fc2bf5979279 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \defgroup <<Group Tag>> <<Group Name>>
/// \ingroup  tag_NS_NPPService
/// .
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup  tag_NS_NPPService
/// \brief
///
///
///
////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_
#define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_

#include <native_service/frameworkunified_sm_framework_types.h>
#include <native_service/frameworkunified_sm_hsm.h>
#include <native_service/frameworkunified_types.h>
#include <string>


class CPersistenceManager;
class CNotificationManager;
class CnotificationpersistentservicePersonalizationManager;

/**
 *  This class act as a controller class which holds the instance of notification, personalization
 *  and persistence manager respectively.
 */
class CNSNPP: public CFrameworkunifiedHSM {
 public:
  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// CNSNPP
  /// Constructor of CNSNPP class
  ///
  /// \param f_happ
  ///      PVOID - application handle
  ///
  /// \return
  ///
  ////////////////////////////////////////////////////////////////////////////////////////////////
  explicit CNSNPP(PVOID f_happ);

  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// ~CNSNPP
  /// Destructor of CNSNPP class
  ///
  /// \param
  ///
  /// \return
  ///
  ////////////////////////////////////////////////////////////////////////////////////////////////
  ~CNSNPP();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// Init
  /// This function is used to allocate dynamic memory for member variables of this class after
  /// creation of object.
  ///
  /// \param f_happ
  ///        HANDLE - Application handle
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus Init(HANDLE f_happ);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// DeInit
  /// This function is used to deinitialize the NPP object.
  ///
  /// \param f_happ
  ///        HANDLE - Application handle
  ///
  /// \return VOID
  ///         VOID - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  VOID DeInit(HANDLE f_happ);

  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// FrameworkunifiedCreate
  /// This function is pure virtual function of parent class.
  /// In this function, states and events of StateMachine are created and connected.
  ///
  /// \param [in] f_peventdata
  ///     PVOID - Event data
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ////////////////////////////////////////////////////////////////////////////////////////////////
  virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_peventdata = NULL);

  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// NotificationpersistentservicePersistAll
  /// Persist all persistent state, user persistent state notification data;
  /// and all global and user related files to permenant storage
  ///
  /// \param [in] f_eshutdowntype
  ///         EFrameworkunifiedShutdownType - shutdown type i.e. normal shutdown, quick, data reset
  ///
  /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
  ///     UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
  ///     0 - persist orignal data and
  ///     1 - persist default data
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ////////////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus NotificationpersistentservicePersistAll(EFrameworkunifiedShutdownType f_eshutdowntype, UI_32 f_uinotificationpersistentservicepersistcategoryflag);

  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// NotificationpersistentserviceSaveNotificationPersistentData
  /// In this function, all the data related to persistent notification is retrieved from
  /// notification manager and stored in persistent file by persistent manager.
  ///
  /// \param [in] f_epersistenttype
  ///     EFrameworkunifiedPersistentVarType - Type of persistent notification
  /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
  ///     UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
  ///     0 - persist orignal data and
  ///     1 - persist default data
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ////////////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus NotificationpersistentserviceSaveNotificationPersistentData(EFrameworkunifiedNotificationType f_epersistenttype,
                                               UI_32 f_uinotificationpersistentservicepersistcategoryflag = 0x0);

  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// NotificationpersistentserviceLoadPersistentNotificationData
  /// In this transition, persistent file is loaded by persistent manager and
  /// persistent notifications and its data is loaded to notification manager.
  ///
  /// \param [in] f_epersistenttype
  ///     EFrameworkunifiedPersistentVarType - Type of persistent notification
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ////////////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus NotificationpersistentserviceLoadPersistentNotificationData(EFrameworkunifiedNotificationType f_epersistenttype);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// DeletePersistedDataFolder
  /// This function does not deletes the data instead just rename the folder which needs to
  /// be deleted. And this data will gets deleted during next startup.
  ///
  /// \param f_uipersistcategoryflag
  ///        UI_32 - Rename the persisted data folder depending on enum EFrameworkunifiedPersistCategory value
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus DeletePersistedDataFolder(UI_32 f_uipersistcategoryflag);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// Syncfs
  /// Syncfs is carried out.
  ///
  /// \param
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus  Syncfs();

  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// Singleton instance of NotificationManager
  ////////////////////////////////////////////////////////////////////////////////////////////////
  CNotificationManager *m_pNotificationManager;           ///< Instance of Notification Manager

  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// Singleton instance of PersonalizationManager
  ////////////////////////////////////////////////////////////////////////////////////////////////
  CnotificationpersistentservicePersonalizationManager *m_pPersonalizationManager;  ///< Instance of Personalization Manager

  ////////////////////////////////////////////////////////////////////////////////////////////////
  /// Singleton instance of PersistenceManager
  ////////////////////////////////////////////////////////////////////////////////////////////////
  CPersistenceManager *m_pPersistenceManager;
  // scheduling priority of read thread
  static SI_32 m_siReadThreadPrio;  // NOLINT (readability/naming)
  // scheduling priority of write thread
  static SI_32 m_siWriteThreadPrio;  // NOLINT (readability/naming)
  // scheduling priority of immediate persistence thread
  static SI_32 m_siImmediatePersistenceThreadPrio;  // NOLINT (readability/naming)
  // number of times CRC check is required. (CRC check will be done more than once only on failure)
  static UI_16
  m_siCRCCheckCount;  // NOLINT (readability/naming)

 private:
  ///< name of reader thread
  const std::string m_cReadThreadName;  // NOLINT (readability/naming)
  ///< name of writer thread
  const std::string m_cWriteThreadName;  // NOLINT (readability/naming)
  ///< name of immediate persistence thread
  const std::string m_cImmediatePersistenceThreadName;  // NOLINT (readability/naming)

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// CreateAndStartChildThreads
  /// This function creates and start all child threads.
  ///
  /// \param f_happ
  ///      HANDLE - Application handle
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus CreateAndStartChildThreads(HANDLE f_happ);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// SwitchToFileStructureVersion1
  /// Copy all the data from old persistent path to new persistent path
  ///
  /// \param [IN] f_uinppversion
  ///        UI_32 - New version of NPPService
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus SwitchToFileStructureVersion1(const UI_32 f_uinppversion);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// SwitchToFileStructureVersion2
  /// Move immediate notification data files from IMMEDIATE_PERSISTENCE_STORAGE_V1 to
  /// IMMEDIATE_PERSISTENCE_STORAGE_V2/AllUserAppData/UserData
  ///
  /// \param [IN] f_uinppversion
  ///        UI_32 - New version of NPPService
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus SwitchToFileStructureVersion2(const UI_32 f_uinppversion);

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// GetNSNPPVersion
  /// Get the version of NSNPP from version.txt
  ///
  /// \param
  ///
  /// \return UI_8
  ///         UI_8 - version number
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  UI_32 GetNSNPPVersion();

  ///////////////////////////////////////////////////////////////////////////////////////////
  /// SetNSNPPVersion
  /// Set the version of NSNPP in version.txt
  ///
  /// \param [IN] f_uiversion
  ///      UI_32 - version number
  ///
  /// \return EFrameworkunifiedStatus
  ///         EFrameworkunifiedStatus - Returns status of operation
  ///
  ///////////////////////////////////////////////////////////////////////////////////////////
  EFrameworkunifiedStatus SetNSNPPVersion(UI_8 f_uiversion);

  HANDLE m_hNSReadThread;  ///< Reader thread handle

  HANDLE m_hNSWriteThread;  ///< Writer thread handle

  HANDLE m_hNSImmediatePersistenceThread;  ///< immediate persistence thread handle
};

#endif  // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_