GXDE Bernese
Loading...
Searching...
No Matches
dbus_introspection.h
1/*
2 * Copyright (C) 2026 CharOfString <root@charofstring.cc>
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation, either version 3 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef DBUS_INTROSPECTION_DBUS_INTROSPECTION_H_
19#define DBUS_INTROSPECTION_DBUS_INTROSPECTION_H_
20
21#include "QList"
22#include "QMap"
23#include "QMultiMap"
24#include "QSharedPointer"
25#include "QString"
26
27#include "bernese/export.h"
28
29namespace bernese {
30namespace dbus_introspection {
31
32// Annotation values by annotation name. A later annotation with the same
33// name replaces the earlier one.
34using Annotations = QMap<QString, QString>;
35
36// One argument of a method or a signal.
37struct Argument {
38 QString type; // D-Bus type signature, like "a{sv}".
39 QString name; // May be empty.
40};
41
42using Arguments = QList<Argument>;
43
44// One method of an interface.
45struct Method {
46 QString name;
47 Arguments input_args;
48 Arguments output_args;
49 Annotations annotations;
50};
51
52// One signal of an interface. Signals only have output arguments.
53struct Signal {
54 QString name;
55 Arguments output_args;
56 Annotations annotations;
57};
58
59// One property of an interface.
60struct Property {
61 enum class Access { kRead, kWrite, kReadWrite };
62
63 QString name;
64 QString type; // D-Bus type signature.
65 Access access = Access::kRead;
66 Annotations annotations;
67};
68
69// One interface. The maps are sorted by member name. Overloaded methods and
70// signals share one name, so they use multi maps.
71struct Interface {
72 QString name;
73 // The interface written back as XML, in the same text form that QtDBus
74 // makes. Generated adaptors store it in their D-Bus Introspection
75 // class info.
76 QString introspection;
77 Annotations annotations;
78 QMultiMap<QString, Method> methods;
79 // Not named "signals" because that word is a Qt keyword macro.
80 QMultiMap<QString, Signal> signal_map;
81 QMap<QString, Property> properties;
82};
83
84// Interfaces by interface name.
85using Interfaces = QMap<QString, QSharedPointer<const Interface>>;
86
97BERNESE_EXPORT Interfaces ParseInterfaces(const QString& xml);
98
108BERNESE_EXPORT bool IsValidMemberName(const QString& name);
109
119BERNESE_EXPORT bool IsValidInterfaceName(const QString& name);
120
121} // namespace dbus_introspection
122} // namespace bernese
123
124#endif // DBUS_INTROSPECTION_DBUS_INTROSPECTION_H_
Definition dbus_introspection.h:37
Definition dbus_introspection.h:71
Definition dbus_introspection.h:45
Definition dbus_introspection.h:60
Definition dbus_introspection.h:53