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