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