2014-12-17 19:02:21 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2012, 2014, John Maguire <john.maguire@gmail.com>
|
|
|
|
Copyright 2012, 2014, David Sansome <me@davidsansome.com>
|
|
|
|
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-12-18 23:54:21 +01:00
|
|
|
#ifndef INTERNET_GOOGLEDRIVE_GOOGLEDRIVESERVICE_H_
|
|
|
|
#define INTERNET_GOOGLEDRIVE_GOOGLEDRIVESERVICE_H_
|
2012-07-12 14:09:20 +02:00
|
|
|
|
2014-12-18 23:35:21 +01:00
|
|
|
#include "internet/core/cloudfileservice.h"
|
2012-07-12 14:09:20 +02:00
|
|
|
|
2012-07-28 18:18:03 +02:00
|
|
|
namespace google_drive {
|
2014-02-07 16:34:20 +01:00
|
|
|
class Client;
|
|
|
|
class ConnectResponse;
|
|
|
|
class File;
|
|
|
|
class ListFilesResponse;
|
|
|
|
class ListChangesResponse;
|
2012-07-28 18:18:03 +02:00
|
|
|
}
|
|
|
|
|
2012-11-28 16:21:14 +01:00
|
|
|
class GoogleDriveService : public CloudFileService {
|
2012-07-12 14:09:20 +02:00
|
|
|
Q_OBJECT
|
2014-12-17 19:02:21 +01:00
|
|
|
|
2012-07-12 14:09:20 +02:00
|
|
|
public:
|
|
|
|
GoogleDriveService(Application* app, InternetModel* parent);
|
|
|
|
|
2012-07-29 16:06:23 +02:00
|
|
|
static const char* kServiceName;
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
2012-11-28 16:21:14 +01:00
|
|
|
virtual bool has_credentials() const;
|
|
|
|
virtual void ShowContextMenu(const QPoint& global_pos);
|
|
|
|
|
2012-07-29 16:06:23 +02:00
|
|
|
google_drive::Client* client() const { return client_; }
|
2012-08-24 22:26:10 +02:00
|
|
|
QString refresh_token() const;
|
2012-07-29 16:06:23 +02:00
|
|
|
|
2012-07-26 16:35:57 +02:00
|
|
|
QUrl GetStreamingUrlFromSongId(const QString& file_id);
|
|
|
|
|
2012-08-17 22:48:45 +02:00
|
|
|
public slots:
|
|
|
|
void Connect();
|
|
|
|
void ForgetCredentials();
|
|
|
|
|
2014-12-17 19:02:21 +01:00
|
|
|
signals:
|
2012-08-17 22:48:45 +02:00
|
|
|
void Connected();
|
|
|
|
|
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);
|
2012-12-05 12:57:10 +01:00
|
|
|
void FilesDeleted(const QList<QUrl>& files);
|
|
|
|
void ListChangesFinished(google_drive::ListChangesResponse* response);
|
2014-03-30 07:01:58 +02:00
|
|
|
void SaveCursor(const QString& cursor);
|
2012-07-12 14:09:20 +02:00
|
|
|
|
2012-08-24 20:33:05 +02:00
|
|
|
void OpenWithDrive();
|
2014-06-05 12:16:16 +02:00
|
|
|
void ConfirmFullRescan();
|
|
|
|
void DoFullRescan();
|
|
|
|
void CheckForUpdates();
|
2012-08-24 20:33:05 +02:00
|
|
|
|
2012-07-12 14:09:20 +02:00
|
|
|
private:
|
2012-08-10 20:46:26 +02:00
|
|
|
void EnsureConnected();
|
2012-07-26 16:55:59 +02:00
|
|
|
void RefreshAuthorisation(const QString& refresh_token);
|
2012-12-05 12:57:10 +01:00
|
|
|
void ListChanges(const QString& cursor);
|
2012-07-12 14:09:20 +02:00
|
|
|
|
2012-07-28 18:18:03 +02:00
|
|
|
google_drive::Client* client_;
|
2012-07-12 14:09:20 +02:00
|
|
|
|
2012-08-24 20:33:05 +02:00
|
|
|
QAction* open_in_drive_action_;
|
2014-06-05 12:16:16 +02:00
|
|
|
QAction* update_action_;
|
|
|
|
QAction* full_rescan_action_;
|
2012-07-12 14:09:20 +02:00
|
|
|
};
|
|
|
|
|
2014-12-18 23:54:21 +01:00
|
|
|
#endif // INTERNET_GOOGLEDRIVE_GOOGLEDRIVESERVICE_H_
|