Clementine-audio-player-Mac.../src/internet/skydrive/skydriveservice.h

81 lines
2.3 KiB
C
Raw Normal View History

/* This file is part of Clementine.
Copyright 2012, 2014, John Maguire <john.maguire@gmail.com>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
Copyright 2014, David Sansome <me@davidsansome.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_SKYDRIVE_SKYDRIVESERVICE_H_
#define INTERNET_SKYDRIVE_SKYDRIVESERVICE_H_
2012-12-13 14:27:21 +01:00
#include <QDateTime>
2020-09-18 16:15:19 +02:00
#include "internet/core/cloudfileservice.h"
class OAuthenticator;
2012-12-13 14:27:21 +01:00
class QNetworkRequest;
class QNetworkReply;
class SkydriveService : public CloudFileService {
Q_OBJECT
public:
SkydriveService(Application* app, InternetModel* parent);
2014-03-30 07:35:27 +02:00
static const char* kServiceName;
static const char* kSettingsGroup;
2021-06-30 20:51:09 +02:00
virtual bool has_credentials() const override;
2014-03-30 07:35:27 +02:00
QUrl GetStreamingUrlFromSongId(const QString& song_id);
QString GetScheme() const { return "onedrive"; }
2014-03-30 07:35:27 +02:00
public slots:
2021-06-30 20:51:09 +02:00
virtual void Connect() override;
2014-03-30 07:35:27 +02:00
void ForgetCredentials();
private slots:
void ConnectFinished(OAuthenticator* oauth);
2012-12-13 14:27:21 +01:00
void FetchUserInfoFinished(QNetworkReply* reply);
void ListFilesFinished(QNetworkReply* reply);
2014-03-30 07:35:27 +02:00
signals:
2012-12-13 14:44:59 +01:00
void Connected();
private:
friend class SkydriveUrlHandler;
QByteArray GetAuthHeader() const;
2012-12-13 14:27:21 +01:00
private:
2014-03-30 07:35:27 +02:00
QString refresh_token() const;
2012-12-13 14:27:21 +01:00
void AddAuthorizationHeader(QNetworkRequest* request);
void FetchUserInfo();
void ListFiles();
2012-12-13 14:27:21 +01:00
void ListFiles(const QString& folder);
2012-12-13 14:44:59 +01:00
void EnsureConnected();
QUrl ItemUrl(const QString& id, const QString& path);
void DoFullRescan() override;
void PopulateContextMenu() override;
void UpdateContextMenu() override;
2012-12-13 14:27:21 +01:00
QString access_token_;
QDateTime expiry_time_;
QAction* full_rescan_action_;
};
2014-12-18 23:54:21 +01:00
#endif // INTERNET_SKYDRIVE_SKYDRIVESERVICE_H_