strawberry-audio-player-win.../src/covermanager/coverprovider.h

91 lines
3.2 KiB
C
Raw Normal View History

2018-02-27 18:06:05 +01:00
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
2021-03-20 21:14:47 +01:00
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
2018-02-27 18:06:05 +01:00
*
* 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/>.
2018-08-09 18:39:44 +02:00
*
2018-02-27 18:06:05 +01:00
*/
#ifndef COVERPROVIDER_H
#define COVERPROVIDER_H
#include "config.h"
2020-02-09 02:29:35 +01:00
#include <QtGlobal>
2018-02-27 18:06:05 +01:00
#include <QObject>
2020-05-10 12:49:11 +02:00
#include <QVariant>
#include <QString>
2020-05-09 01:48:08 +02:00
#include <QStringList>
2018-02-27 18:06:05 +01:00
#include "albumcoverfetcher.h"
2019-04-14 16:40:05 +02:00
class Application;
2021-08-12 23:00:10 +02:00
class NetworkAccessManager;
2018-02-27 18:06:05 +01:00
// 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.
2018-02-27 18:06:05 +01:00
class CoverProvider : public QObject {
Q_OBJECT
2019-04-14 16:40:05 +02:00
public:
2021-08-12 23:00:10 +02:00
explicit CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent);
2018-02-27 18:06:05 +01:00
// A name (very short description) of this provider, like "last.fm".
QString name() const { return name_; }
2020-05-09 01:48:08 +02:00
bool is_enabled() const { return enabled_; }
int order() const { return order_; }
float quality() const { return quality_; }
bool batch() const { return batch_; }
bool allow_missing_album() const { return allow_missing_album_; }
2018-02-27 18:06:05 +01:00
2020-05-09 01:48:08 +02:00
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 void Authenticate() {}
virtual void Deauthenticate() {}
// Starts searching for covers matching the given query text.
// Returns true if the query has been started, or false if an error occurred.
// The provider should remember the ID and emit it along with the result when it finishes.
virtual bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) = 0;
2020-05-09 01:48:08 +02:00
virtual void CancelSearch(const int id) { Q_UNUSED(id); }
2018-02-27 18:06:05 +01:00
2020-05-10 12:49:11 +02:00
virtual void Error(const QString &error, const QVariant &debug = QVariant()) = 0;
2019-04-14 16:40:05 +02:00
signals:
2020-05-09 01:48:08 +02:00
void AuthenticationComplete(bool, QStringList = QStringList());
void AuthenticationSuccess();
void AuthenticationFailure(QStringList);
void SearchResults(int, CoverProviderSearchResults);
void SearchFinished(int, CoverProviderSearchResults);
2018-02-27 18:06:05 +01:00
2021-08-12 23:00:10 +02:00
protected:
2019-04-14 16:40:05 +02:00
Application *app_;
2021-08-12 23:00:10 +02:00
NetworkAccessManager *network_;
2018-02-27 18:06:05 +01:00
QString name_;
2020-05-09 01:48:08 +02:00
bool enabled_;
int order_;
bool authentication_required_;
2019-04-17 22:18:03 +02:00
float quality_;
bool batch_;
bool allow_missing_album_;
2018-02-27 18:06:05 +01:00
};
2021-07-11 09:49:38 +02:00
#endif // COVERPROVIDER_H