#include <kdialog.h>
#include <klocale.h>
/****************************************************************************
** Form implementation generated from reading ui file './profilecertoptionsbase.ui'
**
** Created: Mo Jun 11 20:19:10 2007
**      by: The User Interface Compiler ($Id: qt/main.cpp   3.3.7   edited Aug 31 2005 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/

#include "profilecertoptionsbase.h"

#include <qvariant.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <kcombobox.h>
#include <kurlrequester.h>
#include <qlineedit.h>
#include <klineedit.h>
#include <qcheckbox.h>
#include <kpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>

/*
 *  Constructs a ProfileCertOptionsBase as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 */
ProfileCertOptionsBase::ProfileCertOptionsBase( QWidget* parent, const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    if ( !name )
	setName( "ProfileCertOptionsBase" );
    setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, sizePolicy().hasHeightForWidth() ) );
    ProfileCertOptionsBaseLayout = new QGridLayout( this, 1, 1, 11, 6, "ProfileCertOptionsBaseLayout"); 

    layout157 = new QHBoxLayout( 0, 0, 6, "layout157"); 

    layout156 = new QVBoxLayout( 0, 0, 6, "layout156"); 

    layout155 = new QVBoxLayout( 0, 0, 6, "layout155"); 

    layout117 = new QHBoxLayout( 0, 0, 6, "layout117"); 

    LabelAuthType = new QLabel( this, "LabelAuthType" );
    layout117->addWidget( LabelAuthType );
    spacer23 = new QSpacerItem( 50, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout117->addItem( spacer23 );

    AuthTypeComboBox = new KComboBox( FALSE, this, "AuthTypeComboBox" );
    layout117->addWidget( AuthTypeComboBox );
    layout155->addLayout( layout117 );

    layout150 = new QGridLayout( 0, 1, 1, 0, 6, "layout150"); 

    layout10 = new QHBoxLayout( 0, 0, 6, "layout10"); 

    LabelCertificate = new QLabel( this, "LabelCertificate" );
    layout10->addWidget( LabelCertificate );
    spacer17 = new QSpacerItem( 152, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout10->addItem( spacer17 );

    layout150->addLayout( layout10, 0, 0 );

    CaCertpathURLRequester = new KURLRequester( this, "CaCertpathURLRequester" );

    layout150->addWidget( CaCertpathURLRequester, 2, 1 );

    layout8 = new QHBoxLayout( 0, 0, 6, "layout8"); 

    LabelCaCertificatePath = new QLabel( this, "LabelCaCertificatePath" );
    layout8->addWidget( LabelCaCertificatePath );
    spacer21_2 = new QSpacerItem( 93, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout8->addItem( spacer21_2 );

    layout150->addLayout( layout8, 2, 0 );

    PrivkeyPasswordEdit = new QLineEdit( this, "PrivkeyPasswordEdit" );
    PrivkeyPasswordEdit->setEchoMode( QLineEdit::Password );

    layout150->addWidget( PrivkeyPasswordEdit, 6, 1 );

    RemoteIDLineEdit = new KLineEdit( this, "RemoteIDLineEdit" );
    RemoteIDLineEdit->setEnabled( FALSE );
    RemoteIDLineEdit->setEchoMode( KLineEdit::Normal );

    layout150->addWidget( RemoteIDLineEdit, 3, 1 );

    layout9 = new QHBoxLayout( 0, 0, 6, "layout9"); 

    LabelCertificatePath = new QLabel( this, "LabelCertificatePath" );
    layout9->addWidget( LabelCertificatePath );
    spacer21 = new QSpacerItem( 115, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout9->addItem( spacer21 );

    layout150->addLayout( layout9, 1, 0 );

    privkeypathURLRequester = new KURLRequester( this, "privkeypathURLRequester" );

    layout150->addWidget( privkeypathURLRequester, 5, 1 );

    SpecialServerCertificateURLRequester = new KURLRequester( this, "SpecialServerCertificateURLRequester" );
    SpecialServerCertificateURLRequester->setEnabled( FALSE );

    layout150->addWidget( SpecialServerCertificateURLRequester, 4, 1 );

    layout7 = new QHBoxLayout( 0, 0, 6, "layout7"); 

    UseSpecialRemoteIDcheckBox = new QCheckBox( this, "UseSpecialRemoteIDcheckBox" );
    layout7->addWidget( UseSpecialRemoteIDcheckBox );
    spacer25 = new QSpacerItem( 47, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout7->addItem( spacer25 );

    layout150->addLayout( layout7, 3, 0 );

    certpathURLRequester = new KURLRequester( this, "certpathURLRequester" );

    layout150->addWidget( certpathURLRequester, 1, 1 );

    layout6 = new QHBoxLayout( 0, 0, 6, "layout6"); 

    UseSpecialServerCertificateCheckBox = new QCheckBox( this, "UseSpecialServerCertificateCheckBox" );
    layout6->addWidget( UseSpecialServerCertificateCheckBox );
    spacer25_2 = new QSpacerItem( 16, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout6->addItem( spacer25_2 );

    layout150->addLayout( layout6, 4, 0 );

    layout5 = new QHBoxLayout( 0, 0, 6, "layout5"); 

    LabelPrivateKeyPath = new QLabel( this, "LabelPrivateKeyPath" );
    layout5->addWidget( LabelPrivateKeyPath );
    spacer22 = new QSpacerItem( 109, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout5->addItem( spacer22 );

    layout150->addLayout( layout5, 5, 0 );

    x509certURLRequester = new KURLRequester( this, "x509certURLRequester" );
    x509certURLRequester->setMinimumSize( QSize( 50, 0 ) );

    layout150->addWidget( x509certURLRequester, 0, 1 );

    layout4 = new QHBoxLayout( 0, 0, 6, "layout4"); 

    LabelPrivateKeyPassword = new QLabel( this, "LabelPrivateKeyPassword" );
    layout4->addWidget( LabelPrivateKeyPassword );
    spacer19 = new QSpacerItem( 75, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout4->addItem( spacer19 );

    layout150->addLayout( layout4, 6, 0 );
    layout155->addLayout( layout150 );

    layout151 = new QHBoxLayout( 0, 0, 6, "layout151"); 

    SavePrivateKeyPasswordCheckBox = new QCheckBox( this, "SavePrivateKeyPasswordCheckBox" );
    layout151->addWidget( SavePrivateKeyPasswordCheckBox );
    spacer25_2_2 = new QSpacerItem( 16, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout151->addItem( spacer25_2_2 );
    layout155->addLayout( layout151 );

    layout152 = new QHBoxLayout( 0, 0, 6, "layout152"); 

    UseMailAddressAsIdentifierCheckBox = new QCheckBox( this, "UseMailAddressAsIdentifierCheckBox" );
    layout152->addWidget( UseMailAddressAsIdentifierCheckBox );
    spacer183 = new QSpacerItem( 211, 21, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout152->addItem( spacer183 );
    layout155->addLayout( layout152 );

    layout153 = new QHBoxLayout( 0, 0, 6, "layout153"); 

    AllowEmptyPrivateKeyPasswordCheckBox = new QCheckBox( this, "AllowEmptyPrivateKeyPasswordCheckBox" );
    layout153->addWidget( AllowEmptyPrivateKeyPasswordCheckBox );
    spacer182 = new QSpacerItem( 120, 21, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout153->addItem( spacer182 );
    layout155->addLayout( layout153 );

    layout154 = new QHBoxLayout( 0, 0, 6, "layout154"); 
    layout155->addLayout( layout154 );

    layout41 = new QHBoxLayout( 0, 0, 6, "layout41"); 
    spacer103 = new QSpacerItem( 20, 31, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout41->addItem( spacer103 );

    ImportCertificatePushButton = new KPushButton( this, "ImportCertificatePushButton" );
    ImportCertificatePushButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, ImportCertificatePushButton->sizePolicy().hasHeightForWidth() ) );
    layout41->addWidget( ImportCertificatePushButton );
    layout155->addLayout( layout41 );
    layout156->addLayout( layout155 );
    spacer14 = new QSpacerItem( 21, 40, QSizePolicy::Minimum, QSizePolicy::Expanding );
    layout156->addItem( spacer14 );
    layout157->addLayout( layout156 );
    spacer38_3 = new QSpacerItem( 16, 51, QSizePolicy::Expanding, QSizePolicy::Minimum );
    layout157->addItem( spacer38_3 );

    ProfileCertOptionsBaseLayout->addLayout( layout157, 0, 0 );
    languageChange();
    resize( QSize(396, 410).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );

    // signals and slots connections
    connect( UseSpecialRemoteIDcheckBox, SIGNAL( toggled(bool) ), this, SLOT( useSpecialRemoteIDToggled(bool) ) );
    connect( UseSpecialServerCertificateCheckBox, SIGNAL( toggled(bool) ), this, SLOT( useSpecialServerCertificateToggled(bool) ) );

    // tab order
    setTabOrder( AuthTypeComboBox, x509certURLRequester );
    setTabOrder( x509certURLRequester, certpathURLRequester );
    setTabOrder( certpathURLRequester, CaCertpathURLRequester );
    setTabOrder( CaCertpathURLRequester, UseSpecialRemoteIDcheckBox );
    setTabOrder( UseSpecialRemoteIDcheckBox, RemoteIDLineEdit );
    setTabOrder( RemoteIDLineEdit, UseSpecialServerCertificateCheckBox );
    setTabOrder( UseSpecialServerCertificateCheckBox, SpecialServerCertificateURLRequester );
    setTabOrder( SpecialServerCertificateURLRequester, privkeypathURLRequester );
    setTabOrder( privkeypathURLRequester, PrivkeyPasswordEdit );
    setTabOrder( PrivkeyPasswordEdit, SavePrivateKeyPasswordCheckBox );
    setTabOrder( SavePrivateKeyPasswordCheckBox, UseMailAddressAsIdentifierCheckBox );
    setTabOrder( UseMailAddressAsIdentifierCheckBox, AllowEmptyPrivateKeyPasswordCheckBox );
    setTabOrder( AllowEmptyPrivateKeyPasswordCheckBox, ImportCertificatePushButton );
}

/*
 *  Destroys the object and frees any allocated resources
 */
ProfileCertOptionsBase::~ProfileCertOptionsBase()
{
    // no need to delete child widgets, Qt does it all for us
}

/*
 *  Sets the strings of the subwidgets using the current
 *  language.
 */
void ProfileCertOptionsBase::languageChange()
{
    setCaption( tr2i18n( "Certificate" ) );
    LabelAuthType->setText( tr2i18n( "Authentication type:" ) );
    AuthTypeComboBox->clear();
    AuthTypeComboBox->insertItem( tr2i18n( "X.509 Certificate" ) );
    AuthTypeComboBox->insertItem( tr2i18n( "Pre Shared Key" ) );
    QToolTip::add( AuthTypeComboBox, tr2i18n( "Authentication type" ) );
    LabelCertificate->setText( tr2i18n( "Certificate:" ) );
    QToolTip::add( CaCertpathURLRequester, tr2i18n( "CA certificate path" ) );
    LabelCaCertificatePath->setText( tr2i18n( "CA certificate path:" ) );
    QToolTip::add( PrivkeyPasswordEdit, tr2i18n( "Passphrase to decrypt the private key" ) );
    QToolTip::add( RemoteIDLineEdit, tr2i18n( "Special ID for remote side (rarely needed)" ) );
    LabelCertificatePath->setText( tr2i18n( "Certificates path:" ) );
    QToolTip::add( privkeypathURLRequester, tr2i18n( "Path to the private key file" ) );
    UseSpecialRemoteIDcheckBox->setText( tr2i18n( "Use special &remote ID" ) );
    UseSpecialRemoteIDcheckBox->setAccel( QKeySequence( tr2i18n( "Alt+R" ) ) );
    QToolTip::add( UseSpecialRemoteIDcheckBox, tr2i18n( "Use special ID for the remote side" ) );
    QToolTip::add( certpathURLRequester, tr2i18n( "Path to the certificates, used if no absolute path is given." ) );
    UseSpecialServerCertificateCheckBox->setText( tr2i18n( "&Use special server certificate" ) );
    UseSpecialServerCertificateCheckBox->setAccel( QKeySequence( tr2i18n( "Alt+U" ) ) );
    LabelPrivateKeyPath->setText( tr2i18n( "Private key path:" ) );
    QToolTip::add( x509certURLRequester, tr2i18n( "Path to the certificate file" ) );
    LabelPrivateKeyPassword->setText( tr2i18n( "Private key passphrase:" ) );
    SavePrivateKeyPasswordCheckBox->setText( tr2i18n( "Save private ke&y passphrase" ) );
    SavePrivateKeyPasswordCheckBox->setAccel( QKeySequence( tr2i18n( "Alt+Y" ) ) );
    UseMailAddressAsIdentifierCheckBox->setText( tr2i18n( "Use e&mail address as identifier" ) );
    UseMailAddressAsIdentifierCheckBox->setAccel( QKeySequence( tr2i18n( "Alt+M" ) ) );
    AllowEmptyPrivateKeyPasswordCheckBox->setText( tr2i18n( "Allo&w empty private key passphrase" ) );
    AllowEmptyPrivateKeyPasswordCheckBox->setAccel( QKeySequence( tr2i18n( "Alt+W" ) ) );
    ImportCertificatePushButton->setText( tr2i18n( "Import p1&2 Certificate..." ) );
    ImportCertificatePushButton->setAccel( QKeySequence( tr2i18n( "Alt+2" ) ) );
    QToolTip::add( ImportCertificatePushButton, tr2i18n( "Import a certificate in P12 format" ) );
    QWhatsThis::add( ImportCertificatePushButton, tr2i18n( "Here you can import a certificate in P12 format. You will get it from your administrator if needed." ) );
}

void ProfileCertOptionsBase::useSpecialRemoteIDToggled(bool)
{
    qWarning( "ProfileCertOptionsBase::useSpecialRemoteIDToggled(bool): Not implemented yet" );
}

void ProfileCertOptionsBase::useSpecialServerCertificateToggled(bool)
{
    qWarning( "ProfileCertOptionsBase::useSpecialServerCertificateToggled(bool): Not implemented yet" );
}

#include "profilecertoptionsbase.moc"
