]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
29ddb38f LP |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2013 Lennart Poettering | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU Lesser General Public License as published by | |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public License | |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
19 | ***/ | |
20 | ||
29ddb38f | 21 | #include "bus-introspect.h" |
cf0fbc49 | 22 | #include "log.h" |
29ddb38f | 23 | |
ebcf1f97 | 24 | static int prop_get(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { |
29ddb38f LP |
25 | return -EINVAL; |
26 | } | |
27 | ||
ebcf1f97 | 28 | static int prop_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { |
29ddb38f LP |
29 | return -EINVAL; |
30 | } | |
31 | ||
32 | static const sd_bus_vtable vtable[] = { | |
33 | SD_BUS_VTABLE_START(0), | |
adcdb374 LP |
34 | SD_BUS_METHOD("Hello", "ssas", "a(uu)", NULL, 0), |
35 | SD_BUS_METHOD("DeprecatedHello", "", "", NULL, SD_BUS_VTABLE_DEPRECATED), | |
36 | SD_BUS_METHOD("DeprecatedHelloNoReply", "", "", NULL, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_METHOD_NO_REPLY), | |
29ddb38f LP |
37 | SD_BUS_SIGNAL("Wowza", "sss", 0), |
38 | SD_BUS_SIGNAL("DeprecatedWowza", "ut", SD_BUS_VTABLE_DEPRECATED), | |
39 | SD_BUS_WRITABLE_PROPERTY("AProperty", "s", prop_get, prop_set, 0, 0), | |
40 | SD_BUS_PROPERTY("AReadOnlyDeprecatedProperty", "(ut)", prop_get, 0, SD_BUS_VTABLE_DEPRECATED), | |
41 | SD_BUS_PROPERTY("ChangingProperty", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), | |
df98a87b | 42 | SD_BUS_PROPERTY("Invalidating", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION), |
33702051 | 43 | SD_BUS_PROPERTY("Constant", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_PROPERTY_EXPLICIT), |
29ddb38f LP |
44 | SD_BUS_VTABLE_END |
45 | }; | |
46 | ||
47 | int main(int argc, char *argv[]) { | |
48 | struct introspect intro; | |
49 | ||
50 | log_set_max_level(LOG_DEBUG); | |
51 | ||
7fb411f0 | 52 | assert_se(introspect_begin(&intro, false) >= 0); |
29ddb38f | 53 | |
718db961 LP |
54 | fprintf(intro.f, " <interface name=\"org.foo\">\n"); |
55 | assert_se(introspect_write_interface(&intro, vtable) >= 0); | |
56 | fputs(" </interface>\n", intro.f); | |
29ddb38f LP |
57 | |
58 | fflush(intro.f); | |
59 | fputs(intro.introspection, stdout); | |
60 | ||
61 | introspect_free(&intro); | |
62 | ||
63 | return 0; | |
64 | } |