1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
7 This file is part of systemd.
9 Copyright 2010 Lennart Poettering
11 systemd is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include <dbus/dbus.h>
29 typedef int (*BusPropertyCallback
)(Manager
*m
, DBusMessageIter
*iter
, const char *property
, void *data
);
31 typedef struct BusProperty
{
32 const char *interface
; /* interface of the property */
33 const char *property
; /* name of the property */
34 BusPropertyCallback append
; /* Function that is called to serialize this property */
35 const char *signature
;
36 const void *data
; /* The data of this property */
39 #define BUS_PROPERTIES_INTERFACE \
40 " <interface name=\"org.freedesktop.DBus.Properties\">" \
41 " <method name=\"Get\">" \
42 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \
43 " <arg name=\"property\" direction=\"in\" type=\"s\"/>" \
44 " <arg name=\"value\" direction=\"out\" type=\"v\"/>" \
46 " <method name=\"GetAll\">" \
47 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \
48 " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>" \
52 #define BUS_INTROSPECTABLE_INTERFACE \
53 " <interface name=\"org.freedesktop.DBus.Introspectable\">" \
54 " <method name=\"Introspect\">" \
55 " <arg name=\"data\" type=\"s\" direction=\"out\"/>" \
59 int bus_init_system(Manager
*m
);
60 int bus_init_api(Manager
*m
);
61 void bus_done_system(Manager
*m
);
62 void bus_done_api(Manager
*m
);
64 unsigned bus_dispatch(Manager
*m
);
66 void bus_watch_event(Manager
*m
, Watch
*w
, int events
);
67 void bus_timeout_event(Manager
*m
, Watch
*w
, int events
);
69 int bus_query_pid(Manager
*m
, const char *name
);
71 DBusHandlerResult
bus_default_message_handler(Manager
*m
, DBusMessage
*message
, const char* introspection
, const BusProperty
*properties
);
73 DBusHandlerResult
bus_send_error_reply(Manager
*m
, DBusMessage
*message
, DBusError
*bus_error
, int error
);
75 int bus_property_append_string(Manager
*m
, DBusMessageIter
*i
, const char *property
, void *data
);
76 int bus_property_append_strv(Manager
*m
, DBusMessageIter
*i
, const char *property
, void *data
);
77 int bus_property_append_bool(Manager
*m
, DBusMessageIter
*i
, const char *property
, void *data
);
78 int bus_property_append_int32(Manager
*m
, DBusMessageIter
*i
, const char *property
, void *data
);
79 int bus_property_append_uint32(Manager
*m
, DBusMessageIter
*i
, const char *property
, void *data
);
80 int bus_property_append_uint64(Manager
*m
, DBusMessageIter
*i
, const char *property
, void *data
);
82 #define bus_property_append_int bus_property_append_int32
83 #define bus_property_append_pid bus_property_append_uint32
84 #define bus_property_append_mode bus_property_append_uint32
85 #define bus_property_append_unsigned bus_property_append_uint32
86 #define bus_property_append_usec bus_property_append_uint64
88 #define DEFINE_BUS_PROPERTY_APPEND_ENUM(function,name,type) \
89 int function(Manager *m, DBusMessageIter *i, const char *property, void *data) { \
97 value = name##_to_string(*field); \
99 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &value)) \