kaddressbook

addhostdialog.cpp

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #include <qlabel.h>
00025 #include <qlayout.h>
00026 #include <qpushbutton.h>
00027 #include <qspinbox.h>
00028 #include <qtooltip.h>
00029 
00030 #include <kaccelmanager.h>
00031 #include <kbuttonbox.h>
00032 #include <klineedit.h>
00033 #include <klocale.h>
00034 #include "addhostdialog.h"
00035 
00036 AddHostDialog::AddHostDialog( KPIM::LdapServer *server, QWidget* parent,  const char* name )
00037   : KDialogBase( Plain, i18n( "Add Host" ), Ok | Cancel, Ok, parent, name, true, true )
00038 {
00039   mServer = server;
00040 
00041   QWidget *page = plainPage();
00042   QHBoxLayout *layout = new QHBoxLayout( page, marginHint(), spacingHint() );
00043 
00044   mCfg = new KABC::LdapConfigWidget(
00045        KABC::LdapConfigWidget::W_USER |
00046        KABC::LdapConfigWidget::W_PASS |
00047        KABC::LdapConfigWidget::W_BINDDN |
00048        KABC::LdapConfigWidget::W_REALM |
00049        KABC::LdapConfigWidget::W_HOST |
00050        KABC::LdapConfigWidget::W_PORT |
00051        KABC::LdapConfigWidget::W_VER |
00052        KABC::LdapConfigWidget::W_TIMELIMIT |
00053        KABC::LdapConfigWidget::W_SIZELIMIT |
00054        KABC::LdapConfigWidget::W_DN |
00055        KABC::LdapConfigWidget::W_SECBOX |
00056        KABC::LdapConfigWidget::W_AUTHBOX,
00057         page );
00058 
00059   layout->addWidget( mCfg );
00060   mCfg->setHost( mServer->host() );
00061   mCfg->setPort( mServer->port() );
00062   mCfg->setDn( mServer->baseDN() );
00063   mCfg->setUser( mServer->user() );
00064   mCfg->setBindDN( mServer->bindDN() );
00065   mCfg->setPassword( mServer->pwdBindDN() );
00066   mCfg->setTimeLimit( mServer->timeLimit() );
00067   mCfg->setSizeLimit( mServer->sizeLimit() );
00068   mCfg->setVer( mServer->version() );
00069 
00070   switch ( mServer->security() ) {
00071     case KPIM::LdapServer::TLS:
00072       mCfg->setSecTLS();
00073       break;
00074     case KPIM::LdapServer::SSL:
00075       mCfg->setSecSSL();
00076       break;
00077     default:
00078       mCfg->setSecNO();
00079   }
00080 
00081   switch ( mServer->auth() ) {
00082     case KPIM::LdapServer::Simple:
00083       mCfg->setAuthSimple();
00084       break;
00085     case KPIM::LdapServer::SASL:
00086       mCfg->setAuthSASL();
00087       break;
00088     default:
00089       mCfg->setAuthAnon();
00090   }
00091   mCfg->setMech( mServer->mech() );
00092 
00093   KAcceleratorManager::manage( this );
00094 
00095 }
00096 
00097 AddHostDialog::~AddHostDialog()
00098 {
00099 }
00100 
00101 void AddHostDialog::slotHostEditChanged( const QString &text )
00102 {
00103   enableButtonOK( !text.isEmpty() );
00104 }
00105 
00106 void AddHostDialog::slotOk()
00107 {
00108   mServer->setHost( mCfg->host() );
00109   mServer->setPort( mCfg->port() );
00110   mServer->setBaseDN( mCfg->dn().stripWhiteSpace() );
00111   mServer->setUser( mCfg->user() );
00112   mServer->setBindDN( mCfg->bindDN() );
00113   mServer->setPwdBindDN( mCfg->password() );
00114   mServer->setTimeLimit( mCfg->timeLimit() );
00115   mServer->setSizeLimit( mCfg->sizeLimit() );
00116   mServer->setVersion( mCfg->ver() );
00117   mServer->setSecurity( KPIM::LdapServer::Sec_None );
00118   if ( mCfg->isSecTLS() ) mServer->setSecurity( KPIM::LdapServer::TLS );
00119   if ( mCfg->isSecSSL() ) mServer->setSecurity( KPIM::LdapServer::SSL );
00120   mServer->setAuth( KPIM::LdapServer::Anonymous );
00121   if ( mCfg->isAuthSimple() ) mServer->setAuth( KPIM::LdapServer::Simple );
00122   if ( mCfg->isAuthSASL() ) mServer->setAuth( KPIM::LdapServer::SASL );
00123   mServer->setMech( mCfg->mech() );
00124   KDialog::accept();
00125 }
00126 
00127 #include "addhostdialog.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys