/**********************************************************************
 * LeechCraft - modular cross-platform feature rich internet client.
 * Copyright (C) 2006-2014  Georg Rudoy
 *
 * Boost Software License - Version 1.0 - August 17th, 2003
 *
 * Permission is hereby granted, free of charge, to any person or organization
 * obtaining a copy of the software and accompanying documentation covered by
 * this license (the "Software") to use, reproduce, display, distribute,
 * execute, and transmit the Software, and to prepare derivative works of the
 * Software, and to permit third-parties to whom the Software is furnished to
 * do so, all subject to the following:
 *
 * The copyright notices in the Software and this entire statement, including
 * the above license grant, this restriction and the following disclaimer,
 * must be included in all copies of the Software, in whole or in part, and
 * all derivative works of the Software, unless such copies or derivative
 * works are solely in the form of machine-executable object code generated by
 * a source language processor.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 **********************************************************************/

#pragma once

#include <boost/optional.hpp>
#include <QStringList>
#include <util/sll/eitherfwd.h>

template<typename>
class QFuture;

namespace Media
{
	/** @brief Describes a lyrics search request.
	 *
	 * @sa ILyricsFinder
	 */
	struct LyricsQuery
	{
		/** @brief The artist preforming the track.
		 */
		QString Artist_;

		/** @brief The album this track is on.
		 */
		QString Album_;

		/** @brief The title of the track.
		 */
		QString Title_;

		/** @brief The year of the album the track is on.
		 */
		boost::optional<int> Year_;

		/** @brief The track number.
		 */
		boost::optional<int> Track_;
	};

	/** @brief Describes a single lyrics result item.
	 *
	 * A result item is the lyrics themselves and the provider name these
	 * lyrics were fetched from.
	 *
	 * @sa LyricsResults
	 */
	struct LyricsResultItem
	{
		/** @brief The name of the provider lyrics were fetched from.
		 */
		QString ProviderName_;

		/** @brief The HTML-formatted lyrics string.
		 */
		QString Lyrics_;
	};

	/** @brief Describes the result set for a given lyrics query.
	 *
	 * @sa LyricsResultItem
	 */
	using LyricsResults = QList<LyricsResultItem>;

	/** @brief Interface for plugins supporting finding lyrics.
	 *
	 * Plugins that support searching for lyrics should implement this
	 * interface.
	 */
	class Q_DECL_EXPORT ILyricsFinder
	{
	public:
		virtual ~ILyricsFinder () {}

		/** @brief The result of a lyrics search query.
		 *
		 * The result of a lyrics search query is either a string with a
		 * human-readable error text, or a LyricsResults object.
		 *
		 * @sa LyricsResults
		 */
		using LyricsQueryResult_t = LC::Util::Either<QString, LyricsResults>;

		/** @brief Requests searching for lyrics for the given query.
		 *
		 * The returned future potentially provides multiple results.
		 *
		 * @param[in] query The lyrics query.
		 * @return The future (potentially providing multiple results) with the
		 * search results.
		 */
		virtual QFuture<LyricsQueryResult_t> RequestLyrics (const LyricsQuery& query) = 0;
	};
}

Q_DECLARE_INTERFACE (Media::ILyricsFinder, "org.LeechCraft.Media.ILyricsFinder/1.0")
