1 | // Copyright (C) 2017 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QABSTRACTOAUTH2_H |
5 | #define QABSTRACTOAUTH2_H |
6 | |
7 | #ifndef QT_NO_HTTP |
8 | |
9 | #include <QtCore/qdatetime.h> |
10 | |
11 | #include <QtNetworkAuth/qoauthglobal.h> |
12 | #include <QtNetworkAuth/qabstractoauth.h> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | class QSslConfiguration; |
17 | class QHttpMultiPart; |
18 | class QAbstractOAuth2Private; |
19 | class Q_OAUTH_EXPORT QAbstractOAuth2 : public QAbstractOAuth |
20 | { |
21 | Q_OBJECT |
22 | Q_PROPERTY(QString scope READ scope WRITE setScope NOTIFY scopeChanged) |
23 | Q_PROPERTY(QString userAgent READ userAgent WRITE setUserAgent NOTIFY userAgentChanged) |
24 | Q_PROPERTY(QString clientIdentifierSharedKey |
25 | READ clientIdentifierSharedKey |
26 | WRITE setClientIdentifierSharedKey |
27 | NOTIFY clientIdentifierSharedKeyChanged) |
28 | Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) |
29 | Q_PROPERTY(QDateTime expiration READ expirationAt NOTIFY expirationAtChanged) |
30 | Q_PROPERTY(QString refreshToken |
31 | READ refreshToken |
32 | WRITE setRefreshToken |
33 | NOTIFY refreshTokenChanged) |
34 | |
35 | public: |
36 | explicit QAbstractOAuth2(QObject *parent = nullptr); |
37 | explicit QAbstractOAuth2(QNetworkAccessManager *manager, QObject *parent = nullptr); |
38 | ~QAbstractOAuth2(); |
39 | |
40 | Q_INVOKABLE virtual QUrl createAuthenticatedUrl(const QUrl &url, |
41 | const QVariantMap ¶meters = QVariantMap()); |
42 | Q_INVOKABLE QNetworkReply *(const QUrl &url, |
43 | const QVariantMap ¶meters = QVariantMap()) override; |
44 | Q_INVOKABLE QNetworkReply *get(const QUrl &url, |
45 | const QVariantMap ¶meters = QVariantMap()) override; |
46 | Q_INVOKABLE QNetworkReply *post(const QUrl &url, |
47 | const QVariantMap ¶meters = QVariantMap()) override; |
48 | Q_INVOKABLE virtual QNetworkReply *post(const QUrl &url, const QByteArray &data); |
49 | Q_INVOKABLE virtual QNetworkReply *post(const QUrl &url, QHttpMultiPart *multiPart); |
50 | Q_INVOKABLE QNetworkReply *put(const QUrl &url, |
51 | const QVariantMap ¶meters = QVariantMap()) override; |
52 | Q_INVOKABLE virtual QNetworkReply *put(const QUrl &url, const QByteArray &data); |
53 | Q_INVOKABLE virtual QNetworkReply *put(const QUrl &url, QHttpMultiPart *multiPart); |
54 | Q_INVOKABLE QNetworkReply *deleteResource(const QUrl &url, |
55 | const QVariantMap ¶meters = QVariantMap()) override; |
56 | |
57 | QString scope() const; |
58 | void setScope(const QString &scope); |
59 | |
60 | QString userAgent() const; |
61 | void setUserAgent(const QString &userAgent); |
62 | |
63 | QString responseType() const; |
64 | |
65 | QString clientIdentifierSharedKey() const; |
66 | void setClientIdentifierSharedKey(const QString &clientIdentifierSharedKey); |
67 | |
68 | QString state() const; |
69 | void setState(const QString &state); |
70 | |
71 | QDateTime expirationAt() const; |
72 | |
73 | QString refreshToken() const; |
74 | void setRefreshToken(const QString &refreshToken); |
75 | |
76 | #ifndef QT_NO_SSL |
77 | QSslConfiguration sslConfiguration() const; |
78 | void setSslConfiguration(const QSslConfiguration &configuration); |
79 | #endif |
80 | |
81 | void prepareRequest(QNetworkRequest *request, const QByteArray &verb, |
82 | const QByteArray &body = QByteArray()) override; |
83 | |
84 | Q_SIGNALS: |
85 | void scopeChanged(const QString &scope); |
86 | void userAgentChanged(const QString &userAgent); |
87 | void responseTypeChanged(const QString &responseType); |
88 | void clientIdentifierSharedKeyChanged(const QString &clientIdentifierSharedKey); |
89 | void stateChanged(const QString &state); |
90 | void expirationAtChanged(const QDateTime &expiration); |
91 | void refreshTokenChanged(const QString &refreshToken); |
92 | #ifndef QT_NO_SSL |
93 | void sslConfigurationChanged(const QSslConfiguration &configuration); |
94 | #endif |
95 | |
96 | void error(const QString &error, const QString &errorDescription, const QUrl &uri); |
97 | void authorizationCallbackReceived(const QVariantMap &data); |
98 | |
99 | protected: |
100 | explicit QAbstractOAuth2(QAbstractOAuth2Private &, QObject *parent = nullptr); |
101 | |
102 | void setResponseType(const QString &responseType); |
103 | |
104 | private: |
105 | Q_DECLARE_PRIVATE(QAbstractOAuth2) |
106 | }; |
107 | |
108 | QT_END_NAMESPACE |
109 | |
110 | #endif // QT_NO_HTTP |
111 | |
112 | #endif // QABSTRACTOAUTH2_H |
113 | |