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/qstring.h> |
45 | |
46 | #ifndef QT_NO_DBUS |
47 | |
48 | struct DBusError; |
49 | |
50 | QT_BEGIN_NAMESPACE |
51 | |
52 | |
53 | class QDBusMessage; |
54 | |
55 | class Q_DBUS_EXPORT QDBusError |
56 | { |
57 | public: |
58 | enum ErrorType { |
59 | NoError = 0, |
60 | Other = 1, |
61 | Failed, |
62 | NoMemory, |
63 | ServiceUnknown, |
64 | NoReply, |
65 | BadAddress, |
66 | NotSupported, |
67 | LimitsExceeded, |
68 | AccessDenied, |
69 | NoServer, |
70 | Timeout, |
71 | NoNetwork, |
72 | AddressInUse, |
73 | Disconnected, |
74 | InvalidArgs, |
75 | UnknownMethod, |
76 | TimedOut, |
77 | InvalidSignature, |
78 | UnknownInterface, |
79 | UnknownObject, |
80 | UnknownProperty, |
81 | PropertyReadOnly, |
82 | InternalError, |
83 | InvalidService, |
84 | InvalidObjectPath, |
85 | InvalidInterface, |
86 | InvalidMember, |
87 | |
88 | #ifndef Q_QDOC |
89 | // don't use this one! |
90 | LastErrorType = InvalidMember |
91 | #endif |
92 | }; |
93 | |
94 | QDBusError(); |
95 | #ifndef QT_BOOTSTRAPPED |
96 | explicit QDBusError(const DBusError *error); |
97 | /*implicit*/ QDBusError(const QDBusMessage& msg); |
98 | #endif |
99 | QDBusError(ErrorType error, const QString &message); |
100 | QDBusError(const QDBusError &other); |
101 | QDBusError(QDBusError &&other) noexcept |
102 | : code(other.code), msg(std::move(other.msg)), nm(std::move(other.nm)) |
103 | {} |
104 | QDBusError &operator=(QDBusError &&other) noexcept { swap(other); return *this; } |
105 | QDBusError &operator=(const QDBusError &other); |
106 | #ifndef QT_BOOTSTRAPPED |
107 | QDBusError &operator=(const QDBusMessage &msg); |
108 | #endif |
109 | |
110 | void swap(QDBusError &other) noexcept |
111 | { |
112 | qSwap(code, other.code); |
113 | qSwap(msg, other.msg); |
114 | qSwap(nm, other.nm); |
115 | } |
116 | |
117 | ErrorType type() const; |
118 | QString name() const; |
119 | QString message() const; |
120 | bool isValid() const; |
121 | |
122 | static QString errorString(ErrorType error); |
123 | |
124 | private: |
125 | ErrorType code; |
126 | QString msg; |
127 | QString nm; |
128 | // ### This class has an implicit (therefore inline) destructor |
129 | // so the following field cannot be used: |
130 | void *unused; |
131 | }; |
132 | Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QDBusError) |
133 | |
134 | #ifndef QT_NO_DEBUG_STREAM |
135 | Q_DBUS_EXPORT QDebug operator<<(QDebug, const QDBusError &); |
136 | #endif |
137 | |
138 | QT_END_NAMESPACE |
139 | |
140 | Q_DECLARE_METATYPE(QDBusError) |
141 | |
142 | #endif // QT_NO_DBUS |
143 | #endif |
144 | |