| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Network Auth module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 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 General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #ifndef QABSTRACTOAUTH2_H |
| 31 | #define QABSTRACTOAUTH2_H |
| 32 | |
| 33 | #ifndef QT_NO_HTTP |
| 34 | |
| 35 | #include <QtCore/qdatetime.h> |
| 36 | |
| 37 | #include <QtNetworkAuth/qoauthglobal.h> |
| 38 | #include <QtNetworkAuth/qabstractoauth.h> |
| 39 | |
| 40 | QT_BEGIN_NAMESPACE |
| 41 | |
| 42 | class QHttpMultiPart; |
| 43 | class QAbstractOAuth2Private; |
| 44 | class Q_OAUTH_EXPORT QAbstractOAuth2 : public QAbstractOAuth |
| 45 | { |
| 46 | Q_OBJECT |
| 47 | Q_PROPERTY(QString scope READ scope WRITE setScope NOTIFY scopeChanged) |
| 48 | Q_PROPERTY(QString userAgent READ userAgent WRITE setUserAgent NOTIFY userAgentChanged) |
| 49 | Q_PROPERTY(QString clientIdentifierSharedKey |
| 50 | READ clientIdentifierSharedKey |
| 51 | WRITE setClientIdentifierSharedKey |
| 52 | NOTIFY clientIdentifierSharedKeyChanged) |
| 53 | Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) |
| 54 | Q_PROPERTY(QDateTime expiration READ expirationAt NOTIFY expirationAtChanged) |
| 55 | Q_PROPERTY(QString refreshToken |
| 56 | READ refreshToken |
| 57 | WRITE setRefreshToken |
| 58 | NOTIFY refreshTokenChanged) |
| 59 | |
| 60 | public: |
| 61 | explicit QAbstractOAuth2(QObject *parent = nullptr); |
| 62 | explicit QAbstractOAuth2(QNetworkAccessManager *manager, QObject *parent = nullptr); |
| 63 | ~QAbstractOAuth2(); |
| 64 | |
| 65 | Q_INVOKABLE virtual QUrl createAuthenticatedUrl(const QUrl &url, |
| 66 | const QVariantMap ¶meters = QVariantMap()); |
| 67 | Q_INVOKABLE QNetworkReply *(const QUrl &url, |
| 68 | const QVariantMap ¶meters = QVariantMap()) override; |
| 69 | Q_INVOKABLE QNetworkReply *get(const QUrl &url, |
| 70 | const QVariantMap ¶meters = QVariantMap()) override; |
| 71 | Q_INVOKABLE QNetworkReply *post(const QUrl &url, |
| 72 | const QVariantMap ¶meters = QVariantMap()) override; |
| 73 | Q_INVOKABLE virtual QNetworkReply *post(const QUrl &url, const QByteArray &data); |
| 74 | Q_INVOKABLE virtual QNetworkReply *post(const QUrl &url, QHttpMultiPart *multiPart); |
| 75 | Q_INVOKABLE QNetworkReply *put(const QUrl &url, |
| 76 | const QVariantMap ¶meters = QVariantMap()) override; |
| 77 | Q_INVOKABLE virtual QNetworkReply *put(const QUrl &url, const QByteArray &data); |
| 78 | Q_INVOKABLE virtual QNetworkReply *put(const QUrl &url, QHttpMultiPart *multiPart); |
| 79 | Q_INVOKABLE QNetworkReply *deleteResource(const QUrl &url, |
| 80 | const QVariantMap ¶meters = QVariantMap()) override; |
| 81 | |
| 82 | QString scope() const; |
| 83 | void setScope(const QString &scope); |
| 84 | |
| 85 | QString userAgent() const; |
| 86 | void setUserAgent(const QString &userAgent); |
| 87 | |
| 88 | QString responseType() const; |
| 89 | |
| 90 | QString clientIdentifierSharedKey() const; |
| 91 | void setClientIdentifierSharedKey(const QString &clientIdentifierSharedKey); |
| 92 | |
| 93 | QString state() const; |
| 94 | void setState(const QString &state); |
| 95 | |
| 96 | QDateTime expirationAt() const; |
| 97 | |
| 98 | QString refreshToken() const; |
| 99 | void setRefreshToken(const QString &refreshToken); |
| 100 | |
| 101 | Q_SIGNALS: |
| 102 | void scopeChanged(const QString &scope); |
| 103 | void userAgentChanged(const QString &userAgent); |
| 104 | void responseTypeChanged(const QString &responseType); |
| 105 | void clientIdentifierSharedKeyChanged(const QString &clientIdentifierSharedKey); |
| 106 | void stateChanged(const QString &state); |
| 107 | void expirationAtChanged(const QDateTime &expiration); |
| 108 | void refreshTokenChanged(const QString &refreshToken); |
| 109 | |
| 110 | void error(const QString &error, const QString &errorDescription, const QUrl &uri); |
| 111 | void authorizationCallbackReceived(const QVariantMap &data); |
| 112 | |
| 113 | protected: |
| 114 | explicit QAbstractOAuth2(QAbstractOAuth2Private &, QObject *parent = nullptr); |
| 115 | |
| 116 | void setResponseType(const QString &responseType); |
| 117 | |
| 118 | private: |
| 119 | Q_DECLARE_PRIVATE(QAbstractOAuth2) |
| 120 | }; |
| 121 | |
| 122 | QT_END_NAMESPACE |
| 123 | |
| 124 | #endif // QT_NO_HTTP |
| 125 | |
| 126 | #endif // QABSTRACTOAUTH2_H |
| 127 | |