2020-04-13 19:04:06 +02:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
|
|
|
|
*
|
|
|
|
* Strawberry 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.
|
|
|
|
*
|
|
|
|
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TIDALCOVERPROVIDER_H
|
|
|
|
#define TIDALCOVERPROVIDER_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPair>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QList>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QString>
|
|
|
|
#include <QJsonValue>
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
2020-05-10 12:49:11 +02:00
|
|
|
#include "jsoncoverprovider.h"
|
2020-05-09 01:48:08 +02:00
|
|
|
#include "tidal/tidalservice.h"
|
2020-04-13 19:04:06 +02:00
|
|
|
|
|
|
|
class QNetworkAccessManager;
|
|
|
|
class QNetworkReply;
|
|
|
|
class Application;
|
|
|
|
|
2020-05-10 12:49:11 +02:00
|
|
|
class TidalCoverProvider : public JsonCoverProvider {
|
2020-04-13 19:04:06 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit TidalCoverProvider(Application *app, QObject *parent = nullptr);
|
2020-04-20 18:03:18 +02:00
|
|
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id);
|
2020-04-20 23:26:36 +02:00
|
|
|
void CancelSearch(const int id);
|
2020-04-13 19:04:06 +02:00
|
|
|
|
2020-05-09 01:48:08 +02:00
|
|
|
bool IsAuthenticated() const { return service_ && service_->authenticated(); }
|
|
|
|
void Deauthenticate() { if (service_) service_->Logout(); }
|
|
|
|
|
2020-04-13 19:04:06 +02:00
|
|
|
private slots:
|
|
|
|
void HandleSearchReply(QNetworkReply *reply, const int id);
|
|
|
|
|
|
|
|
private:
|
2020-04-20 23:26:36 +02:00
|
|
|
QByteArray GetReplyData(QNetworkReply *reply);
|
|
|
|
void Error(const QString &error, const QVariant &debug = QVariant());
|
|
|
|
|
|
|
|
private:
|
2020-04-13 19:04:06 +02:00
|
|
|
static const char *kApiUrl;
|
|
|
|
static const char *kResourcesUrl;
|
|
|
|
static const int kLimit;
|
|
|
|
|
|
|
|
TidalService *service_;
|
|
|
|
QNetworkAccessManager *network_;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TIDALCOVERPROVIDER_H
|