-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraktauthenticator.h
49 lines (37 loc) · 1.17 KB
/
traktauthenticator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef TRAKTAUTHENTICATOR_H
#define TRAKTAUTHENTICATOR_H
#include <QObject>
#include <QNetworkRequest>
class TraktReply;
class TraktAuthenticator : public QObject
{
Q_OBJECT
Q_PROPERTY(bool authorized READ authorized NOTIFY authorizedChanged)
Q_PROPERTY(bool authorizing READ authorizing NOTIFY authorizingChanged)
Q_ENUMS(GrantType)
public:
enum GrantType {
GrantAccessCode,
GrantRefreshToken
};
explicit TraktAuthenticator(const QString clientId, const QString &clientSecret, const QString &redirectUrl, QObject *parent = 0);
Q_INVOKABLE QString buildAuthorizeUrl() const;
Q_INVOKABLE void authorize(GrantType type, const QString &token);
void appendHeaders(QNetworkRequest &request) const;
bool authorized() const;
bool authorizing() const;
signals:
void tokensReceived(const QString &refreshToken);
void authorizedChanged();
void authorizingChanged();
private:
QString m_clientId;
QString m_clientSecret;
QString m_redirectUrl;
QString m_accessToken;
bool m_authorized;
bool m_authorizing;
private slots:
void onTokenReceived(TraktReply *reply);
};
#endif // TRAKTAUTHENTICATOR_H