Debian Codegraph @

src/shared/bus-locator.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "sd-bus.h"
4
5 #include "bus-locator.h"
6
7 const BusLocator* const bus_home_mgr = &(BusLocator){
8 .destination = "org.freedesktop.home1",
9 .path = "/org/freedesktop/home1",
10 .interface = "org.freedesktop.home1.Manager",
11 };
12
13 const BusLocator* const bus_import_mgr = &(BusLocator){
14 .destination ="org.freedesktop.import1",
15 .path = "/org/freedesktop/import1",
16 .interface = "org.freedesktop.import1.Manager"
17 };
18
19 const BusLocator* const bus_locale = &(BusLocator){
20 .destination = "org.freedesktop.locale1",
21 .path = "/org/freedesktop/locale1",
22 .interface = "org.freedesktop.locale1"
23 };
24
25 const BusLocator* const bus_login_mgr = &(BusLocator){
26 .destination = "org.freedesktop.login1",
27 .path = "/org/freedesktop/login1",
28 .interface = "org.freedesktop.login1.Manager"
29 };
30
31 const BusLocator* const bus_machine_mgr = &(BusLocator){
32 .destination ="org.freedesktop.machine1",
33 .path = "/org/freedesktop/machine1",
34 .interface = "org.freedesktop.machine1.Manager"
35 };
36
37 const BusLocator* const bus_network_mgr = &(BusLocator){
38 .destination = "org.freedesktop.network1",
39 .path = "/org/freedesktop/network1",
40 .interface = "org.freedesktop.network1.Manager"
41 };
42
43 const BusLocator* const bus_oom_mgr = &(BusLocator){
44 .destination = "org.freedesktop.oom1",
45 .path = "/org/freedesktop/oom1",
46 .interface = "org.freedesktop.oom1.Manager"
47 };
48
49 const BusLocator* const bus_portable_mgr = &(BusLocator){
50 .destination = "org.freedesktop.portable1",
51 .path = "/org/freedesktop/portable1",
52 .interface = "org.freedesktop.portable1.Manager"
53 };
54
55 const BusLocator* const bus_resolve_mgr = &(BusLocator){
56 .destination = "org.freedesktop.resolve1",
57 .path = "/org/freedesktop/resolve1",
58 .interface = "org.freedesktop.resolve1.Manager"
59 };
60
61 const BusLocator* const bus_systemd_mgr = &(BusLocator){
62 .destination = "org.freedesktop.systemd1",
63 .path = "/org/freedesktop/systemd1",
64 .interface = "org.freedesktop.systemd1.Manager"
65 };
66
67 const BusLocator* const bus_sysupdate_mgr = &(BusLocator){
68 .destination = "org.freedesktop.sysupdate1",
69 .path = "/org/freedesktop/sysupdate1",
70 .interface = "org.freedesktop.sysupdate1.Manager"
71 };
72
73 const BusLocator* const bus_timedate = &(BusLocator){
74 .destination = "org.freedesktop.timedate1",
75 .path = "/org/freedesktop/timedate1",
76 .interface = "org.freedesktop.timedate1"
77 };
78
79 const BusLocator* const bus_timesync_mgr = &(BusLocator){
80 .destination = "org.freedesktop.timesync1",
81 .path = "/org/freedesktop/timesync1",
82 .interface = "org.freedesktop.timesync1.Manager"
83 };
84
85 const BusLocator* const bus_hostname = &(BusLocator){
86 .destination = "org.freedesktop.hostname1",
87 .path = "/org/freedesktop/hostname1",
88 .interface = "org.freedesktop.hostname1"
89 };
90
91 /* Shorthand flavors of the sd-bus convenience helpers with destination,path,interface strings encapsulated
92 * within a single struct. */
93 int bus_call_method_async(
94 sd_bus *bus,
95 sd_bus_slot **ret_slot,
96 const BusLocator *locator,
97 const char *member,
98 sd_bus_message_handler_t callback,
99 void *userdata,
100 const char *types, ...) {
101
102 va_list ap;
103 int r;
104
105 assert(locator);
106
107 va_start(ap, types);
108 r = sd_bus_call_method_asyncv(bus, ret_slot, locator->destination, locator->path, locator->interface, member, callback, userdata, types, ap);
109 va_end(ap);
110
111 return r;
112 }
113
114 int bus_call_method(
115 sd_bus *bus,
116 const BusLocator *locator,
117 const char *member,
118 sd_bus_error *reterr_error,
119 sd_bus_message **ret_reply,
120 const char *types, ...) {
121
122 va_list ap;
123 int r;
124
125 assert(locator);
126
127 va_start(ap, types);
128 r = sd_bus_call_methodv(bus, locator->destination, locator->path, locator->interface, member, reterr_error, ret_reply, types, ap);
129 va_end(ap);
130
131 return r;
132 }
133
134 int bus_get_property(
135 sd_bus *bus,
136 const BusLocator *locator,
137 const char *member,
138 sd_bus_error *reterr_error,
139 sd_bus_message **ret_reply,
140 const char *type) {
141
142 assert(locator);
143
144 return sd_bus_get_property(bus, locator->destination, locator->path, locator->interface, member, reterr_error, ret_reply, type);
145 }
146
147 int bus_get_property_trivial(
148 sd_bus *bus,
149 const BusLocator *locator,
150 const char *member,
151 sd_bus_error *reterr_error,
152 char type,
153 void *ret) {
154
155 assert(locator);
156
157 return sd_bus_get_property_trivial(bus, locator->destination, locator->path, locator->interface, member, reterr_error, type, ret);
158 }
159
160 int bus_get_property_string(
161 sd_bus *bus,
162 const BusLocator *locator,
163 const char *member,
164 sd_bus_error *reterr_error,
165 char **ret) {
166
167 assert(locator);
168
169 return sd_bus_get_property_string(bus, locator->destination, locator->path, locator->interface, member, reterr_error, ret);
170 }
171
172 int bus_get_property_strv(
173 sd_bus *bus,
174 const BusLocator *locator,
175 const char *member,
176 sd_bus_error *reterr_error,
177 char ***ret) {
178
179 assert(locator);
180
181 return sd_bus_get_property_strv(bus, locator->destination, locator->path, locator->interface, member, reterr_error, ret);
182 }
183
184 int bus_set_property(
185 sd_bus *bus,
186 const BusLocator *locator,
187 const char *member,
188 sd_bus_error *reterr_error,
189 const char *type, ...) {
190
191 va_list ap;
192 int r;
193
194 assert(locator);
195
196 va_start(ap, type);
197 r = sd_bus_set_propertyv(bus, locator->destination, locator->path, locator->interface, member, reterr_error, type, ap);
198 va_end(ap);
199
200 return r;
201 }
202
203 int bus_match_signal(
204 sd_bus *bus,
205 sd_bus_slot **ret_slot,
206 const BusLocator *locator,
207 const char *member,
208 sd_bus_message_handler_t callback,
209 void *userdata) {
210
211 assert(locator);
212
213 return sd_bus_match_signal(bus, ret_slot, locator->destination, locator->path, locator->interface, member, callback, userdata);
214 }
215
216 int bus_match_signal_async(
217 sd_bus *bus,
218 sd_bus_slot **ret_slot,
219 const BusLocator *locator,
220 const char *member,
221 sd_bus_message_handler_t callback,
222 sd_bus_message_handler_t install_callback,
223 void *userdata) {
224
225 assert(locator);
226
227 return sd_bus_match_signal_async(bus, ret_slot, locator->destination, locator->path, locator->interface, member, callback, install_callback, userdata);
228 }
229
230 int bus_message_new_method_call(
231 sd_bus *bus,
232 sd_bus_message **ret,
233 const BusLocator *locator,
234 const char *member) {
235
236 assert(locator);
237
238 return sd_bus_message_new_method_call(bus, ret, locator->destination, locator->path, locator->interface, member);
239 }