6bce02c44f004c1f75ac6a9777f29df8021e7ebf
[profile/ivi/persistence-client-library.git] / src / persistence_client_library_dbus_service.h
1 #ifndef PERSISTENCE_CLIENT_LIBRARY_DBUS_SERVICE_H_
2 #define PERSISTENCE_CLIENT_LIBRARY_DBUS_SERVICE_H_
3
4 /******************************************************************************
5  * Project         Persistency
6  * (c) copyright   2012
7  * Company         XS Embedded GmbH
8  *****************************************************************************/
9 /******************************************************************************
10  * This Source Code Form is subject to the terms of the
11  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
12  * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 ******************************************************************************/
14  /**
15  * @file           persistence_client_library_dbus_service.h
16  * @ingroup        Persistence client library
17  * @author         Ingo Huerner
18  * @brief          Header of the persistence client library dbus service.
19  * @see
20  */
21
22 #include <dbus/dbus.h>
23 #include <poll.h>
24 #include <pthread.h>
25 #include <sys/eventfd.h>
26 #include <sys/timerfd.h>
27
28 /// mutex to make sure main loop is running
29 extern pthread_mutex_t gDbusInitializedMtx;
30 extern pthread_cond_t  gDbusInitializedCond;
31 extern pthread_mutex_t gDbusPendingRegMtx;
32
33 /// command definitions for main loop
34 typedef enum ECmd
35 {
36    CMD_NONE = 0,                    /// command none
37    CMD_PAS_BLOCK_AND_WRITE_BACK,    /// command block access and write data back
38    CMD_LC_PREPARE_SHUTDOWN,         /// command to prepare shutdown
39    CMD_SEND_NOTIFY_SIGNAL,          /// command send changed notification signal
40    CMD_REG_NOTIFY_SIGNAL,           /// command send register/unregister command
41    //CMD_SEND_PAS_REQUEST,            /// command send admin request
42    CMD_SEND_PAS_REGISTER,           /// command send admin register/unregister
43    //CMD_SEND_LC_REQUEST,             /// command send lifecycle request
44    CMD_SEND_LC_REGISTER,            /// command send lifecycle register/unregister
45    CMD_QUIT                         /// quit command
46 } tCmd;
47
48
49 /// pipe file descriptors
50 extern int gEfds;
51
52
53 /**
54  * @brief DBus main loop to dispatch events and dbus messages
55  *
56  * @param vtable the function pointer tables for '/org/genivi/persistence/adminconsumer' messages
57  * @param vtable2 the function pointer tables for '/com/contiautomotive/NodeStateManager/LifecycleConsumer' messages
58  * @param vtableFallback the fallback function pointer tables
59  * @param userData data to pass to the main loop
60  *
61  * @return 0
62  */
63 int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
64              DBusObjectPathVTable vtableFallback, void* userData);
65
66
67
68 /**
69  * @brief Setup the dbus main dispatching loop
70  *
71  * @return 0
72  */
73 int setup_dbus_mainloop(void);
74
75
76 int deliverToMainloop(tCmd mainloopCmd, unsigned int param1, unsigned int param2);
77
78
79 int deliverToMainloop_NM(tCmd mainloopCmd, unsigned int param1, unsigned int param2);
80
81 #endif /* PERSISTENCE_CLIENT_LIBRARY_DBUS_SERVICE_H_ */