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