1 #ifndef NODESTATEACCESS_H_
2 #define NODESTATEACCESS_H_
4 /**********************************************************************************************************************
6 * Copyright (C) 2012 Continental Automotive Systems, Inc.
8 * Author: Jean-Pierre.Bogler@continental-corporation.com
10 * Interface between NodeStateManager and IPC
12 * This header file is a part of the NodeStateAccess library (NSMA).
13 * The architecture requires that the NodeStateManager (NSM) is independent from the D-Bus binding and code generated by
14 * "gdbus-codegen". Therefore, the D-Bus communication and generated D-Bus objects are handled inside of this library.
15 * The library offers the NSM an interface to use objects generated via gdbus-codgen.
17 * This Source Code Form is subject to the terms of the Mozilla Public
18 * License, v. 2.0. If a copy of the MPL was not distributed with this
19 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
22 * 24.10.2012 Jean-Pierre Bogler CSP_WZ#1322: Initial creation
24 **********************************************************************************************************************/
27 /**********************************************************************************************************************
29 * HEADER FILE INCLUDES
31 **********************************************************************************************************************/
33 #include "NodeStateTypes.h" /* NodeStateTypes to communicate with NSM */
34 #include "gio/gio.h" /* glib types for easier ICP connection */
36 /**********************************************************************************************************************
40 **********************************************************************************************************************/
42 /* Type definitions of callbacks that the NSM registers for the object interfaces */
44 typedef NsmErrorStatus_e (*NSMA_tpfSetBootModeCb) (const gint i32BootMode);
45 typedef NsmErrorStatus_e (*NSMA_tpfSetNodeStateCb) (const NsmNodeState_e enNodeState);
46 typedef NsmErrorStatus_e (*NSMA_tpfSetAppModeCb) (const NsmApplicationMode_e enApplMode);
47 typedef NsmErrorStatus_e (*NSMA_tpfRequestNodeRestartCb) (const NsmRestartReason_e enRestartReason,
48 const guint u32RestartType);
49 typedef NsmErrorStatus_e (*NSMA_tpfSetAppHealthStatusCb) (const gchar *sAppName,
50 const gboolean boAppState);
51 typedef gboolean (*NSMA_tpfCheckLucRequiredCb) (void);
52 typedef NsmErrorStatus_e (*NSMA_tpfRegisterSessionCb) (const gchar *sSessionName,
53 const gchar *sSessionOwner,
54 const NsmSeat_e enSeatId,
55 const NsmSessionState_e ensessionState);
56 typedef NsmErrorStatus_e (*NSMA_tpfUnRegisterSessionCb) (const gchar *sSessionName,
57 const gchar *sSessionOwner,
58 const NsmSeat_e enSeatId);
59 typedef NsmErrorStatus_e (*NSMA_tpfRegisterLifecycleClientCb) (const gchar *sBusName,
60 const gchar *sObjName,
61 const guint u32ShutdownMode,
62 const guint u32TimeoutMs);
63 typedef NsmErrorStatus_e (*NSMA_tpfUnRegisterLifecycleClientCb)(const gchar *sBusName,
64 const gchar *sObjName,
65 const guint u32ShutdownMode);
66 typedef NsmErrorStatus_e (*NSMA_tpfGetAppModeCb) (NsmApplicationMode_e *penAppMode);
67 typedef NsmErrorStatus_e (*NSMA_tpfGetSessionStateCb) (const gchar *sSessionName,
68 const NsmSeat_e enSeatId,
69 NsmSessionState_e *penSessionState);
70 typedef NsmErrorStatus_e (*NSMA_tpfGetNodeStateCb) (NsmNodeState_e *penNodeState);
71 typedef NsmErrorStatus_e (*NSMA_tpfSetSessionStateCb) (const gchar *sSessionName,
72 const gchar *sSessionOwner,
73 const NsmSeat_e enSeatId,
74 const NsmSessionState_e enSessionState);
75 typedef guint (*NSMA_tpfGetAppHealthCountCb) (void);
76 typedef guint (*NSMA_tpfGetInterfaceVersionCb) (void);
79 /* Type definition for the management of Lifecycle clients */
80 typedef gpointer NSMA_tLcConsumerHandle;
81 typedef void (*NSMA_tpfLifecycleReqFinish)(const NsmErrorStatus_e enErrorStatus);
83 /* Type definition to wrap all callbacks in a structure */
86 NSMA_tpfSetBootModeCb pfSetBootModeCb;
87 NSMA_tpfSetNodeStateCb pfSetNodeStateCb;
88 NSMA_tpfSetAppModeCb pfSetAppModeCb;
89 NSMA_tpfRequestNodeRestartCb pfRequestNodeRestartCb;
90 NSMA_tpfSetAppHealthStatusCb pfSetAppHealthStatusCb;
91 NSMA_tpfCheckLucRequiredCb pfCheckLucRequiredCb;
92 NSMA_tpfRegisterSessionCb pfRegisterSessionCb;
93 NSMA_tpfUnRegisterSessionCb pfUnRegisterSessionCb;
94 NSMA_tpfRegisterLifecycleClientCb pfRegisterLifecycleClientCb;
95 NSMA_tpfUnRegisterLifecycleClientCb pfUnRegisterLifecycleClientCb;
96 NSMA_tpfGetAppModeCb pfGetAppModeCb;
97 NSMA_tpfGetSessionStateCb pfGetSessionStateCb;
98 NSMA_tpfGetNodeStateCb pfGetNodeStateCb;
99 NSMA_tpfSetSessionStateCb pfSetSessionStateCb;
100 NSMA_tpfGetAppHealthCountCb pfGetAppHealthCountCb;
101 NSMA_tpfGetInterfaceVersionCb pfGetInterfaceVersionCb;
102 NSMA_tpfLifecycleReqFinish pfLcClientRequestFinish;
103 } NSMA_tstObjectCallbacks;
106 /**********************************************************************************************************************
110 **********************************************************************************************************************/
112 /* There are no exported global variables */
115 /**********************************************************************************************************************
119 **********************************************************************************************************************/
121 /**********************************************************************************************************************
123 * The function is called to initialize the NodeStateAccess library.
124 * It initializes the internal variables and creates a new GMainLoop.
126 * @return TRUE: The NodeStateAccess library could be initialized.
127 * FALSE: Error initializing the NodeStateAccess library.
129 **********************************************************************************************************************/
130 gboolean NSMA_boInit(const NSMA_tstObjectCallbacks *pstCallbacks);
133 /**********************************************************************************************************************
135 * The function is used to send the "NodeState" signal via the IPC.
137 * @param enNodeState: NodeState to be send.
139 * @return TRUE: Signal has been send successfully.
140 * FALSE: Error. Signal could not be send.
142 **********************************************************************************************************************/
143 gboolean NSMA_boSendNodeStateSignal(const NsmNodeState_e enNodeState);
146 /**********************************************************************************************************************
148 * The function is used to send the "SessionChanged" signal via the IPC.
150 * @param pstSession: Pointer to session structure that should be send.
152 * @return TRUE: Signal has been send successfully.
153 * FALSE: Error. Signal could not be send.
155 **********************************************************************************************************************/
156 gboolean NSMA_boSendSessionSignal(const NsmSession_s *pstSession);
159 /**********************************************************************************************************************
161 * The function is used to send the "ApplicationMode" signal via the IPC.
163 * @param enApplicationMode: ApplicationMode to be send.
165 * @return TRUE: Signal has been send successfully.
166 * FALSE: Error. Signal could not be send.
168 **********************************************************************************************************************/
169 gboolean NSMA_boSendApplicationModeSignal(const NsmApplicationMode_e enApplicationMode);
172 /**********************************************************************************************************************
174 * The function is used to set the value of the BootMode property.
176 * @param i32BootMode: New value of BootMode property.
178 * @return TRUE: Successfully set the properties value.
179 * FALSE: Error setting the properties value.
181 **********************************************************************************************************************/
182 gboolean NSMA_boSetBootMode(gint i32BootMode);
185 /**********************************************************************************************************************
187 * The function is used to get the value of the BootMode property.
189 * @param pi32BootMode: Pointer where to store the BootMode.
191 * @return TRUE: Successfully got the properties value.
192 * FALSE: Error getting the properties value.
194 **********************************************************************************************************************/
195 gboolean NSMA_boGetBootMode(gint *pi32BootMode);
198 /**********************************************************************************************************************
200 * The function is used to set the value of the RestartReason property.
202 * @param enRestartReason: New value of RestartReason property.
204 * @return TRUE: Successfully set the properties value.
205 * FALSE: Error setting the properties value.
207 **********************************************************************************************************************/
208 gboolean NSMA_boSetRestartReason(const NsmRestartReason_e enRestartReason);
211 /**********************************************************************************************************************
213 * The function is used to get the value of the RestartReason property.
215 * @param penRestartReason: Pointer where to store the RestartReason.
217 * @return TRUE: Successfully got the properties value.
218 * FALSE: Error getting the properties value.
220 **********************************************************************************************************************/
221 gboolean NSMA_boGetRestartReason(NsmRestartReason_e *penRestartReason);
224 /**********************************************************************************************************************
226 * The function is used to set the value of the WakeUpReason property.
228 * @param enRunningReason: New value of WakeUpReason property.
230 * @return TRUE: Successfully set the properties value.
231 * FALSE: Error setting the properties value.
233 **********************************************************************************************************************/
234 gboolean NSMA_boSetRunningReason(const NsmRunningReason_e enRunningReason);
237 /**********************************************************************************************************************
239 * The function is used to get the value of the RunningReason property.
241 * @param penRunningReason: Pointer where to store the RunningReason.
243 * @return TRUE: Successfully got the properties value.
244 * FALSE: Error getting the properties value.
246 **********************************************************************************************************************/
247 gboolean NSMA_boGetRunningReason(NsmRunningReason_e *penRunningReason);
250 /**********************************************************************************************************************
252 * The function is used to set the value of the ShutdownReason property.
254 * @param enShutdownReason: New value of ShutdownReason property.
256 * @return TRUE: Successfully set the properties value.
257 * FALSE: Error setting the properties value.
259 **********************************************************************************************************************/
260 gboolean NSMA_boSetShutdownReason(const NsmShutdownReason_e enShutdownReason);
263 /**********************************************************************************************************************
265 * The function is used to get the value of the ShutdownReason property.
267 * @param penShutdownReason: Pointer where to store the ShutdownReason.
269 * @return TRUE: Successfully got the properties value.
270 * FALSE: Error getting the properties value.
272 **********************************************************************************************************************/
273 gboolean NSMA_boGetShutdownReason(NsmShutdownReason_e *penShutdownReason);
276 /**********************************************************************************************************************
278 * The function is used to create a LifecycleConsumer client.
280 * @param sBusName: Bus name of the client object.
281 * @param sObjName: Object name of the client object.
282 * @param u32TimeoutMs: Timeout for client calls in ms.
284 * @return Handle to the new life cycle consumer or NULL, if there was an error.
286 **********************************************************************************************************************/
287 NSMA_tLcConsumerHandle NSMA_hCreateLcConsumer(const gchar* sBusName, const gchar* sObjName, const guint u32TimeoutMs);
290 /**********************************************************************************************************************
292 * The function is used to call the "LifecycleRequest" method of a client.
294 * @param hLcClient: Handle of the client (created with "NSMA_hCreateLcConsumer").
295 * @param u32ShutdownType: Shutdown type.
297 * @return TRUE: Successfully called client
298 * FALSE: Error calling the client.
300 **********************************************************************************************************************/
301 gboolean NSMA_boCallLcClientRequest(NSMA_tLcConsumerHandle hLcClient, guint u32ShutdownType);
304 /**********************************************************************************************************************
306 * The function is called to set the default timeout for calls to the life cycle client.
308 * @param hLcClient: Handle of the life cycle client.
309 * @param u32TimeoutMs: Timeout value in ms.
311 * @return TRUE: Successfully set timeout time for client.
312 * FALSE: Error setting the clients timeout time.
314 **********************************************************************************************************************/
315 gboolean NSMA_boSetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint u32TimeoutMs);
318 /**********************************************************************************************************************
320 * The function is called to get the default timeout for calls to the life cycle client.
322 * @param hLcClient: Handle of the life cycle client.
323 * @param pu32TimeoutMs: Pointer where to store the timeout value in ms.
325 * @return TRUE: Successfully got timeout time for client.
326 * FALSE: Error getting the clients timeout time.
328 **********************************************************************************************************************/
329 gboolean NSMA_boGetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint *pu32TimeoutMs);
332 /**********************************************************************************************************************
334 * The function is used to delete a "LifecycleRequest".
336 * @param hLcClient: Handle of the client (created with "NSMA_hCreateLcConsumer").
338 * @return TRUE: Successfully freed clients memory.
339 * FALSE: Error freeing the clients memory.
341 **********************************************************************************************************************/
342 gboolean NSMA_boFreeLcConsumerProxy(NSMA_tLcConsumerHandle hLcConsumer);
345 /**********************************************************************************************************************
347 * The function is blocking. It waits in a loop for events and forwards them to the related callback functions.
349 * @return TRUE: Returned because of user call.
350 * FALSE: Returned because of an internal error.
352 **********************************************************************************************************************/
353 gboolean NSMA_boWaitForEvents(void);
356 /**********************************************************************************************************************
358 * The function is used to force the return of "NSMA_boWaitForEvents".
360 * @return TRUE: Accepted return request.
361 * FALSE: Error. Return request not accepted.
363 **********************************************************************************************************************/
364 gboolean NSMA_boQuitEventLoop(void);
367 /**********************************************************************************************************************
369 * The function is de-initialize the NodeStateAccess library and release all memory used by it.
371 * @return TRUE: Successfully de-initialized access library.
372 * FALSE: Error de-initializing the library.
374 **********************************************************************************************************************/
375 gboolean NSMA_boDeInit(void);
378 #endif /* NODESTATEACCESS_H_ */