diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-02-01 03:33:24 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-02-01 03:33:24 +0100 |
commit | ea4309869e75497ba6a97c540646cb66a157a4d9 (patch) | |
tree | 8a00d7d42718d74e1b88ecb6e074ce9eb1b8a3fd /dbus.h | |
parent | b9f880f4f4903f5dd8198fc1e2e920a9850ac86e (diff) |
add basic (and not very useful) D-Bus support
Diffstat (limited to 'dbus.h')
-rw-r--r-- | dbus.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dbus.h b/dbus.h new file mode 100644 index 0000000000..6a769c9167 --- /dev/null +++ b/dbus.h @@ -0,0 +1,60 @@ +/*-*- Mode: C; c-basic-offset: 8 -*-*/ + +#ifndef foodbushfoo +#define foodbushfoo + +#include <dbus/dbus.h> + +#include "manager.h" + +typedef int (*BusPropertyCallback)(Manager *m, DBusMessageIter *iter, const char *property, void *data); + +typedef struct BusProperty { + const char *interface; /* interface of the property */ + const char *property; /* name of the property */ + BusPropertyCallback append; /* Function that is called to serialize this property */ + const char *signature; + void *data; /* The data of this property */ +} BusProperty; + +#define BUS_PROPERTIES_INTERFACE \ + " <interface name=\"org.freedesktop.DBus.Properties\">" \ + " <method name=\"Get\">" \ + " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \ + " <arg name=\"property\" direction=\"in\" type=\"s\"/>" \ + " <arg name=\"value\" direction=\"out\" type=\"v\"/>" \ + " </method>" \ + " <method name=\"GetAll\">" \ + " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \ + " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>" \ + " </method>" \ + " </interface>" + +#define BUS_INTROSPECTABLE_INTERFACE \ + " <interface name=\"org.freedesktop.DBus.Introspectable\">" \ + " <method name=\"Introspect\">" \ + " <arg name=\"data\" type=\"s\" direction=\"out\"/>" \ + " </method>" \ + " </interface>" + +int bus_init(Manager *m); +void bus_done(Manager *m); + +void bus_dispatch(Manager *m); + +void bus_watch_event(Manager *m, Watch *w, int events); +void bus_timeout_event(Manager *m, Watch *w, int events); + +DBusHandlerResult bus_default_message_handler(Manager *m, DBusMessage *message, const char* introspection, const BusProperty *properties); + +DBusHandlerResult bus_send_error_reply(Manager *m, DBusMessage *message, DBusError *bus_error, int error); + +int bus_property_append_string(Manager *m, DBusMessageIter *i, const char *property, void *data); +int bus_property_append_strv(Manager *m, DBusMessageIter *i, const char *property, void *data); +int bus_property_append_bool(Manager *m, DBusMessageIter *i, const char *property, void *data); + +extern const DBusObjectPathVTable bus_manager_vtable; +extern const DBusObjectPathVTable bus_job_vtable; +extern const DBusObjectPathVTable bus_unit_vtable; + +#endif |