Refactor Tidal, Spotify, Qobuz, Subsonic and cover providers
Use common HTTP, Json and OAuthenticator class
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2018-2025, 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
|
||||
@@ -24,26 +24,22 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/jsonbaserequest.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
|
||||
class NetworkAccessManager;
|
||||
|
||||
// Each implementation of this interface downloads covers from one online service.
|
||||
// There are no limitations on what this service might be - last.fm, Amazon, Google Images - you name it.
|
||||
class CoverProvider : public QObject {
|
||||
class CoverProvider : public JsonBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, const SharedPtr<NetworkAccessManager> network, QObject *parent);
|
||||
|
||||
// A name (very short description) of this provider, like "last.fm".
|
||||
QString name() const { return name_; }
|
||||
bool is_enabled() const { return enabled_; }
|
||||
int order() const { return order_; }
|
||||
@@ -54,10 +50,14 @@ class CoverProvider : public QObject {
|
||||
void set_enabled(const bool enabled) { enabled_ = enabled; }
|
||||
void set_order(const int order) { order_ = order; }
|
||||
|
||||
bool AuthenticationRequired() const { return authentication_required_; }
|
||||
virtual bool IsAuthenticated() const { return true; }
|
||||
virtual QString service_name() const override { return name_; }
|
||||
virtual bool authentication_required() const override { return authentication_required_; }
|
||||
virtual bool authenticated() const override { return true; }
|
||||
virtual bool use_authorization_header() const override { return false; }
|
||||
virtual QByteArray authorization_header() const override { return QByteArray(); }
|
||||
|
||||
virtual void Authenticate() {}
|
||||
virtual void Deauthenticate() {}
|
||||
virtual void ClearSession() {}
|
||||
|
||||
// Starts searching for covers matching the given query text.
|
||||
// Returns true if the query has been started, or false if an error occurred.
|
||||
@@ -65,12 +65,10 @@ class CoverProvider : public QObject {
|
||||
virtual bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) = 0;
|
||||
virtual void CancelSearch(const int id) { Q_UNUSED(id); }
|
||||
|
||||
virtual void Error(const QString &error, const QVariant &debug = QVariant()) = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void AuthenticationComplete(const bool success, const QStringList &errors = QStringList());
|
||||
void AuthenticationFinished(const bool success, const QString &error = QString());
|
||||
void AuthenticationSuccess();
|
||||
void AuthenticationFailure(const QStringList &errors);
|
||||
void AuthenticationFailure(const QString &error);
|
||||
void SearchResults(const int id, const CoverProviderSearchResults &results);
|
||||
void SearchFinished(const int id, const CoverProviderSearchResults &results);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user