//---------------------------------
// Name:			MainDialog.h
// Purpose:			Firmware packager main dialog class
// Toolchain(s):	Microsoft Visual C++
// Creation date:	02-Jun-06
// Created by:		JJo
//---------------------------------

#ifndef FIRMWARE_PACKAGER_MAIN_DIALOG
#define FIRMWARE_PACKAGER_MAIN_DIALOG

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

#include <afxwin.h>
#include <afxdlgs.h>
#include <tomcrypt.h>
#include "resource.h"
#include "ProgressDialog.h"

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

class MainDialog : public CDialog {

// Attributes
private:
	ProgressDialog * m_pProgressDialog;
	int m_keyLength;
	int m_blockLength;
	CWinThread * m_thread;
	BOOL m_closeThread;

// Private methods
private:
	BOOL MainDialog::IsECBSelected();
	BOOL MainDialog::IsCBCSelected();
	BOOL MainDialog::IsCTRSelected();
	BOOL MainDialog::IsEAXSelected();
	BOOL MainDialog::IsAESSelected();
	BOOL MainDialog::Is3DESSelected();
	BOOL MainDialog::IsInputFileSelected();
	BOOL MainDialog::IsOutputFileSelected();

	CString MainDialog::GetKey();
	CString MainDialog::GetIV();
	CString MainDialog::GetInputFilePath();
	CString MainDialog::GetOutputFilePath();
	CString MainDialog::GetOutputFileName();
	DWORD MainDialog::GetKeySel();
	DWORD MainDialog::GetIVSel();

	void MainDialog::SetKey(const char * value);
	void MainDialog::SetIV(const char * value);
	void MainDialog::SetKeySel(DWORD value);
	void MainDialog::SetIVSel(DWORD value);

	void MainDialog::AddInputFile(const char * fileName, const char * filePath);
	void MainDialog::AddOutputFile(const char * fileName, const char * filePath);

	void MainDialog::CheckAES();
	void MainDialog::CheckECB();

	void MainDialog::EnablePackageButton();
	void MainDialog::EnableIV();
	void MainDialog::DisableIV();

	void MainDialog::ASCII2Hex(const char * ascii,
							   unsigned char * hex,
							   unsigned int length);
	static UINT MainDialog::Encrypt(LPVOID pParam);

// Public methods
public:
	MainDialog::MainDialog();
	MainDialog::~MainDialog();

	virtual BOOL MainDialog::OnInitDialog();

	afx_msg void MainDialog::OnClose();
	afx_msg void MainDialog::OnExitClicked();
	afx_msg void MainDialog::OnInputBrowseClicked();
	afx_msg void MainDialog::OnOutputBrowseClicked();
	afx_msg void MainDialog::OnPackageClicked();
	afx_msg void MainDialog::OnKeyUpdated();
	afx_msg void MainDialog::OnIVUpdated();
	afx_msg void MainDialog::OnAESClicked();
	afx_msg void MainDialog::On3DESClicked();
	afx_msg void MainDialog::OnECBClicked();
	afx_msg void MainDialog::OnCBCClicked();

	DECLARE_MESSAGE_MAP()
};

#endif // FIRMWARE_PACKAGER_MAIN_DIALOG
