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
|
|
|
|
|
|
|
class NetworkAccessManager;
|
|
|
|
class QNetworkReply;
|
|
|
|
|
|
|
|
class DropboxAuthenticator : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit DropboxAuthenticator(QObject* parent = 0);
|
|
|
|
void StartAuthorisation(const QString& email);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void RequestTokenFinished(QNetworkReply* reply);
|
2012-11-29 17:28:47 +01:00
|
|
|
void RedirectArrived(QTcpSocket* socket, QByteArray buffer);
|
|
|
|
void NewConnection();
|
|
|
|
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
|