OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
qml_oauth.hpp
1#pragma once
2#include <ossia/network/context.hpp>
3
4#include <QObject>
5
6#if QT_VERSION > QT_VERSION_CHECK(6, 10, 0)
7#if QT_NETWORKAUTH_LIB
8#include <QJSValue>
9#include <QQmlEngine>
10#include <QUrl>
11#include <QVariant>
12
13#include <verdigris>
14#include <nano_observer.hpp>
15
16class QNetworkAccessManager;
17class QOAuthHttpServerReplyHandler;
18class QOAuth2AuthorizationCodeFlow;
19namespace ossia::qt
20{
21class OSSIA_EXPORT qml_oauth
22 : public QObject
23 , public Nano::Observer
24{
25 W_OBJECT(qml_oauth)
26public:
27 qml_oauth();
28 ~qml_oauth();
29
30 void grant();
31 W_INVOKABLE(grant)
32
33 void granted() E_SIGNAL(OSSIA_EXPORT, granted);
34
35 QString token() const noexcept;
36 void setToken(const QString& tk) noexcept;
37 void tokenChanged(QString token) E_SIGNAL(OSSIA_EXPORT, tokenChanged, token);
38
39 QString clientIdentifier() const noexcept;
40 void setClientIdentifier(const QString& tk) noexcept;
41 void clientIdentifierChanged(QString token)
42 E_SIGNAL(OSSIA_EXPORT, clientIdentifierChanged, token);
43
44 QString clientIdentifierSharedKey() const noexcept;
45 void setClientIdentifierSharedKey(const QString& tk) noexcept;
46 void clientIdentifierSharedKeyChanged(QString token)
47 E_SIGNAL(OSSIA_EXPORT, clientIdentifierSharedKeyChanged, token);
48
49 QUrl authorizationUrl() const noexcept;
50 void setAuthorizationUrl(const QUrl& tk) noexcept;
51 void authorizationUrlChanged(QUrl token)
52 E_SIGNAL(OSSIA_EXPORT, authorizationUrlChanged, token);
53
54 QUrl accessTokenUrl() const noexcept;
55 void setAccessTokenUrl(const QUrl& tk) noexcept;
56 void accessTokenUrlChanged(QUrl token)
57 E_SIGNAL(OSSIA_EXPORT, accessTokenUrlChanged, token);
58
59 QStringList requestedScopeTokens() const noexcept;
60 void setRequestedScopeTokens(const QStringList& tk) noexcept;
61 void requestedScopeTokensChanged(QStringList token)
62 E_SIGNAL(OSSIA_EXPORT, requestedScopeTokensChanged, token);
63
64 void requestFailed(QString error) E_SIGNAL(OSSIA_EXPORT, requestFailed, error);
65 void send(QString verb, QUrl url, QJSValue config, QJSValue callback);
66 W_INVOKABLE(send)
67
68 W_PROPERTY(QString, accessToken READ token WRITE setToken NOTIFY tokenChanged)
69 W_PROPERTY(QUrl, accessTokenUrl READ accessTokenUrl WRITE setAccessTokenUrl NOTIFY accessTokenUrlChanged)
70 W_PROPERTY(QUrl, authorizationUrl READ authorizationUrl WRITE setAuthorizationUrl NOTIFY authorizationUrlChanged)
71 W_PROPERTY(QString, clientIdentifierSharedKey READ clientIdentifierSharedKey WRITE setClientIdentifierSharedKey NOTIFY clientIdentifierSharedKeyChanged)
72 W_PROPERTY(QString, clientIdentifier READ clientIdentifier WRITE setClientIdentifier NOTIFY clientIdentifierChanged)
73 W_PROPERTY(QStringList, requestedScopeTokens READ requestedScopeTokens WRITE setRequestedScopeTokens NOTIFY requestedScopeTokensChanged)
74
75 // Callbacks
76 QJSValue onOpen;
77 QJSValue onClose;
78 QJSValue onError;
79 QJSValue onMessage;
80
81private:
82 QNetworkAccessManager* m_networkManager{};
83 QOAuth2AuthorizationCodeFlow* m_oauth{};
84 QOAuthHttpServerReplyHandler* m_replyHandler{};
85};
86
87}
88
89Q_DECLARE_METATYPE(ossia::qt::qml_oauth*)
90W_REGISTER_ARGTYPE(ossia::qt::qml_oauth*)
91#endif
92#endif
Definition qml_device.cpp:43