Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qdbusintrospection.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qdbusintrospection_p.h"
6
#
include
"qdbusxmlparser_p.h"
7
8
#
ifndef
QT_NO_DBUS
9
10
QT_BEGIN_NAMESPACE
11
12
/*!
13
\class QDBusIntrospection
14
\inmodule QtDBus
15
\brief Information about introspected objects and interfaces on D-Bus.
16
\internal
17
18
This class provides structures and methods for parsing the XML introspection data for D-Bus.
19
Normally, you don't have to use the methods provided here: QDBusInterface and QDBusObject will
20
do that for you.
21
22
But they may prove useful if the XML data was obtained through other means (like parsing a file).
23
*/
24
25
QDBusIntrospection::DiagnosticsReporter::~DiagnosticsReporter()
26
=
default
;
27
28
/*!
29
\class QDBusIntrospection::Argument
30
\inmodule QtDBus
31
\brief One argument to a D-Bus method or signal.
32
33
This struct represents one argument passed to a method or received from a method or signal in
34
D-Bus. The struct does not contain information on the direction (input or output).
35
*/
36
37
/*!
38
\variable QDBusIntrospection::Argument::type
39
The argument type.
40
*/
41
42
/*!
43
\variable QDBusIntrospection::Argument::name
44
The argument name. The argument name is optional, so this may be a null QString.
45
*/
46
47
/*!
48
\fn QDBusIntrospection::Argument::operator==(const Argument &other) const
49
Compares this object against \a other and return true if they are the same.
50
*/
51
52
/*!
53
\class QDBusIntrospection::Method
54
\inmodule QtDBus
55
\brief Information about one method.
56
57
This struct represents one method discovered through introspection. A method is composed of
58
its \a name, its input arguments, its output arguments, and, optionally, annotations. There are no
59
"in-out" arguments.
60
*/
61
62
/*!
63
\variable QDBusIntrospection::Method::name
64
The method's name.
65
*/
66
67
/*!
68
\variable QDBusIntrospection::Method::inputArgs
69
A list of the method's input arguments.
70
*/
71
72
/*!
73
\variable QDBusIntrospection::Method::outputArgs
74
A list of the method's output arguments (i.e., return values).
75
*/
76
77
/*!
78
\variable QDBusIntrospection::Method::annotations
79
The annotations associated with the method. Each annotation is a pair of strings, where the key
80
is of the same format as a D-Bus interface name. The value is arbitrary.
81
*/
82
83
/*!
84
\fn QDBusIntrospection::Method::operator==(const Method &other) const
85
Compares this object against \a other and return true if they are the same.
86
*/
87
88
/*!
89
\class QDBusIntrospection::Signal
90
\inmodule QtDBus
91
\brief Information about one signal.
92
93
This struct represents one signal discovered through introspection. A signal is composed of
94
its \a name, its output arguments, and, optionally, annotations.
95
*/
96
97
/*!
98
\variable QDBusIntrospection::Signal::name
99
The signal's name.
100
*/
101
102
/*!
103
\variable QDBusIntrospection::Signal::outputArgs
104
A list of the signal's arguments.
105
*/
106
107
/*!
108
\variable QDBusIntrospection::Signal::annotations
109
The annotations associated with the signal. Each annotation is a pair of strings, where the key
110
is of the same format as a D-Bus interface name. The value is arbitrary.
111
*/
112
113
/*!
114
\fn QDBusIntrospection::Signal::operator==(const Signal& other) const
115
Compares this object against \a other and return true if they are the same.
116
*/
117
118
/*!
119
\class QDBusIntrospection::Property
120
\inmodule QtDBus
121
\brief Information about one property.
122
123
This struct represents one property discovered through introspection. A property is composed of
124
its \a name, its \a type, its \a access rights, and, optionally, annotations.
125
*/
126
127
/*!
128
\variable QDBusIntrospection::Property::name
129
The property's name.
130
*/
131
132
/*!
133
\variable QDBusIntrospection::Property::type
134
The property's type.
135
*/
136
137
/*!
138
\enum QDBusIntrospection::Property::Access
139
The possible access rights for a property:
140
\value Read
141
\value Write
142
\value ReadWrite
143
*/
144
145
/*!
146
\variable QDBusIntrospection::Property::access
147
The property's access rights.
148
*/
149
150
/*!
151
\variable QDBusIntrospection::Property::annotations
152
The annotations associated with the property. Each annotation is a pair of strings, where the key
153
is of the same format as a D-Bus interface name. The value is arbitrary.
154
*/
155
156
/*!
157
\fn QDBusIntrospection::Property::operator==(const Property &other) const
158
Compares this object against \a other and return true if they are the same.
159
*/
160
161
/*!
162
\class QDBusIntrospection::Interface
163
\inmodule QtDBus
164
\brief Information about one interface on the bus.
165
166
Each interface on D-Bus has a unique \a name, identifying where that interface was defined.
167
Interfaces may have annotations, methods, signals and properties, but none are mandatory.
168
*/
169
170
/*!
171
\variable QDBusIntrospection::Interface::name
172
The interface's name.
173
*/
174
175
/*!
176
\variable QDBusIntrospection::Interface::introspection
177
The XML document fragment describing this interface.
178
179
If parsed again through parseInterface, the object returned should have the same contents as
180
this object.
181
*/
182
183
/*!
184
\variable QDBusIntrospection::Interface::annotations
185
The annotations associated with the interface. Each annotation is a pair of strings, where the key
186
is of the same format as a D-Bus interface name. The value is arbitrary.
187
*/
188
189
/*!
190
\variable QDBusIntrospection::Interface::methods
191
The methods available in this interface. Note that method names are not unique (i.e., methods
192
can be overloaded with multiple arguments types).
193
*/
194
195
/*!
196
\variable QDBusIntrospection::Interface::signals_
197
The signals available in this interface. Note that signal names are not unique (i.e., signals
198
can be overloaded with multiple argument types).
199
200
This member is called "signals_" because "signals" is a reserved keyword in Qt.
201
*/
202
203
/*!
204
\variable QDBusIntrospection::Interface::properties
205
The properties available in this interface. Property names are unique.
206
*/
207
208
/*!
209
\fn QDBusIntrospection::Interface::operator==(const Interface &other) const
210
Compares this object against \a other and return true if they are the same.
211
212
Note that two interfaces are considered to be the same if they have the same name. The internal
213
structures in the objects are not compared.
214
*/
215
216
/*!
217
\class QDBusIntrospection::Object
218
\inmodule QtDBus
219
\brief Information about one object on the bus.
220
221
An object on the D-Bus bus is represented by its service and path on the service but, unlike
222
interfaces, objects are mutable. That is, their contents can change with time. Therefore,
223
while the (service, path) pair uniquely identifies an object, the information contained in
224
this struct may no longer represent the object.
225
226
An object can contain interfaces and child (sub) objects.
227
*/
228
229
/*!
230
\variable QDBusIntrospection::Object::service
231
The object's service name.
232
233
\sa parseObject()
234
*/
235
236
/*!
237
\variable QDBusIntrospection::Object::path
238
The object's path on the service. This is an absolute path.
239
240
\sa parseObject()
241
*/
242
243
/*!
244
\variable QDBusIntrospection::Object::interfaces
245
The list of interface names in this object.
246
*/
247
248
/*!
249
\variable QDBusIntrospection::Object::childObjects
250
The list of child object names in this object. Note that this is a relative name, not an
251
absolute path. To obtain the absolute path, concatenate with \l
252
{QDBusIntrospection::Object::path}{path}.
253
*/
254
255
/*!
256
\typedef QDBusIntrospection::Annotations
257
Contains a QMap of an annotation pair. The annotation's name is stored in the QMap key and
258
must be unique. The annotation's value is stored in the QMap's value and is arbitrary.
259
*/
260
261
/*!
262
\typedef QDBusIntrospection::Arguments
263
Contains a list of arguments to either a Method or a Signal. The arguments' order is important.
264
*/
265
266
/*!
267
\typedef QDBusIntrospection::Methods
268
Contains a QMap of methods and their names. The method's name is stored in the map's key and
269
is not necessarily unique. The order in which multiple methods with the same name are stored
270
in this map is undefined.
271
*/
272
273
/*!
274
\typedef QDBusIntrospection::Signals
275
Contains a QMap of signals and their names. The signal's name is stored in the map's key and
276
is not necessarily unique. The order in which multiple signals with the same name are stored
277
in this map is undefined.
278
*/
279
280
/*!
281
\typedef QDBusIntrospection::Properties
282
Contains a QMap of properties and their names. Each property must have a unique name.
283
*/
284
285
/*!
286
\typedef QDBusIntrospection::Interfaces
287
Contains a QMap of interfaces and their names. Each interface has a unique name.
288
*/
289
290
/*!
291
\typedef QDBusIntrospection::Objects
292
Contains a QMap of objects and their paths relative to their immediate parent.
293
*/
294
295
/*!
296
Parses the XML document fragment (given by \a xml) containing one interface.
297
298
The first element tag in this XML data must be either <node> or <interface>. If it is
299
<node>, then the <interface> tag must be a child tag of the <node> one.
300
301
If there are multiple interfaces in this XML data, it is undefined which one will be
302
returned.
303
*/
304
QDBusIntrospection::Interface QDBusIntrospection::parseInterface(
const
QString &xml,
305
DiagnosticsReporter *reporter)
306
{
307
// be lazy
308
Interfaces ifs = parseInterfaces(xml, reporter);
309
if
(ifs.isEmpty())
310
return
Interface();
311
312
// return the first in map order (probably alphabetical order)
313
return
*ifs.constBegin().value();
314
}
315
316
/*!
317
Parses the XML document fragment (given by \a xml) containing several interfaces.
318
319
If the first element tag in this document fragment is <node>, the interfaces parsed will
320
be those found as child elements of the <node> tag.
321
*/
322
QDBusIntrospection::Interfaces QDBusIntrospection::parseInterfaces(
const
QString &xml,
323
DiagnosticsReporter *reporter)
324
{
325
QString null;
326
QDBusXmlParser parser(null, null, xml, reporter);
327
return
parser.interfaces();
328
}
329
330
/*!
331
Parses the XML document fragment (given by \a xml) containing one object, found at the service
332
\a service and path \a path.
333
334
The first element tag in this document must be <node>. If that tag does not contain
335
a name attribute, the \a path argument will be used to determine the path of this
336
object node.
337
338
This function does not parse the interfaces contained in the node, nor sub-object's contents.
339
It will only list their names.
340
*/
341
QDBusIntrospection::Object QDBusIntrospection::parseObject(
const
QString &xml,
342
const
QString &service,
343
const
QString &path,
344
DiagnosticsReporter *reporter)
345
{
346
QDBusXmlParser parser(service, path, xml, reporter);
347
QSharedDataPointer<QDBusIntrospection::Object> retval = parser.object();
348
if
(!retval)
349
return
QDBusIntrospection::Object();
350
return
*retval;
351
}
352
353
QT_END_NAMESPACE
354
355
#
endif
// QT_NO_DBUS
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
dbus
qdbusintrospection.cpp
Generated on
for Qt by
1.18.0