/**********************************************************************
 * 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.
 **********************************************************************/

#include "anutil.h"
#include <QString>
#include <QObject>
#include <interfaces/an/constants.h>
#include <util/util.h>

namespace LeechCraft
{
namespace Util
{
namespace AN
{
	namespace LAN = LeechCraft::AN;

	QMap<QString, QString> GetCategoryNameMap ()
	{
		static const auto cat2hr = MakeMap<QString, QString> ({
				{ LAN::CatIM, QObject::tr ("Instant messaging") },
				{ LAN::CatOrganizer, QObject::tr ("Organizer") },
				{ LAN::CatDownloads, QObject::tr ("Downloads") },
				{ LAN::CatPackageManager, QObject::tr ("Package manager") },
				{ LAN::CatMediaPlayer, QObject::tr ("Media player") },
				{ LAN::CatTerminal, QObject::tr ("Terminal") },
				{ LAN::CatGeneric, QObject::tr ("Generic") }
			});
		return cat2hr;
	}

	QStringList GetKnownEventTypes (const QString& category)
	{
		static const auto cat2types = MakeMap<QString, QStringList> ({
				{ LAN::CatIM,
					{
						LAN::TypeIMAttention,
						LAN::TypeIMIncFile,
						LAN::TypeIMIncMsg,
						LAN::TypeIMMUCHighlight,
						LAN::TypeIMMUCInvite,
						LAN::TypeIMMUCMsg,
						LAN::TypeIMStatusChange,
						LAN::TypeIMSubscrGrant,
						LAN::TypeIMSubscrRequest,
						LAN::TypeIMSubscrRevoke,
						LAN::TypeIMSubscrSub,
						LAN::TypeIMSubscrUnsub,
						LAN::TypeIMEventTuneChange,
						LAN::TypeIMEventMoodChange,
						LAN::TypeIMEventActivityChange,
						LAN::TypeIMEventLocationChange
					}
				},
				{
					LAN::CatOrganizer,
					{
						LAN::TypeOrganizerEventDue
					}
				},
				{
					LAN::CatDownloads,
					{
						LAN::TypeDownloadError,
						LAN::TypeDownloadFinished
					}
				},
				{
					LAN::CatPackageManager,
					{
						LAN::TypePackageUpdated
					}
				},
				{
					LAN::CatMediaPlayer,
					{
						LAN::TypeMediaPlaybackStatus
					}
				},
				{
					LAN::CatTerminal,
					{
						LAN::TypeTerminalActivity,
						LAN::TypeTerminalInactivity,
						LAN::TypeTerminalBell
					}
				},
				{
					LAN::CatGeneric,
					{
						LAN::TypeGeneric
					}
				}
			});
		return cat2types.value (category);
	}

	QString GetCategoryName (const QString& category)
	{
		return GetCategoryNameMap ().value (category, category);
	}

	QString GetTypeName (const QString& type)
	{
		static const auto type2hr = MakeMap<QString, QString> ({
				{ LAN::TypeIMAttention, QObject::tr ("Attention request") },
				{ LAN::TypeIMIncFile, QObject::tr ("Incoming file transfer request") },
				{ LAN::TypeIMIncMsg, QObject::tr ("Incoming chat message") },
				{ LAN::TypeIMMUCHighlight, QObject::tr ("MUC highlight") },
				{ LAN::TypeIMMUCInvite, QObject::tr ("MUC invitation") },
				{ LAN::TypeIMMUCMsg, QObject::tr ("General MUC message") },
				{ LAN::TypeIMStatusChange, QObject::tr ("Contact status change") },
				{ LAN::TypeIMSubscrGrant, QObject::tr ("Authorization granted") },
				{ LAN::TypeIMSubscrRevoke, QObject::tr ("Authorization revoked") },
				{ LAN::TypeIMSubscrRequest, QObject::tr ("Authorization requested") },
				{ LAN::TypeIMSubscrSub, QObject::tr ("Contact subscribed") },
				{ LAN::TypeIMSubscrUnsub, QObject::tr ("Contact unsubscribed") },
				{ LAN::TypeIMEventTuneChange, QObject::tr ("Contact's tune changed") },
				{ LAN::TypeIMEventMoodChange, QObject::tr ("Contact's mood changed") },
				{ LAN::TypeIMEventActivityChange, QObject::tr ("Contact's activity changed") },
				{ LAN::TypeIMEventLocationChange, QObject::tr ("Contact's location changed") },

				{ LAN::TypeOrganizerEventDue, QObject::tr ("Event is due") },

				{ LAN::TypeDownloadError, QObject::tr ("Download error") },
				{ LAN::TypeDownloadFinished, QObject::tr ("Download finished") },

				{ LAN::TypePackageUpdated, QObject::tr ("Package updated") },

				{ LAN::TypeMediaPlaybackStatus, QObject::tr ("Media playback status changed") },

				{ LAN::TypeTerminalBell, QObject::tr ("Bell in a terminal") },
				{ LAN::TypeTerminalActivity, QObject::tr ("Activity in a terminal") },
				{ LAN::TypeTerminalInactivity, QObject::tr ("Inactivity in a terminal") },

				{ LAN::TypeGeneric, QObject::tr ("Generic") }
			});
		return type2hr.value (type, type);
	}
}
}
}
