]>
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 | ||
30 | int bus_async_unregister_and_quit(sd_event *e, sd_bus *bus, const char *name); | |
31 | ||
32 | int bus_event_loop_with_idle(sd_event *e, sd_bus *bus, const char *name, usec_t timeout); | |
33 | 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); | |
34 | ||
35 | int bus_verify_polkit(sd_bus *bus, sd_bus_message *m, const char *action, bool interactive, bool *_challenge, sd_bus_error *e); | |
36 | ||
37 | 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); | |
38 | void bus_verify_polkit_async_registry_free(sd_bus *bus, Hashmap *registry); | |
39 | ||
0f8bd8de | 40 | int bus_open_system_systemd(sd_bus **_bus); |
a1da8583 TG |
41 | |
42 | int bus_generic_print_property(const char *name, sd_bus_message *property, bool all); | |
0c842e0a | 43 | |
40ca29a1 LP |
44 | DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_unref); |
45 | DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, sd_bus_message_unref); | |
46 | ||
47 | #define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp) | |
40ca29a1 | 48 | #define _cleanup_bus_message_unref_ _cleanup_(sd_bus_message_unrefp) |
c3350683 LP |
49 | #define _cleanup_bus_error_free_ _cleanup_(sd_bus_error_free) |
50 | ||
51 | #define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \ | |
52 | int function(sd_bus *bus, \ | |
53 | const char *path, \ | |
54 | const char *interface, \ | |
55 | const char *property, \ | |
56 | sd_bus_message *reply, \ | |
57 | sd_bus_error *error, \ | |
58 | void *userdata) { \ | |
59 | \ | |
60 | const char *value; \ | |
61 | type *field = userdata; \ | |
62 | int r; \ | |
63 | \ | |
64 | assert(bus); \ | |
65 | assert(reply); \ | |
66 | assert(field); \ | |
67 | \ | |
68 | value = strempty(name##_to_string(*field)); \ | |
69 | \ | |
70 | r = sd_bus_message_append_basic(reply, 's', value); \ | |
71 | if (r < 0) \ | |
72 | return r; \ | |
73 | \ | |
74 | return 1; \ | |
75 | } \ | |
76 | struct __useless_struct_to_allow_trailing_semicolon__ | |
77 | ||
78 | #define BUS_ERROR_NO_SUCH_UNIT "org.freedesktop.systemd1.NoSuchUnit" | |
79 | #define BUS_ERROR_LOAD_FAILED "org.freedesktop.systemd1.LoadFailed" | |
80 | #define BUS_ERROR_JOB_FAILED "org.freedesktop.systemd1.JobFailed" | |
81 | ||
82 | #define BUS_ERROR_NO_SUCH_MACHINE "org.freedesktop.machine1.NoSuchMachine" | |
83 | #define BUS_ERROR_NO_MACHINE_FOR_PID "org.freedesktop.machine1.NoMachineForPID" | |
84 | #define BUS_ERROR_MACHINE_EXISTS "org.freedesktop.machine1.MachineExists" |