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()
169#ifndef QT_BOOTSTRAPPED
171
172
173
174QDBusError::QDBusError(
const DBusError *error)
177 if (!error || !q_dbus_error_is_set(error))
180 code = get(error->name);
181 msg = QString::fromUtf8(error->message);
182 nm = QString::fromUtf8(error->name);
186
187
188
189QDBusError::QDBusError(
const QDBusMessage &qdmsg)
192 if (qdmsg.type() != QDBusMessage::ErrorMessage)
195 code = get(qdmsg.errorName().toUtf8().constData());
196 nm = qdmsg.errorName();
197 msg = qdmsg.errorMessage();
202
203
204
205QDBusError::QDBusError(ErrorType error,
const QString &mess)
208 nm = QLatin1StringView(errorMessages[error]);
213
214
215
216QDBusError::QDBusError(
const QDBusError &other)
217 : code(other.code), msg(other.msg), nm(other.nm)
222
223
224
226QDBusError &QDBusError::operator=(
const QDBusError &other)
234#ifndef QT_BOOTSTRAPPED
236
237
238
239QDBusError &QDBusError::operator=(
const QDBusMessage &qdmsg)
241 if (qdmsg.type() == QDBusMessage::ErrorMessage) {
242 code = get(qdmsg.errorName().toUtf8().constData());
243 nm = qdmsg.errorName();
244 msg = qdmsg.errorMessage();
255
256
257
258
260QDBusError::ErrorType QDBusError::type()
const
266
267
268
269
270
272QString QDBusError::name()
const
278
279
280
281
283QString QDBusError::message()
const
289
290
291
293bool QDBusError::isValid()
const
295 return (code != NoError);
299
300
301
302QString QDBusError::errorString(ErrorType error)
304 return QLatin1StringView(errorMessages[error]);
307#ifndef QT_NO_DEBUG_STREAM
310 QDebugStateSaver saver(dbg);
311 dbg.nospace() <<
"QDBusError(" << msg.name() <<
", " << msg.message() <<
')';
317
318
319
323#include "moc_qdbuserror.cpp"
328
329
330
331
332
333QT_WARNING_DISABLE_MSVC(4503)
static QDBusError::ErrorType get(const char *name)
QDebug operator<<(QDebug dbg, const QDBusError &msg)