| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QDBUSCONTEXT_H |
| 5 | #define QDBUSCONTEXT_H |
| 6 | |
| 7 | #include <QtDBus/qtdbusglobal.h> |
| 8 | #include <QtCore/qstring.h> |
| 9 | #include <QtDBus/qdbuserror.h> |
| 10 | |
| 11 | #ifndef QT_NO_DBUS |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | |
| 16 | class QDBusConnection; |
| 17 | class QDBusMessage; |
| 18 | |
| 19 | class QDBusContextPrivate; |
| 20 | class Q_DBUS_EXPORT QDBusContext |
| 21 | { |
| 22 | public: |
| 23 | QDBusContext(); |
| 24 | ~QDBusContext(); |
| 25 | |
| 26 | bool calledFromDBus() const; |
| 27 | QDBusConnection connection() const; |
| 28 | const QDBusMessage &message() const; |
| 29 | |
| 30 | // convenience methods |
| 31 | bool isDelayedReply() const; |
| 32 | // yes, they are const, so that you can use them even from const methods |
| 33 | void setDelayedReply(bool enable) const; |
| 34 | void sendErrorReply(const QString &name, const QString &msg = QString()) const; |
| 35 | void sendErrorReply(QDBusError::ErrorType type, const QString &msg = QString()) const; |
| 36 | |
| 37 | private: |
| 38 | QDBusContextPrivate *d_ptr; |
| 39 | friend class QDBusContextPrivate; |
| 40 | }; |
| 41 | |
| 42 | QT_END_NAMESPACE |
| 43 | |
| 44 | #endif // QT_NO_DBUS |
| 45 | #endif |
| 46 | |