/*
 *  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 CA_NEW_DIALOG_H
#define CA_NEW_DIALOG_H

#include <QDialog>
#include "CA.h"
#include "MailAccountWidget.h"

class QWidget;
class QLineEdit;
class QPushButton;
class QSpinBox;
class QComboBox;
class QCheckBox;

class QLineEditFiltered: public QLineEdit
{
	Q_OBJECT

public:
	QLineEditFiltered(QWidget *parent = 0);

protected slots:
	void textCheck(const QString &name);

protected:
	QString mCorrectText;
};


class CaNewDialog: public QDialog
{
	Q_OBJECT;
	
public:
	CaNewDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
	
	QString name();
	QString caKeyName();
	int defaultCertDays();
	int defaultCrlDays();
	QString caAlgo();
	QString defaultMD();
	int caCertDays();
	QString caSubject();
	QString policyCountryName();
	QString policyStateOrProvinceName();
	QString policyLocalityName();
	QString policyOrganizationName();
	QString policyOrganizationalUnitName();
	QString policyCommonName();
	QString policyEmailAddress();
	MailAccountWidget *getMailWidget();
	
public slots:
	void accept();
	
private slots:
	void browseCaKeyName();
	void commonChanged(const QString &common);
	void emailChanged(const QString &email);
	
private:
	MailAccountWidget *mailWidget;
	QWidget *createGeneralTab();
	QWidget *createCaSubjectTab();
	QWidget *createPolicyTab();
	
	QLineEditFiltered *mName;
	QString mCorrectName;
	QLineEdit *mCaKeyName;
	QPushButton *mCaKeyBrowse;
	QSpinBox *mDefaultCertDays;
	QSpinBox *mDefaultCrlDays;
	QComboBox *mDefaultAlgo;
	QComboBox *mDefaultMD;
	
	QSpinBox *mCaCertDays;
	QLineEdit *mCaCountryCode;
	QLineEditFiltered *mCaStateOrProvinceName;
	QLineEditFiltered *mCaLocalityName;
	QLineEditFiltered *mCaOrganizationName;
	QLineEditFiltered *mCaOrganizationalUnitName;
	QLineEditFiltered *mCaCommonName;
	QLineEdit *mCaEmailAddress;
	
	QComboBox *mPolicyCountryName;
	QComboBox *mPolicyStateOrProvinceName;
	QComboBox *mPolicyLocalityName;
	QComboBox *mPolicyOrganizationName;
	QComboBox *mPolicyOrganizationalUnitName;
	QComboBox *mPolicyCommonName;
	QComboBox *mPolicyEmailAddress;

	QPushButton *mAccept;
	QPushButton *mCancel;
};

#endif
