
//**************************************************************************/
// Copyright (c) 2008 Autodesk, Inc.
// All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//**************************************************************************/
// DESCRIPTION:
// CREATED: October 2008
//**************************************************************************/

#include <QFileInfoList>

namespace mudbox {

/// \brief This class holds all the information Mudbox needs about a plugin.
///
/// Normally you do not create instances of this class directly.  Instead, in your
/// plug-in class you use the \a MB_PLUGIN macro like this:
///
/// \code
/// MB_PLUGIN( "<Plugin Name>", "<Brief Description>", "<Author's Name>", "<Related URL (if any)>", <pointer to initializer function> );
/// \endcode
///
/// The initializer function must be a static method that takes no arguments and returns \b void. If there is no
/// initializer plugin for the class, this parameter can be \a NULL.
///
struct MBDLL_DECL Plugin
{
	typedef void initializer( void );

	/// Null constructor
	Plugin( void ) {};
	
	/// Constructor.  Use MB_PLUGIN macro instead.
	Plugin( const QString &sName, const QString &sDescription, const QString &sAuthor, const QString &sURL, const QString &sCompileTime, initializer *fFunc = 0 );
	
	/// This method sets the version number based on a plug-in name.
	static void SetVersion( const QString& sName, const QString &sVersion );

	QString m_sName;				///< The name of the plug-in
	QString m_sDescription;			///< A brief description of what it does
	QString m_sAuthor;				///< The name of the plug-in's author
	QString m_sURL;					///< A URL that contains information related to the plug-in (if any)
	QString m_sCompileTime;			///< The date and time that the plugin was loaded (generated automatically)
	QString m_sPluginFolder;		///< The path of the folder that the plug-in was loaded from (set at load time)
	initializer *m_pInitializer;	///< A pointer to the initializer funtion of the plug-in.
	QString m_sVersion;				///< The version of the plug-in
};
	
/// \brief WindowPlugin is an interface to implement window based plugins.
///
/// When a window based plugin inherits from this class, it will be automatically
/// added as a Window menu item and also in the New Tab contextual menu. 
class MBDLL_DECL WindowPlugin : public QObject
{
public:
	/// This method is called when Mudbox is loaded.
	virtual void Start() = 0;
	
	/// This method is called when Mudbox quits.
	virtual void Stop() = 0;
	
	/// This method returns whether the plugin is currently enabled or not.
	virtual bool IsEnabled() = 0;
	
	/// This method must implement the widget creation.
	virtual QWidget* CreateWidget(QWidget *parent, QString name) = 0;
	
	/// This method returns a pointer to the widget.
	virtual QWidget* Widget() = 0;
	
	/// This method returns the name of the plugin.
	virtual QString Name();
	
	/// This method returns the title of the plugin.
	virtual QString Title();
	
	/// This method returns true if the plugin is added to the window menu.
	virtual bool AddToWindowMenu();
	
protected:
	QString	m_name;
	QString	m_title;
	bool	m_addToWindowMenu;
};
	
/// \brief WebBrowserPlugin is a base class to implement the web browser based plugins.
///
/// The WebBrowserPlugin class is a base class that provides basic web browser 
/// functionalities.
class MBDLL_DECL WebBrowserPlugin : public WindowPlugin
{
public:
	WebBrowserPlugin(const QString name, const QString title);
	
	/// This enum contains all the navigation points.
	typedef enum
	{
		eNavNone = 0,
		eNavMudLife,
		eNavTutorials,
		eNavMeshUpload,
		eNavStampUpload,
		eNavStencilUpload,
	} NavigationPoints;
	
	/// This enum contains all file types.
	typedef enum
	{
		eFileTypeStamps,
		eFileTypeStencils,
		eFileTypeMeshes,
	} FileType;	
	
	/// This methods allows navigation. This is usually used by the host application.
	virtual void Navigate(const NavigationPoints nav) = 0;
	
	/// This methods allows files upload.
	virtual void Upload(const QStringList &files, const FileType fileType) = 0;
	
	/// This methods displays a loading message.
	virtual void GetFileList(const FileType fileType, QFileInfoList &fileList, QString filter = "") = 0;
};

}; // end of namespace mudbox
