1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtDBus module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QDBUSERROR_H
41#define QDBUSERROR_H
42
43#include <QtDBus/qtdbusglobal.h>
44#include <QtCore/qobjectdefs.h>
45#include <QtCore/qstring.h>
46
47#ifndef QT_NO_DBUS
48
49struct DBusError;
50
51QT_BEGIN_NAMESPACE
52
53
54class QDBusMessage;
55
56class Q_DBUS_EXPORT QDBusError
57{
58 Q_GADGET
59public:
60 enum ErrorType {
61 NoError = 0,
62 Other = 1,
63 Failed,
64 NoMemory,
65 ServiceUnknown,
66 NoReply,
67 BadAddress,
68 NotSupported,
69 LimitsExceeded,
70 AccessDenied,
71 NoServer,
72 Timeout,
73 NoNetwork,
74 AddressInUse,
75 Disconnected,
76 InvalidArgs,
77 UnknownMethod,
78 TimedOut,
79 InvalidSignature,
80 UnknownInterface,
81 UnknownObject,
82 UnknownProperty,
83 PropertyReadOnly,
84 InternalError,
85 InvalidService,
86 InvalidObjectPath,
87 InvalidInterface,
88 InvalidMember,
89
90#ifndef Q_QDOC
91 // don't use this one!
92 LastErrorType = InvalidMember
93#endif
94 };
95 Q_ENUM(ErrorType)
96
97 QDBusError();
98#ifndef QT_BOOTSTRAPPED
99 explicit QDBusError(const DBusError *error);
100 Q_IMPLICIT QDBusError(const QDBusMessage& msg);
101#endif
102 QDBusError(ErrorType error, const QString &message);
103 QDBusError(const QDBusError &other);
104 QDBusError(QDBusError &&other) noexcept
105 : code(other.code), msg(std::move(other.msg)), nm(std::move(other.nm))
106 {}
107 QDBusError &operator=(QDBusError &&other) noexcept { swap(other); return *this; }
108 QDBusError &operator=(const QDBusError &other);
109#ifndef QT_BOOTSTRAPPED
110 QDBusError &operator=(const QDBusMessage &msg);
111#endif
112
113 void swap(QDBusError &other) noexcept
114 {
115 qSwap(code, other.code);
116 qSwap(msg, other.msg);
117 qSwap(nm, other.nm);
118 }
119
120 ErrorType type() const;
121 QString name() const;
122 QString message() const;
123 bool isValid() const;
124
125 static QString errorString(ErrorType error);
126
127private:
128 ErrorType code;
129 QString msg;
130 QString nm;
131 // ### This class has an implicit (therefore inline) destructor
132 // so the following field cannot be used:
133 void *unused;
134};
135Q_DECLARE_SHARED(QDBusError)
136
137#ifndef QT_NO_DEBUG_STREAM
138Q_DBUS_EXPORT QDebug operator<<(QDebug, const QDBusError &);
139#endif
140
141QT_END_NAMESPACE
142
143Q_DECLARE_METATYPE(QDBusError)
144#else
145QT_BEGIN_NAMESPACE
146class Q_DBUS_EXPORT QDBusError {}; // dummy class for moc
147QT_END_NAMESPACE
148#endif // QT_NO_DBUS
149#endif
150