2012-11-29 17:03:52 +01:00
|
|
|
#ifndef DROPBOXAUTHENTICATOR_H
|
|
|
|
#define DROPBOXAUTHENTICATOR_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2012-11-29 17:28:47 +01:00
|
|
|
#include <QTcpServer>
|
2012-11-29 17:03:52 +01:00
|
|
|
|
2012-11-30 14:40:54 +01:00
|
|
|
class LocalRedirectServer;
|
2012-11-29 17:03:52 +01:00
|
|
|
class NetworkAccessManager;
|
|
|
|
class QNetworkReply;
|
|
|
|
|
|
|
|
class DropboxAuthenticator : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit DropboxAuthenticator(QObject* parent = 0);
|
2012-11-29 18:19:41 +01:00
|
|
|
void StartAuthorisation();
|
|
|
|
|
|
|
|
const QString& access_token() const { return access_token_; }
|
|
|
|
const QString& access_token_secret() const { return access_token_secret_; }
|
|
|
|
const QString& uid() const { return uid_; }
|
|
|
|
const QString& name() const { return name_; }
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
static QByteArray GenerateAuthorisationHeader(const QString& token,
|
|
|
|
const QString& secret);
|
2012-11-29 18:43:56 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
signals:
|
2012-11-29 18:19:41 +01:00
|
|
|
void Finished();
|
2012-11-29 17:03:52 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void RequestTokenFinished(QNetworkReply* reply);
|
2012-11-30 14:40:54 +01:00
|
|
|
void RedirectArrived(LocalRedirectServer* server);
|
2012-11-29 17:28:47 +01:00
|
|
|
void RequestAccessTokenFinished(QNetworkReply* reply);
|
2012-11-29 17:46:37 +01:00
|
|
|
void RequestAccountInformationFinished(QNetworkReply* reply);
|
2012-11-29 17:28:47 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Authorise();
|
|
|
|
void RequestAccessToken();
|
2012-11-29 17:46:37 +01:00
|
|
|
QByteArray GenerateAuthorisationHeader();
|
|
|
|
void RequestAccountInformation();
|
2012-11-29 17:03:52 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
NetworkAccessManager* network_;
|
2012-11-29 17:28:47 +01:00
|
|
|
QTcpServer server_;
|
|
|
|
|
2012-11-29 17:46:37 +01:00
|
|
|
// Temporary access token used for first authentication flow.
|
2012-11-29 17:28:47 +01:00
|
|
|
QString token_;
|
|
|
|
QString secret_;
|
2012-11-29 17:46:37 +01:00
|
|
|
|
|
|
|
// Permanent OAuth access tokens.
|
|
|
|
QString access_token_;
|
|
|
|
QString access_token_secret_;
|
2012-11-29 17:53:37 +01:00
|
|
|
|
|
|
|
// User's Dropbox uid & name.
|
|
|
|
QString uid_;
|
|
|
|
QString name_;
|
2012-11-29 17:03:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DROPBOXAUTHENTICATOR_H
|