summaryrefslogtreecommitdiff
path: root/NodeStateAccessStub/NodeStateAccess.h
blob: 96beb25c94a81715e0f86fa611634e33ff7ba4b8 (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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#ifndef NODESTATEACCESS_H_
#define NODESTATEACCESS_H_

/**********************************************************************************************************************
*
* Copyright (C) 2012 Continental Automotive Systems, Inc.
*
* Author: Jean-Pierre.Bogler@continental-corporation.com
*
* Interface between NodeStateManager and IPC
*
* This header file is a part of the NodeStateAccess library (NSMA) stub.
* The architecture requires that the NodeStateManager (NSM) is independent
* from the D-Bus binding and generated code. The interface functions of the
* library have to be implemented according to their description.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Date       Author             Reason
* 24.10.2012 Jean-Pierre Bogler CSP_WZ#1322: Initial creation
*
**********************************************************************************************************************/


/**********************************************************************************************************************
*
*  HEADER FILE INCLUDES
*
**********************************************************************************************************************/

#include "NodeStateTypes.h" /* NodeStateTypes to communicate with NSM */
#include "gio/gio.h"        /* glib types for easier ICP connection   */

/**********************************************************************************************************************
*
*  TYPE
*
**********************************************************************************************************************/

/* Type definitions of callbacks that the NSM registers for the object interfaces */

typedef NsmErrorStatus_e (*NSMA_tpfSetBootModeCb)              (const gint                  i32BootMode);
typedef NsmErrorStatus_e (*NSMA_tpfSetNodeStateCb)             (const NsmNodeState_e        enNodeState);
typedef NsmErrorStatus_e (*NSMA_tpfSetAppModeCb)               (const NsmApplicationMode_e  enApplMode);
typedef NsmErrorStatus_e (*NSMA_tpfRequestNodeRestartCb)       (const NsmRestartReason_e    enRestartReason,
                                                                const guint                 u32RestartType);
typedef NsmErrorStatus_e (*NSMA_tpfSetAppHealthStatusCb)       (const gchar                *sAppName,
                                                                const gboolean              boAppState);
typedef gboolean         (*NSMA_tpfCheckLucRequiredCb)         (void);
typedef NsmErrorStatus_e (*NSMA_tpfRegisterSessionCb)          (const gchar                *sSessionName,
                                                                const gchar                *sSessionOwner,
                                                                const NsmSeat_e             enSeatId,
                                                                const NsmSessionState_e     ensessionState);
typedef NsmErrorStatus_e (*NSMA_tpfUnRegisterSessionCb)        (const gchar                *sSessionName,
                                                                const gchar                *sSessionOwner,
                                                                const NsmSeat_e             enSeatId);
typedef NsmErrorStatus_e (*NSMA_tpfRegisterLifecycleClientCb)  (const gchar                *sBusName,
                                                                const gchar                *sObjName,
                                                                const guint                 u32ShutdownMode,
                                                                const guint                 u32TimeoutMs);
typedef NsmErrorStatus_e (*NSMA_tpfUnRegisterLifecycleClientCb)(const gchar                *sBusName,
                                                                const gchar                *sObjName,
                                                                const guint                 u32ShutdownMode);
typedef NsmErrorStatus_e (*NSMA_tpfGetAppModeCb)               (NsmApplicationMode_e       *penAppMode);
typedef NsmErrorStatus_e (*NSMA_tpfGetSessionStateCb)          (const gchar                *sSessionName,
                                                                const NsmSeat_e             enSeatId,
                                                                NsmSessionState_e          *penSessionState);
typedef NsmErrorStatus_e (*NSMA_tpfGetNodeStateCb)             (NsmNodeState_e             *penNodeState);
typedef NsmErrorStatus_e (*NSMA_tpfSetSessionStateCb)          (const gchar                *sSessionName,
                                                                const gchar                *sSessionOwner,
                                                                const NsmSeat_e             enSeatId,
                                                                const NsmSessionState_e     enSessionState);
typedef guint (*NSMA_tpfGetAppHealthCountCb)                   (void);
typedef guint (*NSMA_tpfGetInterfaceVersionCb)                 (void);


/* Type definition for the management of Lifecycle clients */
typedef gpointer NSMA_tLcConsumerHandle;
typedef void (*NSMA_tpfLifecycleReqFinish)(const NsmErrorStatus_e enErrorStatus);

/* Type definition to wrap all callbacks in a structure */
typedef struct
{
  NSMA_tpfSetBootModeCb               pfSetBootModeCb;
  NSMA_tpfSetNodeStateCb              pfSetNodeStateCb;
  NSMA_tpfSetAppModeCb                pfSetAppModeCb;
  NSMA_tpfRequestNodeRestartCb        pfRequestNodeRestartCb;
  NSMA_tpfSetAppHealthStatusCb        pfSetAppHealthStatusCb;
  NSMA_tpfCheckLucRequiredCb          pfCheckLucRequiredCb;
  NSMA_tpfRegisterSessionCb           pfRegisterSessionCb;
  NSMA_tpfUnRegisterSessionCb         pfUnRegisterSessionCb;
  NSMA_tpfRegisterLifecycleClientCb   pfRegisterLifecycleClientCb;
  NSMA_tpfUnRegisterLifecycleClientCb pfUnRegisterLifecycleClientCb;
  NSMA_tpfGetAppModeCb                pfGetAppModeCb;
  NSMA_tpfGetSessionStateCb           pfGetSessionStateCb;
  NSMA_tpfGetNodeStateCb              pfGetNodeStateCb;
  NSMA_tpfSetSessionStateCb           pfSetSessionStateCb;
  NSMA_tpfGetAppHealthCountCb         pfGetAppHealthCountCb;
  NSMA_tpfGetInterfaceVersionCb       pfGetInterfaceVersionCb;
  NSMA_tpfLifecycleReqFinish          pfLcClientRequestFinish;
} NSMA_tstObjectCallbacks;


/**********************************************************************************************************************
*
*  GLOBAL VARIABLES
*
**********************************************************************************************************************/

/* There are no exported global variables */


/**********************************************************************************************************************
*
*  FUNCTION PROTOTYPE
*
**********************************************************************************************************************/

/**********************************************************************************************************************
*
* The function is called to initialize the NodeStateAccess library.
* It initializes the internal variables and creates a new GMainLoop.
*
* @return TRUE:  The NodeStateAccess library could be initialized.
*         FALSE: Error initializing the NodeStateAccess library.
*
**********************************************************************************************************************/
gboolean NSMA_boInit(const NSMA_tstObjectCallbacks *pstCallbacks);


/**********************************************************************************************************************
*
* The function is used to send the "NodeState" signal via the IPC.
*
* @param enNodeState: NodeState to be send.
*
* @return TRUE:  Signal has been send successfully.
*         FALSE: Error. Signal could not be send.
*
**********************************************************************************************************************/
gboolean NSMA_boSendNodeStateSignal(const NsmNodeState_e enNodeState);


/**********************************************************************************************************************
*
* The function is used to send the "SessionChanged" signal via the IPC.
*
* @param pstSession: Pointer to session structure that should be send.
*
* @return TRUE:  Signal has been send successfully.
*         FALSE: Error. Signal could not be send.
*
**********************************************************************************************************************/
gboolean NSMA_boSendSessionSignal(const NsmSession_s *pstSession);


/**********************************************************************************************************************
*
* The function is used to send the "ApplicationMode" signal via the IPC.
*
* @param enApplicationMode: ApplicationMode to be send.
*
* @return TRUE:  Signal has been send successfully.
*         FALSE: Error. Signal could not be send.
*
**********************************************************************************************************************/
gboolean NSMA_boSendApplicationModeSignal(const NsmApplicationMode_e enApplicationMode);


/**********************************************************************************************************************
*
* The function is used to set the value of the BootMode property.
*
* @param i32BootMode: New value of BootMode property.
*
* @return TRUE:  Successfully set the properties value.
*         FALSE: Error setting the properties value.
*
**********************************************************************************************************************/
gboolean NSMA_boSetBootMode(gint i32BootMode);


/**********************************************************************************************************************
*
* The function is used to get the value of the BootMode property.
*
* @param pi32BootMode: Pointer where to store the BootMode.
*
* @return TRUE:  Successfully got the properties value.
*         FALSE: Error getting the properties value.
*
**********************************************************************************************************************/
gboolean NSMA_boGetBootMode(gint *pi32BootMode);


/**********************************************************************************************************************
*
* The function is used to set the value of the RestartReason property.
*
* @param enRestartReason: New value of RestartReason property.
*
* @return TRUE:  Successfully set the properties value.
*         FALSE: Error setting the properties value.
*
**********************************************************************************************************************/
gboolean NSMA_boSetRestartReason(const NsmRestartReason_e enRestartReason);


/**********************************************************************************************************************
*
* The function is used to get the value of the RestartReason property.
*
* @param penRestartReason: Pointer where to store the RestartReason.
*
* @return TRUE:  Successfully got the properties value.
*         FALSE: Error getting the properties value.
*
**********************************************************************************************************************/
gboolean NSMA_boGetRestartReason(NsmRestartReason_e *penRestartReason);


/**********************************************************************************************************************
*
* The function is used to set the value of the WakeUpReason property.
*
* @param enRunningReason: New value of WakeUpReason property.
*
* @return TRUE:  Successfully set the properties value.
*         FALSE: Error setting the properties value.
*
**********************************************************************************************************************/
gboolean NSMA_boSetRunningReason(const NsmRunningReason_e enRunningReason);


/**********************************************************************************************************************
*
* The function is used to get the value of the RunningReason property.
*
* @param penRunningReason: Pointer where to store the RunningReason.
*
* @return TRUE:  Successfully got the properties value.
*         FALSE: Error getting the properties value.
*
**********************************************************************************************************************/
gboolean NSMA_boGetRunningReason(NsmRunningReason_e *penRunningReason);


/**********************************************************************************************************************
*
* The function is used to set the value of the ShutdownReason property.
*
* @param enShutdownReason: New value of ShutdownReason property.
*
* @return TRUE:  Successfully set the properties value.
*         FALSE: Error setting the properties value.
*
**********************************************************************************************************************/
gboolean NSMA_boSetShutdownReason(const NsmShutdownReason_e enShutdownReason);


/**********************************************************************************************************************
*
* The function is used to get the value of the ShutdownReason property.
*
* @param penShutdownReason: Pointer where to store the ShutdownReason.
*
* @return TRUE:  Successfully got the properties value.
*         FALSE: Error getting the properties value.
*
**********************************************************************************************************************/
gboolean NSMA_boGetShutdownReason(NsmShutdownReason_e *penShutdownReason);


/**********************************************************************************************************************
*
* The function is used to create a LifecycleConsumer client.
*
* @param sBusName:     Bus name of the client object.
* @param sObjName:     Object name of the client object.
* @param u32TimeoutMs: Timeout for client calls in ms.
*
* @return Handle to the new life cycle consumer or NULL, if there was an error.
*
**********************************************************************************************************************/
NSMA_tLcConsumerHandle NSMA_hCreateLcConsumer(const gchar* sBusName, const gchar* sObjName, const guint  u32TimeoutMs);


/**********************************************************************************************************************
*
* The function is used to call the "LifecycleRequest" method of a client.
*
* @param hLcClient:       Handle of the client (created with "NSMA_hCreateLcConsumer").
* @param u32ShutdownType: Shutdown type.
*
* @return TRUE:  Successfully called client
*         FALSE: Error calling the client.
*
**********************************************************************************************************************/
gboolean NSMA_boCallLcClientRequest(NSMA_tLcConsumerHandle hLcClient, guint u32ShutdownType);


/**********************************************************************************************************************
*
* The function is called to set the default timeout for calls to the life cycle client.
*
* @param hLcClient:    Handle of the life cycle client.
* @param u32TimeoutMs: Timeout value in ms.
*
* @return TRUE:  Successfully set timeout time for client.
*         FALSE: Error setting the clients timeout time.
*
**********************************************************************************************************************/
gboolean NSMA_boSetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint u32TimeoutMs);


