2
This file is part of KAddressBook.
3
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
As a special exception, permission is given to link this program
20
with any edition of Qt, and distribute the resulting executable,
21
without including the source code for Qt in the source distribution.
24
#include "addhostdialog.h"
26
#include <QtGui/QHBoxLayout>
27
#include <QtGui/QPushButton>
29
#include <kacceleratormanager.h>
30
#include <kldap/ldapserver.h>
31
#include <kldap/ldapconfigwidget.h>
32
#include <klineedit.h>
35
AddHostDialog::AddHostDialog( KLDAP::LdapServer *server, QWidget* parent )
38
setCaption( i18n( "Add Host" ) );
39
setButtons( Ok | Cancel );
40
setDefaultButton( Ok );
42
showButtonSeparator( true );
46
QWidget *page = new QWidget( this );
47
setMainWidget( page );
48
QHBoxLayout *layout = new QHBoxLayout( page );
49
layout->setSpacing( spacingHint() );
50
layout->setMargin( 0 );
52
mCfg = new KLDAP::LdapConfigWidget(
53
KLDAP::LdapConfigWidget::W_USER |
54
KLDAP::LdapConfigWidget::W_PASS |
55
KLDAP::LdapConfigWidget::W_BINDDN |
56
KLDAP::LdapConfigWidget::W_REALM |
57
KLDAP::LdapConfigWidget::W_HOST |
58
KLDAP::LdapConfigWidget::W_PORT |
59
KLDAP::LdapConfigWidget::W_VER |
60
KLDAP::LdapConfigWidget::W_TIMELIMIT |
61
KLDAP::LdapConfigWidget::W_SIZELIMIT |
62
KLDAP::LdapConfigWidget::W_PAGESIZE |
63
KLDAP::LdapConfigWidget::W_DN |
64
KLDAP::LdapConfigWidget::W_SECBOX |
65
KLDAP::LdapConfigWidget::W_AUTHBOX,
68
layout->addWidget( mCfg );
69
mCfg->setHost( mServer->host() );
70
mCfg->setPort( mServer->port() );
71
mCfg->setDn( mServer->baseDn() );
72
mCfg->setUser( mServer->user() );
73
mCfg->setBindDn( mServer->bindDn() );
74
mCfg->setPassword( mServer->password() );
75
mCfg->setTimeLimit( mServer->timeLimit() );
76
mCfg->setSizeLimit( mServer->sizeLimit() );
77
mCfg->setPageSize( mServer->pageSize() );
78
mCfg->setVersion( mServer->version() );
80
switch ( mServer->security() ) {
81
case KLDAP::LdapServer::TLS:
82
mCfg->setSecurity( KLDAP::LdapConfigWidget::TLS );
84
case KLDAP::LdapServer::SSL:
85
mCfg->setSecurity( KLDAP::LdapConfigWidget::SSL );
88
mCfg->setSecurity( KLDAP::LdapConfigWidget::None );
91
switch ( mServer->auth() ) {
92
case KLDAP::LdapServer::Simple:
93
mCfg->setAuth( KLDAP::LdapConfigWidget::Simple );
95
case KLDAP::LdapServer::SASL:
96
mCfg->setAuth( KLDAP::LdapConfigWidget::SASL );
99
mCfg->setAuth( KLDAP::LdapConfigWidget::Anonymous );
101
mCfg->setMech( mServer->mech() );
103
KAcceleratorManager::manage( this );
104
connect(this,SIGNAL(okClicked()),SLOT(slotOk()));
107
AddHostDialog::~AddHostDialog()
111
void AddHostDialog::slotHostEditChanged( const QString &text )
113
enableButtonOk( !text.isEmpty() );
116
void AddHostDialog::slotOk()
118
mServer->setHost( mCfg->host() );
119
mServer->setPort( mCfg->port() );
120
mServer->setBaseDn( mCfg->dn() );
121
mServer->setUser( mCfg->user() );
122
mServer->setBindDn( mCfg->bindDn() );
123
mServer->setPassword( mCfg->password() );
124
mServer->setTimeLimit( mCfg->timeLimit() );
125
mServer->setSizeLimit( mCfg->sizeLimit() );
126
mServer->setPageSize( mCfg->pageSize() );
127
mServer->setVersion( mCfg->version() );
128
switch ( mCfg->security() ) {
129
case KLDAP::LdapConfigWidget::TLS:
130
mServer->setSecurity( KLDAP::LdapServer::TLS );
132
case KLDAP::LdapConfigWidget::SSL:
133
mServer->setSecurity( KLDAP::LdapServer::SSL );
136
mServer->setSecurity( KLDAP::LdapServer::None );
138
switch ( mCfg->auth() ) {
139
case KLDAP::LdapConfigWidget::Simple:
140
mServer->setAuth( KLDAP::LdapServer::Simple );
142
case KLDAP::LdapConfigWidget::SASL:
143
mServer->setAuth( KLDAP::LdapServer::SASL );
146
mServer->setAuth( KLDAP::LdapServer::Anonymous );
148
mServer->setMech( mCfg->mech() );
152
#include "addhostdialog.moc"