f66861f98c42656c901198cb98d14c4cfcf90c76
[profile/ivi/node-state-manager.git] / NodeStateAccess / NodeStateAccess.h
1 #ifndef NODESTATEACCESS_H_
2 #define NODESTATEACCESS_H_
3
4 /**********************************************************************************************************************
5 *
6 * Copyright (C) 2012 Continental Automotive Systems, Inc.
7 *
8 * Author: Jean-Pierre.Bogler@continental-corporation.com
9 *
10 * Interface between NodeStateManager and IPC
11 *
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.
16 *
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/.
20 *
21 * Date       Author             Reason
22 * 24.10.2012 Jean-Pierre Bogler CSP_WZ#1322: Initial creation
23 *
24 **********************************************************************************************************************/
25
26
27 /**********************************************************************************************************************
28 *
29 *  HEADER FILE INCLUDES
30 *
31 **********************************************************************************************************************/
32
33 #include "NodeStateTypes.h" /* NodeStateTypes to communicate with NSM */
34 #include "gio/gio.h"        /* glib types for easier ICP connection   */
35
36 /**********************************************************************************************************************
37 *
38 *  TYPE
39 *
40 **********************************************************************************************************************/
41
42 /* Type definitions of callbacks that the NSM registers for the object interfaces */
43
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);
77
78
79 /* Type definition for the management of Lifecycle clients */
80 typedef gpointer NSMA_tLcConsumerHandle;
81 typedef void (*NSMA_tpfLifecycleReqFinish)(const NsmErrorStatus_e enErrorStatus);
82
83 /* Type definition to wrap all callbacks in a structure */
84 typedef struct
85 {
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;
104
105
106 /**********************************************************************************************************************
107 *
108 *  GLOBAL VARIABLES
109 *
110 **********************************************************************************************************************/
111
112 /* There are no exported global variables */
113
114
115 /**********************************************************************************************************************
116 *
117 *  FUNCTION PROTOTYPE
118 *
119 **********************************************************************************************************************/
120
121 /**********************************************************************************************************************
122 *
123 * The function is called to initialize the NodeStateAccess library.
124 * It initializes the internal variables and creates a new GMainLoop.
125 *
126 * @return TRUE:  The NodeStateAccess library could be initialized.
127 *         FALSE: Error initializing the NodeStateAccess library.
128 *
129 **********************************************************************************************************************/
130 gboolean NSMA_boInit(const NSMA_tstObjectCallbacks *pstCallbacks);
131
132
133 /**********************************************************************************************************************
134 *
135 * The function is used to send the "NodeState" signal via the IPC.
136 *
137 * @param enNodeState: NodeState to be send.
138 *
139 * @return TRUE:  Signal has been send successfully.
140 *         FALSE: Error. Signal could not be send.
141 *
142 **********************************************************************************************************************/
143 gboolean NSMA_boSendNodeStateSignal(const NsmNodeState_e enNodeState);
144
145
146 /**********************************************************************************************************************
147 *
148 * The function is used to send the "SessionChanged" signal via the IPC.
149 *
150 * @param pstSession: Pointer to session structure that should be send.
151 *
152 * @return TRUE:  Signal has been send successfully.
153 *         FALSE: Error. Signal could not be send.
154 *
155 **********************************************************************************************************************/
156 gboolean NSMA_boSendSessionSignal(const NsmSession_s *pstSession);
157
158
159 /**********************************************************************************************************************
160 *
161 * The function is used to send the "ApplicationMode" signal via the IPC.
162 *
163 * @param enApplicationMode: ApplicationMode to be send.
164 *
165 * @return TRUE:  Signal has been send successfully.
166 *         FALSE: Error. Signal could not be send.
167 *
168 **********************************************************************************************************************/
169 gboolean NSMA_boSendApplicationModeSignal(const NsmApplicationMode_e enApplicationMode);
170
171
172 /**********************************************************************************************************************
173 *
174 * The function is used to set the value of the BootMode property.
175 *
176 * @param i32BootMode: New value of BootMode property.
177 *
178 * @return TRUE:  Successfully set the properties value.
179 *         FALSE: Error setting the properties value.
180 *
181 **********************************************************************************************************************/
182 gboolean NSMA_boSetBootMode(gint i32BootMode);
183
184
185 /**********************************************************************************************************************
186 *
187 * The function is used to get the value of the BootMode property.
188 *
189 * @param pi32BootMode: Pointer where to store the BootMode.
190 *
191 * @return TRUE:  Successfully got the properties value.
192 *         FALSE: Error getting the properties value.
193 *
194 **********************************************************************************************************************/
195 gboolean NSMA_boGetBootMode(gint *pi32BootMode);
196
197
198 /**********************************************************************************************************************
199 *
200 * The function is used to set the value of the RestartReason property.
201 *
202 * @param enRestartReason: New value of RestartReason property.
203 *
204 * @return TRUE:  Successfully set the properties value.
205 *         FALSE: Error setting the properties value.
206 *
207 **********************************************************************************************************************/
208 gboolean NSMA_boSetRestartReason(const NsmRestartReason_e enRestartReason);
209
210
211 /**********************************************************************************************************************
212 *
213 * The function is used to get the value of the RestartReason property.
214 *
215 * @param penRestartReason: Pointer where to store the RestartReason.
216 *
217 * @return TRUE:  Successfully got the properties value.
218 *         FALSE: Error getting the properties value.
219 *
220 **********************************************************************************************************************/
221 gboolean NSMA_boGetRestartReason(NsmRestartReason_e *penRestartReason);
222
223
224 /**********************************************************************************************************************
225 *
226 * The function is used to set the value of the WakeUpReason property.
227 *
228 * @param enRunningReason: New value of WakeUpReason property.
229 *
230 * @return TRUE:  Successfully set the properties value.
231 *         FALSE: Error setting the properties value.
232 *
233 **********************************************************************************************************************/
234 gboolean NSMA_boSetRunningReason(const NsmRunningReason_e enRunningReason);
235
236
237 /**********************************************************************************************************************
238 *
239 * The function is used to get the value of the RunningReason property.
240 *
241 * @param penRunningReason: Pointer where to store the RunningReason.
242 *
243 * @return TRUE:  Successfully got the properties value.
244 *         FALSE: Error getting the properties value.
245 *
246 **********************************************************************************************************************/
247 gboolean NSMA_boGetRunningReason(NsmRunningReason_e *penRunningReason);
248
249
250 /**********************************************************************************************************************
251 *
252 * The function is used to set the value of the ShutdownReason property.
253 *
254 * @param enShutdownReason: New value of ShutdownReason property.
255 *
256 * @return TRUE:  Successfully set the properties value.
257 *         FALSE: Error setting the properties value.
258 *
259 **********************************************************************************************************************/
260 gboolean NSMA_boSetShutdownReason(const NsmShutdownReason_e enShutdownReason);
261
262
263 /**********************************************************************************************************************
264 *
265 * The function is used to get the value of the ShutdownReason property.
266 *
267 * @param penShutdownReason: Pointer where to store the ShutdownReason.
268 *
269 * @return TRUE:  Successfully got the properties value.
270 *         FALSE: Error getting the properties value.
271 *
272 **********************************************************************************************************************/
273 gboolean NSMA_boGetShutdownReason(NsmShutdownReason_e *penShutdownReason);
274
275
276 /**********************************************************************************************************************
277 *
278 * The function is used to create a LifecycleConsumer client.
279 *
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.
283 *
284 * @return Handle to the new life cycle consumer or NULL, if there was an error.
285 *
286 **********************************************************************************************************************/
287 NSMA_tLcConsumerHandle NSMA_hCreateLcConsumer(const gchar* sBusName, const gchar* sObjName, const guint  u32TimeoutMs);
288
289
290 /**********************************************************************************************************************
291 *
292 * The function is used to call the "LifecycleRequest" method of a client.
293 *
294 * @param hLcClient:       Handle of the client (created with "NSMA_hCreateLcConsumer").
295 * @param u32ShutdownType: Shutdown type.
296 *
297 * @return TRUE:  Successfully called client
298 *         FALSE: Error calling the client.
299 *
300 **********************************************************************************************************************/
301 gboolean NSMA_boCallLcClientRequest(NSMA_tLcConsumerHandle hLcClient, guint u32ShutdownType);
302
303
304 /**********************************************************************************************************************
305 *
306 * The function is called to set the default timeout for calls to the life cycle client.
307 *
308 * @param hLcClient:    Handle of the life cycle client.
309 * @param u32TimeoutMs: Timeout value in ms.
310 *
311 * @return TRUE:  Successfully set timeout time for client.
312 *         FALSE: Error setting the clients timeout time.
313 *
314 **********************************************************************************************************************/
315 gboolean NSMA_boSetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint u32TimeoutMs);
316
317
318 /**********************************************************************************************************************
319 *
320 * The function is called to get the default timeout for calls to the life cycle client.
321 *
322 * @param hLcClient:     Handle of the life cycle client.
323 * @param pu32TimeoutMs: Pointer where to store the timeout value in ms.
324 *
325 * @return TRUE:  Successfully got timeout time for client.
326 *         FALSE: Error getting the clients timeout time.
327 *
328 **********************************************************************************************************************/
329 gboolean NSMA_boGetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint *pu32TimeoutMs);
330
331
332 /**********************************************************************************************************************
333 *
334 * The function is used to delete a "LifecycleRequest".
335 *
336 * @param hLcClient: Handle of the client (created with "NSMA_hCreateLcConsumer").
337 *
338 * @return TRUE:  Successfully freed clients memory.
339 *         FALSE: Error freeing the clients memory.
340 *
341 **********************************************************************************************************************/
342 gboolean NSMA_boFreeLcConsumerProxy(NSMA_tLcConsumerHandle hLcConsumer);
343
344
345 /**********************************************************************************************************************
346 *
347 * The function is blocking. It waits in a loop for events and forwards them to the related callback functions.
348 *
349 * @return TRUE:  Returned because of user call.
350 *         FALSE: Returned because of an internal error.
351 *
352 **********************************************************************************************************************/
353 gboolean NSMA_boWaitForEvents(void);
354
355
356 /**********************************************************************************************************************
357 *
358 * The function is used to force the return of "NSMA_boWaitForEvents".
359 *
360 * @return TRUE:  Accepted return request.
361 *         FALSE: Error. Return request not accepted.
362 *
363 **********************************************************************************************************************/
364 gboolean NSMA_boQuitEventLoop(void);
365
366
367 /**********************************************************************************************************************
368 *
369 * The function is de-initialize the NodeStateAccess library and release all memory used by it.
370 *
371 * @return TRUE:  Successfully de-initialized access library.
372 *         FALSE: Error de-initializing the library.
373 *
374 **********************************************************************************************************************/
375 gboolean NSMA_boDeInit(void);
376
377
378 #endif /* NODESTATEACCESS_H_ */