7#include <qvarlengtharray.h>
8#include <private/qoffsetstringarray_p.h>
10#ifndef QT_BOOTSTRAPPED
20QT_IMPL_METATYPE_EXTERN(QDBusError)
22static constexpr const auto errorMessages = qOffsetStringArray(
25 "org.freedesktop.DBus.Error.Failed",
26 "org.freedesktop.DBus.Error.NoMemory",
27 "org.freedesktop.DBus.Error.ServiceUnknown",
28 "org.freedesktop.DBus.Error.NoReply",
29 "org.freedesktop.DBus.Error.BadAddress",
30 "org.freedesktop.DBus.Error.NotSupported",
31 "org.freedesktop.DBus.Error.LimitsExceeded",
32 "org.freedesktop.DBus.Error.AccessDenied",
33 "org.freedesktop.DBus.Error.NoServer",
34 "org.freedesktop.DBus.Error.Timeout",
35 "org.freedesktop.DBus.Error.NoNetwork",
36 "org.freedesktop.DBus.Error.AddressInUse",
37 "org.freedesktop.DBus.Error.Disconnected",
38 "org.freedesktop.DBus.Error.InvalidArgs",
39 "org.freedesktop.DBus.Error.UnknownMethod",
40 "org.freedesktop.DBus.Error.TimedOut",
41 "org.freedesktop.DBus.Error.InvalidSignature",
42 "org.freedesktop.DBus.Error.UnknownInterface",
43 "org.freedesktop.DBus.Error.UnknownObject",
44 "org.freedesktop.DBus.Error.UnknownProperty",
45 "org.freedesktop.DBus.Error.PropertyReadOnly",
46 "org.qtproject.QtDBus.Error.InternalError",
47 "org.qtproject.QtDBus.Error.InvalidService",
48 "org.qtproject.QtDBus.Error.InvalidObjectPath",
49 "org.qtproject.QtDBus.Error.InvalidInterface",
50 "org.qtproject.QtDBus.Error.InvalidMember",
54#ifndef QT_BOOTSTRAPPED
58 return QDBusError::NoError;
59 for (
int i = 0; i < errorMessages.count(); ++i)
60 if (strcmp(name, errorMessages.at(i)) == 0)
61 return QDBusError::ErrorType(i);
62 return QDBusError::Other;
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
157
158
159
160QDBusError::QDBusError()
168#ifndef QT_BOOTSTRAPPED
170
171
172
173QDBusError::QDBusError(
const DBusError *error)
176 if (!error || !q_dbus_error_is_set(error))
179 code = get(error->name);
180 msg = QString::fromUtf8(error->message);
181 nm = QString::fromUtf8(error->name);
185
186
187
188QDBusError::QDBusError(
const QDBusMessage &qdmsg)
191 if (qdmsg.type() != QDBusMessage::ErrorMessage)
194 code = get(qdmsg.errorName().toUtf8().constData());
195 nm = qdmsg.errorName();
196 msg = qdmsg.errorMessage();
201
202
203
204QDBusError::QDBusError(ErrorType error,
const QString &mess)
207 nm = QLatin1StringView(errorMessages[error]);
212
213
214
215QDBusError::QDBusError(
const QDBusError &other)
216 : code(other.code), msg(other.msg), nm(other.nm)
221
222
223
225QDBusError &QDBusError::operator=(
const QDBusError &other)
233#ifndef QT_BOOTSTRAPPED
235
236
237
238QDBusError &QDBusError::operator=(
const QDBusMessage &qdmsg)
240 if (qdmsg.type() == QDBusMessage::ErrorMessage) {
241 code = get(qdmsg.errorName().toUtf8().constData());
242 nm = qdmsg.errorName();
243 msg = qdmsg.errorMessage();
254
255
256
257
259QDBusError::ErrorType QDBusError::type()
const
265
266
267
268
269
271QString QDBusError::name()
const
277
278
279
280
282QString QDBusError::message()
const
288
289
290
292bool QDBusError::isValid()
const
294 return (code != NoError);
298
299
300
301QString QDBusError::errorString(ErrorType error)
303 return QLatin1StringView(errorMessages[error]);
306#ifndef QT_NO_DEBUG_STREAM
309 QDebugStateSaver saver(dbg);
310 dbg.nospace() <<
"QDBusError(" << msg.name() <<
", " << msg.message() <<
')';
316
317
318
322#include "moc_qdbuserror.cpp"
327
328
329
330
331
332QT_WARNING_DISABLE_MSVC(4503)
Combined button and popup list for selecting options.
static QDBusError::ErrorType get(const char *name)
QDebug operator<<(QDebug dbg, const QDBusError &msg)