/**
    File        : IPlugin.h
    Description : Virtual classes for creating plugins
    Author      : Raymond Marsh
    Created     : 08/01/2009
    Copyright 2009, 2010 Raymond Marsh

    This program is distributed under the terms of the GNU General Public License.
    To view a copy of the license see the file 'copying.txt'

    This file is part of the Ace Personal Finance Assistant Suite.

    Ace Personal Finance Assistant 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.

    Ace Personal Finance Assistant 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 Ace Personal Finance Assistant.
    If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef IPLUGIN_H_INCLUDED
#define IPLUGIN_H_INCLUDED

#include <vector>
#include "Base.h"
#include "Data.h"

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#ifdef MY_DLL_EXPORTS
#define DLL_IMPORT_EXPORT __declspec(dllexport)
#else
#define DLL_IMPORT_EXPORT __declspec(dllimport)
#endif

const wxString g_strFuncRegister   = _("RegisterPlugin");
const wxString g_strFuncUnregister = _("UnregisterPlugin");

enum PLUGIN_TYPE
{
    PT_ACCOUNTTYPE = 9150,
    PT_REPORT
};

class IPluginHost;

class DLL_IMPORT_EXPORT IPlugin : public wxEvtHandler
{
    public:
    virtual ~IPlugin() { }
    virtual void InitializePlugin(IPluginHost*)  = 0;
    virtual void ShutdownPlugin()                = 0;
    virtual wxString GetPluginName()             = 0;
    virtual PLUGIN_TYPE GetPluginType()          = 0;
    virtual int GetPluginWeight()                = 0;
    virtual wxString GetPluginVersionString()    = 0;
    virtual wxString GetWxVersionString()        = 0;
};

class DLL_IMPORT_EXPORT CAccountTypePluginBase : public IPlugin
{
    public:
    virtual ~CAccountTypePluginBase() { }
    virtual int GetHeaderToDisplay(std::vector<std::pair<wxString, int> >&)               = 0;
    virtual int GetItemsToDisplay(const STransaction&, wxArrayString&, std::vector<int>&) = 0;
    virtual int GetTransactionViewer(wxString Title,
                                     STransaction& Transaction,
                                     bool IsNewTransaction,
                                     bool CanEditTransaction)                             = 0;
};

class DLL_IMPORT_EXPORT CReportPluginBase : public IPlugin
{
    public:
    virtual ~CReportPluginBase() { }
};

class IPluginHost
{
    public:
    virtual ~IPluginHost() { }
    virtual long GetNewId()                                             = 0;
    virtual wxEvtHandler* GetEvtHandler()                               = 0;
    virtual wxMenuBar* GetMainMenuBar()                                 = 0;
    virtual wxToolBar* GetMainToolBar()                                 = 0;
    virtual CDataBase* GetGlobalDataObject()                            = 0;
    virtual void GetViewer(const wxString, CAccountTypePluginBase**)    = 0;
    virtual bool GetAvailableAccountTypes(wxArrayString&)               = 0;
};

typedef bool (*DLLFunctionPtr)(IPlugin**);

struct SPluginInfo
{
    wxString          PluginName;
    PLUGIN_TYPE       PluginType;
    IPlugin*          pPlugin;
    wxDynamicLibrary* pLibLoader;
    DLLFunctionPtr    pFuncRegisterPlugin;
    DLLFunctionPtr    pFuncUnregisterPlugin;
    SPluginInfo() : pLibLoader(NULL), pPlugin(NULL), pFuncRegisterPlugin(NULL), pFuncUnregisterPlugin(NULL) { }
};

#ifdef __cplusplus
}
#endif // __cplusplus


#endif // IPLUGIN_H_INCLUDED
