/* CoverFetchManager.h */

/* Copyright (C) 2011-2024 Michael Lugmair (Lucio Carreras)
 *
 * This file is part of sayonara player
 *
 * This program 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.

 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef COVERFETCHMANAGER_H
#define COVERFETCHMANAGER_H

#include "Utils/Singleton.h"
#include "Utils/Pimpl.h"

#include <QList>
#include <QObject>

namespace Cover
{
	namespace Fetcher
	{
		class Base;
		class Url;

		using CoverFetcherPtr = std::shared_ptr<Cover::Fetcher::Base>;
		using CoverFetcherList = QList<CoverFetcherPtr>;

		class Manager :
			public QObject
		{
				Q_OBJECT
				SINGLETON(Manager)
				PIMPL(Manager)

			public:
				void registerCoverFetcher(CoverFetcherPtr fetcher);

				[[nodiscard]] QList<Url> artistAddresses(const QString& artist) const;

				[[nodiscard]] QList<Url> albumAddresses(const QString& artist, const QString& album) const;

				[[nodiscard]] QList<Url> searchAddresses(const QString& str) const;

				[[nodiscard]] QList<Url>
				radioSearchAddresses(const QString& stationName, const QString& radioUrl) const;

				[[nodiscard]] QList<Url> searchAddresses(const QString& str,
				                                         const QString& coverFetcherIdentifier) const;

				[[nodiscard]] CoverFetcherPtr coverfetcher(const Url& url) const;

				[[nodiscard]] CoverFetcherList coverfetchers() const;

				[[nodiscard]] bool isActive(const CoverFetcherPtr fetcher) const;
				[[nodiscard]] bool isActive(const QString& identifier) const;

				[[nodiscard]] Url directFetcherUrl(const QString& url) const;

				[[nodiscard]] Url websiteFetcherUrl(const QString& url) const;

				static bool isSearchstringWebsite(const QString& searchstring);

			private slots:
				void serversChanged();
		};
	}
}
#endif // COVERFETCHMANAGER_H
