chiark / gitweb /
bus: properly handle if new objects are installed in the node tree while we are dispa...
[elogind.git] / src / systemd / sd-bus-protocol.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foosdbusprotocolhfoo
4 #define foosdbusprotocolhfoo
5
6 /***
7   This file is part of systemd.
8
9   Copyright 2013 Lennart Poettering
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU Lesser General Public License as published by
13   the Free Software Foundation; either version 2.1 of the License, or
14   (at your option) any later version.
15
16   systemd is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   Lesser General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <endian.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Types of message */
32
33 enum {
34         _SD_BUS_MESSAGE_TYPE_INVALID = 0,
35         SD_BUS_MESSAGE_TYPE_METHOD_CALL,
36         SD_BUS_MESSAGE_TYPE_METHOD_RETURN,
37         SD_BUS_MESSAGE_TYPE_METHOD_ERROR,
38         SD_BUS_MESSAGE_TYPE_SIGNAL,
39         _SD_BUS_MESSAGE_TYPE_MAX
40 };
41
42 /* Primitive types */
43
44 enum {
45         _SD_BUS_TYPE_INVALID         = 0,
46         SD_BUS_TYPE_BYTE             = 'y',
47         SD_BUS_TYPE_BOOLEAN          = 'b',
48         SD_BUS_TYPE_INT16            = 'n',
49         SD_BUS_TYPE_UINT16           = 'q',
50         SD_BUS_TYPE_INT32            = 'i',
51         SD_BUS_TYPE_UINT32           = 'u',
52         SD_BUS_TYPE_INT64            = 'x',
53         SD_BUS_TYPE_UINT64           = 't',
54         SD_BUS_TYPE_DOUBLE           = 'd',
55         SD_BUS_TYPE_STRING           = 's',
56         SD_BUS_TYPE_OBJECT_PATH      = 'o',
57         SD_BUS_TYPE_SIGNATURE        = 'g',
58         SD_BUS_TYPE_UNIX_FD          = 'h',
59         SD_BUS_TYPE_ARRAY            = 'a',
60         SD_BUS_TYPE_VARIANT          = 'v',
61         SD_BUS_TYPE_STRUCT           = 'r', /* not actually used in signatures */
62         SD_BUS_TYPE_STRUCT_BEGIN     = '(',
63         SD_BUS_TYPE_STRUCT_END       = ')',
64         SD_BUS_TYPE_DICT_ENTRY       = 'e', /* not actually used in signatures */
65         SD_BUS_TYPE_DICT_ENTRY_BEGIN = '{',
66         SD_BUS_TYPE_DICT_ENTRY_END   = '}',
67 };
68
69 /* Endianness */
70
71 enum {
72         _SD_BUS_INVALID_ENDIAN = 0,
73         SD_BUS_LITTLE_ENDIAN   = 'l',
74         SD_BUS_BIG_ENDIAN      = 'B',
75 #if __BYTE_ORDER == __BIG_ENDIAN
76         SD_BUS_NATIVE_ENDIAN   = SD_BUS_BIG_ENDIAN,
77         SD_BUS_REVERSE_ENDIAN  = SD_BUS_LITTLE_ENDIAN
78 #else
79         SD_BUS_NATIVE_ENDIAN   = SD_BUS_LITTLE_ENDIAN,
80         SD_BUS_REVERSE_ENDIAN  = SD_BUS_BIG_ENDIAN
81 #endif
82 };
83
84 /* Flags */
85
86 enum {
87         SD_BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
88         SD_BUS_MESSAGE_NO_AUTO_START = 2
89 };
90
91 /* Header fields */
92
93 enum {
94         _SD_BUS_MESSAGE_HEADER_INVALID = 0,
95         SD_BUS_MESSAGE_HEADER_PATH,
96         SD_BUS_MESSAGE_HEADER_INTERFACE,
97         SD_BUS_MESSAGE_HEADER_MEMBER,
98         SD_BUS_MESSAGE_HEADER_ERROR_NAME,
99         SD_BUS_MESSAGE_HEADER_REPLY_SERIAL,
100         SD_BUS_MESSAGE_HEADER_DESTINATION,
101         SD_BUS_MESSAGE_HEADER_SENDER,
102         SD_BUS_MESSAGE_HEADER_SIGNATURE,
103         SD_BUS_MESSAGE_HEADER_UNIX_FDS,
104         _SD_BUS_MESSAGE_HEADER_MAX
105 };
106
107 #define SD_BUS_INTROSPECT_DOCTYPE                                       \
108         "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
109         "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
110
111 #define SD_BUS_INTROSPECT_INTERFACE_PEER                                \
112         " <interface name=\"org.freedesktop.DBus.Peer\">\n"             \
113         "  <method name=\"Ping\"/>\n"                                   \
114         "  <method name=\"GetMachineId\">\n"                            \
115         "   <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
116         "  </method>\n"                                                 \
117         " </interface>\n"
118
119 #define SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE                      \
120         " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"   \
121         "  <method name=\"Introspect\">\n"                              \
122         "   <arg name=\"data\" type=\"s\" direction=\"out\"/>\n"        \
123         "  </method>\n"                                                 \
124         " </interface>\n"
125
126 #define SD_BUS_INTROSPECT_INTERFACE_PROPERTIES                          \
127         " <interface name=\"org.freedesktop.DBus.Properties\">\n"       \
128         "  <method name=\"Get\">\n"                                     \
129         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
130         "   <arg name=\"property\" direction=\"in\" type=\"s\"/>\n"     \
131         "   <arg name=\"value\" direction=\"out\" type=\"v\"/>\n"       \
132         "  </method>\n"                                                 \
133         "  <method name=\"GetAll\">\n"                                  \
134         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
135         "   <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
136         "  </method>\n"                                                 \
137         "  <method name=\"Set\">\n"                                     \
138         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
139         "   <arg name=\"property\" direction=\"in\" type=\"s\"/>\n"     \
140         "   <arg name=\"value\" direction=\"in\" type=\"v\"/>\n"        \
141         "  </method>\n"                                                 \
142         "  <signal name=\"PropertiesChanged\">\n"                       \
143         "   <arg type=\"s\" name=\"interface\"/>\n"                     \
144         "   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n"        \
145         "   <arg type=\"as\" name=\"invalidated_properties\"/>\n"       \
146         "  </signal>\n"                                                 \
147         " </interface>\n"
148
149 #define SD_BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER                      \
150         " <interface name=\"org.freedesktop.DBus.ObjectManager\">\n"    \
151         "  <method name=\"GetManagedObjects\">\n"                       \
152         "   <arg type=\"a{oa{sa{sv}}}\" name=\"object_paths_interfaces_and_properties\" direction=\"out\"/>\n" \
153         "  </method>\n"                                                 \
154         "  <signal name=\"InterfacesAdded\">\n"                         \
155         "   <arg type=\"o\" name=\"object_path\"/>\n"                   \
156         "   <arg type=\"a{sa{sv}}\" name=\"interfaces_and_properties\"/>\n" \
157         "  </signal>\n"                                                 \
158         "  <signal name=\"InterfacesRemoved\">\n"                       \
159         "   <arg type=\"o\" name=\"object_path\"/>\n"                   \
160         "   <arg type=\"as\" name=\"interfaces\"/>\n"                   \
161         "  </signal>\n"                                                 \
162         " </interface>\n"
163
164 #ifdef __cplusplus
165 }
166 #endif
167
168 #endif