]>
Commit | Line | Data |
---|---|---|
40ca29a1 LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #pragma once | |
4 | ||
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2013 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
11 | under the terms of the GNU Lesser General Public License as published by | |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | Lesser General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU Lesser General Public License | |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
22 | ***/ | |
23 | ||
24 | #include "sd-event.h" | |
25 | #include "sd-bus.h" | |
26 | #include "hashmap.h" | |
27 | #include "time-util.h" | |
28 | #include "util.h" | |
29 | ||
d21ed1ea LP |
30 | typedef enum BusTransport { |
31 | BUS_TRANSPORT_LOCAL, | |
32 | BUS_TRANSPORT_REMOTE, | |
33 | BUS_TRANSPORT_CONTAINER, | |
34 | _BUS_TRANSPORT_MAX, | |
35 | _BUS_TRANSPORT_INVALID = -1 | |
36 | } BusTransport; | |
37 | ||
ffc06c35 KS |
38 | struct bus_properties_map { |
39 | const char *type; | |
40 | const char *name; | |
41 | void *ptr; | |
42 | }; | |
43 | ||
44 | int bus_map_all_properties(sd_bus *bus, | |
45 | const char *destination, | |
46 | const char *path, | |
47 | const struct bus_properties_map *map); | |
48 | ||
40ca29a1 LP |
49 | int bus_async_unregister_and_quit(sd_event *e, sd_bus *bus, const char *name); |
50 | ||
51 | int bus_event_loop_with_idle(sd_event *e, sd_bus *bus, const char *name, usec_t timeout); | |
52 | int bus_property_get_tristate(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, sd_bus_error *error, void *userdata); | |
53 | ||
54 | int bus_verify_polkit(sd_bus *bus, sd_bus_message *m, const char *action, bool interactive, bool *_challenge, sd_bus_error *e); | |
55 | ||
56 | int bus_verify_polkit_async(sd_bus *bus, Hashmap **registry, sd_bus_message *m, const char *action, bool interactive, sd_bus_error *error, sd_bus_message_handler_t callback, void *userdata); | |
57 | void bus_verify_polkit_async_registry_free(sd_bus *bus, Hashmap *registry); | |
58 | ||
0f8bd8de | 59 | int bus_open_system_systemd(sd_bus **_bus); |
a1da8583 | 60 | |
d21ed1ea LP |
61 | int bus_open_transport(BusTransport transport, const char *host, bool user, sd_bus **bus); |
62 | ||
a1da8583 | 63 | int bus_generic_print_property(const char *name, sd_bus_message *property, bool all); |
0c842e0a | 64 | |
40ca29a1 LP |
65 | DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_unref); |
66 | DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, sd_bus_message_unref); | |
67 | ||
68 | #define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp) | |
40ca29a1 | 69 | #define _cleanup_bus_message_unref_ _cleanup_(sd_bus_message_unrefp) |
c3350683 LP |
70 | #define _cleanup_bus_error_free_ _cleanup_(sd_bus_error_free) |
71 | ||
72 | #define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \ | |
73 | int function(sd_bus *bus, \ | |
74 | const char *path, \ | |
75 | const char *interface, \ | |
76 | const char *property, \ | |
77 | sd_bus_message *reply, \ | |
78 | sd_bus_error *error, \ | |
79 | void *userdata) { \ | |
80 | \ | |
81 | const char *value; \ | |
82 | type *field = userdata; \ | |
83 | int r; \ | |
84 | \ | |
85 | assert(bus); \ | |
86 | assert(reply); \ | |
87 | assert(field); \ | |
88 | \ | |
89 | value = strempty(name##_to_string(*field)); \ | |
90 | \ | |
91 | r = sd_bus_message_append_basic(reply, 's', value); \ | |
92 | if (r < 0) \ | |
93 | return r; \ | |
94 | \ | |
95 | return 1; \ | |
96 | } \ | |
97 | struct __useless_struct_to_allow_trailing_semicolon__ | |
98 | ||
99 | #define BUS_ERROR_NO_SUCH_UNIT "org.freedesktop.systemd1.NoSuchUnit" | |
100 | #define BUS_ERROR_LOAD_FAILED "org.freedesktop.systemd1.LoadFailed" | |
101 | #define BUS_ERROR_JOB_FAILED "org.freedesktop.systemd1.JobFailed" | |
102 | ||
103 | #define BUS_ERROR_NO_SUCH_MACHINE "org.freedesktop.machine1.NoSuchMachine" | |
104 | #define BUS_ERROR_NO_MACHINE_FOR_PID "org.freedesktop.machine1.NoMachineForPID" | |
105 | #define BUS_ERROR_MACHINE_EXISTS "org.freedesktop.machine1.MachineExists" |