00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "cryptoconfigmodule.h"
00033 #include "cryptoconfigmodule_p.h"
00034 #include "directoryserviceswidget.h"
00035 #include "kdhorizontalline.h"
00036
00037 #include <kleo/cryptoconfig.h>
00038
00039 #include <klineedit.h>
00040 #include <klocale.h>
00041 #include <kdialogbase.h>
00042 #include <kdebug.h>
00043 #include <knuminput.h>
00044 #include <kiconloader.h>
00045 #include <kglobal.h>
00046 #include <kurlrequester.h>
00047
00048 #include <qgrid.h>
00049 #include <qlabel.h>
00050 #include <qlayout.h>
00051 #include <qvbox.h>
00052 #include <qhbox.h>
00053 #include <qpushbutton.h>
00054 #include <qregexp.h>
00055 #include <qstyle.h>
00056 #include <qapplication.h>
00057
00058 using namespace Kleo;
00059
00060 static inline QPixmap loadIcon( QString s ) {
00061 return KGlobal::instance()->iconLoader()
00062 ->loadIcon( s.replace( QRegExp( "[^a-zA-Z0-9_]" ), "_" ), KIcon::NoGroup, KIcon::SizeMedium );
00063 }
00064
00065 static unsigned int num_components_with_options( const Kleo::CryptoConfig * config ) {
00066 if ( !config )
00067 return 0;
00068 const QStringList components = config->componentList();
00069 unsigned int result = 0;
00070 for ( QStringList::const_iterator it = components.begin() ; it != components.end() ; ++it )
00071 if ( const Kleo::CryptoConfigComponent * const comp = config->component( *it ) )
00072 if ( !comp->groupList().empty() )
00073 ++result;
00074 return result;
00075 }
00076
00077 static const KJanusWidget::Face determineJanusFace( const Kleo::CryptoConfig * config ) {
00078 return num_components_with_options( config ) < 2
00079 ? KJanusWidget::Plain
00080 : KJanusWidget::IconList ;
00081 }
00082
00083 Kleo::CryptoConfigModule::CryptoConfigModule( Kleo::CryptoConfig* config, QWidget * parent, const char * name )
00084 : KJanusWidget( parent, name, determineJanusFace( config ) ), mConfig( config )
00085 {
00086 QWidget * vbox = 0;
00087 if ( face() == Plain ) {
00088 vbox = plainPage();
00089 QVBoxLayout * vlay = new QVBoxLayout( vbox, 0, KDialog::spacingHint() );
00090 vlay->setAutoAdd( true );
00091 }
00092
00093 const QStringList components = config->componentList();
00094 for ( QStringList::const_iterator it = components.begin(); it != components.end(); ++it ) {
00095
00096 Kleo::CryptoConfigComponent* comp = config->component( *it );
00097 Q_ASSERT( comp );
00098 if ( comp->groupList().empty() )
00099 continue;
00100 if ( face() != Plain ) {
00101 vbox = addVBoxPage( comp->description(), QString::null, loadIcon( comp->iconName() ) );
00102 }
00103
00104 QScrollView * scrollView = new QScrollView( vbox );
00105 scrollView->setHScrollBarMode( QScrollView::AlwaysOff );
00106 scrollView->setResizePolicy( QScrollView::AutoOneFit );
00107 QVBox* boxInScrollView = new QVBox( scrollView->viewport() );
00108 boxInScrollView->setMargin( KDialog::marginHint() );
00109 scrollView->addChild( boxInScrollView );
00110
00111 CryptoConfigComponentGUI* compGUI =
00112 new CryptoConfigComponentGUI( this, comp, boxInScrollView, (*it).local8Bit() );
00113
00114 mComponentGUIs.append( compGUI );
00115
00116
00117 const int deskHeight = QApplication::desktop()->height();
00118 int dialogHeight;
00119 if (deskHeight > 1000)
00120 dialogHeight = 800;
00121 else if (deskHeight > 650)
00122 dialogHeight = 500;
00123 else
00124 dialogHeight = 400;
00125 QSize sz = scrollView->sizeHint();
00126 scrollView->setMinimumSize( sz.width()
00127 + scrollView->style().pixelMetric(QStyle::PM_ScrollBarExtent),
00128 QMIN( compGUI->sizeHint().height(), dialogHeight ) );
00129 }
00130 if ( mComponentGUIs.empty() ) {
00131 Q_ASSERT( face() == Plain );
00132 const QString msg = i18n("The gpgconf tool used to provide the information "
00133 "for this dialog does not seem to be installed "
00134 "properly. It did not return any components. "
00135 "Try running \"%1\" on the command line for more "
00136 "information.")
00137 .arg( components.empty() ? "gpgconf --list-components" : "gpgconf --list-options gpg" );
00138 QLabel * label = new QLabel( msg, vbox );
00139 label->setAlignment( Qt::WordBreak );
00140 label->setMinimumHeight( fontMetrics().lineSpacing() * 5 );
00141 }
00142 }
00143
00144 void Kleo::CryptoConfigModule::save()
00145 {
00146 bool changed = false;
00147 QValueList<CryptoConfigComponentGUI *>::Iterator it = mComponentGUIs.begin();
00148 for( ; it != mComponentGUIs.end(); ++it ) {
00149 if ( (*it)->save() )
00150 changed = true;
00151 }
00152 if ( changed )
00153 mConfig->sync(true );
00154 }
00155
00156 void Kleo::CryptoConfigModule::reset()
00157 {
00158 QValueList<CryptoConfigComponentGUI *>::Iterator it = mComponentGUIs.begin();
00159 for( ; it != mComponentGUIs.end(); ++it ) {
00160 (*it)->load();
00161 }
00162 }
00163
00164 void Kleo::CryptoConfigModule::defaults()
00165 {
00166 QValueList<CryptoConfigComponentGUI *>::Iterator it = mComponentGUIs.begin();
00167 for( ; it != mComponentGUIs.end(); ++it ) {
00168 (*it)->defaults();
00169 }
00170 }
00171
00172 void Kleo::CryptoConfigModule::cancel()
00173 {
00174 mConfig->clear();
00175 }
00176
00178
00179 Kleo::CryptoConfigComponentGUI::CryptoConfigComponentGUI(
00180 CryptoConfigModule* module, Kleo::CryptoConfigComponent* component,
00181 QWidget* parent, const char* name )
00182 : QWidget( parent, name ),
00183 mComponent( component )
00184 {
00185 QGridLayout * glay = new QGridLayout( this, 1, 3, 0, KDialog::spacingHint() );
00186 const QStringList groups = mComponent->groupList();
00187 if ( groups.size() > 1 ) {
00188 glay->setColSpacing( 0, KDHorizontalLine::indentHint() );
00189 for ( QStringList::const_iterator it = groups.begin(), end = groups.end() ; it != end; ++it ) {
00190 Kleo::CryptoConfigGroup* group = mComponent->group( *it );
00191 Q_ASSERT( group );
00192 if ( !group )
00193 continue;
00194 KDHorizontalLine * hl = new KDHorizontalLine( group->description(), this );
00195 const int row = glay->numRows();
00196 glay->addMultiCellWidget( hl, row, row, 0, 2 );
00197 mGroupGUIs.append( new CryptoConfigGroupGUI( module, group, glay, this ) );
00198 }
00199 } else if ( !groups.empty() ) {
00200 mGroupGUIs.append( new CryptoConfigGroupGUI( module, mComponent->group( groups.front() ), glay, this ) );
00201 }
00202 glay->setRowStretch( glay->numRows(), 1 );
00203 }
00204
00205
00206 bool Kleo::CryptoConfigComponentGUI::save()
00207 {
00208 bool changed = false;
00209 QValueList<CryptoConfigGroupGUI *>::Iterator it = mGroupGUIs.begin();
00210 for( ; it != mGroupGUIs.end(); ++it ) {
00211 if ( (*it)->save() )
00212 changed = true;
00213 }
00214 return changed;
00215 }
00216
00217 void Kleo::CryptoConfigComponentGUI::load()
00218 {
00219 QValueList<CryptoConfigGroupGUI *>::Iterator it = mGroupGUIs.begin();
00220 for( ; it != mGroupGUIs.end(); ++it )
00221 (*it)->load();
00222 }
00223
00224 void Kleo::CryptoConfigComponentGUI::defaults()
00225 {
00226 QValueList<CryptoConfigGroupGUI *>::Iterator it = mGroupGUIs.begin();
00227 for( ; it != mGroupGUIs.end(); ++it )
00228 (*it)->defaults();
00229 }
00230
00232
00233 Kleo::CryptoConfigGroupGUI::CryptoConfigGroupGUI(
00234 CryptoConfigModule* module, Kleo::CryptoConfigGroup* group,
00235 QGridLayout * glay, QWidget* widget, const char* name )
00236 : QObject( module, name ), mGroup( group )
00237 {
00238 const int startRow = glay->numRows();
00239 const QStringList entries = mGroup->entryList();
00240 for( QStringList::const_iterator it = entries.begin(), end = entries.end() ; it != end; ++it ) {
00241 Kleo::CryptoConfigEntry* entry = group->entry( *it );
00242 Q_ASSERT( entry );
00243 if ( entry->level() > CryptoConfigEntry::Level_Advanced ) continue;
00244 CryptoConfigEntryGUI* entryGUI =
00245 CryptoConfigEntryGUIFactory::createEntryGUI( module, entry, *it, glay, widget );
00246 if ( entryGUI ) {
00247 mEntryGUIs.append( entryGUI );
00248 entryGUI->load();
00249 }
00250 }
00251 const int endRow = glay->numRows() - 1;
00252 if ( endRow < startRow )
00253 return;
00254
00255 const QString iconName = group->iconName();
00256 if ( iconName.isEmpty() )
00257 return;
00258
00259 QLabel * l = new QLabel( widget );
00260 l->setPixmap( loadIcon( iconName ) );
00261 glay->addMultiCellWidget( l, startRow, endRow, 0, 0, Qt::AlignTop );
00262 }
00263
00264 bool Kleo::CryptoConfigGroupGUI::save()
00265 {
00266 bool changed = false;
00267 QValueList<CryptoConfigEntryGUI *>::Iterator it = mEntryGUIs.begin();
00268 for( ; it != mEntryGUIs.end(); ++it ) {
00269 if ( (*it)->isChanged() ) {
00270 (*it)->save();
00271 changed = true;
00272 }
00273 }
00274 return changed;
00275 }
00276
00277 void Kleo::CryptoConfigGroupGUI::load()
00278 {
00279 QValueList<CryptoConfigEntryGUI *>::Iterator it = mEntryGUIs.begin();
00280 for( ; it != mEntryGUIs.end(); ++it )
00281 (*it)->load();
00282 }
00283
00284 void Kleo::CryptoConfigGroupGUI::defaults()
00285 {
00286 QValueList<CryptoConfigEntryGUI *>::Iterator it = mEntryGUIs.begin();
00287 for( ; it != mEntryGUIs.end(); ++it )
00288 (*it)->resetToDefault();
00289 }
00290
00292
00293 CryptoConfigEntryGUI* Kleo::CryptoConfigEntryGUIFactory::createEntryGUI( CryptoConfigModule* module, Kleo::CryptoConfigEntry* entry, const QString& entryName, QGridLayout * glay, QWidget* widget, const char* name )
00294 {
00295 if ( entry->isList() ) {
00296 switch( entry->argType() ) {
00297 case Kleo::CryptoConfigEntry::ArgType_None:
00298
00299 return new CryptoConfigEntrySpinBox( module, entry, entryName, glay, widget, name );
00300 case Kleo::CryptoConfigEntry::ArgType_Int:
00301 case Kleo::CryptoConfigEntry::ArgType_UInt:
00302
00303 return new CryptoConfigEntryLineEdit( module, entry, entryName, glay, widget, name );
00304 case Kleo::CryptoConfigEntry::ArgType_URL:
00305 case Kleo::CryptoConfigEntry::ArgType_Path:
00306 case Kleo::CryptoConfigEntry::ArgType_DirPath:
00307 case Kleo::CryptoConfigEntry::ArgType_String:
00308 kdWarning(5150) << "No widget implemented for list of type " << entry->argType() << endl;
00309 return 0;
00310 case Kleo::CryptoConfigEntry::ArgType_LDAPURL:
00311 return new CryptoConfigEntryLDAPURL( module, entry, entryName, glay, widget, name );
00312 }
00313 kdWarning(5150) << "No widget implemented for list of (unknown) type " << entry->argType() << endl;
00314 return 0;
00315 }
00316
00317 switch( entry->argType() ) {
00318 case Kleo::CryptoConfigEntry::ArgType_None:
00319 return new CryptoConfigEntryCheckBox( module, entry, entryName, glay, widget, name );
00320 case Kleo::CryptoConfigEntry::ArgType_Int:
00321 case Kleo::CryptoConfigEntry::ArgType_UInt:
00322 return new CryptoConfigEntrySpinBox( module, entry, entryName, glay, widget, name );
00323 case Kleo::CryptoConfigEntry::ArgType_URL:
00324 return new CryptoConfigEntryURL( module, entry, entryName, glay, widget, name );
00325 case Kleo::CryptoConfigEntry::ArgType_Path:
00326 return new CryptoConfigEntryPath( module, entry, entryName, glay, widget, name );
00327 case Kleo::CryptoConfigEntry::ArgType_DirPath:
00328 return new CryptoConfigEntryDirPath( module, entry, entryName, glay, widget, name );
00329 case Kleo::CryptoConfigEntry::ArgType_LDAPURL:
00330 kdWarning(5150) << "No widget implemented for type " << entry->argType() << endl;
00331 return 0;
00332 case Kleo::CryptoConfigEntry::ArgType_String:
00333 return new CryptoConfigEntryLineEdit( module, entry, entryName, glay, widget, name );
00334 }
00335 kdWarning(5150) << "No widget implemented for (unknown) type " << entry->argType() << endl;
00336 return 0;
00337 }
00338
00340
00341 Kleo::CryptoConfigEntryGUI::CryptoConfigEntryGUI(
00342 CryptoConfigModule* module,
00343 Kleo::CryptoConfigEntry* entry,
00344 const QString& entryName,
00345 const char* name )
00346 : QObject( module, name ), mEntry( entry ), mName( entryName ), mChanged( false )
00347 {
00348 connect( this, SIGNAL( changed() ), module, SIGNAL( changed() ) );
00349 }
00350
00351 QString Kleo::CryptoConfigEntryGUI::description() const
00352 {
00353 QString descr = mEntry->description();
00354 if ( descr.isEmpty() )
00355 descr = QString( "<%1>" ).arg( mName );
00356 return descr;
00357 }
00358
00359 void Kleo::CryptoConfigEntryGUI::resetToDefault()
00360 {
00361 mEntry->resetToDefault();
00362 load();
00363 }
00364
00366
00367 Kleo::CryptoConfigEntryLineEdit::CryptoConfigEntryLineEdit(
00368 CryptoConfigModule* module,
00369 Kleo::CryptoConfigEntry* entry, const QString& entryName,
00370 QGridLayout * glay, QWidget* widget, const char* name )
00371 : CryptoConfigEntryGUI( module, entry, entryName, name )
00372 {
00373 const int row = glay->numRows();
00374 mLineEdit = new KLineEdit( widget );
00375 QLabel* label = new QLabel( mLineEdit, description(), widget );
00376 glay->addWidget( label, row, 1 );
00377 glay->addWidget( mLineEdit, row, 2 );
00378 if ( entry->isReadOnly() ) {
00379 label->setEnabled( false );
00380 mLineEdit->setEnabled( false );
00381 } else {
00382 connect( mLineEdit, SIGNAL( textChanged( const QString& ) ), SLOT( slotChanged() ) );
00383 }
00384 }
00385
00386 void Kleo::CryptoConfigEntryLineEdit::doSave()
00387 {
00388 mEntry->setStringValue( mLineEdit->text() );
00389 }
00390
00391 void Kleo::CryptoConfigEntryLineEdit::doLoad()
00392 {
00393 mLineEdit->setText( mEntry->stringValue() );
00394 }
00395
00397
00398 Kleo::CryptoConfigEntryPath::CryptoConfigEntryPath(
00399 CryptoConfigModule* module,
00400 Kleo::CryptoConfigEntry* entry, const QString& entryName,
00401 QGridLayout * glay, QWidget* widget, const char* name )
00402 : CryptoConfigEntryGUI( module, entry, entryName, name )
00403 {
00404 const int row = glay->numRows();
00405 mUrlRequester = new KURLRequester( widget );
00406 mUrlRequester->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly );
00407 QLabel* label = new QLabel( mUrlRequester, description(), widget );
00408 glay->addWidget( label, row, 1 );
00409 glay->addWidget( mUrlRequester, row, 2 );
00410 if ( entry->isReadOnly() ) {
00411 label->setEnabled( false );
00412 mUrlRequester->setEnabled( false );
00413 } else {
00414 connect( mUrlRequester, SIGNAL( textChanged( const QString& ) ), SLOT( slotChanged() ) );
00415 }
00416 }
00417
00418 void Kleo::CryptoConfigEntryPath::doSave()
00419 {
00420 KURL url;
00421 url.setPath( mUrlRequester->url() );
00422 mEntry->setURLValue( url );
00423 }
00424
00425 void Kleo::CryptoConfigEntryPath::doLoad()
00426 {
00427 mUrlRequester->setURL( mEntry->urlValue().path() );
00428 }
00429
00431
00432 Kleo::CryptoConfigEntryDirPath::CryptoConfigEntryDirPath(
00433 CryptoConfigModule* module,
00434 Kleo::CryptoConfigEntry* entry, const QString& entryName,
00435 QGridLayout * glay, QWidget* widget, const char* name )
00436 : CryptoConfigEntryGUI( module, entry, entryName, name )
00437 {
00438 const int row = glay->numRows();
00439 mUrlRequester = new KURLRequester( widget );
00440 mUrlRequester->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
00441 QLabel* label = new QLabel( mUrlRequester, description(), widget );
00442 glay->addWidget( label, row, 1 );
00443 glay->addWidget( mUrlRequester, row, 2 );
00444 if ( entry->isReadOnly() ) {
00445 label->setEnabled( false );
00446 mUrlRequester->setEnabled( false );
00447 } else {
00448 connect( mUrlRequester, SIGNAL( textChanged( const QString& ) ), SLOT( slotChanged() ) );
00449 }
00450 }
00451
00452 void Kleo::CryptoConfigEntryDirPath::doSave()
00453 {
00454 KURL url;
00455 url.setPath( mUrlRequester->url() );
00456 mEntry->setURLValue( url );
00457
00458 }
00459
00460 void Kleo::CryptoConfigEntryDirPath::doLoad()
00461 {
00462 mUrlRequester->setURL( mEntry->urlValue().path() );
00463 }
00464
00466
00467 Kleo::CryptoConfigEntryURL::CryptoConfigEntryURL(
00468 CryptoConfigModule* module,
00469 Kleo::CryptoConfigEntry* entry, const QString& entryName,
00470 QGridLayout * glay, QWidget* widget, const char* name )
00471 : CryptoConfigEntryGUI( module, entry, entryName, name )
00472 {
00473 const int row = glay->numRows();
00474 mUrlRequester = new KURLRequester( widget );
00475 mUrlRequester->setMode( KFile::File | KFile::ExistingOnly );
00476 QLabel* label = new QLabel( mUrlRequester, description(), widget );
00477 glay->addWidget( label, row, 1 );
00478 glay->addWidget( mUrlRequester, row, 2 );
00479 if ( entry->isReadOnly() ) {
00480 label->setEnabled( false );
00481 mUrlRequester->setEnabled( false );
00482 } else {
00483 connect( mUrlRequester, SIGNAL( textChanged( const QString& ) ), SLOT( slotChanged() ) );
00484 }
00485 }
00486
00487 void Kleo::CryptoConfigEntryURL::doSave()
00488 {
00489 mEntry->setURLValue( mUrlRequester->url() );
00490 }
00491
00492 void Kleo::CryptoConfigEntryURL::doLoad()
00493 {
00494 mUrlRequester->setURL( mEntry->urlValue().url() );
00495 }
00496
00498
00499 Kleo::CryptoConfigEntrySpinBox::CryptoConfigEntrySpinBox(
00500 CryptoConfigModule* module,
00501 Kleo::CryptoConfigEntry* entry, const QString& entryName,
00502 QGridLayout * glay, QWidget* widget, const char* name )
00503 : CryptoConfigEntryGUI( module, entry, entryName, name )
00504 {
00505
00506 if ( entry->argType() == Kleo::CryptoConfigEntry::ArgType_None && entry->isList() ) {
00507 mKind = ListOfNone;
00508 } else if ( entry->argType() == Kleo::CryptoConfigEntry::ArgType_UInt ) {
00509 mKind = UInt;
00510 } else {
00511 Q_ASSERT( entry->argType() == Kleo::CryptoConfigEntry::ArgType_Int );
00512 mKind = Int;
00513 }
00514
00515 const int row = glay->numRows();
00516 mNumInput = new KIntNumInput( widget );
00517 QLabel* label = new QLabel( mNumInput, description(), widget );
00518 glay->addWidget( label, row, 1 );
00519 glay->addWidget( mNumInput, row, 2 );
00520
00521 if ( entry->isReadOnly() ) {
00522 label->setEnabled( false );
00523 mNumInput->setEnabled( false );
00524 } else {
00525 if ( mKind == UInt || mKind == ListOfNone )
00526 mNumInput->setMinValue( 0 );
00527 connect( mNumInput, SIGNAL( valueChanged(int) ), SLOT( slotChanged() ) );
00528 }
00529 }
00530
00531 void Kleo::CryptoConfigEntrySpinBox::doSave()
00532 {
00533 int value = mNumInput->value();
00534 switch ( mKind ) {
00535 case ListOfNone:
00536 mEntry->setNumberOfTimesSet( value );
00537 break;
00538 case UInt:
00539 mEntry->setUIntValue( value );
00540 break;
00541 case Int:
00542 mEntry->setIntValue( value );
00543 break;
00544 }
00545 }
00546
00547 void Kleo::CryptoConfigEntrySpinBox::doLoad()
00548 {
00549 int value = 0;
00550 switch ( mKind ) {
00551 case ListOfNone:
00552 value = mEntry->numberOfTimesSet();
00553 break;
00554 case UInt:
00555 value = mEntry->uintValue();
00556 break;
00557 case Int:
00558 value = mEntry->intValue();
00559 break;
00560 }
00561 mNumInput->setValue( value );
00562 }
00563
00565
00566 Kleo::CryptoConfigEntryCheckBox::CryptoConfigEntryCheckBox(
00567 CryptoConfigModule* module,
00568 Kleo::CryptoConfigEntry* entry, const QString& entryName,
00569 QGridLayout * glay, QWidget* widget, const char* name )
00570 : CryptoConfigEntryGUI( module, entry, entryName, name )
00571 {
00572 const int row = glay->numRows();
00573 mCheckBox = new QCheckBox( widget );
00574 glay->addMultiCellWidget( mCheckBox, row, row, 1, 2 );
00575 mCheckBox->setText( description() );
00576 if ( entry->isReadOnly() ) {
00577 mCheckBox->setEnabled( false );
00578 } else {
00579 connect( mCheckBox, SIGNAL( toggled(bool) ), SLOT( slotChanged() ) );
00580 }
00581 }
00582
00583 void Kleo::CryptoConfigEntryCheckBox::doSave()
00584 {
00585 mEntry->setBoolValue( mCheckBox->isChecked() );
00586 }
00587
00588 void Kleo::CryptoConfigEntryCheckBox::doLoad()
00589 {
00590 mCheckBox->setChecked( mEntry->boolValue() );
00591 }
00592
00593 Kleo::CryptoConfigEntryLDAPURL::CryptoConfigEntryLDAPURL(
00594 CryptoConfigModule* module,
00595 Kleo::CryptoConfigEntry* entry,
00596 const QString& entryName,
00597 QGridLayout * glay, QWidget* widget, const char* name )
00598 : CryptoConfigEntryGUI( module, entry, entryName, name )
00599 {
00600 mLabel = new QLabel( widget );
00601 mPushButton = new QPushButton( i18n( "Edit..." ), widget );
00602
00603 const int row = glay->numRows();
00604 glay->addWidget( new QLabel( mPushButton, description(), widget ), row, 1 );
00605 QHBoxLayout * hlay = new QHBoxLayout;
00606 glay->addLayout( hlay, row, 2 );
00607 hlay->addWidget( mLabel, 1 );
00608 hlay->addWidget( mPushButton );
00609
00610 if ( entry->isReadOnly() ) {
00611 mLabel->setEnabled( false );
00612 mPushButton->hide();
00613 } else {
00614 connect( mPushButton, SIGNAL( clicked() ), SLOT( slotOpenDialog() ) );
00615 }
00616 }
00617
00618 void Kleo::CryptoConfigEntryLDAPURL::doLoad()
00619 {
00620 setURLList( mEntry->urlValueList() );
00621 }
00622
00623 void Kleo::CryptoConfigEntryLDAPURL::doSave()
00624 {
00625 mEntry->setURLValueList( mURLList );
00626 }
00627
00628 void Kleo::CryptoConfigEntryLDAPURL::slotOpenDialog()
00629 {
00630
00631
00632 KDialogBase dialog( mPushButton->parentWidget(), 0, true ,
00633 i18n( "Configure LDAP Servers" ),
00634 KDialogBase::Default|KDialogBase::Cancel|KDialogBase::Ok,
00635 KDialogBase::Ok, true );
00636 DirectoryServicesWidget* dirserv = new DirectoryServicesWidget( mEntry, &dialog );
00637 dirserv->load();
00638 dialog.setMainWidget( dirserv );
00639 connect( &dialog, SIGNAL( defaultClicked() ), dirserv, SLOT( defaults() ) );
00640 if ( dialog.exec() ) {
00641
00642
00643 setURLList( dirserv->urlList() );
00644 slotChanged();
00645 }
00646 }
00647
00648 void Kleo::CryptoConfigEntryLDAPURL::setURLList( const KURL::List& urlList )
00649 {
00650 mURLList = urlList;
00651 if ( mURLList.isEmpty() )
00652 mLabel->setText( i18n( "No server configured yet" ) );
00653 else
00654 mLabel->setText( i18n( "1 server configured", "%n servers configured", mURLList.count() ) );
00655 }
00656
00657 #include "cryptoconfigmodule.moc"
00658 #include "cryptoconfigmodule_p.moc"