]> git.ipfire.org Git - people/ms/systemd.git/blob - dbus.h
add basic (and not very useful) D-Bus support
[people/ms/systemd.git] / dbus.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #ifndef foodbushfoo
4 #define foodbushfoo
5
6 #include <dbus/dbus.h>
7
8 #include "manager.h"
9
10 typedef int (*BusPropertyCallback)(Manager *m, DBusMessageIter *iter, const char *property, void *data);
11
12 typedef struct BusProperty {
13 const char *interface; /* interface of the property */
14 const char *property; /* name of the property */
15 BusPropertyCallback append; /* Function that is called to serialize this property */
16 const char *signature;
17 void *data; /* The data of this property */
18 } BusProperty;
19
20 #define BUS_PROPERTIES_INTERFACE \
21 " <interface name=\"org.freedesktop.DBus.Properties\">" \
22 " <method name=\"Get\">" \
23 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \
24 " <arg name=\"property\" direction=\"in\" type=\"s\"/>" \
25 " <arg name=\"value\" direction=\"out\" type=\"v\"/>" \
26 " </method>" \
27 " <method name=\"GetAll\">" \
28 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \
29 " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>" \
30 " </method>" \
31 " </interface>"
32
33 #define BUS_INTROSPECTABLE_INTERFACE \
34 " <interface name=\"org.freedesktop.DBus.Introspectable\">" \
35 " <method name=\"Introspect\">" \
36 " <arg name=\"data\" type=\"s\" direction=\"out\"/>" \
37 " </method>" \
38 " </interface>"
39
40 int bus_init(Manager *m);
41 void bus_done(Manager *m);
42
43 void bus_dispatch(Manager *m);
44
45 void bus_watch_event(Manager *m, Watch *w, int events);
46 void bus_timeout_event(Manager *m, Watch *w, int events);
47
48 DBusHandlerResult bus_default_message_handler(Manager *m, DBusMessage *message, const char* introspection, const BusProperty *properties);
49
50 DBusHandlerResult bus_send_error_reply(Manager *m, DBusMessage *message, DBusError *bus_error, int error);
51
52 int bus_property_append_string(Manager *m, DBusMessageIter *i, const char *property, void *data);
53 int bus_property_append_strv(Manager *m, DBusMessageIter *i, const char *property, void *data);
54 int bus_property_append_bool(Manager *m, DBusMessageIter *i, const char *property, void *data);
55
56 extern const DBusObjectPathVTable bus_manager_vtable;
57 extern const DBusObjectPathVTable bus_job_vtable;
58 extern const DBusObjectPathVTable bus_unit_vtable;
59
60 #endif