00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "accountdialog.h"
00021 #include "sieveconfig.h"
00022 #include "kmacctmaildir.h"
00023 #include "kmacctlocal.h"
00024 #include "accountmanager.h"
00025 #include "popaccount.h"
00026 #include "kmacctimap.h"
00027 #include "kmacctcachedimap.h"
00028 #include "kmfoldermgr.h"
00029 #include "protocols.h"
00030 #include "folderrequester.h"
00031 #include "kmmainwidget.h"
00032 #include "kmfolder.h"
00033 #include <kpimidentities/identitymanager.h>
00034 #include <kpimidentities/identitycombo.h>
00035 #include <kpimidentities/identity.h>
00036 #include <mailtransport/servertest.h>
00037 using namespace MailTransport;
00038 #include "globalsettings.h"
00039
00040 #include <KGlobalSettings>
00041 #include <KFileDialog>
00042 #include <KLocale>
00043 #include <KDebug>
00044 #include <KMessageBox>
00045 #include <KNumInput>
00046 #include <KSeparator>
00047 #include <KProtocolInfo>
00048 #include <KIconLoader>
00049 #include <KMenu>
00050
00051 #include <QButtonGroup>
00052 #include <QCheckBox>
00053 #include <QLayout>
00054 #include <QTabWidget>
00055 #include <QRadioButton>
00056 #include <QValidator>
00057 #include <QLabel>
00058 #include <QPushButton>
00059 #include <QComboBox>
00060 #include <QToolButton>
00061 #include <QGroupBox>
00062 #include <QGridLayout>
00063 #include <QTextStream>
00064 #include <QList>
00065 #include <QVBoxLayout>
00066 #include <QHBoxLayout>
00067 #include <QHash>
00068
00069 #include <netdb.h>
00070 #include <netinet/in.h>
00071
00072 #include <cassert>
00073 #include <stdlib.h>
00074
00075 #ifdef HAVE_PATHS_H
00076 #include <paths.h>
00077 #endif
00078
00079 #ifndef _PATH_MAILDIR
00080 #define _PATH_MAILDIR "/var/spool/mail"
00081 #endif
00082
00083 namespace {
00084
00085 class BusyCursorHelper : public QObject
00086 {
00087 public:
00088 inline BusyCursorHelper( QObject *parent )
00089 : QObject( parent )
00090 {
00091 qApp->setOverrideCursor( Qt::BusyCursor );
00092 }
00093
00094 inline ~BusyCursorHelper()
00095 {
00096 qApp->restoreOverrideCursor();
00097 }
00098 };
00099
00100 }
00101
00102 namespace KMail {
00103
00104 class ProcmailRCParser
00105 {
00106 public:
00107 ProcmailRCParser(const QString &fileName = QString());
00108 ~ProcmailRCParser();
00109
00110 QStringList getLockFilesList() const { return mLockFiles; }
00111 QStringList getSpoolFilesList() const { return mSpoolFiles; }
00112
00113 protected:
00114 void processGlobalLock(const QString&);
00115 void processLocalLock(const QString&);
00116 void processVariableSetting(const QString&, int);
00117 QString expandVars(const QString&);
00118
00119 QFile mProcmailrc;
00120 QTextStream *mStream;
00121 QStringList mLockFiles;
00122 QStringList mSpoolFiles;
00123 QHash<QByteArray, QString> mVars;
00124 };
00125
00126 ProcmailRCParser::ProcmailRCParser(const QString &filename)
00127 : mProcmailrc(filename),
00128 mStream(new QTextStream(&mProcmailrc))
00129 {
00130
00131 mVars.insert( "HOME", QDir::homePath() );
00132
00133 if( filename.isEmpty() ) {
00134 mProcmailrc.setFileName(QDir::homePath() + "/.procmailrc");
00135 }
00136
00137 QRegExp lockFileGlobal("^LOCKFILE=", Qt::CaseSensitive);
00138 QRegExp lockFileLocal("^:0", Qt::CaseSensitive);
00139
00140 if( mProcmailrc.open(QIODevice::ReadOnly) ) {
00141
00142 QString s;
00143
00144 while( !mStream->atEnd() ) {
00145
00146 s = mStream->readLine().trimmed();
00147
00148 if( s[0] == '#' ) continue;
00149
00150 int commentPos = -1;
00151
00152 if( (commentPos = s.indexOf('#')) > -1 ) {
00153
00154 s.truncate(commentPos);
00155 s = s.trimmed();
00156 }
00157
00158 if( lockFileGlobal.indexIn(s) != -1 ) {
00159 processGlobalLock(s);
00160 } else if( lockFileLocal.indexIn(s) != -1 ) {
00161 processLocalLock(s);
00162 } else if( int i = s.indexOf('=') ) {
00163 processVariableSetting(s,i);
00164 }
00165 }
00166
00167 }
00168 QString default_Location = qgetenv("MAIL");
00169
00170 if (default_Location.isNull()) {
00171 default_Location = _PATH_MAILDIR;
00172 default_Location += '/';
00173 default_Location += qgetenv("USER");
00174 }
00175 if ( !mSpoolFiles.contains(default_Location) )
00176 mSpoolFiles << default_Location;
00177
00178 default_Location = default_Location + ".lock";
00179 if ( !mLockFiles.contains(default_Location) )
00180 mLockFiles << default_Location;
00181 }
00182
00183 ProcmailRCParser::~ProcmailRCParser()
00184 {
00185 delete mStream;
00186 }
00187
00188 void
00189 ProcmailRCParser::processGlobalLock(const QString &s)
00190 {
00191 QString val = expandVars(s.mid(s.indexOf('=') + 1).trimmed());
00192 if ( !mLockFiles.contains(val) )
00193 mLockFiles << val;
00194 }
00195
00196 void
00197 ProcmailRCParser::processLocalLock(const QString &s)
00198 {
00199 QString val;
00200 int colonPos = s.lastIndexOf(':');
00201
00202 if (colonPos > 0) {
00203 val = s.mid(colonPos + 1).trimmed();
00204
00205 if ( val.length() ) {
00206
00207
00208 val = expandVars(val);
00209 if ( val[0] != '/' && mVars.contains("MAILDIR") )
00210 val.insert(0, mVars["MAILDIR"] + '/');
00211 }
00212
00213 }
00214
00215
00216 QString line, prevLine;
00217 do {
00218 prevLine = line;
00219 line = mStream->readLine().trimmed();
00220 } while ( !mStream->atEnd() && (line[0] == '*' ||
00221 prevLine[prevLine.length() - 1] == '\\' ));
00222
00223 if( line[0] != '!' && line[0] != '|' && line[0] != '{' ) {
00224
00225
00226 line = line.trimmed();
00227 line = expandVars(line);
00228
00229
00230 if( line[0] != '/' && mVars.contains("MAILDIR") )
00231 line.insert(0, mVars["MAILDIR"] + '/');
00232
00233
00234 if ( !mSpoolFiles.contains(line) )
00235 mSpoolFiles << line;
00236
00237 if( colonPos > 0 && val.isEmpty() ) {
00238
00239
00240 val = line;
00241
00242
00243 if( mVars.contains("LOCKEXT") )
00244 val += mVars["LOCKEXT"];
00245 else
00246 val += ".lock";
00247 }
00248
00249 if ( !val.isNull() && !mLockFiles.contains(val) ) {
00250 mLockFiles << val;
00251 }
00252 }
00253
00254 }
00255
00256 void
00257 ProcmailRCParser::processVariableSetting(const QString &s, int eqPos)
00258 {
00259 if( eqPos == -1) return;
00260
00261 QString varName = s.left(eqPos),
00262 varValue = expandVars(s.mid(eqPos + 1).trimmed());
00263
00264 mVars.insert( varName.toLatin1(), varValue );
00265 }
00266
00267 QString
00268 ProcmailRCParser::expandVars(const QString &s)
00269 {
00270 if( s.isEmpty()) return s;
00271
00272 QString expS = s;
00273
00274 for ( QHash<QByteArray, QString>::const_iterator it = mVars.begin(); it != mVars.end(); ++it ) {
00275 expS.replace( QString::fromLatin1("$") + it.key(), it.value() );
00276 }
00277
00278 return expS;
00279 }
00280
00281
00282
00283 AccountDialog::AccountDialog( const QString & caption, KMAccount *account,
00284 QWidget *parent )
00285 : KDialog( parent ),
00286 mAccount( account ),
00287 mServerTest( 0 ),
00288 mSieveConfigEditor( 0 )
00289 {
00290 setCaption( caption );
00291 setButtons( Ok|Cancel|Help );
00292 mValidator = new QRegExpValidator( QRegExp( "[A-Za-z0-9-_:.]*" ), 0 );
00293 setHelp("receiving-mail");
00294
00295 KAccount::Type accountType = mAccount->type();
00296
00297 if( accountType == KAccount::Local )
00298 {
00299 makeLocalAccountPage();
00300 }
00301 else if( accountType == KAccount::Maildir )
00302 {
00303 makeMaildirAccountPage();
00304 }
00305 else if( accountType == KAccount::Pop )
00306 {
00307 makePopAccountPage();
00308 }
00309 else if( accountType == KAccount::Imap )
00310 {
00311 makeImapAccountPage();
00312 }
00313 else if( accountType == KAccount::DImap )
00314 {
00315 makeImapAccountPage(true);
00316 }
00317 else
00318 {
00319 QString msg = i18n( "Account type is not supported." );
00320 KMessageBox::information( topLevelWidget(),msg,i18n("Configure Account") );
00321 return;
00322 }
00323
00324 setupSettings();
00325 connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
00326 }
00327
00328 AccountDialog::~AccountDialog()
00329 {
00330 delete mValidator;
00331 mValidator = 0;
00332 delete mServerTest;
00333 mServerTest = 0;
00334 }
00335
00336 void AccountDialog::makeLocalAccountPage()
00337 {
00338 QWidget *page = new QWidget( this );
00339 mLocal.ui.setupUi( page );
00340 setMainWidget( page );
00341
00342 ProcmailRCParser procmailrcParser;
00343 mLocal.ui.locationEdit->addItems( procmailrcParser.getSpoolFilesList() );
00344 mLocal.ui.choose->setAutoDefault( false );
00345 mLocal.ui.procmailLockFileName->addItems( procmailrcParser.getLockFilesList() );
00346 mLocal.ui.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(), 10000, 1 );
00347
00348 connect( mLocal.ui.choose, SIGNAL(clicked()), this, SLOT(slotLocationChooser()) );
00349 connect( mLocal.ui.lockProcmail, SIGNAL(toggled(bool)),
00350 mLocal.ui.procmailLockFileName, SLOT(setEnabled(bool)) );
00351 connect( mLocal.ui.intervalCheck, SIGNAL(toggled(bool)),
00352 this, SLOT(slotEnableLocalInterval(bool)) );
00353 connect( KGlobalSettings::self(),SIGNAL(kdisplayFontChanged()),
00354 SLOT(slotFontChanged()) );
00355 }
00356
00357 void AccountDialog::makeMaildirAccountPage()
00358 {
00359 QWidget *page = new QWidget( this );
00360 mMaildir.ui.setupUi( page );
00361 setMainWidget( page );
00362 ProcmailRCParser procmailrcParser;
00363
00364 mMaildir.ui.locationEdit->addItems( procmailrcParser.getSpoolFilesList() );
00365 mMaildir.ui.choose->setAutoDefault( false );
00366 mMaildir.ui.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(), 10000, 1 );
00367
00368 connect( mMaildir.ui.choose, SIGNAL(clicked()),
00369 this, SLOT(slotMaildirChooser()) );
00370 connect( mMaildir.ui.intervalCheck, SIGNAL(toggled(bool)),
00371 this, SLOT(slotEnableMaildirInterval(bool)) );
00372 connect( KGlobalSettings::self(),SIGNAL(kdisplayFontChanged()),
00373 SLOT(slotFontChanged()) );
00374 }
00375
00376
00377 void AccountDialog::makePopAccountPage()
00378 {
00379 QWidget *page = new QWidget( this );
00380 mPop.ui.setupUi( page );
00381 setMainWidget( page );
00382
00383 connect( mPop.ui.passwordEdit, SIGNAL( textEdited( const QString& ) ),
00384 this, SLOT( slotPopPasswordChanged( const QString& ) ) );
00385
00386
00387
00388 mPop.ui.hostEdit->setValidator( mValidator );
00389
00390 connect( mPop.ui.leaveOnServerCheck, SIGNAL( clicked() ),
00391 this, SLOT( slotLeaveOnServerClicked() ) );
00392 connect( mPop.ui.leaveOnServerDaysCheck, SIGNAL( toggled(bool) ),
00393 this, SLOT( slotEnableLeaveOnServerDays(bool)) );
00394 connect( mPop.ui.leaveOnServerDaysSpin, SIGNAL(valueChanged(int)),
00395 SLOT(slotLeaveOnServerDaysChanged(int)));
00396 connect( mPop.ui.leaveOnServerCountCheck, SIGNAL( toggled(bool) ),
00397 this, SLOT( slotEnableLeaveOnServerCount(bool)) );
00398 connect( mPop.ui.leaveOnServerCountSpin, SIGNAL(valueChanged(int)),
00399 SLOT(slotLeaveOnServerCountChanged(int)));
00400 connect( mPop.ui.leaveOnServerSizeCheck, SIGNAL( toggled(bool) ),
00401 this, SLOT( slotEnableLeaveOnServerSize(bool)) );
00402
00403 connect(mPop.ui.filterOnServerSizeSpin, SIGNAL(valueChanged(int)),
00404 SLOT(slotFilterOnServerSizeChanged(int)));
00405 connect( mPop.ui.filterOnServerCheck, SIGNAL(toggled(bool)),
00406 mPop.ui.filterOnServerSizeSpin, SLOT(setEnabled(bool)) );
00407 connect( mPop.ui.filterOnServerCheck, SIGNAL( clicked() ),
00408 this, SLOT( slotFilterOnServerClicked() ) );
00409
00410 connect( mPop.ui.intervalCheck, SIGNAL(toggled(bool)),
00411 this, SLOT(slotEnablePopInterval(bool)) );
00412 mPop.ui.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(),
00413 10000, 1 );
00414
00415
00416 connect( mPop.ui.checkCapabilities, SIGNAL(clicked()),
00417 SLOT(slotCheckPopCapabilities()) );
00418 mPop.encryptionButtonGroup = new QButtonGroup();
00419 mPop.encryptionButtonGroup->addButton( mPop.ui.encryptionNone,
00420 Transport::EnumEncryption::None );
00421 mPop.encryptionButtonGroup->addButton( mPop.ui.encryptionSSL,
00422 Transport::EnumEncryption::SSL );
00423 mPop.encryptionButtonGroup->addButton( mPop.ui.encryptionTLS,
00424 Transport::EnumEncryption::TLS );
00425
00426 connect( mPop.encryptionButtonGroup, SIGNAL(buttonClicked(int)),
00427 SLOT(slotPopEncryptionChanged(int)) );
00428
00429 if ( KProtocolInfo::capabilities("pop3").contains("SASL") == 0 )
00430 {
00431 mPop.ui.authNTLM->hide();
00432 mPop.ui.authGSSAPI->hide();
00433 }
00434 mPop.authButtonGroup = new QButtonGroup();
00435 mPop.authButtonGroup->addButton( mPop.ui.authUser );
00436 mPop.authButtonGroup->addButton( mPop.ui.authLogin );
00437 mPop.authButtonGroup->addButton( mPop.ui.authPlain );
00438 mPop.authButtonGroup->addButton( mPop.ui.authCRAM_MD5 );
00439 mPop.authButtonGroup->addButton( mPop.ui.authDigestMd5 );
00440 mPop.authButtonGroup->addButton( mPop.ui.authNTLM );
00441 mPop.authButtonGroup->addButton( mPop.ui.authGSSAPI );
00442 mPop.authButtonGroup->addButton( mPop.ui.authAPOP );
00443
00444 connect( mPop.ui.usePipeliningCheck, SIGNAL(clicked()),
00445 SLOT(slotPipeliningClicked()) );
00446
00447 connect(KGlobalSettings::self(),SIGNAL(kdisplayFontChanged()),
00448 SLOT(slotFontChanged()));
00449 }
00450
00451
00452 void AccountDialog::makeImapAccountPage( bool connected )
00453 {
00454 QWidget *page = new QWidget( this );
00455 mImap.ui.setupUi( page );
00456 setMainWidget( page );
00457 if( connected )
00458 mImap.ui.titleLabel->setText( i18n("Account Type: Disconnected IMAP Account") );
00459 else
00460 mImap.ui.titleLabel->setText( i18n("Account Type: IMAP Account") );
00461
00462
00463
00464 mImap.ui.hostEdit->setValidator( mValidator );
00465
00466 mImap.ui.button->setAutoRaise( true );
00467 mImap.ui.button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
00468 mImap.ui.button->setFixedSize( 22, 22 );
00469 mImap.ui.button->setIcon( KIcon("view-refresh") );
00470 mImap.ui.editPNS->setIcon( KIcon("document-properties") );
00471 mImap.ui.editPNS->setFixedSize( 22, 22 );
00472 mImap.ui.editONS->setIcon( KIcon("document-properties") );
00473 mImap.ui.editONS->setFixedSize( 22, 22 );
00474 mImap.ui.editSNS->setIcon( KIcon("document-properties") );
00475 mImap.ui.editSNS->setFixedSize( 22, 22 );
00476
00477 if( connected ) {
00478
00479 mImap.ui.autoExpungeCheck->hide();
00480 mImap.ui.loadOnDemandCheck->hide();
00481 mImap.ui.listOnlyOpenCheck->hide();
00482 }
00483
00484
00485 mImap.trashCombo = new FolderRequester( page,
00486 kmkernel->getKMMainWidget()->folderTree() );
00487 mImap.trashCombo->setShowOutbox( false );
00488 mImap.ui.trashLabel->setBuddy( mImap.trashCombo );
00489 mImap.ui.trashLayout->addWidget( mImap.trashCombo, 1 );
00490 mImap.ui.trashLabel->setBuddy( mImap.trashCombo );
00491
00492 mImap.identityCombo = new KPIMIdentities::IdentityCombo( kmkernel->identityManager(), page );
00493 mImap.ui.identityLabel->setBuddy( mImap.identityCombo );
00494 mImap.ui.identityLayout->addWidget( mImap.identityCombo, 1 );
00495 mImap.ui.identityLabel->setBuddy( mImap.identityCombo );
00496
00497 mImap.encryptionButtonGroup = new QButtonGroup();
00498 mImap.encryptionButtonGroup->addButton( mImap.ui.encryptionNone,
00499 Transport::EnumEncryption::None );
00500 mImap.encryptionButtonGroup->addButton( mImap.ui.encryptionSSL,
00501 Transport::EnumEncryption::SSL );
00502 mImap.encryptionButtonGroup->addButton( mImap.ui.encryptionTLS,
00503 Transport::EnumEncryption::TLS );
00504
00505 mImap.authButtonGroup = new QButtonGroup();
00506 mImap.authButtonGroup->addButton( mImap.ui.authUser );
00507 mImap.authButtonGroup->addButton( mImap.ui.authLogin );
00508 mImap.authButtonGroup->addButton( mImap.ui.authPlain );
00509 mImap.authButtonGroup->addButton( mImap.ui.authCramMd5 );
00510 mImap.authButtonGroup->addButton( mImap.ui.authDigestMd5 );
00511 mImap.authButtonGroup->addButton( mImap.ui.authNTLM );
00512 mImap.authButtonGroup->addButton( mImap.ui.authGSSAPI );
00513 mImap.authButtonGroup->addButton( mImap.ui.authAnonymous );
00514
00515
00516 connect( mImap.ui.button, SIGNAL(clicked()), this, SLOT(slotReloadNamespaces()) );
00517 connect( mImap.ui.editPNS, SIGNAL(clicked()), this, SLOT(slotEditPersonalNamespace()) );
00518 connect( mImap.ui.editONS, SIGNAL(clicked()), this, SLOT(slotEditOtherUsersNamespace()) );
00519 connect( mImap.ui.editSNS, SIGNAL(clicked()), this, SLOT(slotEditSharedNamespace()) );
00520 connect( mImap.ui.intervalCheck, SIGNAL(toggled(bool)), this, SLOT(slotEnableImapInterval(bool)) );
00521 connect( mImap.ui.useDefaultIdentityCheck, SIGNAL( toggled(bool) ), this, SLOT( slotIdentityCheckboxChanged() ) );
00522 connect( mImap.ui.checkCapabilities, SIGNAL(clicked()), SLOT(slotCheckImapCapabilities()));
00523 connect( mImap.encryptionButtonGroup, SIGNAL(buttonClicked(int)), SLOT(slotImapEncryptionChanged(int)) );
00524
00525
00526 mSieveConfigEditor = new SieveConfigEditor( mImap.ui.tabWidget );
00527 mSieveConfigEditor->layout()->setMargin( KDialog::marginHint() );
00528 mImap.ui.tabWidget->addTab( mSieveConfigEditor, i18n("&Filtering") );
00529
00530 connect( KGlobalSettings::self(),SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()) );
00531 }
00532
00533
00534 void AccountDialog::setupSettings()
00535 {
00536 QComboBox *folderCombo = 0;
00537 bool intervalCheckingEnabled = ( mAccount->checkInterval() > 0 );
00538 int interval = mAccount->checkInterval();
00539 if ( !intervalCheckingEnabled )
00540 interval = 5;
00541
00542 KAccount::Type accountType = mAccount->type();
00543 if( accountType == KAccount::Local )
00544 {
00545 ProcmailRCParser procmailrcParser;
00546 KMAcctLocal *acctLocal = static_cast<KMAcctLocal*>(mAccount);
00547
00548 if ( acctLocal->location().isEmpty() )
00549 acctLocal->setLocation( procmailrcParser.getSpoolFilesList().first() );
00550 else
00551 mLocal.ui.locationEdit->addItem( acctLocal->location() );
00552
00553 if ( acctLocal->procmailLockFileName().isEmpty() )
00554 acctLocal->setProcmailLockFileName( procmailrcParser.getLockFilesList().first() );
00555 else
00556 mLocal.ui.procmailLockFileName->addItem( acctLocal->procmailLockFileName() );
00557
00558 mLocal.ui.nameEdit->setText( mAccount->name() );
00559 mLocal.ui.nameEdit->setFocus();
00560 mLocal.ui.locationEdit->setEditText( acctLocal->location() );
00561 if (acctLocal->lockType() == mutt_dotlock)
00562 mLocal.ui.lockMutt->setChecked(true);
00563 else if (acctLocal->lockType() == mutt_dotlock_privileged)
00564 mLocal.ui.lockMuttPriv->setChecked(true);
00565 else if (acctLocal->lockType() == procmail_lockfile) {
00566 mLocal.ui.lockProcmail->setChecked(true);
00567 mLocal.ui.procmailLockFileName->setEditText(acctLocal->procmailLockFileName());
00568 } else if (acctLocal->lockType() == FCNTL)
00569 mLocal.ui.lockFcntl->setChecked(true);
00570 else if (acctLocal->lockType() == lock_none)
00571 mLocal.ui.lockNone->setChecked(true);
00572
00573 mLocal.ui.intervalSpin->setValue( interval );
00574 mLocal.ui.intervalCheck->setChecked( intervalCheckingEnabled );
00575 mLocal.ui.includeInCheck->setChecked( !mAccount->checkExclude() );
00576 mLocal.ui.precommand->setText( mAccount->precommand() );
00577
00578 slotEnableLocalInterval( intervalCheckingEnabled );
00579 folderCombo = mLocal.ui.folderCombo;
00580 }
00581 else if( accountType == KAccount::Pop )
00582 {
00583 PopAccount &ap = *(PopAccount*)mAccount;
00584 mPop.ui.nameEdit->setText( mAccount->name() );
00585 mPop.ui.nameEdit->setFocus();
00586 mPop.ui.loginEdit->setText( ap.login() );
00587 mPop.ui.passwordEdit->setText( ap.passwd());
00588 mPop.ui.hostEdit->setText( ap.host() );
00589 mPop.ui.portEdit->setValue( ap.port() );
00590 mPop.ui.usePipeliningCheck->setChecked( ap.usePipelining() );
00591 mPop.ui.storePasswordCheck->setChecked( ap.storePasswd() );
00592 mPop.ui.leaveOnServerCheck->setChecked( ap.leaveOnServer() );
00593 mPop.ui.leaveOnServerDaysCheck->setEnabled( ap.leaveOnServer() );
00594 mPop.ui.leaveOnServerDaysCheck->setChecked( ap.leaveOnServerDays() >= 1 );
00595 mPop.ui.leaveOnServerDaysSpin->setValue( ap.leaveOnServerDays() >= 1 ?
00596 ap.leaveOnServerDays() : 7 );
00597 mPop.ui.leaveOnServerCountCheck->setEnabled( ap.leaveOnServer() );
00598 mPop.ui.leaveOnServerCountCheck->setChecked( ap.leaveOnServerCount() >= 1 );
00599 mPop.ui.leaveOnServerCountSpin->setValue( ap.leaveOnServerCount() >= 1 ?
00600 ap.leaveOnServerCount() : 100 );
00601 mPop.ui.leaveOnServerSizeCheck->setEnabled( ap.leaveOnServer() );
00602 mPop.ui.leaveOnServerSizeCheck->setChecked( ap.leaveOnServerSize() >= 1 );
00603 mPop.ui.leaveOnServerSizeSpin->setValue( ap.leaveOnServerSize() >= 1 ?
00604 ap.leaveOnServerSize() : 10 );
00605 mPop.ui.filterOnServerCheck->setChecked( ap.filterOnServer() );
00606 mPop.ui.filterOnServerSizeSpin->setValue( ap.filterOnServerCheckSize() );
00607 mPop.ui.intervalCheck->setChecked( intervalCheckingEnabled );
00608 mPop.ui.intervalSpin->setValue( interval );
00609 mPop.ui.includeInCheck->setChecked( !mAccount->checkExclude() );
00610 mPop.ui.precommand->setText( ap.precommand() );
00611 if (ap.useSSL())
00612 mPop.ui.encryptionSSL->setChecked( true );
00613 else if (ap.useTLS())
00614 mPop.ui.encryptionTLS->setChecked( true );
00615 else mPop.ui.encryptionNone->setChecked( true );
00616 if (ap.auth() == "LOGIN")
00617 mPop.ui.authLogin->setChecked( true );
00618 else if (ap.auth() == "PLAIN")
00619 mPop.ui.authPlain->setChecked( true );
00620 else if (ap.auth() == "CRAM-MD5")
00621 mPop.ui.authCRAM_MD5->setChecked( true );
00622 else if (ap.auth() == "DIGEST-MD5")
00623 mPop.ui.authDigestMd5->setChecked( true );
00624 else if (ap.auth() == "NTLM")
00625 mPop.ui.authNTLM->setChecked( true );
00626 else if (ap.auth() == "GSSAPI")
00627 mPop.ui.authGSSAPI->setChecked( true );
00628 else if (ap.auth() == "APOP")
00629 mPop.ui.authAPOP->setChecked( true );
00630 else mPop.ui.authUser->setChecked( true );
00631
00632 slotEnableLeaveOnServerDays( mPop.ui.leaveOnServerDaysCheck->isEnabled() ?
00633 ap.leaveOnServerDays() >= 1 : 0);
00634 slotEnableLeaveOnServerCount( mPop.ui.leaveOnServerCountCheck->isEnabled() ?
00635 ap.leaveOnServerCount() >= 1 : 0);
00636 slotEnableLeaveOnServerSize( mPop.ui.leaveOnServerSizeCheck->isEnabled() ?
00637 ap.leaveOnServerSize() >= 1 : 0);
00638 slotEnablePopInterval( intervalCheckingEnabled );
00639 folderCombo = mPop.ui.folderCombo;
00640 }
00641 else if( accountType == KAccount::Imap )
00642 {
00643 KMAcctImap &ai = *(KMAcctImap*)mAccount;
00644 mImap.ui.nameEdit->setText( mAccount->name() );
00645 mImap.ui.nameEdit->setFocus();
00646 mImap.ui.loginEdit->setText( ai.login() );
00647 mImap.ui.passwordEdit->setText( ai.passwd());
00648 mImap.ui.hostEdit->setText( ai.host() );
00649 mImap.ui.portEdit->setValue( ai.port() );
00650 mImap.ui.autoExpungeCheck->setChecked( ai.autoExpunge() );
00651 mImap.ui.hiddenFoldersCheck->setChecked( ai.hiddenFolders() );
00652 mImap.ui.subscribedFoldersCheck->setChecked( ai.onlySubscribedFolders() );
00653 mImap.ui.locallySubscribedFoldersCheck->setChecked( ai.onlyLocallySubscribedFolders() );
00654 mImap.ui.loadOnDemandCheck->setChecked( ai.loadOnDemand() );
00655 mImap.ui.listOnlyOpenCheck->setChecked( ai.listOnlyOpenFolders() );
00656 mImap.ui.storePasswordCheck->setChecked( ai.storePasswd() );
00657 mImap.ui.intervalCheck->setChecked( intervalCheckingEnabled );
00658 mImap.ui.intervalSpin->setValue( interval);
00659 mImap.ui.includeInCheck->setChecked( !ai.checkExclude() );
00660 QString trashfolder = ai.trash();
00661 if (trashfolder.isEmpty())
00662 trashfolder = kmkernel->trashFolder()->idString();
00663 mImap.trashCombo->setFolder( trashfolder );
00664 slotEnableImapInterval( intervalCheckingEnabled );
00665 mImap.identityCombo->setCurrentIdentity( mAccount->identityId() );
00666 mImap.ui.useDefaultIdentityCheck->setChecked( mAccount->useDefaultIdentity() );
00667
00668 if (ai.useSSL())
00669 mImap.ui.encryptionSSL->setChecked( true );
00670 else if (ai.useTLS())
00671 mImap.ui.encryptionTLS->setChecked( true );
00672 else mImap.ui.encryptionNone->setChecked( true );
00673 if (ai.auth() == "CRAM-MD5")
00674 mImap.ui.authCramMd5->setChecked( true );
00675 else if (ai.auth() == "DIGEST-MD5")
00676 mImap.ui.authDigestMd5->setChecked( true );
00677 else if (ai.auth() == "NTLM")
00678 mImap.ui.authNTLM->setChecked( true );
00679 else if (ai.auth() == "GSSAPI")
00680 mImap.ui.authGSSAPI->setChecked( true );
00681 else if (ai.auth() == "ANONYMOUS")
00682 mImap.ui.authAnonymous->setChecked( true );
00683 else if (ai.auth() == "PLAIN")
00684 mImap.ui.authPlain->setChecked( true );
00685 else if (ai.auth() == "LOGIN")
00686 mImap.ui.authLogin->setChecked( true );
00687 else mImap.ui.authUser->setChecked( true );
00688 if ( mSieveConfigEditor )
00689 mSieveConfigEditor->setConfig( ai.sieveConfig() );
00690 }
00691 else if( accountType == KAccount::DImap )
00692 {
00693 KMAcctCachedImap &ai = *(KMAcctCachedImap*)mAccount;
00694 mImap.ui.nameEdit->setText( mAccount->name() );
00695 mImap.ui.nameEdit->setFocus();
00696 mImap.ui.loginEdit->setText( ai.login() );
00697 mImap.ui.passwordEdit->setText( ai.passwd());
00698 mImap.ui.hostEdit->setText( ai.host() );
00699 mImap.ui.portEdit->setValue( ai.port() );
00700 mImap.ui.hiddenFoldersCheck->setChecked( ai.hiddenFolders() );
00701 mImap.ui.subscribedFoldersCheck->setChecked( ai.onlySubscribedFolders() );
00702 mImap.ui.locallySubscribedFoldersCheck->setChecked( ai.onlyLocallySubscribedFolders() );
00703 mImap.ui.storePasswordCheck->setChecked( ai.storePasswd() );
00704 mImap.ui.intervalCheck->setChecked( intervalCheckingEnabled );
00705 mImap.ui.intervalSpin->setValue( interval );
00706 mImap.ui.includeInCheck->setChecked( !ai.checkExclude() );
00707 QString trashfolder = ai.trash();
00708 if (trashfolder.isEmpty())
00709 trashfolder = kmkernel->trashFolder()->idString();
00710 mImap.trashCombo->setFolder( trashfolder );
00711 slotEnableImapInterval( intervalCheckingEnabled );
00712 mImap.identityCombo->setCurrentIdentity( mAccount->identityId() );
00713 mImap.ui.useDefaultIdentityCheck->setChecked( mAccount->useDefaultIdentity() );
00714
00715 if (ai.useSSL())
00716 mImap.ui.encryptionSSL->setChecked( true );
00717 else if (ai.useTLS())
00718 mImap.ui.encryptionTLS->setChecked( true );
00719 else mImap.ui.encryptionNone->setChecked( true );
00720 if (ai.auth() == "CRAM-MD5")
00721 mImap.ui.authCramMd5->setChecked( true );
00722 else if (ai.auth() == "DIGEST-MD5")
00723 mImap.ui.authDigestMd5->setChecked( true );
00724 else if (ai.auth() == "GSSAPI")
00725 mImap.ui.authGSSAPI->setChecked( true );
00726 else if (ai.auth() == "NTLM")
00727 mImap.ui.authNTLM->setChecked( true );
00728 else if (ai.auth() == "ANONYMOUS")
00729 mImap.ui.authAnonymous->setChecked( true );
00730 else if (ai.auth() == "PLAIN")
00731 mImap.ui.authPlain->setChecked( true );
00732 else if (ai.auth() == "LOGIN")
00733 mImap.ui.authLogin->setChecked( true );
00734 else mImap.ui.authUser->setChecked( true );
00735 if ( mSieveConfigEditor )
00736 mSieveConfigEditor->setConfig( ai.sieveConfig() );
00737 }
00738 else if( accountType == KAccount::Maildir )
00739 {
00740 KMAcctMaildir *acctMaildir = dynamic_cast<KMAcctMaildir*>(mAccount);
00741
00742 mMaildir.ui.nameEdit->setText( mAccount->name() );
00743 mMaildir.ui.nameEdit->setFocus();
00744 mMaildir.ui.locationEdit->setEditText( acctMaildir->location() );
00745
00746 mMaildir.ui.intervalSpin->setValue( interval );
00747 mMaildir.ui.intervalCheck->setChecked( intervalCheckingEnabled );
00748 mMaildir.ui.includeInCheck->setChecked( !mAccount->checkExclude() );
00749 mMaildir.ui.precommand->setText( mAccount->precommand() );
00750 slotEnableMaildirInterval( intervalCheckingEnabled );
00751 folderCombo = mMaildir.ui.folderCombo;
00752 }
00753 else
00754 return;
00755
00756 if ( accountType == KAccount::Imap ||
00757 accountType == KAccount::DImap )
00758 {
00759
00760 ImapAccountBase &ai = *(ImapAccountBase*)mAccount;
00761
00762 if ( ( ai.namespaces().isEmpty() || ai.namespaceToDelimiter().isEmpty() ) &&
00763 !ai.login().isEmpty() && !ai.passwd().isEmpty() && !ai.host().isEmpty() )
00764 {
00765 slotReloadNamespaces();
00766 } else {
00767 slotSetupNamespaces( ai.namespacesWithDelimiter() );
00768 }
00769 }
00770
00771 if (!folderCombo) return;
00772
00773 KMFolderDir *fdir = (KMFolderDir*)&kmkernel->folderMgr()->dir();
00774 KMFolder *acctFolder = mAccount->folder();
00775 if( acctFolder == 0 )
00776 {
00777 acctFolder = (KMFolder*)fdir->first();
00778 }
00779 if( acctFolder == 0 )
00780 {
00781 folderCombo->addItem( i18n("<none>") );
00782 }
00783 else
00784 {
00785 int i = 0;
00786 int curIndex = -1;
00787 kmkernel->folderMgr()->createI18nFolderList(&mFolderNames, &mFolderList);
00788 while (i < mFolderNames.count())
00789 {
00790
00791 KMFolder *folder = mFolderList.at(i);
00792 if (folder->isSystemFolder())
00793 {
00794 mFolderList.removeAll(folder);
00795 mFolderNames.removeAt(i);
00796 } else {
00797 if (folder == acctFolder) curIndex = i;
00798 i++;
00799 }
00800 }
00801 mFolderNames.prepend(i18n("inbox"));
00802 mFolderList.prepend(kmkernel->inboxFolder());
00803 folderCombo->addItems(mFolderNames);
00804 folderCombo->setCurrentIndex(curIndex + 1);
00805
00806
00807 if (folderCombo->count() == 0)
00808 folderCombo->addItem( i18n("inbox") );
00809 }
00810 }
00811
00812 void AccountDialog::slotLeaveOnServerClicked()
00813 {
00814 bool state = mPop.ui.leaveOnServerCheck->isChecked();
00815 mPop.ui.leaveOnServerDaysCheck->setEnabled( state );
00816 mPop.ui.leaveOnServerCountCheck->setEnabled( state );
00817 mPop.ui.leaveOnServerSizeCheck->setEnabled( state );
00818 if ( state ) {
00819 if ( mPop.ui.leaveOnServerDaysCheck->isChecked() ) {
00820 slotEnableLeaveOnServerDays( state );
00821 }
00822 if ( mPop.ui.leaveOnServerCountCheck->isChecked() ) {
00823 slotEnableLeaveOnServerCount( state );
00824 }
00825 if ( mPop.ui.leaveOnServerSizeCheck->isChecked() ) {
00826 slotEnableLeaveOnServerSize( state );
00827 }
00828 } else {
00829 slotEnableLeaveOnServerDays( state );
00830 slotEnableLeaveOnServerCount( state );
00831 slotEnableLeaveOnServerSize( state );
00832 }
00833 if ( mServerTest && !mServerTest->capabilities().contains( ServerTest::UIDL ) &&
00834 mPop.ui.leaveOnServerCheck->isChecked() ) {
00835 KMessageBox::information( topLevelWidget(),
00836 i18n("The server does not seem to support unique "
00837 "message numbers, but this is a "
00838 "requirement for leaving messages on the "
00839 "server.\n"
00840 "Since some servers do not correctly "
00841 "announce their capabilities you still "
00842 "have the possibility to turn leaving "
00843 "fetched messages on the server on.") );
00844 }
00845 }
00846
00847 void AccountDialog::slotFilterOnServerClicked()
00848 {
00849 if ( mServerTest && !mServerTest->capabilities().contains( ServerTest::Top ) &&
00850 mPop.ui.filterOnServerCheck->isChecked() ) {
00851 KMessageBox::information( topLevelWidget(),
00852 i18n("The server does not seem to support "
00853 "fetching message headers, but this is a "
00854 "requirement for filtering messages on the "
00855 "server.\n"
00856 "Since some servers do not correctly "
00857 "announce their capabilities you still "
00858 "have the possibility to turn filtering "
00859 "messages on the server on.") );
00860 }
00861 }
00862
00863 void AccountDialog::slotPipeliningClicked()
00864 {
00865 if (mPop.ui.usePipeliningCheck->isChecked())
00866 KMessageBox::information( topLevelWidget(),
00867 i18n("Please note that this feature can cause some POP3 servers "
00868 "that do not support pipelining to send corrupted mail;\n"
00869 "this is configurable, though, because some servers support pipelining "
00870 "but do not announce their capabilities. To check whether your POP3 server "
00871 "announces pipelining support use the \"Check What the Server "
00872 "Supports\" button at the bottom of the dialog;\n"
00873 "if your server does not announce it, but you want more speed, then "
00874 "you should do some testing first by sending yourself a batch "
00875 "of mail and downloading it."), QString(),
00876 "pipelining");
00877 }
00878
00879
00880 void AccountDialog::slotPopEncryptionChanged( int id )
00881 {
00882 kDebug(5006) << "ID:" << id;
00883
00884 if ( id == Transport::EnumEncryption::SSL || mPop.ui.portEdit->value() == 995 )
00885 mPop.ui.portEdit->setValue( ( id == Transport::EnumEncryption::SSL ) ? 995 : 110 );
00886
00887 enablePopFeatures();
00888 const QAbstractButton *old = mPop.authButtonGroup->checkedButton();
00889 if ( old && !old->isEnabled() )
00890 checkHighest( mPop.authButtonGroup );
00891 }
00892
00893 void AccountDialog::slotPopPasswordChanged(const QString& text)
00894 {
00895 if ( text.isEmpty() )
00896 mPop.ui.storePasswordCheck->setCheckState( Qt::Unchecked );
00897 else
00898 mPop.ui.storePasswordCheck->setCheckState( Qt::Checked );
00899 }
00900
00901 void AccountDialog::slotImapEncryptionChanged( int id )
00902 {
00903 kDebug(5006) << id;
00904
00905 if ( id == Transport::EnumEncryption::SSL || mImap.ui.portEdit->value() == 993 )
00906 mImap.ui.portEdit->setValue( ( id == Transport::EnumEncryption::SSL ) ? 993 : 143 );
00907
00908 enableImapAuthMethods();
00909 QAbstractButton *old = mImap.authButtonGroup->checkedButton();
00910 if ( !old->isEnabled() )
00911 checkHighest( mImap.authButtonGroup );
00912 }
00913
00914
00915 void AccountDialog::slotCheckPopCapabilities()
00916 {
00917 if ( mPop.ui.hostEdit->text().isEmpty() )
00918 {
00919 KMessageBox::sorry( this, i18n( "Please specify a server and port on "
00920 "the General tab first." ) );
00921 return;
00922 }
00923 delete mServerTest;
00924 mServerTest = new ServerTest( this );
00925 BusyCursorHelper *busyCursorHelper = new BusyCursorHelper( mServerTest );
00926 mServerTest->setProgressBar( mPop.ui.checkCapabilitiesProgress );
00927 mPop.ui.checkCapabilitiesStack->setCurrentIndex( 1 );
00928 Transport::EnumEncryption::type encryptionType;
00929 if ( mPop.ui.encryptionSSL->isChecked() )
00930 encryptionType = Transport::EnumEncryption::SSL;
00931 else
00932 encryptionType = Transport::EnumEncryption::None;
00933 mServerTest->setPort( encryptionType, mPop.ui.portEdit->value() );
00934 mServerTest->setServer( mPop.ui.hostEdit->text() );
00935 mServerTest->setProtocol( "pop" );
00936 connect( mServerTest, SIGNAL( finished(QList<int>) ),
00937 this, SLOT( slotPopCapabilities(QList<int>) ) );
00938 connect( mServerTest, SIGNAL( finished(QList<int>) ),
00939 busyCursorHelper, SLOT( deleteLater() ) );
00940 mServerTest->start();
00941 mServerTestFailed = false;
00942 }
00943
00944
00945 void AccountDialog::slotCheckImapCapabilities()
00946 {
00947 if ( mImap.ui.hostEdit->text().isEmpty() )
00948 {
00949 KMessageBox::sorry( this, i18n( "Please specify a server and port on "
00950 "the General tab first." ) );
00951 return;
00952 }
00953 delete mServerTest;
00954 mServerTest = new ServerTest( this );
00955 BusyCursorHelper *busyCursorHelper = new BusyCursorHelper( mServerTest );
00956 mServerTest->setProgressBar( mImap.ui.checkCapabilitiesProgress );
00957 mImap.ui.checkCapabilitiesStack->setCurrentIndex( 1 );
00958 Transport::EnumEncryption::type encryptionType;
00959 if ( mImap.ui.encryptionSSL->isChecked() )
00960 encryptionType = Transport::EnumEncryption::SSL;
00961 else
00962 encryptionType = Transport::EnumEncryption::None;
00963 mServerTest->setPort( encryptionType, mImap.ui.portEdit->value() );
00964 mServerTest->setServer( mImap.ui.hostEdit->text() );
00965 mServerTest->setProtocol( "imap" );
00966 connect( mServerTest, SIGNAL( finished(QList<int>) ),
00967 this, SLOT( slotImapCapabilities(QList<int>) ) );
00968 connect( mServerTest, SIGNAL( finished(QList<int>) ),
00969 busyCursorHelper, SLOT( deleteLater() ) );
00970 mServerTest->start();
00971 mServerTestFailed = false;
00972 }
00973
00974 void AccountDialog::slotPopCapabilities( QList<int> encryptionTypes )
00975 {
00976 mPop.ui.checkCapabilitiesStack->setCurrentIndex( 0 );
00977
00978
00979
00980 if ( encryptionTypes.isEmpty() ) {
00981 mServerTestFailed = true;
00982 return;
00983 }
00984
00985 mPop.ui.encryptionNone->setEnabled( encryptionTypes.contains( Transport::EnumEncryption::None ) );
00986 mPop.ui.encryptionSSL->setEnabled( encryptionTypes.contains( Transport::EnumEncryption::SSL ) );
00987 mPop.ui.encryptionTLS->setEnabled( encryptionTypes.contains( Transport::EnumEncryption::TLS ) );
00988 checkHighest( mPop.encryptionButtonGroup );
00989 }
00990
00991
00992 void AccountDialog::enablePopFeatures()
00993 {
00994 kDebug(5006);
00995 if ( !mServerTest || mServerTestFailed )
00996 return;
00997
00998 QList<int> supportedAuths;
00999 if ( mPop.encryptionButtonGroup->checkedId() == Transport::EnumEncryption::None )
01000 supportedAuths = mServerTest->normalProtocols();
01001 if ( mPop.encryptionButtonGroup->checkedId() == Transport::EnumEncryption::SSL )
01002 supportedAuths = mServerTest->secureProtocols();
01003 if ( mPop.encryptionButtonGroup->checkedId() == Transport::EnumEncryption::TLS )
01004 supportedAuths = mServerTest->tlsProtocols();
01005
01006 mPop.ui.authPlain->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::PLAIN ) );
01007 mPop.ui.authLogin->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::LOGIN ) );
01008 mPop.ui.authCRAM_MD5->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::CRAM_MD5 ) );
01009 mPop.ui.authDigestMd5->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::DIGEST_MD5 ) );
01010 mPop.ui.authNTLM->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::NTLM ) );
01011 mPop.ui.authGSSAPI->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::GSSAPI ) );
01012 mPop.ui.authAPOP->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::APOP ) );
01013
01014 if ( mServerTest && !mServerTest->capabilities().contains( ServerTest::Pipelining ) &&
01015 mPop.ui.usePipeliningCheck->isChecked() ) {
01016 mPop.ui.usePipeliningCheck->setChecked( false );
01017 KMessageBox::information( topLevelWidget(),
01018 i18n("The server does not seem to support "
01019 "pipelining; therefore, this option has "
01020 "been disabled.\n"
01021 "Since some servers do not correctly "
01022 "announce their capabilities you still "
01023 "have the possibility to turn pipelining "
01024 "on. But please note that this feature can "
01025 "cause some POP servers that do not "
01026 "support pipelining to send corrupt "
01027 "messages. So before using this feature "
01028 "with important mail you should first "
01029 "test it by sending yourself a larger "
01030 "number of test messages which you all "
01031 "download in one go from the POP "
01032 "server.") );
01033 }
01034
01035 if ( mServerTest && !mServerTest->capabilities().contains( ServerTest::UIDL ) &&
01036 mPop.ui.leaveOnServerCheck->isChecked() ) {
01037 mPop.ui.leaveOnServerCheck->setChecked( false );
01038 KMessageBox::information( topLevelWidget(),
01039 i18n("The server does not seem to support unique "
01040 "message numbers, but this is a "
01041 "requirement for leaving messages on the "
01042 "server; therefore, this option has been "
01043 "disabled.\n"
01044 "Since some servers do not correctly "
01045 "announce their capabilities you still "
01046 "have the possibility to turn leaving "
01047 "fetched messages on the server on.") );
01048 }
01049
01050 if ( mServerTest && !mServerTest->capabilities().contains( ServerTest::Top ) &&
01051 mPop.ui.filterOnServerCheck->isChecked() ) {
01052 mPop.ui.filterOnServerCheck->setChecked( false );
01053 KMessageBox::information( topLevelWidget(),
01054 i18n("The server does not seem to support "
01055 "fetching message headers, but this is a "
01056 "requirement for filtering messages on the "
01057 "server; therefore, this option has been "
01058 "disabled.\n"
01059 "Since some servers do not correctly "
01060 "announce their capabilities you still "
01061 "have the possibility to turn filtering "
01062 "messages on the server on.") );
01063 }
01064 }
01065
01066 void AccountDialog::slotImapCapabilities( QList<int> encryptionTypes )
01067 {
01068 mImap.ui.checkCapabilitiesStack->setCurrentIndex( 0 );
01069
01070
01071
01072 if ( encryptionTypes.isEmpty() ) {
01073 mServerTestFailed = true;
01074 return;
01075 }
01076
01077 mImap.ui.encryptionNone->setEnabled( encryptionTypes.contains( Transport::EnumEncryption::None ) );
01078 mImap.ui.encryptionSSL->setEnabled( encryptionTypes.contains( Transport::EnumEncryption::SSL ) );
01079 mImap.ui.encryptionTLS->setEnabled( encryptionTypes.contains( Transport::EnumEncryption::TLS ) );
01080 checkHighest( mImap.encryptionButtonGroup );
01081 }
01082
01083 void AccountDialog::slotLeaveOnServerDaysChanged ( int value )
01084 {
01085 mPop.ui.leaveOnServerDaysSpin->setSuffix( i18np(" day", " days", value) );
01086 }
01087
01088
01089 void AccountDialog::slotLeaveOnServerCountChanged ( int value )
01090 {
01091 mPop.ui.leaveOnServerCountSpin->setSuffix( i18np(" message", " messages", value) );
01092 }
01093
01094
01095 void AccountDialog::slotFilterOnServerSizeChanged ( int value )
01096 {
01097 mPop.ui.filterOnServerSizeSpin->setSuffix( i18np(" byte", " bytes", value) );
01098 }
01099
01100 void AccountDialog::slotIdentityCheckboxChanged()
01101 {
01102 if ( mAccount->type() == KAccount::Imap ||
01103 mAccount->type() == KAccount::DImap ) {
01104 mImap.identityCombo->setEnabled( !mImap.ui.useDefaultIdentityCheck->isChecked() );
01105 }
01106 else
01107 assert( false );
01108 }
01109
01110 void AccountDialog::enableImapAuthMethods()
01111 {
01112 kDebug(5006);
01113 if ( !mServerTest || mServerTestFailed )
01114 return;
01115
01116 QList<int> supportedAuths;
01117 if ( mImap.encryptionButtonGroup->checkedId() == Transport::EnumEncryption::None )
01118 supportedAuths = mServerTest->normalProtocols();
01119 if ( mImap.encryptionButtonGroup->checkedId() == Transport::EnumEncryption::SSL )
01120 supportedAuths = mServerTest->secureProtocols();
01121 if ( mImap.encryptionButtonGroup->checkedId() == Transport::EnumEncryption::TLS )
01122 supportedAuths = mServerTest->tlsProtocols();
01123
01124 mImap.ui.authPlain->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::PLAIN ) );
01125 mImap.ui.authLogin->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::LOGIN ) );
01126 mImap.ui.authCramMd5->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::CRAM_MD5 ) );
01127 mImap.ui.authDigestMd5->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::DIGEST_MD5 ) );
01128 mImap.ui.authNTLM->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::NTLM ) );
01129 mImap.ui.authGSSAPI->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::GSSAPI ) );
01130 mImap.ui.authAnonymous->setEnabled( supportedAuths.contains( Transport::EnumAuthenticationType::ANONYMOUS ) );