8#include <qvarlengtharray.h>
9#include <private/qoffsetstringarray_p.h>
11#ifndef QT_BOOTSTRAPPED
21QT_IMPL_METATYPE_EXTERN(QDBusError)
23static constexpr const auto errorMessages = qOffsetStringArray(
26 "org.freedesktop.DBus.Error.Failed",
27 "org.freedesktop.DBus.Error.NoMemory",
28 "org.freedesktop.DBus.Error.ServiceUnknown",
29 "org.freedesktop.DBus.Error.NoReply",
30 "org.freedesktop.DBus.Error.BadAddress",
31 "org.freedesktop.DBus.Error.NotSupported",
32 "org.freedesktop.DBus.Error.LimitsExceeded",
33 "org.freedesktop.DBus.Error.AccessDenied",
34 "org.freedesktop.DBus.Error.NoServer",
35 "org.freedesktop.DBus.Error.Timeout",
36 "org.freedesktop.DBus.Error.NoNetwork",
37 "org.freedesktop.DBus.Error.AddressInUse",
38 "org.freedesktop.DBus.Error.Disconnected",
39 "org.freedesktop.DBus.Error.InvalidArgs",
40 "org.freedesktop.DBus.Error.UnknownMethod",
41 "org.freedesktop.DBus.Error.TimedOut",
42 "org.freedesktop.DBus.Error.InvalidSignature",
43 "org.freedesktop.DBus.Error.UnknownInterface",
44 "org.freedesktop.DBus.Error.UnknownObject",
45 "org.freedesktop.DBus.Error.UnknownProperty",
46 "org.freedesktop.DBus.Error.PropertyReadOnly",
47 "org.qtproject.QtDBus.Error.InternalError",
48 "org.qtproject.QtDBus.Error.InvalidService",
49 "org.qtproject.QtDBus.Error.InvalidObjectPath",
50 "org.qtproject.QtDBus.Error.InvalidInterface",
51 "org.qtproject.QtDBus.Error.InvalidMember",
55#ifndef QT_BOOTSTRAPPED
59 return QDBusError::NoError;
60 for (
int i = 0; i < errorMessages.count(); ++i)
61 if (strcmp(name, errorMessages.at(i)) == 0)
62 return QDBusError::ErrorType(i);
63 return QDBusError::Other;
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
94
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
155
158
159
160
161QDBusError::QDBusError()
164#if QT_VERSION <= QT_VERSION_CHECK(7
, 0
, 0
)
171#ifndef QT_BOOTSTRAPPED
173
174
175
176QDBusError::QDBusError(
const DBusError *error)
179 if (!error || !q_dbus_error_is_set(error))
182 code = get(error->name);
183 msg = QString::fromUtf8(error->message);
184 nm = QString::fromUtf8(error->name);
188
189
190
191QDBusError::QDBusError(
const QDBusMessage &qdmsg)
194 if (qdmsg.type() != QDBusMessage::ErrorMessage)
197 code = get(qdmsg.errorName().toUtf8().constData());
198 nm = qdmsg.errorName();
199 msg = qdmsg.errorMessage();
204
205
206
207QDBusError::QDBusError(ErrorType error,
const QString &mess)
210 nm = QLatin1StringView(errorMessages[error]);
215
216
217
218QDBusError::QDBusError(
const QDBusError &other)
219 : code(other.code), msg(other.msg), nm(other.nm)
224
225
226
228QDBusError &QDBusError::operator=(
const QDBusError &other)
236#ifndef QT_BOOTSTRAPPED
238
239
240
241QDBusError &QDBusError::operator=(
const QDBusMessage &qdmsg)
243 if (qdmsg.type() == QDBusMessage::ErrorMessage) {
244 code = get(qdmsg.errorName().toUtf8().constData());
245 nm = qdmsg.errorName();
246 msg = qdmsg.errorMessage();
257
258
259
260
262QDBusError::ErrorType QDBusError::type()
const
268
269
270
271
272
274QString QDBusError::name()
const
280
281
282
283
285QString QDBusError::message()
const
291
292
293
295bool QDBusError::isValid()
const
297 return (code != NoError);
301
302
303
304QString QDBusError::errorString(ErrorType error)
306 return QLatin1StringView(errorMessages[error]);
309#ifndef QT_NO_DEBUG_STREAM
312 QDebugStateSaver saver(dbg);
313 dbg.nospace() <<
"QDBusError(" << msg.name() <<
", " << msg.message() <<
')';
319
320
321
325#include "moc_qdbuserror.cpp"
330
331
332
333
334
335QT_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)