2012-07-12 14:09:20 +02:00
|
|
|
#ifndef GOOGLEDRIVESERVICE_H
|
|
|
|
#define GOOGLEDRIVESERVICE_H
|
|
|
|
|
|
|
|
#include "internetservice.h"
|
|
|
|
|
|
|
|
#include "core/network.h"
|
2012-07-28 20:35:12 +02:00
|
|
|
#include "core/tagreaderclient.h"
|
2012-07-12 14:09:20 +02:00
|
|
|
|
|
|
|
class QStandardItem;
|
|
|
|
|
2012-07-27 16:04:12 +02:00
|
|
|
class LibraryBackend;
|
|
|
|
class LibraryModel;
|
|
|
|
class QSortFilterProxyModel;
|
2012-07-12 14:09:20 +02:00
|
|
|
|
2012-07-28 18:18:03 +02:00
|
|
|
namespace google_drive {
|
|
|
|
class Client;
|
|
|
|
class ConnectResponse;
|
|
|
|
class File;
|
|
|
|
class ListFilesResponse;
|
|
|
|
}
|
|
|
|
|
2012-07-12 14:09:20 +02:00
|
|
|
class GoogleDriveService : public InternetService {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
GoogleDriveService(Application* app, InternetModel* parent);
|
|
|
|
|
2012-07-29 16:06:23 +02:00
|
|
|
static const char* kServiceName;
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
|
|
|
google_drive::Client* client() const { return client_; }
|
|
|
|
|
2012-07-12 14:09:20 +02:00
|
|
|
QStandardItem* CreateRootItem();
|
|
|
|
void LazyPopulate(QStandardItem* item);
|
|
|
|
|
2012-07-26 16:35:57 +02:00
|
|
|
QUrl GetStreamingUrlFromSongId(const QString& file_id);
|
|
|
|
|
2012-07-12 14:09:20 +02:00
|
|
|
private slots:
|
2012-07-28 18:18:03 +02:00
|
|
|
void ConnectFinished(google_drive::ConnectResponse* response);
|
|
|
|
void FilesFound(const QList<google_drive::File>& files);
|
|
|
|
void ListFilesFinished(google_drive::ListFilesResponse* response);
|
2012-07-28 20:35:12 +02:00
|
|
|
void ReadTagsFinished(TagReaderClient::ReplyType* reply,
|
|
|
|
const google_drive::File& metadata,
|
|
|
|
const QString& url);
|
2012-07-12 14:09:20 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Connect();
|
2012-07-26 16:55:59 +02:00
|
|
|
void RefreshAuthorisation(const QString& refresh_token);
|
2012-07-28 18:18:03 +02:00
|
|
|
void MaybeAddFileToDatabase(const google_drive::File& file);
|
2012-07-31 11:57:04 +02:00
|
|
|
void ListFilesForMimeType(const QString& mime_type);
|
2012-07-12 14:09:20 +02:00
|
|
|
|
|
|
|
QStandardItem* root_;
|
|
|
|
|
2012-07-28 18:18:03 +02:00
|
|
|
google_drive::Client* client_;
|
2012-07-12 14:09:20 +02:00
|
|
|
|
|
|
|
NetworkAccessManager network_;
|
2012-07-27 16:04:12 +02:00
|
|
|
|
|
|
|
LibraryBackend* library_backend_;
|
|
|
|
LibraryModel* library_model_;
|
|
|
|
QSortFilterProxyModel* library_sort_model_;
|
|
|
|
|
|
|
|
int indexing_task_id_;
|
2012-07-12 14:09:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|