@@ -577,7 +577,7 @@ void AlbumCoverChoiceController::SaveArtManualToSong(Song *song, const QUrl &art
|
||||
case Song::Source::Tidal:
|
||||
case Song::Source::Qobuz:
|
||||
case Song::Source::Subsonic:
|
||||
InternetService *service = app_->internet_services()->ServiceBySource(song->source());
|
||||
InternetServicePtr service = app_->internet_services()->ServiceBySource(song->source());
|
||||
if (!service) break;
|
||||
if (service->artists_collection_backend()) {
|
||||
service->artists_collection_backend()->UpdateManualAlbumArtAsync(song->effective_albumartist(), song->album(), art_manual);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QTimer>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/song.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
@@ -37,7 +38,7 @@ using namespace std::chrono_literals;
|
||||
|
||||
const int AlbumCoverFetcher::kMaxConcurrentRequests = 5;
|
||||
|
||||
AlbumCoverFetcher::AlbumCoverFetcher(CoverProviders *cover_providers, NetworkAccessManager *network, QObject *parent)
|
||||
AlbumCoverFetcher::AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
cover_providers_(cover_providers),
|
||||
network_(network),
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
#include "coversearchstatistics.h"
|
||||
#include "albumcoverimageresult.h"
|
||||
|
||||
@@ -107,7 +109,7 @@ class AlbumCoverFetcher : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumCoverFetcher(CoverProviders *cover_providers, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~AlbumCoverFetcher() override;
|
||||
|
||||
static const int kMaxConcurrentRequests;
|
||||
@@ -129,8 +131,8 @@ class AlbumCoverFetcher : public QObject {
|
||||
private:
|
||||
void AddRequest(const CoverSearchRequest &req);
|
||||
|
||||
CoverProviders *cover_providers_;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<CoverProviders> cover_providers_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
quint64 next_id_;
|
||||
|
||||
QQueue<CoverSearchRequest> queued_requests_;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/networktimeouts.h"
|
||||
#include "utilities/imageutils.h"
|
||||
@@ -51,7 +52,7 @@ const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 6000;
|
||||
const int AlbumCoverFetcherSearch::kTargetSize = 500;
|
||||
const float AlbumCoverFetcherSearch::kGoodScore = 4.0;
|
||||
|
||||
AlbumCoverFetcherSearch::AlbumCoverFetcherSearch(const CoverSearchRequest &request, NetworkAccessManager *network, QObject *parent)
|
||||
AlbumCoverFetcherSearch::AlbumCoverFetcherSearch(const CoverSearchRequest &request, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
request_(request),
|
||||
image_load_timeout_(new NetworkTimeouts(kImageLoadTimeoutMs, this)),
|
||||
@@ -79,7 +80,7 @@ void AlbumCoverFetcherSearch::TerminateSearch() {
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
|
||||
void AlbumCoverFetcherSearch::Start(SharedPtr<CoverProviders> cover_providers) {
|
||||
|
||||
// Ignore Radio Paradise "commercial" break.
|
||||
if (request_.artist.compare("commercial-free", Qt::CaseInsensitive) == 0 && request_.title.compare("listener-supported", Qt::CaseInsensitive) == 0) {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
#include "coversearchstatistics.h"
|
||||
#include "albumcoverimageresult.h"
|
||||
@@ -52,10 +53,10 @@ class AlbumCoverFetcherSearch : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumCoverFetcherSearch(const CoverSearchRequest &request, NetworkAccessManager *network, QObject *parent);
|
||||
explicit AlbumCoverFetcherSearch(const CoverSearchRequest &request, SharedPtr<NetworkAccessManager> network, QObject *parent);
|
||||
~AlbumCoverFetcherSearch() override;
|
||||
|
||||
void Start(CoverProviders *cover_providers);
|
||||
void Start(SharedPtr<CoverProviders> cover_providers);
|
||||
|
||||
// Cancels all pending requests. No Finished signals will be emitted, and it is the caller's responsibility to delete the AlbumCoverFetcherSearch.
|
||||
void Cancel();
|
||||
@@ -114,7 +115,7 @@ class AlbumCoverFetcherSearch : public QObject {
|
||||
};
|
||||
QMultiMap<float, CandidateImage> candidate_images_;
|
||||
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
|
||||
bool cancel_requested_;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ void AlbumCoverLoader::CancelTasks(const QSet<quint64> &ids) {
|
||||
|
||||
quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions &options, const Song &song) {
|
||||
|
||||
TaskPtr task = std::make_shared<Task>();
|
||||
TaskPtr task = make_shared<Task>();
|
||||
task->options = options;
|
||||
task->art_embedded = song.art_embedded();
|
||||
task->art_automatic = song.art_automatic();
|
||||
@@ -118,7 +118,7 @@ quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions &options,
|
||||
|
||||
quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions &options, const bool art_embedded, const QUrl &art_automatic, const QUrl &art_manual, const bool art_unset, const QUrl &song_url, const Song::Source song_source) {
|
||||
|
||||
TaskPtr task = std::make_shared<Task>();
|
||||
TaskPtr task = make_shared<Task>();
|
||||
task->options = options;
|
||||
task->art_embedded = art_embedded;
|
||||
task->art_automatic = art_automatic;
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
@@ -34,6 +32,7 @@
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "albumcoverloaderoptions.h"
|
||||
#include "albumcoverloaderresult.h"
|
||||
@@ -43,8 +42,6 @@ class QThread;
|
||||
class QNetworkReply;
|
||||
class NetworkAccessManager;
|
||||
|
||||
using std::shared_ptr;
|
||||
|
||||
class AlbumCoverLoader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -94,7 +91,7 @@ class AlbumCoverLoader : public QObject {
|
||||
QUrl art_automatic_updated;
|
||||
int redirects;
|
||||
};
|
||||
using TaskPtr = shared_ptr<Task>;
|
||||
using TaskPtr = SharedPtr<Task>;
|
||||
|
||||
class LoadImageResult {
|
||||
public:
|
||||
@@ -127,7 +124,7 @@ class AlbumCoverLoader : public QObject {
|
||||
|
||||
private:
|
||||
static const int kMaxRedirects = 3;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
bool stop_requested_;
|
||||
QMutex mutex_load_image_async_;
|
||||
QQueue<TaskPtr> tasks_;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QObject>
|
||||
@@ -64,6 +63,8 @@
|
||||
#include <QSize>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
@@ -97,7 +98,7 @@
|
||||
const char *AlbumCoverManager::kSettingsGroup = "CoverManager";
|
||||
constexpr int AlbumCoverManager::kThumbnailSize = 120;
|
||||
|
||||
AlbumCoverManager::AlbumCoverManager(Application *app, CollectionBackend *collection_backend, QMainWindow *mainwindow, QWidget *parent)
|
||||
AlbumCoverManager::AlbumCoverManager(Application *app, SharedPtr<CollectionBackend> collection_backend, QMainWindow *mainwindow, QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
ui_(new Ui_CoverManager),
|
||||
mainwindow_(mainwindow),
|
||||
@@ -231,7 +232,7 @@ void AlbumCoverManager::Init() {
|
||||
|
||||
s.endGroup();
|
||||
|
||||
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverManager::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverManager::AlbumCoverLoaded);
|
||||
|
||||
cover_searcher_->Init(cover_fetcher_);
|
||||
|
||||
@@ -255,7 +256,7 @@ void AlbumCoverManager::showEvent(QShowEvent *e) {
|
||||
void AlbumCoverManager::closeEvent(QCloseEvent *e) {
|
||||
|
||||
if (!cover_fetching_tasks_.isEmpty()) {
|
||||
std::unique_ptr<QMessageBox> message_box(new QMessageBox(QMessageBox::Question, tr("Really cancel?"), tr("Closing this window will stop searching for album covers."), QMessageBox::Abort, this));
|
||||
ScopedPtr<QMessageBox> message_box(new QMessageBox(QMessageBox::Question, tr("Really cancel?"), tr("Closing this window will stop searching for album covers."), QMessageBox::Abort, this));
|
||||
message_box->addButton(tr("Don't stop!"), QMessageBox::AcceptRole);
|
||||
|
||||
if (message_box->exec() != QMessageBox::Abort) {
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QImage>
|
||||
#include <QIcon>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "albumcoverloaderoptions.h"
|
||||
@@ -76,7 +77,7 @@ class AlbumCoverManager : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumCoverManager(Application *app, CollectionBackend *collection_backend, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
||||
explicit AlbumCoverManager(Application *app, SharedPtr<CollectionBackend> collection_backend, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
||||
~AlbumCoverManager() override;
|
||||
|
||||
void Reset();
|
||||
@@ -87,7 +88,7 @@ class AlbumCoverManager : public QMainWindow {
|
||||
|
||||
SongList GetSongsInAlbum(const QModelIndex &idx) const;
|
||||
|
||||
CollectionBackend *backend() const { return collection_backend_; }
|
||||
SharedPtr<CollectionBackend> collection_backend() const { return collection_backend_; }
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e) override;
|
||||
@@ -190,7 +191,7 @@ class AlbumCoverManager : public QMainWindow {
|
||||
Ui_CoverManager *ui_;
|
||||
QMainWindow *mainwindow_;
|
||||
Application *app_;
|
||||
CollectionBackend *collection_backend_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
AlbumCoverChoiceController *album_cover_choice_controller_;
|
||||
|
||||
QAction *filter_all_;
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
@@ -33,6 +31,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QDropEvent>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "playlist/songmimedata.h"
|
||||
@@ -63,10 +62,10 @@ QMimeData *AlbumCoverManagerList::mimeData(const QList<QListWidgetItem*> items)
|
||||
}
|
||||
|
||||
// Get the QAbstractItemModel data so the picture works
|
||||
std::unique_ptr<QMimeData> orig_data(QListWidget::mimeData(items));
|
||||
ScopedPtr<QMimeData> orig_data(QListWidget::mimeData(items));
|
||||
|
||||
SongMimeData *mime_data = new SongMimeData;
|
||||
mime_data->backend = manager_->backend();
|
||||
mime_data->backend = manager_->collection_backend();
|
||||
mime_data->songs = songs;
|
||||
mime_data->setUrls(urls);
|
||||
mime_data->setData(orig_data->formats()[0], orig_data->data(orig_data->formats()[0]));
|
||||
|
||||
@@ -128,7 +128,7 @@ AlbumCoverSearcher::AlbumCoverSearcher(const QIcon &no_cover_icon, Application *
|
||||
ui_->covers->setItemDelegate(new SizeOverlayDelegate(this));
|
||||
ui_->covers->setModel(model_);
|
||||
|
||||
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverSearcher::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverSearcher::AlbumCoverLoaded);
|
||||
QObject::connect(ui_->search, &QPushButton::clicked, this, &AlbumCoverSearcher::Search);
|
||||
QObject::connect(ui_->covers, &GroupedIconView::doubleClicked, this, &AlbumCoverSearcher::CoverDoubleClicked);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/mimeutils.h"
|
||||
#include "widgets/busyindicator.h"
|
||||
@@ -38,7 +39,7 @@
|
||||
#include "coverfromurldialog.h"
|
||||
#include "ui_coverfromurldialog.h"
|
||||
|
||||
CoverFromURLDialog::CoverFromURLDialog(NetworkAccessManager *network, QWidget *parent)
|
||||
CoverFromURLDialog::CoverFromURLDialog(SharedPtr<NetworkAccessManager> network, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
network_(network),
|
||||
ui_(new Ui_CoverFromURLDialog) {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "albumcoverimageresult.h"
|
||||
|
||||
class QWidget;
|
||||
@@ -40,7 +41,7 @@ class CoverFromURLDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CoverFromURLDialog(NetworkAccessManager *network, QWidget *parent = nullptr);
|
||||
explicit CoverFromURLDialog(SharedPtr<NetworkAccessManager> network, QWidget *parent = nullptr);
|
||||
~CoverFromURLDialog() override;
|
||||
|
||||
// Opens the dialog. This returns an image found at the URL chosen by user or null image if the dialog got rejected.
|
||||
@@ -51,7 +52,7 @@ class CoverFromURLDialog : public QDialog {
|
||||
void LoadCoverFromURLFinished();
|
||||
|
||||
private:
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
Ui_CoverFromURLDialog *ui_;
|
||||
AlbumCoverImageResult last_album_cover_;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "coverprovider.h"
|
||||
|
||||
CoverProvider::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) : QObject(parent), app_(app), network_(network), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required), quality_(quality), batch_(batch), allow_missing_album_(allow_missing_album) {}
|
||||
CoverProvider::CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent) : QObject(parent), app_(app), network_(network), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required), quality_(quality), batch_(batch), allow_missing_album_(allow_missing_album) {}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
|
||||
class Application;
|
||||
@@ -41,7 +42,7 @@ class CoverProvider : public QObject {
|
||||
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, Application *app, NetworkAccessManager *network, QObject *parent);
|
||||
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, SharedPtr<NetworkAccessManager> network, QObject *parent);
|
||||
|
||||
// A name (very short description) of this provider, like "last.fm".
|
||||
QString name() const { return name_; }
|
||||
@@ -79,7 +80,7 @@ class CoverProvider : public QObject {
|
||||
using ParamList = QList<Param>;
|
||||
|
||||
Application *app_;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
QString name_;
|
||||
bool enabled_;
|
||||
int order_;
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "albumcoverloaderresult.h"
|
||||
#include "currentalbumcoverloader.h"
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(Application *app, QObject *parent)
|
||||
: QObject(parent),
|
||||
app_(app),
|
||||
@@ -46,8 +48,8 @@ CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(Application *app, QObject *pare
|
||||
options_.desired_scaled_size = QSize(120, 120);
|
||||
options_.default_cover = ":/pictures/cdcase.png";
|
||||
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &CurrentAlbumCoverLoader::LoadAlbumCover);
|
||||
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CurrentAlbumCoverLoader::AlbumCoverReady);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &CurrentAlbumCoverLoader::LoadAlbumCover);
|
||||
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CurrentAlbumCoverLoader::AlbumCoverReady);
|
||||
|
||||
ReloadSettingsAsync();
|
||||
|
||||
@@ -85,7 +87,7 @@ void CurrentAlbumCoverLoader::AlbumCoverReady(const quint64 id, AlbumCoverLoader
|
||||
id_ = 0;
|
||||
|
||||
if (!result.album_cover.image.isNull()) {
|
||||
temp_cover_ = std::make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_ = make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_->setAutoRemove(true);
|
||||
if (temp_cover_->open()) {
|
||||
if (result.album_cover.image.save(temp_cover_->fileName(), "JPEG")) {
|
||||
@@ -102,7 +104,7 @@ void CurrentAlbumCoverLoader::AlbumCoverReady(const quint64 id, AlbumCoverLoader
|
||||
|
||||
QUrl thumbnail_url;
|
||||
if (!result.image_scaled.isNull()) {
|
||||
temp_cover_thumbnail_ = std::make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_thumbnail_ = make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_thumbnail_->setAutoRemove(true);
|
||||
if (temp_cover_thumbnail_->open()) {
|
||||
if (result.image_scaled.save(temp_cover_thumbnail_->fileName(), "JPEG")) {
|
||||
|
||||
@@ -24,14 +24,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "albumcoverloaderoptions.h"
|
||||
#include "albumcoverloaderresult.h"
|
||||
@@ -67,12 +66,11 @@ class CurrentAlbumCoverLoader : public QObject {
|
||||
|
||||
QString temp_file_pattern_;
|
||||
|
||||
std::unique_ptr<QTemporaryFile> temp_cover_;
|
||||
std::unique_ptr<QTemporaryFile> temp_cover_thumbnail_;
|
||||
ScopedPtr<QTemporaryFile> temp_cover_;
|
||||
ScopedPtr<QTemporaryFile> temp_cover_thumbnail_;
|
||||
quint64 id_;
|
||||
|
||||
Song last_song_;
|
||||
|
||||
};
|
||||
|
||||
#endif // CURRENTALBUMCOVERLOADER_H
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
const char *DeezerCoverProvider::kApiUrl = "https://api.deezer.com";
|
||||
const int DeezerCoverProvider::kLimit = 10;
|
||||
|
||||
DeezerCoverProvider::DeezerCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
DeezerCoverProvider::DeezerCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Deezer", true, false, 2.0, true, true, app, network, parent) {}
|
||||
|
||||
DeezerCoverProvider::~DeezerCoverProvider() {
|
||||
|
||||
@@ -40,7 +40,7 @@ class DeezerCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeezerCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit DeezerCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~DeezerCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
@@ -49,12 +50,14 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "discogscoverprovider.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
const char *DiscogsCoverProvider::kUrlSearch = "https://api.discogs.com/database/search";
|
||||
const char *DiscogsCoverProvider::kAccessKeyB64 = "dGh6ZnljUGJlZ1NEeXBuSFFxSVk=";
|
||||
const char *DiscogsCoverProvider::kSecretKeyB64 = "ZkFIcmlaSER4aHhRSlF2U3d0bm5ZVmdxeXFLWUl0UXI=";
|
||||
const int DiscogsCoverProvider::kRequestsDelay = 1000;
|
||||
|
||||
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Discogs", false, false, 0.0, false, false, app, network, parent),
|
||||
timer_flush_requests_(new QTimer(this)) {
|
||||
|
||||
@@ -86,7 +89,7 @@ bool DiscogsCoverProvider::StartSearch(const QString &artist, const QString &alb
|
||||
|
||||
if (artist.isEmpty() || album.isEmpty()) return false;
|
||||
|
||||
std::shared_ptr<DiscogsCoverSearchContext> search = std::make_shared<DiscogsCoverSearchContext>(id, artist, album);
|
||||
SharedPtr<DiscogsCoverSearchContext> search = make_shared<DiscogsCoverSearchContext>(id, artist, album);
|
||||
|
||||
requests_search_.insert(search->id, search);
|
||||
queue_search_requests_.enqueue(search);
|
||||
@@ -121,7 +124,7 @@ void DiscogsCoverProvider::FlushRequests() {
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::SendSearchRequest(std::shared_ptr<DiscogsCoverSearchContext> search) {
|
||||
void DiscogsCoverProvider::SendSearchRequest(SharedPtr<DiscogsCoverSearchContext> search) {
|
||||
|
||||
ParamList params = ParamList() << Param("format", "album")
|
||||
<< Param("artist", search->artist.toLower())
|
||||
@@ -227,7 +230,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
reply->deleteLater();
|
||||
|
||||
if (!requests_search_.contains(id)) return;
|
||||
std::shared_ptr<DiscogsCoverSearchContext> search = requests_search_.value(id);
|
||||
SharedPtr<DiscogsCoverSearchContext> search = requests_search_.value(id);
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
if (data.isEmpty()) {
|
||||
@@ -307,7 +310,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::StartReleaseRequest(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url) {
|
||||
void DiscogsCoverProvider::StartReleaseRequest(SharedPtr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url) {
|
||||
|
||||
DiscogsCoverReleaseContext release(search->id, release_id, url);
|
||||
search->requests_release_.insert(release_id, release);
|
||||
@@ -334,7 +337,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
reply->deleteLater();
|
||||
|
||||
if (!requests_search_.contains(search_id)) return;
|
||||
std::shared_ptr<DiscogsCoverSearchContext> search = requests_search_.value(search_id);
|
||||
SharedPtr<DiscogsCoverSearchContext> search = requests_search_.value(search_id);
|
||||
|
||||
if (!search->requests_release_.contains(release_id)) return;
|
||||
const DiscogsCoverReleaseContext &release = search->requests_release_.value(release_id);
|
||||
@@ -447,7 +450,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::EndSearch(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id) {
|
||||
void DiscogsCoverProvider::EndSearch(SharedPtr<DiscogsCoverSearchContext> search, const quint64 release_id) {
|
||||
|
||||
if (search->requests_release_.contains(release_id)) {
|
||||
search->requests_release_.remove(release_id);
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaType>
|
||||
#include <QPair>
|
||||
@@ -37,6 +35,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
|
||||
@@ -49,7 +48,7 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DiscogsCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit DiscogsCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~DiscogsCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
@@ -77,12 +76,12 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
||||
};
|
||||
|
||||
private:
|
||||
void SendSearchRequest(std::shared_ptr<DiscogsCoverSearchContext> search);
|
||||
void SendSearchRequest(SharedPtr<DiscogsCoverSearchContext> search);
|
||||
void SendReleaseRequest(const DiscogsCoverReleaseContext &release);
|
||||
QNetworkReply *CreateRequest(QUrl url, const ParamList ¶ms_provided = ParamList());
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
void StartReleaseRequest(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url);
|
||||
void EndSearch(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id = 0);
|
||||
void StartReleaseRequest(SharedPtr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url);
|
||||
void EndSearch(SharedPtr<DiscogsCoverSearchContext> search, const quint64 release_id = 0);
|
||||
void Error(const QString &error, const QVariant &debug = QVariant()) override;
|
||||
|
||||
private slots:
|
||||
@@ -97,9 +96,9 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
||||
static const int kRequestsDelay;
|
||||
|
||||
QTimer *timer_flush_requests_;
|
||||
QQueue<std::shared_ptr<DiscogsCoverSearchContext>> queue_search_requests_;
|
||||
QQueue<SharedPtr<DiscogsCoverSearchContext>> queue_search_requests_;
|
||||
QQueue<DiscogsCoverReleaseContext> queue_release_requests_;
|
||||
QMap<int, std::shared_ptr<DiscogsCoverSearchContext>> requests_search_;
|
||||
QMap<int, SharedPtr<DiscogsCoverSearchContext>> requests_search_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "coverprovider.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
|
||||
JsonCoverProvider::JsonCoverProvider(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)
|
||||
JsonCoverProvider::JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: CoverProvider(name, enabled, authentication_required, quality, batch, allow_missing_album, app, network, parent) {}
|
||||
|
||||
QJsonObject JsonCoverProvider::ExtractJsonObj(const QByteArray &data) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "coverprovider.h"
|
||||
|
||||
class Application;
|
||||
@@ -36,7 +37,7 @@ class JsonCoverProvider : public CoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JsonCoverProvider(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);
|
||||
explicit JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent);
|
||||
|
||||
protected:
|
||||
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@@ -49,7 +50,7 @@ const char *LastFmCoverProvider::kUrl = "https://ws.audioscrobbler.com/2.0/";
|
||||
const char *LastFmCoverProvider::kApiKey = "211990b4c96782c05d1536e7219eb56e";
|
||||
const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
||||
|
||||
LastFmCoverProvider::LastFmCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
LastFmCoverProvider::LastFmCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Last.fm", true, false, 1.0, true, false, app, network, parent) {}
|
||||
|
||||
LastFmCoverProvider::~LastFmCoverProvider() {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
|
||||
class NetworkAccessManager;
|
||||
@@ -39,7 +40,7 @@ class LastFmCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LastFmCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit LastFmCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~LastFmCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@@ -48,7 +49,7 @@ const char *MusicbrainzCoverProvider::kAlbumCoverUrl = "https://coverartarchive.
|
||||
const int MusicbrainzCoverProvider::kLimit = 8;
|
||||
const int MusicbrainzCoverProvider::kRequestsDelay = 1000;
|
||||
|
||||
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("MusicBrainz", true, false, 1.5, true, false, app, network, parent),
|
||||
timer_flush_requests_(new QTimer(this)) {
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
|
||||
class QNetworkReply;
|
||||
@@ -41,7 +42,7 @@ class MusicbrainzCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MusicbrainzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit MusicbrainzCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~MusicbrainzCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "providers/musixmatchprovider.h"
|
||||
@@ -39,7 +40,7 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "musixmatchcoverprovider.h"
|
||||
|
||||
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Musixmatch", true, false, 1.0, true, false, app, network, parent) {}
|
||||
|
||||
MusixmatchCoverProvider::~MusixmatchCoverProvider() {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "providers/musixmatchprovider.h"
|
||||
|
||||
@@ -38,7 +39,7 @@ class MusixmatchCoverProvider : public JsonCoverProvider, MusixmatchProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MusixmatchCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit MusixmatchCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~MusixmatchCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@@ -47,7 +48,7 @@
|
||||
|
||||
constexpr int QobuzCoverProvider::kLimit = 10;
|
||||
|
||||
QobuzCoverProvider::QobuzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
QobuzCoverProvider::QobuzCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Qobuz", true, true, 2.0, true, true, app, network, parent),
|
||||
service_(app->internet_services()->Service<QobuzService>()) {}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QSslError>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "qobuz/qobuzservice.h"
|
||||
|
||||
@@ -41,7 +42,7 @@ class QobuzCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QobuzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit QobuzCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~QobuzCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
@@ -60,7 +61,7 @@ class QobuzCoverProvider : public JsonCoverProvider {
|
||||
private:
|
||||
static const int kLimit;
|
||||
|
||||
QobuzService *service_;
|
||||
QobuzServicePtr service_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@@ -60,7 +61,7 @@ const char *SpotifyCoverProvider::kClientSecretB64 = "N2ZlMDMxODk1NTBlNDE3ZGI1ZW
|
||||
const char *SpotifyCoverProvider::kApiUrl = "https://api.spotify.com/v1";
|
||||
const int SpotifyCoverProvider::kLimit = 10;
|
||||
|
||||
SpotifyCoverProvider::SpotifyCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
SpotifyCoverProvider::SpotifyCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Spotify", true, true, 2.5, true, true, app, network, parent),
|
||||
server_(nullptr),
|
||||
expires_in_(0),
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
|
||||
class QNetworkReply;
|
||||
@@ -45,7 +46,7 @@ class SpotifyCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SpotifyCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit SpotifyCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~SpotifyCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@@ -46,7 +47,7 @@
|
||||
|
||||
constexpr int TidalCoverProvider::kLimit = 10;
|
||||
|
||||
TidalCoverProvider::TidalCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
TidalCoverProvider::TidalCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Tidal", true, true, 2.5, true, true, app, network, parent),
|
||||
service_(app->internet_services()->Service<TidalService>()) {}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <QJsonValue>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "tidal/tidalservice.h"
|
||||
|
||||
@@ -43,7 +44,7 @@ class TidalCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit TidalCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~TidalCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
@@ -64,7 +65,7 @@ class TidalCoverProvider : public JsonCoverProvider {
|
||||
private:
|
||||
static const int kLimit;
|
||||
|
||||
TidalService *service_;
|
||||
TidalServicePtr service_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user