]> git.ipfire.org Git - people/ms/systemd.git/blame - dbus.h
automount: implement automount unit type
[people/ms/systemd.git] / dbus.h
CommitLineData
ea430986
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3#ifndef foodbushfoo
4#define foodbushfoo
5
a7334b09
LP
6/***
7 This file is part of systemd.
8
9 Copyright 2010 Lennart Poettering
10
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.
15
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.
20
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/>.
23***/
24
ea430986
LP
25#include <dbus/dbus.h>
26
27#include "manager.h"
28
29typedef int (*BusPropertyCallback)(Manager *m, DBusMessageIter *iter, const char *property, void *data);
30
31typedef 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;
b9f49ee4 36 const void *data; /* The data of this property */
ea430986
LP
37} BusProperty;
38
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\"/>" \
45 " </method>" \
46 " <method name=\"GetAll\">" \
47 " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \
48 " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>" \
49 " </method>" \
50 " </interface>"
51
52#define BUS_INTROSPECTABLE_INTERFACE \
53 " <interface name=\"org.freedesktop.DBus.Introspectable\">" \
54 " <method name=\"Introspect\">" \
55 " <arg name=\"data\" type=\"s\" direction=\"out\"/>" \
56 " </method>" \
57 " </interface>"
58
f278026d
LP
59int bus_init_system(Manager *m);
60int bus_init_api(Manager *m);
61void bus_done_system(Manager *m);
62void bus_done_api(Manager *m);
ea430986 63
c1e1601e 64unsigned bus_dispatch(Manager *m);
ea430986
LP
65
66void bus_watch_event(Manager *m, Watch *w, int events);
67void bus_timeout_event(Manager *m, Watch *w, int events);
68
69DBusHandlerResult bus_default_message_handler(Manager *m, DBusMessage *message, const char* introspection, const BusProperty *properties);
70
71DBusHandlerResult bus_send_error_reply(Manager *m, DBusMessage *message, DBusError *bus_error, int error);
72
05e343b7
LP
73int bus_query_pid(Manager *m, const char *name);
74
ea430986
LP
75int bus_property_append_string(Manager *m, DBusMessageIter *i, const char *property, void *data);
76int bus_property_append_strv(Manager *m, DBusMessageIter *i, const char *property, void *data);
77int bus_property_append_bool(Manager *m, DBusMessageIter *i, const char *property, void *data);
38131695
LP
78int bus_property_append_uint32(Manager *m, DBusMessageIter *i, const char *property, void *data);
79int bus_property_append_uint64(Manager *m, DBusMessageIter *i, const char *property, void *data);
ea430986
LP
80
81extern const DBusObjectPathVTable bus_manager_vtable;
82extern const DBusObjectPathVTable bus_job_vtable;
83extern const DBusObjectPathVTable bus_unit_vtable;
84
c1e1601e
LP
85void bus_unit_send_change_signal(Unit *u);
86void bus_unit_send_removed_signal(Unit *u);
87
88void bus_job_send_change_signal(Job *j);
89void bus_job_send_removed_signal(Job *j);
90
6f4706b7
LP
91#define DEFINE_BUS_PROPERTY_APPEND_ENUM(function,name,type) \
92 static int function(Manager *m, DBusMessageIter *i, const char *property, void *data) { \
93 const char *value; \
94 type *field = data; \
95 \
96 assert(m); \
97 assert(i); \
98 assert(property); \
99 \
100 value = name##_to_string(*field); \
101 \
102 if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &value)) \
103 return -ENOMEM; \
104 \
105 return 0; \
106 }
107
ea430986 108#endif