chiark / gitweb /
bus: internalize a lot of protocol definitions
[elogind.git] / src / libsystemd-bus / bus-protocol.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2013 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24
25 /* Endianness */
26
27 enum {
28         _BUS_INVALID_ENDIAN = 0,
29         BUS_LITTLE_ENDIAN   = 'l',
30         BUS_BIG_ENDIAN      = 'B',
31 #if __BYTE_ORDER == __BIG_ENDIAN
32         BUS_NATIVE_ENDIAN   = BUS_BIG_ENDIAN,
33         BUS_REVERSE_ENDIAN  = BUS_LITTLE_ENDIAN
34 #else
35         BUS_NATIVE_ENDIAN   = BUS_LITTLE_ENDIAN,
36         BUS_REVERSE_ENDIAN  = BUS_BIG_ENDIAN
37 #endif
38 };
39
40 /* Flags */
41
42 enum {
43         BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
44         BUS_MESSAGE_NO_AUTO_START = 2
45 };
46
47 /* Header fields */
48
49 enum {
50         _BUS_MESSAGE_HEADER_INVALID = 0,
51         BUS_MESSAGE_HEADER_PATH,
52         BUS_MESSAGE_HEADER_INTERFACE,
53         BUS_MESSAGE_HEADER_MEMBER,
54         BUS_MESSAGE_HEADER_ERROR_NAME,
55         BUS_MESSAGE_HEADER_REPLY_SERIAL,
56         BUS_MESSAGE_HEADER_DESTINATION,
57         BUS_MESSAGE_HEADER_SENDER,
58         BUS_MESSAGE_HEADER_SIGNATURE,
59         BUS_MESSAGE_HEADER_UNIX_FDS,
60         _BUS_MESSAGE_HEADER_MAX
61 };
62
63 /* RequestName returns */
64 enum  {
65         BUS_NAME_PRIMARY_OWNER = 1,
66         BUS_NAME_IN_QUEUE = 2,
67         BUS_NAME_EXISTS = 3,
68         BUS_NAME_ALREADY_OWNER = 4
69 };
70
71 /* ReleaseName returns */
72 enum {
73         BUS_NAME_RELEASED = 1,
74         BUS_NAME_NON_EXISTENT = 2,
75         BUS_NAME_NOT_OWNER = 3,
76 };
77
78 #define BUS_INTROSPECT_DOCTYPE                                       \
79         "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
80         "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
81
82 #define BUS_INTROSPECT_INTERFACE_PEER                                \
83         " <interface name=\"org.freedesktop.DBus.Peer\">\n"             \
84         "  <method name=\"Ping\"/>\n"                                   \
85         "  <method name=\"GetMachineId\">\n"                            \
86         "   <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
87         "  </method>\n"                                                 \
88         " </interface>\n"
89
90 #define BUS_INTROSPECT_INTERFACE_INTROSPECTABLE                      \
91         " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"   \
92         "  <method name=\"Introspect\">\n"                              \
93         "   <arg name=\"data\" type=\"s\" direction=\"out\"/>\n"        \
94         "  </method>\n"                                                 \
95         " </interface>\n"
96
97 #define BUS_INTROSPECT_INTERFACE_PROPERTIES                          \
98         " <interface name=\"org.freedesktop.DBus.Properties\">\n"       \
99         "  <method name=\"Get\">\n"                                     \
100         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
101         "   <arg name=\"property\" direction=\"in\" type=\"s\"/>\n"     \
102         "   <arg name=\"value\" direction=\"out\" type=\"v\"/>\n"       \
103         "  </method>\n"                                                 \
104         "  <method name=\"GetAll\">\n"                                  \
105         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
106         "   <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
107         "  </method>\n"                                                 \
108         "  <method name=\"Set\">\n"                                     \
109         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
110         "   <arg name=\"property\" direction=\"in\" type=\"s\"/>\n"     \
111         "   <arg name=\"value\" direction=\"in\" type=\"v\"/>\n"        \
112         "  </method>\n"                                                 \
113         "  <signal name=\"PropertiesChanged\">\n"                       \
114         "   <arg type=\"s\" name=\"interface\"/>\n"                     \
115         "   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n"        \
116         "   <arg type=\"as\" name=\"invalidated_properties\"/>\n"       \
117         "  </signal>\n"                                                 \
118         " </interface>\n"
119
120 #define BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER                      \
121         " <interface name=\"org.freedesktop.DBus.ObjectManager\">\n"    \
122         "  <method name=\"GetManagedObjects\">\n"                       \
123         "   <arg type=\"a{oa{sa{sv}}}\" name=\"object_paths_interfaces_and_properties\" direction=\"out\"/>\n" \
124         "  </method>\n"                                                 \
125         "  <signal name=\"InterfacesAdded\">\n"                         \
126         "   <arg type=\"o\" name=\"object_path\"/>\n"                   \
127         "   <arg type=\"a{sa{sv}}\" name=\"interfaces_and_properties\"/>\n" \
128         "  </signal>\n"                                                 \
129         "  <signal name=\"InterfacesRemoved\">\n"                       \
130         "   <arg type=\"o\" name=\"object_path\"/>\n"                   \
131         "   <arg type=\"as\" name=\"interfaces\"/>\n"                   \
132         "  </signal>\n"                                                 \
133         " </interface>\n"