/**********************************************************************
 * LeechCraft - modular cross-platform feature rich internet client.
 * Copyright (C) 2006-2014  Georg Rudoy
 *
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
 **********************************************************************/

#pragma once

#include <functional>
#include <QString>
#include <QFlags>
#include <interfaces/core/icoreproxyfwd.h>
#include <util/threads/coro/channelfwd.h>
#include "lmputilconfig.h"
#include "mediainfo.h"

template<typename, typename>
class QMap;

namespace LC::LMP
{
	enum SubstitutionFlag
	{
		SFNone,
		SFSafeFilesystem
	};
	Q_DECLARE_FLAGS (SubstitutionFlags, SubstitutionFlag);

	LMP_UTIL_API QMap<QString, std::function<QString (MediaInfo)>> GetSubstGetters ();

	LMP_UTIL_API QMap<QString, std::function<void (MediaInfo&, QString)>> GetSubstSetters ();

	LMP_UTIL_API QStringList GetSubstGettersKeys ();

	LMP_UTIL_API QString PerformSubstitutions (QString mask,
			const MediaInfo& info, SubstitutionFlags flags = SFNone);

	LMP_UTIL_API QStringList PerformSubstitutions (const QString& mask,
			const QList<MediaInfo>& infos,
			const std::function<void (int, QString)>& setter,
			SubstitutionFlags flags = SFSafeFilesystem);

	template<typename T>
	struct AlbumArtInfo
	{
		QString Service_;
		T AlbumArt_;
	};

	LMP_UTIL_API Util::Channel_ptr<AlbumArtInfo<QUrl>> GetAlbumArtUrls (const ICoreProxy_ptr&, const QString& artist, const QString& album);
	LMP_UTIL_API Util::Channel_ptr<AlbumArtInfo<QImage>> GetAlbumArtImages (const ICoreProxy_ptr&, const QString& artist, const QString& album);
}

Q_DECLARE_OPERATORS_FOR_FLAGS (LC::LMP::SubstitutionFlags)
