/*
 *  Copyright (C) 2007-2008 CMM Sigma Andrzej Chmielowiec <cmmsigma@cmmsigma.eu>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3
 *  as published by the Free Software Foundation.
 *
 *  This program 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.
 */

#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#include <QtGui>
#include <QMainWindow>

#include "AboutBox.h"

class GenCertReqWidget;

class MainWindow: public QMainWindow
{
	Q_OBJECT
	
public:
	MainWindow();
	
private slots:
	void selectKeySlot();
	void generateCertReqSlot();
	void helpSlot();
	void aboutSlot();
	void langEnSlot();
	void langPlSlot();
	
private:
	QString getPass(bool confirm = false);
	void langExclamation();
	bool runOpenssl();
	
	void createActions();
	void createMenus();
	void createToolBars();
	void createAboutBox();
	
	// Key data and algorithm.
	QLineEdit *mKeyPath;
	QPushButton *mSelectKey;
	QComboBox *mKeyAlgo;
	QComboBox *mKeyMD;
	
	// Request data.
	GenCertReqWidget *mGenCertReq;
	
	// Generation button.
	QPushButton *mGenerate;
	
	// OpenSSL command name and arguments.
	QString mOpensslCmd;
	QString mOpensslConfFilePath;
	QStringList mOpensslArgs;
	QString mOpensslOut;
	QString mOpensslError;
	
	QAction *mSelectKeyAct;
	QAction *mHelpAct;
	QAction *mAboutAct;
	QAction *mExitAct;
	QActionGroup *mLang;
	QAction *mLangEn;
	QAction *mLangPl;
	
	AboutBox *mAboutBox;
	
};

#endif
