]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/dbus-path.c
Merge pull request #2594 from keszybz/spelling
[thirdparty/systemd.git] / src / core / dbus-path.c
CommitLineData
01f78473
LP
1/***
2 This file is part of systemd.
3
4 Copyright 2010 Lennart Poettering
5
6 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
01f78473
LP
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 14 Lesser General Public License for more details.
01f78473 15
5430f7f2 16 You should have received a copy of the GNU Lesser General Public License
01f78473
LP
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18***/
19
07630cea 20#include "bus-util.h"
cf0fbc49 21#include "dbus-path.h"
718db961 22#include "path.h"
07630cea
LP
23#include "string-util.h"
24#include "unit.h"
718db961
LP
25
26static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, path_result, PathResult);
27
28static int property_get_paths(
29 sd_bus *bus,
30 const char *path,
31 const char *interface,
32 const char *property,
33 sd_bus_message *reply,
ebcf1f97
LP
34 void *userdata,
35 sd_bus_error *error) {
718db961
LP
36
37 Path *p = userdata;
ebf57b80 38 PathSpec *k;
718db961 39 int r;
ebf57b80 40
718db961
LP
41 assert(bus);
42 assert(reply);
ebf57b80
LP
43 assert(p);
44
718db961
LP
45 r = sd_bus_message_open_container(reply, 'a', "(ss)");
46 if (r < 0)
47 return r;
ebf57b80
LP
48
49 LIST_FOREACH(spec, k, p->specs) {
718db961
LP
50 r = sd_bus_message_append(reply, "(ss)", path_type_to_string(k->type), k->path);
51 if (r < 0)
52 return r;
ebf57b80
LP
53 }
54
718db961 55 return sd_bus_message_close_container(reply);
ebf57b80
LP
56}
57
718db961
LP
58static int property_get_unit(
59 sd_bus *bus,
60 const char *path,
61 const char *interface,
62 const char *property,
63 sd_bus_message *reply,
ebcf1f97
LP
64 void *userdata,
65 sd_bus_error *error) {
b284eabd 66
718db961 67 Unit *p = userdata, *trigger;
b284eabd 68
718db961
LP
69 assert(bus);
70 assert(reply);
71 assert(p);
b284eabd 72
718db961 73 trigger = UNIT_TRIGGER(p);
b284eabd 74
718db961
LP
75 return sd_bus_message_append(reply, "s", trigger ? trigger->id : "");
76}
cd43ca73 77
718db961
LP
78const sd_bus_vtable bus_path_vtable[] = {
79 SD_BUS_VTABLE_START(0),
556089dc
LP
80 SD_BUS_PROPERTY("Unit", "s", property_get_unit, 0, SD_BUS_VTABLE_PROPERTY_CONST),
81 SD_BUS_PROPERTY("Paths", "a(ss)", property_get_paths, 0, SD_BUS_VTABLE_PROPERTY_CONST),
82 SD_BUS_PROPERTY("MakeDirectory", "b", bus_property_get_bool, offsetof(Path, make_directory), SD_BUS_VTABLE_PROPERTY_CONST),
83 SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Path, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
718db961
LP
84 SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Path, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
85 SD_BUS_VTABLE_END
d200735e 86};