/**********************************************************************************************************************
*
* The function is called to get the default timeout for calls to the life cycle client.
*
* @param hLcClient:     Handle of the life cycle client.
* @param pu32TimeoutMs: Pointer where to store the timeout value in ms.
*
* @return TRUE:  Successfully got timeout time for client.
*         FALSE: Error getting the clients timeout time.
*
**********************************************************************************************************************/
gboolean NSMA_boGetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint *pu32TimeoutMs);


/**********************************************************************************************************************
*
* The function is used to delete a "LifecycleRequest".
*
* @param hLcClient: Handle of the client (created with "NSMA_hCreateLcConsumer").
*
* @return TRUE:  Successfully freed clients memory.
*         FALSE: Error freeing the clients memory.
*
**********************************************************************************************************************/
gboolean NSMA_boFreeLcConsumerProxy(NSMA_tLcConsumerHandle hLcConsumer);


/**********************************************************************************************************************
*
* The function is blocking. It waits in a loop for events and forwards them to the related callback functions.
*
* @return TRUE:  Returned because of user call.
*         FALSE: Returned because of an internal error.
*
**********************************************************************************************************************/
gboolean NSMA_boWaitForEvents(void);


/**********************************************************************************************************************
*
* The function is used to force the return of "NSMA_boWaitForEvents".
*
* @return TRUE:  Accepted return request.
*         FALSE: Error. Return request not accepted.
*
**********************************************************************************************************************/
gboolean NSMA_boQuitEventLoop(void);


/**********************************************************************************************************************
*
* The function is de-initialize the NodeStateAccess library and release all memory used by it.
*
* @return TRUE:  Successfully de-initialized access library.
*         FALSE: Error de-initializing the library.
*
**********************************************************************************************************************/
gboolean NSMA_boDeInit(void);


#endif /* NODESTATEACCESS_H_ */