//---------------------------------
// Name:			Main.cpp
// Purpose:			Firmware updater application entry point
// Toolchain(s):	Microsoft Visual C++
// Creation date:	26-May-06
// Created by:		JJo
//---------------------------------

//---------------------------------
// Includes

#include <afxwin.h>
#include "GUI/MainDialog.h"
#include "Misc/Configuration.h"

//---------------------------------
// Defines

#define APP_NAME	"Firmware Updater"

//---------------------------------
// Class

class Main : public CWinApp {

public:
	Main::Main() : CWinApp(APP_NAME) {}
	Main::~Main() {}

	BOOL Main::InitInstance() {

		try {

			if (this->m_lpCmdLine[0] != '\0') {

				// Command-line mode
				/*Configuration configuration;
				configuration.Parse(m_lpCmdLine);

				// Start upgrade process
				UpgradingDialog upgradingDialog(NULL, &configuration);
				
				upgradingDialog.DoModal();*/
			}
			else {

				// Create main dialog and start message loop
				this->m_pMainWnd = new MainDialog();
				this->m_pMainWnd->ShowWindow(SW_SHOWNORMAL);

				return TRUE;
			}
		}
		catch (CConfigurationException * e) {

			e->ReportError();
			Configuration::DisplayOptions();
		}
		catch (CException * e) {

			e->ReportError();
		}
		catch (...) {

			AfxMessageBox("Unhandled exception");
		}

		return FALSE;
	}
};

//---------------------------------
// Application

Main theApp;
