• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

libkdepim

  • sources
  • kde-4.14
  • kdepim
  • libkdepim
  • ldap
addhostdialog.cpp
Go to the documentation of this file.
1 /*
2  This file is part of libkldap.
3 
4  Copyright (c) 2002-2010 Tobias Koenig <tokoe@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include "addhostdialog_p.h"
23 
24 #include <QHBoxLayout>
25 
26 #include <kacceleratormanager.h>
27 #include <kldap/ldapserver.h>
28 #include <kldap/ldapconfigwidget.h>
29 #include <klocale.h>
30 
31 AddHostDialog::AddHostDialog( KLDAP::LdapServer *server, QWidget *parent )
32  : KDialog( parent )
33 {
34  setCaption( i18n( "Add Host" ) );
35  setButtons( Ok | Cancel );
36  setDefaultButton( Ok );
37  setModal( true );
38  showButtonSeparator( true );
39 
40  mServer = server;
41 
42  QWidget *page = new QWidget( this );
43  setMainWidget( page );
44  QHBoxLayout *layout = new QHBoxLayout( page );
45  layout->setSpacing( spacingHint() );
46  layout->setMargin( 0 );
47 
48  mCfg = new KLDAP::LdapConfigWidget(
49  KLDAP::LdapConfigWidget::W_USER |
50  KLDAP::LdapConfigWidget::W_PASS |
51  KLDAP::LdapConfigWidget::W_BINDDN |
52  KLDAP::LdapConfigWidget::W_REALM |
53  KLDAP::LdapConfigWidget::W_HOST |
54  KLDAP::LdapConfigWidget::W_PORT |
55  KLDAP::LdapConfigWidget::W_VER |
56  KLDAP::LdapConfigWidget::W_TIMELIMIT |
57  KLDAP::LdapConfigWidget::W_SIZELIMIT |
58  KLDAP::LdapConfigWidget::W_PAGESIZE |
59  KLDAP::LdapConfigWidget::W_DN |
60  KLDAP::LdapConfigWidget::W_FILTER |
61  KLDAP::LdapConfigWidget::W_SECBOX |
62  KLDAP::LdapConfigWidget::W_AUTHBOX,
63  page );
64 
65  layout->addWidget( mCfg );
66  mCfg->setHost( mServer->host() );
67  mCfg->setPort( mServer->port() );
68  mCfg->setDn( mServer->baseDn() );
69  mCfg->setUser( mServer->user() );
70  mCfg->setBindDn( mServer->bindDn() );
71  mCfg->setPassword( mServer->password() );
72  mCfg->setTimeLimit( mServer->timeLimit() );
73  mCfg->setSizeLimit( mServer->sizeLimit() );
74  mCfg->setPageSize( mServer->pageSize() );
75  mCfg->setVersion( mServer->version() );
76  mCfg->setFilter( mServer->filter() );
77 
78  switch ( mServer->security() ) {
79  case KLDAP::LdapServer::TLS:
80  mCfg->setSecurity( KLDAP::LdapConfigWidget::TLS );
81  break;
82  case KLDAP::LdapServer::SSL:
83  mCfg->setSecurity( KLDAP::LdapConfigWidget::SSL );
84  break;
85  default:
86  mCfg->setSecurity( KLDAP::LdapConfigWidget::None );
87  }
88 
89  switch ( mServer->auth() ) {
90  case KLDAP::LdapServer::Simple:
91  mCfg->setAuth( KLDAP::LdapConfigWidget::Simple );
92  break;
93  case KLDAP::LdapServer::SASL:
94  mCfg->setAuth( KLDAP::LdapConfigWidget::SASL );
95  break;
96  default:
97  mCfg->setAuth( KLDAP::LdapConfigWidget::Anonymous );
98  }
99  mCfg->setMech( mServer->mech() );
100 
101  KAcceleratorManager::manage( this );
102  connect(mCfg, SIGNAL(hostNameChanged(QString)), this, SLOT(slotHostEditChanged(QString)));
103  connect( this, SIGNAL(okClicked()), SLOT(slotOk()) );
104  enableButtonOk(!mServer->host().isEmpty());
105  readConfig();
106 }
107 
108 AddHostDialog::~AddHostDialog()
109 {
110  writeConfig();
111 }
112 
113 void AddHostDialog::slotHostEditChanged( const QString &text )
114 {
115  enableButtonOk( !text.isEmpty() );
116 }
117 
118 void AddHostDialog::readConfig()
119 {
120  KConfigGroup group( KGlobal::config(), "AddHostDialog" );
121  const QSize size = group.readEntry( "Size", QSize(600, 400) );
122  if ( size.isValid() ) {
123  resize( size );
124  }
125 }
126 
127 void AddHostDialog::writeConfig()
128 {
129  KConfigGroup group( KGlobal::config(), "AddHostDialog" );
130  group.writeEntry( "Size", size() );
131  group.sync();
132 }
133 
134 
135 void AddHostDialog::slotOk()
136 {
137  mServer->setHost( mCfg->host() );
138  mServer->setPort( mCfg->port() );
139  mServer->setBaseDn( mCfg->dn() );
140  mServer->setUser( mCfg->user() );
141  mServer->setBindDn( mCfg->bindDn() );
142  mServer->setPassword( mCfg->password() );
143  mServer->setTimeLimit( mCfg->timeLimit() );
144  mServer->setSizeLimit( mCfg->sizeLimit() );
145  mServer->setPageSize( mCfg->pageSize() );
146  mServer->setVersion( mCfg->version() );
147  mServer->setFilter( mCfg->filter() );
148  switch ( mCfg->security() ) {
149  case KLDAP::LdapConfigWidget::TLS:
150  mServer->setSecurity( KLDAP::LdapServer::TLS );
151  break;
152  case KLDAP::LdapConfigWidget::SSL:
153  mServer->setSecurity( KLDAP::LdapServer::SSL );
154  break;
155  default:
156  mServer->setSecurity( KLDAP::LdapServer::None );
157  }
158  switch ( mCfg->auth() ) {
159  case KLDAP::LdapConfigWidget::Simple:
160  mServer->setAuth( KLDAP::LdapServer::Simple );
161  break;
162  case KLDAP::LdapConfigWidget::SASL:
163  mServer->setAuth( KLDAP::LdapServer::SASL );
164  break;
165  default:
166  mServer->setAuth( KLDAP::LdapServer::Anonymous );
167  }
168  mServer->setMech( mCfg->mech() );
169  KDialog::accept();
170 }
171 
172 #include "moc_addhostdialog_p.cpp"
AddHostDialog::~AddHostDialog
~AddHostDialog()
Definition: addhostdialog.cpp:108
QWidget
QSize::isValid
bool isValid() const
QHBoxLayout
KDialog
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QString::isEmpty
bool isEmpty() const
addhostdialog_p.h
QString
QLayout::setMargin
void setMargin(int margin)
AddHostDialog::AddHostDialog
AddHostDialog(KLDAP::LdapServer *server, QWidget *parent=0)
Definition: addhostdialog.cpp:31
QSize
QBoxLayout::setSpacing
void setSpacing(int spacing)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdepim

Skip menu "libkdepim"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal