2013-02-12 13:54:19 +01:00
|
|
|
#ifndef BOXSERVICE_H
|
|
|
|
#define BOXSERVICE_H
|
|
|
|
|
|
|
|
#include "cloudfileservice.h"
|
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
class OAuthenticator;
|
|
|
|
class QNetworkReply;
|
|
|
|
class QNetworkRequest;
|
|
|
|
|
|
|
|
class BoxService : public CloudFileService {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
BoxService(Application* app, InternetModel* parent);
|
|
|
|
|
|
|
|
static const char* kServiceName;
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
|
|
|
virtual bool has_credentials() const;
|
|
|
|
QUrl GetStreamingUrlFromSongId(const QString& id);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void Connect();
|
|
|
|
void ForgetCredentials();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
signals:
|
2013-02-12 13:54:19 +01:00
|
|
|
void Connected();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void ConnectFinished(OAuthenticator* oauth);
|
|
|
|
void FetchUserInfoFinished(QNetworkReply* reply);
|
2013-02-13 14:19:50 +01:00
|
|
|
void FetchFolderItemsFinished(QNetworkReply* reply, const int folder_id);
|
2014-02-07 16:34:20 +01:00
|
|
|
void RedirectFollowed(QNetworkReply* reply, const Song& song,
|
|
|
|
const QString& mime_type);
|
2013-02-12 13:54:19 +01:00
|
|
|
void InitialiseEventsFinished(QNetworkReply* reply);
|
|
|
|
void FetchEventsFinished(QNetworkReply* reply);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString refresh_token() const;
|
|
|
|
bool is_authenticated() const;
|
|
|
|
void AddAuthorizationHeader(QNetworkRequest* request) const;
|
|
|
|
void UpdateFiles();
|
2013-02-13 14:19:50 +01:00
|
|
|
void FetchRecursiveFolderItems(const int folder_id, const int offset = 0);
|
2013-02-12 13:54:19 +01:00
|
|
|
void UpdateFilesFromCursor(const QString& cursor);
|
|
|
|
QNetworkReply* FetchContentUrlForFile(const QString& file_id);
|
|
|
|
void InitialiseEventsCursor();
|
|
|
|
void MaybeAddFileEntry(const QVariantMap& entry);
|
|
|
|
void EnsureConnected();
|
|
|
|
|
|
|
|
QString access_token_;
|
|
|
|
QDateTime expiry_time_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BOXSERVICE_H
|