/**********************************************************************
 * LeechCraft - modular cross-platform feature rich internet client.
 * Copyright (C) 2010-2011 Oleg Linkin
 *
 * 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.
 **********************************************************************/

#ifndef PLUGINS_AZOTH_PLUGINS_ACETAMIDE_CORE_H
#define PLUGINS_AZOTH_PLUGINS_ACETAMIDE_CORE_H
#include <QObject>
#include <interfaces/iinfo.h>
#include <interfaces/structures.h>
#include "localtypes.h"

class QStandardItemModel;

namespace LeechCraft
{
namespace Azoth
{
class IProxyObject;

namespace Acetamide
{

	class IrcProtocol;
	class IrcAccount;
	class NickServIdentifyWidget;

	class Core : public QObject
	{
		Q_OBJECT

		ICoreProxy_ptr Proxy_;
		std::shared_ptr<IrcProtocol> IrcProtocol_;
		QObject *PluginProxy_;
		QStandardItemModel* Model_;
		NickServIdentifyWidget* NickServIdentifyWidget_;
		QList<NickServIdentify> NickServIdentifyList_;

		Core ();
	public:
		static Core& Instance ();

		void Init ();
		void SecondInit ();
		void Release ();
		QList<QObject*> GetProtocols () const;

		void SetPluginProxy (QObject*);
		IProxyObject* GetPluginProxy () const;
		void SetProxy (ICoreProxy_ptr);
		ICoreProxy_ptr GetProxy () const;
		void SendEntity (const Entity&);

		NickServIdentifyWidget* GetNickServIdentifyWidget () const;
		QStandardItemModel* GetNickServIdentifyModel () const;

		void AddNickServIdentify (const NickServIdentify&);
		QList<NickServIdentify> GetAllNickServIdentify () const;
		QList<NickServIdentify> GetNickServIdentifyWithNick (const QString&) const;
		QList<NickServIdentify> GetNickServIdentifyWithNickServ (const QString&) const;
		QList<NickServIdentify> GetNickServIdentifyWithServ (const QString&) const;
		QList<NickServIdentify> GetNickServIdentifyWithMainParams (const QString&,
				const QString&, const QString&) const;
	private slots:
		void handleItemsAdded (const QList<QObject*>&);
	signals:
		void gotEntity (const LeechCraft::Entity&);
	};
}
}
}

#endif // PLUGINS_AZOTH_PLUGINS_ACETAMIDE_CORE_H
