* add a main page for the documentation of the project
[framework/uifw/edbus.git] / src / lib / dbus / E_DBus.h
1 #ifndef E_DBUS_H
2 #define E_DBUS_H
3
4 #define DBUS_API_SUBJECT_TO_CHANGE
5
6 #ifdef _WIN32
7 # ifdef interface
8 #  undef interface
9 # endif
10 #endif
11
12 #ifdef _WIN32
13 # ifdef interface
14 #  undef interface
15 # endif
16 # define DBUS_API_SUBJECT_TO_CHANGE
17 #endif
18
19 #include <dbus/dbus.h>
20 #include <Eina.h>
21
22 #ifdef EAPI
23 # undef EAPI
24 #endif
25
26 #ifdef _WIN32
27 # ifdef EFL_EDBUS_BUILD
28 #  ifdef DLL_EXPORT
29 #   define EAPI __declspec(dllexport)
30 #  else
31 #   define EAPI
32 #  endif /* ! DLL_EXPORT */
33 # else
34 #  define EAPI __declspec(dllimport)
35 # endif /* ! EFL_EDBUS_BUILD */
36 #else
37 # ifdef __GNUC__
38 #  if __GNUC__ >= 4
39 #   define EAPI __attribute__ ((visibility("default")))
40 #  else
41 #   define EAPI
42 #  endif
43 # else
44 #  define EAPI
45 # endif
46 #endif
47
48 /**
49  * @mainpage EDbus
50  *
51  * @section edbus_intro_sec Introduction
52  *
53  * EDbus is a wrapper around the
54  * <a href="http://www.freedesktop.org/wiki/Software/dbus">dbus</a>
55  * library, which is a message bus system. It also implement a set of
56  * specifications using dbus as interprocess comunication.
57  *
58  * @section edbus_modules_sec Modules
59  *
60  * @li @ref EDbus_Group Wrapper around the dbus library, which
61  * implementent an inter-process communication (IPC) system for
62  * software applications to communicate with one another.
63  * @li @ref EBluez_Group Implementation of the <a
64  * href="http://www.bluez.org/">BlueZ</a> specifications, for wireless
65  * communications with Bleutooth devices.
66  * @li @ref EConnman_Group Implementation of the <a
67  * href="http://connman.net/">connman</a> specifications, which
68  * manages internet connections within embedded devices running the
69  * Linux operating system.
70  * @li @ref EHal_Group Implementation of the <a
71  * href="http://www.freedesktop.org/wiki/Software/hal">HAL</a>
72  * specifications, which is a (software) layer between the hardware
73  * devices of a computer and the softwares that run on that
74  * computer (Hardware Abstraction Layer) . HAL is deprecated, in favor
75  * of DeviceKit.
76  * @li @ref ENotify_Group To de described. 
77  * @li @ref EOfono_Group Implementation of the <a
78  * href="http://ofono.org/">ofono</a> specifications, which is an
79  * interface for mobile telephony applications.
80  * @li @ref EUkit_Group Implementation of the <a
81  * href="http://freedesktop.org/wiki/Software/DeviceKit">DeviceKit</a>
82  * specifications, which is, like HAL, an Hardware Abstraction
83  * Layer. DeviceKit is a replacement of the deprecated HAL system. It
84  * has two submodules: UDisks, which manipulate storage devices, and
85  * UPower, which manage power devices.
86  */
87
88 /**
89  * @defgroup EDbus_Group EDbus
90  *
91  * @{
92  */
93
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97    EAPI extern int E_DBUS_DOMAIN_GLOBAL;
98    EAPI extern int E_DBUS_EVENT_SIGNAL;
99
100    typedef struct E_DBus_Connection E_DBus_Connection;
101    typedef struct E_DBus_Object E_DBus_Object;
102    typedef struct E_DBus_Interface E_DBus_Interface;
103    typedef struct E_DBus_Signal_Handler E_DBus_Signal_Handler;
104
105    typedef DBusMessage *(* E_DBus_Method_Cb)(E_DBus_Object *obj, DBusMessage *message);
106    typedef void (*E_DBus_Method_Return_Cb) (void *data, DBusMessage *msg, DBusError *error);
107    typedef void (*E_DBus_Signal_Cb) (void *data, DBusMessage *msg);
108
109    typedef void (*E_DBus_Object_Property_Get_Cb) (E_DBus_Object *obj, const char *property, int *type, void **value);
110    typedef int  (*E_DBus_Object_Property_Set_Cb) (E_DBus_Object *obj, const char *property, int type, void *value);
111
112 /**
113  * A callback function for a DBus call
114  * @param user_data the data passed in to the method call
115  * @param event_data a struct containing the return data.
116  */
117    typedef void (*E_DBus_Callback_Func) (void *user_data, void *method_return, DBusError *error);
118    typedef void *(*E_DBus_Unmarshal_Func) (DBusMessage *msg, DBusError *err);
119    typedef void (*E_DBus_Free_Func) (void *data);
120
121    typedef struct E_DBus_Callback E_DBus_Callback;
122
123
124    EAPI int e_dbus_init(void);
125    EAPI int e_dbus_shutdown(void);
126
127 /* setting up the connection */
128
129    EAPI E_DBus_Connection *e_dbus_bus_get(DBusBusType type);
130
131    EAPI void e_dbus_connection_ref(E_DBus_Connection *conn);
132
133    EAPI E_DBus_Connection *e_dbus_connection_setup(DBusConnection *conn);
134    EAPI void e_dbus_connection_close(E_DBus_Connection *conn);
135
136 /* receiving method calls */
137    EAPI E_DBus_Interface *e_dbus_interface_new(const char *interface);
138    EAPI void e_dbus_interface_ref(E_DBus_Interface *iface);
139    EAPI void e_dbus_interface_unref(E_DBus_Interface *iface);
140    EAPI void e_dbus_object_interface_attach(E_DBus_Object *obj, E_DBus_Interface *iface);
141    EAPI void e_dbus_object_interface_detach(E_DBus_Object *obj, E_DBus_Interface *iface);
142    EAPI int e_dbus_interface_method_add(E_DBus_Interface *iface, const char *member, const char *signature, const char *reply_signature, E_DBus_Method_Cb func);
143
144    EAPI int e_dbus_interface_signal_add(E_DBus_Interface *iface, const char *name, const char *signature);
145
146    EAPI E_DBus_Object *e_dbus_object_add(E_DBus_Connection *conn, const char *object_path, void *data);
147    EAPI void e_dbus_object_free(E_DBus_Object *obj);
148    EAPI void *e_dbus_object_data_get(E_DBus_Object *obj);
149    EAPI E_DBus_Connection *e_dbus_object_conn_get(E_DBus_Object *obj);
150    EAPI const char *e_dbus_object_path_get(E_DBus_Object *obj);
151    EAPI const Eina_List *e_dbus_object_interfaces_get(E_DBus_Object *obj);
152
153    EAPI void e_dbus_object_property_get_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Get_Cb func);
154    EAPI void e_dbus_object_property_set_cb_set(E_DBus_Object *obj, E_DBus_Object_Property_Set_Cb func);
155
156
157 /* sending method calls */
158
159
160    EAPI DBusPendingCall *e_dbus_message_send(E_DBus_Connection *conn, DBusMessage *msg, E_DBus_Method_Return_Cb cb_return, int timeout, void *data);
161
162    EAPI DBusPendingCall *e_dbus_method_call_send(E_DBus_Connection *conn, DBusMessage *msg, E_DBus_Unmarshal_Func unmarshal_func, E_DBus_Callback_Func cb_func, E_DBus_Free_Func free_func, int timeout, void *data);
163
164
165 /* signal receiving */
166
167    EAPI E_DBus_Signal_Handler *e_dbus_signal_handler_add(E_DBus_Connection *conn, const char *sender, const char *path, const char *interface, const char *member, E_DBus_Signal_Cb cb_signal, void *data);
168    EAPI void e_dbus_signal_handler_del(E_DBus_Connection *conn, E_DBus_Signal_Handler *sh);
169
170 /* standard dbus method calls */
171
172    EAPI DBusPendingCall *e_dbus_request_name(E_DBus_Connection *conn, const char *name,
173                                              unsigned int flags,
174                                              E_DBus_Method_Return_Cb cb_return,
175                                              const void *data);
176    EAPI DBusPendingCall *e_dbus_release_name(E_DBus_Connection *conn, const char *name,
177                                              E_DBus_Method_Return_Cb cb_return,
178                                              const void *data);
179
180    EAPI DBusPendingCall *e_dbus_get_name_owner(E_DBus_Connection *conn, const char *name,
181                                                E_DBus_Method_Return_Cb cb_return,
182                                                const void *data);
183    EAPI DBusPendingCall *e_dbus_list_names(E_DBus_Connection *conn,
184                                            E_DBus_Method_Return_Cb cb_return,
185                                            const void *data);
186    EAPI DBusPendingCall *e_dbus_list_activatable_names(E_DBus_Connection *conn,
187                                                        E_DBus_Method_Return_Cb cb_return,
188                                                        const void *data);
189    EAPI DBusPendingCall *e_dbus_name_has_owner(E_DBus_Connection *conn, const char *name,
190                                                E_DBus_Method_Return_Cb cb_return,
191                                                const void *data);
192    EAPI DBusPendingCall *e_dbus_start_service_by_name(E_DBus_Connection *conn, const char *name, unsigned int flags,
193                                                       E_DBus_Method_Return_Cb cb_return,
194                                                       const void *data);
195
196 /* standard methods calls on objects */
197    EAPI DBusPendingCall *e_dbus_peer_ping(E_DBus_Connection *conn, const char *destination,
198                                           const char *path, E_DBus_Method_Return_Cb cb_return,
199                                           const void *data);
200    EAPI DBusPendingCall *e_dbus_peer_get_machine_id(E_DBus_Connection *conn,
201                                                     const char *destination, const char *path,
202                                                     E_DBus_Method_Return_Cb cb_return,
203                                                     const void *data);
204    EAPI DBusPendingCall *e_dbus_properties_get_all(E_DBus_Connection *conn, const char *destination,
205                                                    const char *path, const char *interface,
206                                                    E_DBus_Method_Return_Cb cb_return,
207                                                    const void *data);
208    EAPI DBusPendingCall *e_dbus_properties_get(E_DBus_Connection *conn, const char *destination,
209                                                const char *path, const char *interface,
210                                                const char *property,
211                                                E_DBus_Method_Return_Cb cb_return,
212                                                const void *data);
213    EAPI DBusPendingCall *e_dbus_properties_set(E_DBus_Connection *conn, const char *destination,
214                                                const char *path, const char *interface,
215                                                const char *property, int value_type,
216                                                const void *value, E_DBus_Method_Return_Cb cb_return,
217                                                const void *data);
218
219
220    EAPI E_DBus_Callback *e_dbus_callback_new(E_DBus_Callback_Func cb_func, E_DBus_Unmarshal_Func unmarshal_func, E_DBus_Free_Func free_func, void *user_data);
221
222    EAPI void e_dbus_callback_free(E_DBus_Callback *callback);
223    EAPI void e_dbus_callback_call(E_DBus_Callback *cb, void *data, DBusError *error);
224    EAPI void *e_dbus_callback_unmarshal(E_DBus_Callback *cb, DBusMessage *msg, DBusError *err);
225    EAPI void e_dbus_callback_return_free(E_DBus_Callback *callback, void *data);
226
227 #ifdef __cplusplus
228 }
229 #endif
230
231 /**
232  * @}
233  */
234
235 #endif