00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include "accountdialog.h"
00023
00024 #include <qbuttongroup.h>
00025 #include <qcheckbox.h>
00026 #include <klineedit.h>
00027 #include <qlayout.h>
00028 #include <qtabwidget.h>
00029 #include <qradiobutton.h>
00030 #include <qvalidator.h>
00031 #include <qlabel.h>
00032 #include <qpushbutton.h>
00033 #include <qwhatsthis.h>
00034 #include <qhbox.h>
00035
00036 #include <kfiledialog.h>
00037 #include <klocale.h>
00038 #include <kdebug.h>
00039 #include <kmessagebox.h>
00040 #include <knuminput.h>
00041 #include <kseparator.h>
00042 #include <kapplication.h>
00043 #include <kmessagebox.h>
00044
00045 #include <netdb.h>
00046 #include <netinet/in.h>
00047
00048 #include "sieveconfig.h"
00049 using KMail::SieveConfig;
00050 using KMail::SieveConfigEditor;
00051 #include "kmacctmaildir.h"
00052 #include "kmacctlocal.h"
00053 #include "kmacctmgr.h"
00054 #include "kmacctexppop.h"
00055 #include "kmacctimap.h"
00056 #include "kmacctcachedimap.h"
00057 #include "kmfoldermgr.h"
00058 #include "kmservertest.h"
00059 #include "protocols.h"
00060 #include "globalsettings.h"
00061
00062
00063 #include <cassert>
00064 #include <stdlib.h>
00065
00066 #ifdef HAVE_PATHS_H
00067 #include <paths.h>
00068 #endif
00069
00070 #ifndef _PATH_MAILDIR
00071 #define _PATH_MAILDIR "/var/spool/mail"
00072 #endif
00073
00074 class ProcmailRCParser
00075 {
00076 public:
00077 ProcmailRCParser(QString fileName = QString::null);
00078 ~ProcmailRCParser();
00079
00080 QStringList getLockFilesList() const { return mLockFiles; }
00081 QStringList getSpoolFilesList() const { return mSpoolFiles; }
00082
00083 protected:
00084 void processGlobalLock(const QString&);
00085 void processLocalLock(const QString&);
00086 void processVariableSetting(const QString&, int);
00087 QString expandVars(const QString&);
00088
00089 QFile mProcmailrc;
00090 QTextStream *mStream;
00091 QStringList mLockFiles;
00092 QStringList mSpoolFiles;
00093 QAsciiDict<QString> mVars;
00094 };
00095
00096 ProcmailRCParser::ProcmailRCParser(QString fname)
00097 : mProcmailrc(fname),
00098 mStream(new QTextStream(&mProcmailrc))
00099 {
00100 mVars.setAutoDelete(true);
00101
00102
00103 mVars.insert( "HOME", new QString( QDir::homeDirPath() ) );
00104
00105 if( !fname || fname.isEmpty() ) {
00106 fname = QDir::homeDirPath() + "/.procmailrc";
00107 mProcmailrc.setName(fname);
00108 }
00109
00110 QRegExp lockFileGlobal("^LOCKFILE=", true);
00111 QRegExp lockFileLocal("^:0", true);
00112
00113 if( mProcmailrc.open(IO_ReadOnly) ) {
00114
00115 QString s;
00116
00117 while( !mStream->eof() ) {
00118
00119 s = mStream->readLine().stripWhiteSpace();
00120
00121 if( s[0] == '#' ) continue;
00122
00123 int commentPos = -1;
00124
00125 if( (commentPos = s.find('#')) > -1 ) {
00126
00127 s.truncate(commentPos);
00128 s = s.stripWhiteSpace();
00129 }
00130
00131 if( lockFileGlobal.search(s) != -1 ) {
00132 processGlobalLock(s);
00133 } else if( lockFileLocal.search(s) != -1 ) {
00134 processLocalLock(s);
00135 } else if( int i = s.find('=') ) {
00136 processVariableSetting(s,i);
00137 }
00138 }
00139
00140 }
00141 QString default_Location = getenv("MAIL");
00142
00143 if (default_Location.isNull()) {
00144 default_Location = _PATH_MAILDIR;
00145 default_Location += '/';
00146 default_Location += getenv("USER");
00147 }
00148 if ( !mSpoolFiles.contains(default_Location) )
00149 mSpoolFiles << default_Location;
00150
00151 default_Location = default_Location + ".lock";
00152 if ( !mLockFiles.contains(default_Location) )
00153 mLockFiles << default_Location;
00154 }
00155
00156 ProcmailRCParser::~ProcmailRCParser()
00157 {
00158 delete mStream;
00159 }
00160
00161 void
00162 ProcmailRCParser::processGlobalLock(const QString &s)
00163 {
00164 QString val = expandVars(s.mid(s.find('=') + 1).stripWhiteSpace());
00165 if ( !mLockFiles.contains(val) )
00166 mLockFiles << val;
00167 }
00168
00169 void
00170 ProcmailRCParser::processLocalLock(const QString &s)
00171 {
00172 QString val;
00173 int colonPos = s.findRev(':');
00174
00175 if (colonPos > 0) {
00176 val = s.mid(colonPos + 1).stripWhiteSpace();
00177
00178 if ( val.length() ) {
00179
00180
00181 val = expandVars(val);
00182 if( val[0] != '/' && mVars.find("MAILDIR") )
00183 val.insert(0, *(mVars["MAILDIR"]) + '/');
00184 }
00185
00186 }
00187
00188
00189 QString line, prevLine;
00190 do {
00191 prevLine = line;
00192 line = mStream->readLine().stripWhiteSpace();
00193 } while ( !mStream->eof() && (line[0] == '*' ||
00194 prevLine[prevLine.length() - 1] == '\\' ));
00195
00196 if( line[0] != '!' && line[0] != '|' && line[0] != '{' ) {
00197
00198
00199 line = line.stripWhiteSpace();
00200 line = expandVars(line);
00201
00202
00203 if( line[0] != '/' && mVars.find("MAILDIR") )
00204 line.insert(0, *(mVars["MAILDIR"]) + '/');
00205
00206
00207 if ( !mSpoolFiles.contains(line) )
00208 mSpoolFiles << line;
00209
00210 if( colonPos > 0 && (!val || val.isEmpty()) ) {
00211
00212
00213 val = line;
00214
00215
00216 if( mVars.find("LOCKEXT") )
00217 val += *(mVars["LOCKEXT"]);
00218 else
00219 val += ".lock";
00220 }
00221
00222 if ( !val.isNull() && !mLockFiles.contains(val) ) {
00223 mLockFiles << val;
00224 }
00225 }
00226
00227 }
00228
00229 void
00230 ProcmailRCParser::processVariableSetting(const QString &s, int eqPos)
00231 {
00232 if( eqPos == -1) return;
00233
00234 QString varName = s.left(eqPos),
00235 varValue = expandVars(s.mid(eqPos + 1).stripWhiteSpace());
00236
00237 mVars.insert(varName.latin1(), new QString(varValue));
00238 }
00239
00240 QString
00241 ProcmailRCParser::expandVars(const QString &s)
00242 {
00243 if( s.isEmpty()) return s;
00244
00245 QString expS = s;
00246
00247 QAsciiDictIterator<QString> it( mVars );
00248
00249 while ( it.current() ) {
00250 expS.replace(QString::fromLatin1("$") + it.currentKey(), *it.current());
00251 ++it;
00252 }
00253
00254 return expS;
00255 }
00256
00257
00258
00259 AccountDialog::AccountDialog( const QString & caption, KMAccount *account,
00260 QWidget *parent, const char *name, bool modal )
00261 : KDialogBase( parent, name, modal, caption, Ok|Cancel|Help, Ok, true ),
00262 mAccount( account ),
00263 mServerTest( 0 ),
00264 mCurCapa( AllCapa ),
00265 mCapaNormal( AllCapa ),
00266 mCapaSSL( AllCapa ),
00267 mCapaTLS( AllCapa ),
00268 mSieveConfigEditor( 0 )
00269 {
00270 mValidator = new QRegExpValidator( QRegExp( "[A-Za-z0-9-_:.]*" ), 0 );
00271 setHelp("receiving-mail");
00272
00273 QString accountType = mAccount->type();
00274
00275 if( accountType == "local" )
00276 {
00277 makeLocalAccountPage();
00278 }
00279 else if( accountType == "maildir" )
00280 {
00281 makeMaildirAccountPage();
00282 }
00283 else if( accountType == "pop" )
00284 {
00285 makePopAccountPage();
00286 }
00287 else if( accountType == "imap" )
00288 {
00289 makeImapAccountPage();
00290 }
00291 else if( accountType == "cachedimap" )
00292 {
00293 makeImapAccountPage(true);
00294 }
00295 else
00296 {
00297 QString msg = i18n( "Account type is not supported." );
00298 KMessageBox::information( topLevelWidget(),msg,i18n("Configure Account") );
00299 return;
00300 }
00301
00302 setupSettings();
00303 }
00304
00305 AccountDialog::~AccountDialog()
00306 {
00307 delete mValidator;
00308 mValidator = 0;
00309 delete mServerTest;
00310 mServerTest = 0;
00311 }
00312
00313 void AccountDialog::makeLocalAccountPage()
00314 {
00315 ProcmailRCParser procmailrcParser;
00316 QFrame *page = makeMainWidget();
00317 QGridLayout *topLayout = new QGridLayout( page, 12, 3, 0, spacingHint() );
00318 topLayout->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00319 topLayout->setRowStretch( 11, 10 );
00320 topLayout->setColStretch( 1, 10 );
00321
00322 mLocal.titleLabel = new QLabel( i18n("Account Type: Local Account"), page );
00323 topLayout->addMultiCellWidget( mLocal.titleLabel, 0, 0, 0, 2 );
00324 QFont titleFont( mLocal.titleLabel->font() );
00325 titleFont.setBold( true );
00326 mLocal.titleLabel->setFont( titleFont );
00327 KSeparator *hline = new KSeparator( KSeparator::HLine, page);
00328 topLayout->addMultiCellWidget( hline, 1, 1, 0, 2 );
00329
00330 QLabel *label = new QLabel( i18n("&Name:"), page );
00331 topLayout->addWidget( label, 2, 0 );
00332 mLocal.nameEdit = new KLineEdit( page );
00333 label->setBuddy( mLocal.nameEdit );
00334 topLayout->addWidget( mLocal.nameEdit, 2, 1 );
00335
00336 label = new QLabel( i18n("&Location:"), page );
00337 topLayout->addWidget( label, 3, 0 );
00338 mLocal.locationEdit = new QComboBox( true, page );
00339 label->setBuddy( mLocal.locationEdit );
00340 topLayout->addWidget( mLocal.locationEdit, 3, 1 );
00341 mLocal.locationEdit->insertStringList(procmailrcParser.getSpoolFilesList());
00342
00343 QPushButton *choose = new QPushButton( i18n("Choo&se..."), page );
00344 choose->setAutoDefault( false );
00345 connect( choose, SIGNAL(clicked()), this, SLOT(slotLocationChooser()) );
00346 topLayout->addWidget( choose, 3, 2 );
00347
00348 QButtonGroup *group = new QButtonGroup(i18n("Locking Method"), page );
00349 group->setColumnLayout(0, Qt::Horizontal);
00350 group->layout()->setSpacing( 0 );
00351 group->layout()->setMargin( 0 );
00352 QGridLayout *groupLayout = new QGridLayout( group->layout() );
00353 groupLayout->setAlignment( Qt::AlignTop );
00354 groupLayout->setSpacing( 6 );
00355 groupLayout->setMargin( 11 );
00356
00357 mLocal.lockProcmail = new QRadioButton( i18n("Procmail loc&kfile:"), group);
00358 groupLayout->addWidget(mLocal.lockProcmail, 0, 0);
00359
00360 mLocal.procmailLockFileName = new QComboBox( true, group );
00361 groupLayout->addWidget(mLocal.procmailLockFileName, 0, 1);
00362 mLocal.procmailLockFileName->insertStringList(procmailrcParser.getLockFilesList());
00363 mLocal.procmailLockFileName->setEnabled(false);
00364
00365 QObject::connect(mLocal.lockProcmail, SIGNAL(toggled(bool)),
00366 mLocal.procmailLockFileName, SLOT(setEnabled(bool)));
00367
00368 mLocal.lockMutt = new QRadioButton(
00369 i18n("&Mutt dotlock"), group);
00370 groupLayout->addWidget(mLocal.lockMutt, 1, 0);
00371
00372 mLocal.lockMuttPriv = new QRadioButton(
00373 i18n("M&utt dotlock privileged"), group);
00374 groupLayout->addWidget(mLocal.lockMuttPriv, 2, 0);
00375
00376 mLocal.lockFcntl = new QRadioButton(
00377 i18n("&FCNTL"), group);
00378 groupLayout->addWidget(mLocal.lockFcntl, 3, 0);
00379
00380 mLocal.lockNone = new QRadioButton(
00381 i18n("Non&e (use with care)"), group);
00382 groupLayout->addWidget(mLocal.lockNone, 4, 0);
00383
00384 topLayout->addMultiCellWidget( group, 4, 4, 0, 2 );
00385
00386 #if 0
00387 QHBox* resourceHB = new QHBox( page );
00388 resourceHB->setSpacing( 11 );
00389 mLocal.resourceCheck =
00390 new QCheckBox( i18n( "Account for semiautomatic resource handling" ), resourceHB );
00391 mLocal.resourceClearButton =
00392 new QPushButton( i18n( "Clear" ), resourceHB );
00393 QWhatsThis::add( mLocal.resourceClearButton,
00394 i18n( "Delete all allocations for the resource represented by this account." ) );
00395 mLocal.resourceClearButton->setEnabled( false );
00396 connect( mLocal.resourceCheck, SIGNAL( toggled(bool) ),
00397 mLocal.resourceClearButton, SLOT( setEnabled(bool) ) );
00398 connect( mLocal.resourceClearButton, SIGNAL( clicked() ),
00399 this, SLOT( slotClearResourceAllocations() ) );
00400 mLocal.resourceClearPastButton =
00401 new QPushButton( i18n( "Clear Past" ), resourceHB );
00402 mLocal.resourceClearPastButton->setEnabled( false );
00403 connect( mLocal.resourceCheck, SIGNAL( toggled(bool) ),
00404 mLocal.resourceClearPastButton, SLOT( setEnabled(bool) ) );
00405 QWhatsThis::add( mLocal.resourceClearPastButton,
00406 i18n( "Delete all outdated allocations for the resource represented by this account." ) );
00407 connect( mLocal.resourceClearPastButton, SIGNAL( clicked() ),
00408 this, SLOT( slotClearPastResourceAllocations() ) );
00409 topLayout->addMultiCellWidget( resourceHB, 5, 5, 0, 2 );
00410 #endif
00411
00412 mLocal.excludeCheck =
00413 new QCheckBox( i18n("E&xclude from \"Check Mail\""), page );
00414 topLayout->addMultiCellWidget( mLocal.excludeCheck, 5, 5, 0, 2 );
00415
00416 mLocal.intervalCheck =
00417 new QCheckBox( i18n("Enable &interval mail checking"), page );
00418 topLayout->addMultiCellWidget( mLocal.intervalCheck, 6, 6, 0, 2 );
00419 connect( mLocal.intervalCheck, SIGNAL(toggled(bool)),
00420 this, SLOT(slotEnableLocalInterval(bool)) );
00421 mLocal.intervalLabel = new QLabel( i18n("Check inter&val:"), page );
00422 topLayout->addWidget( mLocal.intervalLabel, 7, 0 );
00423 mLocal.intervalSpin = new KIntNumInput( page );
00424 mLocal.intervalLabel->setBuddy( mLocal.intervalSpin );
00425 mLocal.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(), 10000, 1, FALSE );
00426 mLocal.intervalSpin->setSuffix( i18n(" min") );
00427 mLocal.intervalSpin->setValue( 1 );
00428 topLayout->addWidget( mLocal.intervalSpin, 7, 1 );
00429
00430 label = new QLabel( i18n("&Destination folder:"), page );
00431 topLayout->addWidget( label, 8, 0 );
00432 mLocal.folderCombo = new QComboBox( false, page );
00433 label->setBuddy( mLocal.folderCombo );
00434 topLayout->addWidget( mLocal.folderCombo, 8, 1 );
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448 label = new QLabel( i18n("&Pre-command:"), page );
00449 topLayout->addWidget( label, 9, 0 );
00450 mLocal.precommand = new KLineEdit( page );
00451 label->setBuddy( mLocal.precommand );
00452 topLayout->addWidget( mLocal.precommand, 9, 1 );
00453
00454 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
00455 }
00456
00457 void AccountDialog::makeMaildirAccountPage()
00458 {
00459 ProcmailRCParser procmailrcParser;
00460
00461 QFrame *page = makeMainWidget();
00462 QGridLayout *topLayout = new QGridLayout( page, 11, 3, 0, spacingHint() );
00463 topLayout->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00464 topLayout->setRowStretch( 11, 10 );
00465 topLayout->setColStretch( 1, 10 );
00466
00467 mMaildir.titleLabel = new QLabel( i18n("Account Type: Maildir Account"), page );
00468 topLayout->addMultiCellWidget( mMaildir.titleLabel, 0, 0, 0, 2 );
00469 QFont titleFont( mMaildir.titleLabel->font() );
00470 titleFont.setBold( true );
00471 mMaildir.titleLabel->setFont( titleFont );
00472 QFrame *hline = new QFrame( page );
00473 hline->setFrameStyle( QFrame::Sunken | QFrame::HLine );
00474 topLayout->addMultiCellWidget( hline, 1, 1, 0, 2 );
00475
00476 mMaildir.nameEdit = new KLineEdit( page );
00477 topLayout->addWidget( mMaildir.nameEdit, 2, 1 );
00478 QLabel *label = new QLabel( mMaildir.nameEdit, i18n("&Name:"), page );
00479 topLayout->addWidget( label, 2, 0 );
00480
00481 mMaildir.locationEdit = new QComboBox( true, page );
00482 topLayout->addWidget( mMaildir.locationEdit, 3, 1 );
00483 mMaildir.locationEdit->insertStringList(procmailrcParser.getSpoolFilesList());
00484 label = new QLabel( mMaildir.locationEdit, i18n("&Location:"), page );
00485 topLayout->addWidget( label, 3, 0 );
00486
00487 QPushButton *choose = new QPushButton( i18n("Choo&se..."), page );
00488 choose->setAutoDefault( false );
00489 connect( choose, SIGNAL(clicked()), this, SLOT(slotMaildirChooser()) );
00490 topLayout->addWidget( choose, 3, 2 );
00491
00492 #if 0
00493 QHBox* resourceHB = new QHBox( page );
00494 resourceHB->setSpacing( 11 );
00495 mMaildir.resourceCheck =
00496 new QCheckBox( i18n( "Account for semiautomatic resource handling" ), resourceHB );
00497 mMaildir.resourceClearButton =
00498 new QPushButton( i18n( "Clear" ), resourceHB );
00499 mMaildir.resourceClearButton->setEnabled( false );
00500 connect( mMaildir.resourceCheck, SIGNAL( toggled(bool) ),
00501 mMaildir.resourceClearButton, SLOT( setEnabled(bool) ) );
00502 QWhatsThis::add( mMaildir.resourceClearButton,
00503 i18n( "Delete all allocations for the resource represented by this account." ) );
00504 connect( mMaildir.resourceClearButton, SIGNAL( clicked() ),
00505 this, SLOT( slotClearResourceAllocations() ) );
00506 mMaildir.resourceClearPastButton =
00507 new QPushButton( i18n( "Clear Past" ), resourceHB );
00508 mMaildir.resourceClearPastButton->setEnabled( false );
00509 connect( mMaildir.resourceCheck, SIGNAL( toggled(bool) ),
00510 mMaildir.resourceClearPastButton, SLOT( setEnabled(bool) ) );
00511 QWhatsThis::add( mMaildir.resourceClearPastButton,
00512 i18n( "Delete all outdated allocations for the resource represented by this account." ) );
00513 connect( mMaildir.resourceClearPastButton, SIGNAL( clicked() ),
00514 this, SLOT( slotClearPastResourceAllocations() ) );
00515 topLayout->addMultiCellWidget( resourceHB, 4, 4, 0, 2 );
00516 #endif
00517
00518 mMaildir.excludeCheck =
00519 new QCheckBox( i18n("E&xclude from \"Check Mail\""), page );
00520 topLayout->addMultiCellWidget( mMaildir.excludeCheck, 4, 4, 0, 2 );
00521
00522 mMaildir.intervalCheck =
00523 new QCheckBox( i18n("Enable &interval mail checking"), page );
00524 topLayout->addMultiCellWidget( mMaildir.intervalCheck, 5, 5, 0, 2 );
00525 connect( mMaildir.intervalCheck, SIGNAL(toggled(bool)),
00526 this, SLOT(slotEnableMaildirInterval(bool)) );
00527 mMaildir.intervalLabel = new QLabel( i18n("Check inter&val:"), page );
00528 topLayout->addWidget( mMaildir.intervalLabel, 6, 0 );
00529 mMaildir.intervalSpin = new KIntNumInput( page );
00530 mMaildir.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(), 10000, 1, FALSE );
00531 mMaildir.intervalSpin->setSuffix( i18n(" min") );
00532 mMaildir.intervalSpin->setValue( 1 );
00533 mMaildir.intervalLabel->setBuddy( mMaildir.intervalSpin );
00534 topLayout->addWidget( mMaildir.intervalSpin, 6, 1 );
00535
00536 mMaildir.folderCombo = new QComboBox( false, page );
00537 topLayout->addWidget( mMaildir.folderCombo, 7, 1 );
00538 label = new QLabel( mMaildir.folderCombo,
00539 i18n("&Destination folder:"), page );
00540 topLayout->addWidget( label, 7, 0 );
00541
00542 mMaildir.precommand = new KLineEdit( page );
00543 topLayout->addWidget( mMaildir.precommand, 8, 1 );
00544 label = new QLabel( mMaildir.precommand, i18n("&Pre-command:"), page );
00545 topLayout->addWidget( label, 8, 0 );
00546
00547 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
00548 }
00549
00550
00551 void AccountDialog::makePopAccountPage()
00552 {
00553 QFrame *page = makeMainWidget();
00554 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
00555
00556 mPop.titleLabel = new QLabel( page );
00557 mPop.titleLabel->setText( i18n("Account Type: POP Account") );
00558 QFont titleFont( mPop.titleLabel->font() );
00559 titleFont.setBold( true );
00560 mPop.titleLabel->setFont( titleFont );
00561 topLayout->addWidget( mPop.titleLabel );
00562 KSeparator *hline = new KSeparator( KSeparator::HLine, page);
00563 topLayout->addWidget( hline );
00564
00565 QTabWidget *tabWidget = new QTabWidget(page);
00566 topLayout->addWidget( tabWidget );
00567
00568 QWidget *page1 = new QWidget( tabWidget );
00569 tabWidget->addTab( page1, i18n("&General") );
00570
00571 QGridLayout *grid = new QGridLayout( page1, 16, 2, marginHint(), spacingHint() );
00572 grid->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00573 grid->setRowStretch( 15, 10 );
00574 grid->setColStretch( 1, 10 );
00575
00576 QLabel *label = new QLabel( i18n("&Name:"), page1 );
00577 grid->addWidget( label, 0, 0 );
00578 mPop.nameEdit = new KLineEdit( page1 );
00579 label->setBuddy( mPop.nameEdit );
00580 grid->addWidget( mPop.nameEdit, 0, 1 );
00581
00582 label = new QLabel( i18n("&Login:"), page1 );
00583 QWhatsThis::add( label, i18n("Your Internet Service Provider gave you a <em>user name</em> which is used to authenticate you with their servers. It usually is the first part of your email address (the part before <em>@</em>).") );
00584 grid->addWidget( label, 1, 0 );
00585 mPop.loginEdit = new KLineEdit( page1 );
00586 label->setBuddy( mPop.loginEdit );
00587 grid->addWidget( mPop.loginEdit, 1, 1 );
00588
00589 label = new QLabel( i18n("P&assword:"), page1 );
00590 grid->addWidget( label, 2, 0 );
00591 mPop.passwordEdit = new KLineEdit( page1 );
00592 mPop.passwordEdit->setEchoMode( QLineEdit::Password );
00593 label->setBuddy( mPop.passwordEdit );
00594 grid->addWidget( mPop.passwordEdit, 2, 1 );
00595
00596 label = new QLabel( i18n("Ho&st:"), page1 );
00597 grid->addWidget( label, 3, 0 );
00598 mPop.hostEdit = new KLineEdit( page1 );
00599
00600
00601 mPop.hostEdit->setValidator(mValidator);
00602 label->setBuddy( mPop.hostEdit );
00603 grid->addWidget( mPop.hostEdit, 3, 1 );
00604
00605 label = new QLabel( i18n("&Port:"), page1 );
00606 grid->addWidget( label, 4, 0 );
00607 mPop.portEdit = new KLineEdit( page1 );
00608 mPop.portEdit->setValidator( new QIntValidator(this) );
00609 label->setBuddy( mPop.portEdit );
00610 grid->addWidget( mPop.portEdit, 4, 1 );
00611
00612 mPop.storePasswordCheck =
00613 new QCheckBox( i18n("Sto&re POP password in configuration file"), page1 );
00614 grid->addMultiCellWidget( mPop.storePasswordCheck, 5, 5, 0, 1 );
00615
00616 mPop.leaveOnServerCheck =
00617 new QCheckBox( i18n("Lea&ve fetched messages on the server"), page1 );
00618 connect( mPop.leaveOnServerCheck, SIGNAL( clicked() ),
00619 this, SLOT( slotLeaveOnServerClicked() ) );
00620 grid->addMultiCellWidget( mPop.leaveOnServerCheck, 6, 6, 0, 1 );
00621
00622 #if 0
00623 QHBox* resourceHB = new QHBox( page1 );
00624 resourceHB->setSpacing( 11 );
00625 mPop.resourceCheck =
00626 new QCheckBox( i18n( "Account for semiautomatic resource handling" ), resourceHB );
00627 mPop.resourceClearButton =
00628 new QPushButton( i18n( "Clear" ), resourceHB );
00629 mPop.resourceClearButton->setEnabled( false );
00630 connect( mPop.resourceCheck, SIGNAL( toggled(bool) ),
00631 mPop.resourceClearButton, SLOT( setEnabled(bool) ) );
00632 QWhatsThis::add( mPop.resourceClearButton,
00633 i18n( "Delete all allocations for the resource represented by this account." ) );
00634 connect( mPop.resourceClearButton, SIGNAL( clicked() ),
00635 this, SLOT( slotClearResourceAllocations() ) );
00636 mPop.resourceClearPastButton =
00637 new QPushButton( i18n( "Clear Past" ), resourceHB );
00638 mPop.resourceClearPastButton->setEnabled( false );
00639 connect( mPop.resourceCheck, SIGNAL( toggled(bool) ),
00640 mPop.resourceClearPastButton, SLOT( setEnabled(bool) ) );
00641 QWhatsThis::add( mPop.resourceClearPastButton,
00642 i18n( "Delete all outdated allocations for the resource represented by this account." ) );
00643 connect( mPop.resourceClearPastButton, SIGNAL( clicked() ),
00644 this, SLOT( slotClearPastResourceAllocations() ) );
00645 grid->addMultiCellWidget( resourceHB, 7, 7, 0, 2 );
00646 #endif
00647
00648 mPop.excludeCheck =
00649 new QCheckBox( i18n("E&xclude from \"Check Mail\""), page1 );
00650 grid->addMultiCellWidget( mPop.excludeCheck, 7, 7, 0, 1 );
00651
00652 QHBox * hbox = new QHBox( page1 );
00653 hbox->setSpacing( KDialog::spacingHint() );
00654 mPop.filterOnServerCheck =
00655 new QCheckBox( i18n("&Filter messages if they are greater than"), hbox );
00656 mPop.filterOnServerSizeSpin = new KIntNumInput ( hbox );
00657 mPop.filterOnServerSizeSpin->setEnabled( false );
00658 hbox->setStretchFactor( mPop.filterOnServerSizeSpin, 1 );
00659 mPop.filterOnServerSizeSpin->setRange( 1, 10000000, 100, FALSE );
00660 mPop.filterOnServerSizeSpin->setValue( 50000 );
00661 mPop.filterOnServerSizeSpin->setSuffix( i18n(" byte") );
00662 grid->addMultiCellWidget( hbox, 8, 8, 0, 1 );
00663 connect( mPop.filterOnServerCheck, SIGNAL(toggled(bool)),
00664 mPop.filterOnServerSizeSpin, SLOT(setEnabled(bool)) );
00665 connect( mPop.filterOnServerCheck, SIGNAL( clicked() ),
00666 this, SLOT( slotFilterOnServerClicked() ) );
00667 QString msg = i18n("If you select this option, POP Filters will be used to "
00668 "decide what to do with messages. You can then select "
00669 "to download, delete or keep them on the server." );
00670 QWhatsThis::add( mPop.filterOnServerCheck, msg );
00671 QWhatsThis::add( mPop.filterOnServerSizeSpin, msg );
00672
00673 mPop.intervalCheck =
00674 new QCheckBox( i18n("Enable &interval mail checking"), page1 );
00675 grid->addMultiCellWidget( mPop.intervalCheck, 9, 9, 0, 1 );
00676 connect( mPop.intervalCheck, SIGNAL(toggled(bool)),
00677 this, SLOT(slotEnablePopInterval(bool)) );
00678 mPop.intervalLabel = new QLabel( i18n("Chec&k interval:"), page1 );
00679 grid->addWidget( mPop.intervalLabel, 10, 0 );
00680 mPop.intervalSpin = new KIntNumInput( page1 );
00681 mPop.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(), 10000, 1, FALSE );
00682 mPop.intervalSpin->setSuffix( i18n(" min") );
00683 mPop.intervalSpin->setValue( 1 );
00684 mPop.intervalLabel->setBuddy( mPop.intervalSpin );
00685 grid->addWidget( mPop.intervalSpin, 10, 1 );
00686
00687 label = new QLabel( i18n("Des&tination folder:"), page1 );
00688 grid->addWidget( label, 11, 0 );
00689 mPop.folderCombo = new QComboBox( false, page1 );
00690 label->setBuddy( mPop.folderCombo );
00691 grid->addWidget( mPop.folderCombo, 11, 1 );
00692
00693 label = new QLabel( i18n("Precom&mand:"), page1 );
00694 grid->addWidget( label, 12, 0 );
00695 mPop.precommand = new KLineEdit( page1 );
00696 label->setBuddy(mPop.precommand);
00697 grid->addWidget( mPop.precommand, 12, 1 );
00698
00699 QWidget *page2 = new QWidget( tabWidget );
00700 tabWidget->addTab( page2, i18n("&Extras") );
00701 QVBoxLayout *vlay = new QVBoxLayout( page2, marginHint(), spacingHint() );
00702
00703 mPop.usePipeliningCheck =
00704 new QCheckBox( i18n("&Use pipelining for faster mail download"), page2 );
00705 connect(mPop.usePipeliningCheck, SIGNAL(clicked()),
00706 SLOT(slotPipeliningClicked()));
00707 vlay->addWidget( mPop.usePipeliningCheck );
00708
00709 mPop.encryptionGroup = new QButtonGroup( 1, Qt::Horizontal,
00710 i18n("Encryption"), page2 );
00711 mPop.encryptionNone =
00712 new QRadioButton( i18n("&None"), mPop.encryptionGroup );
00713 mPop.encryptionSSL =
00714 new QRadioButton( i18n("Use &SSL for secure mail download"),
00715 mPop.encryptionGroup );
00716 mPop.encryptionTLS =
00717 new QRadioButton( i18n("Use &TLS for secure mail download"),
00718 mPop.encryptionGroup );
00719 connect(mPop.encryptionGroup, SIGNAL(clicked(int)),
00720 SLOT(slotPopEncryptionChanged(int)));
00721 vlay->addWidget( mPop.encryptionGroup );
00722
00723 mPop.authGroup = new QButtonGroup( 1, Qt::Horizontal,
00724 i18n("Authentication Method"), page2 );
00725 mPop.authUser = new QRadioButton( i18n("Clear te&xt") , mPop.authGroup,
00726 "auth clear text" );
00727 mPop.authLogin = new QRadioButton( i18n("Please translate this "
00728 "authentication method only if you have a good reason", "&LOGIN"),
00729 mPop.authGroup, "auth login" );
00730 mPop.authPlain = new QRadioButton( i18n("Please translate this "
00731 "authentication method only if you have a good reason", "&PLAIN"),
00732 mPop.authGroup, "auth plain" );
00733 mPop.authCRAM_MD5 = new QRadioButton( i18n("CRAM-MD&5"), mPop.authGroup, "auth cram-md5" );
00734 mPop.authDigestMd5 = new QRadioButton( i18n("&DIGEST-MD5"), mPop.authGroup, "auth digest-md5" );
00735 mPop.authAPOP = new QRadioButton( i18n("&APOP"), mPop.authGroup, "auth apop" );
00736 vlay->addWidget( mPop.authGroup );
00737
00738 vlay->addStretch();
00739
00740 QHBoxLayout *buttonLay = new QHBoxLayout( vlay );
00741 mPop.checkCapabilities =
00742 new QPushButton( i18n("Check &What the Server Supports"), page2 );
00743 connect(mPop.checkCapabilities, SIGNAL(clicked()),
00744 SLOT(slotCheckPopCapabilities()));
00745 buttonLay->addStretch();
00746 buttonLay->addWidget( mPop.checkCapabilities );
00747
00748 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
00749 }
00750
00751
00752 void AccountDialog::makeImapAccountPage( bool connected )
00753 {
00754 QFrame *page = makeMainWidget();
00755 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
00756
00757 mImap.titleLabel = new QLabel( page );
00758 if( connected )
00759 mImap.titleLabel->setText( i18n("Account Type: Disconnected IMAP Account") );
00760 else
00761 mImap.titleLabel->setText( i18n("Account Type: IMAP Account") );
00762 QFont titleFont( mImap.titleLabel->font() );
00763 titleFont.setBold( true );
00764 mImap.titleLabel->setFont( titleFont );
00765 topLayout->addWidget( mImap.titleLabel );
00766 KSeparator *hline = new KSeparator( KSeparator::HLine, page);
00767 topLayout->addWidget( hline );
00768
00769 QTabWidget *tabWidget = new QTabWidget(page);
00770 topLayout->addWidget( tabWidget );
00771
00772 QWidget *page1 = new QWidget( tabWidget );
00773 tabWidget->addTab( page1, i18n("&General") );
00774
00775 int row = -1;
00776 QGridLayout *grid = new QGridLayout( page1, 15, 2, marginHint(), spacingHint() );
00777 grid->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00778 grid->setRowStretch( 15, 10 );
00779 grid->setColStretch( 1, 10 );
00780
00781 ++row;
00782 QLabel *label = new QLabel( i18n("&Name:"), page1 );
00783 grid->addWidget( label, row, 0 );
00784 mImap.nameEdit = new KLineEdit( page1 );
00785 label->setBuddy( mImap.nameEdit );
00786 grid->addWidget( mImap.nameEdit, row, 1 );
00787
00788 ++row;
00789 label = new QLabel( i18n("&Login:"), page1 );
00790 QWhatsThis::add( label, i18n("Your Internet Service Provider gave you a <em>user name</em> which is used to authenticate you with their servers. It usually is the first part of your email address (the part before <em>@</em>).") );
00791 grid->addWidget( label, row, 0 );
00792 mImap.loginEdit = new KLineEdit( page1 );
00793 label->setBuddy( mImap.loginEdit );
00794 grid->addWidget( mImap.loginEdit, row, 1 );
00795
00796 ++row;
00797 label = new QLabel( i18n("P&assword:"), page1 );
00798 grid->addWidget( label, row, 0 );
00799 mImap.passwordEdit = new KLineEdit( page1 );
00800 mImap.passwordEdit->setEchoMode( QLineEdit::Password );
00801 label->setBuddy( mImap.passwordEdit );
00802 grid->addWidget( mImap.passwordEdit, row, 1 );
00803
00804 ++row;
00805 label = new QLabel( i18n("Ho&st:"), page1 );
00806 grid->addWidget( label, row, 0 );
00807 mImap.hostEdit = new KLineEdit( page1 );
00808
00809
00810 mImap.hostEdit->setValidator(mValidator);
00811 label->setBuddy( mImap.hostEdit );
00812 grid->addWidget( mImap.hostEdit, row, 1 );
00813
00814 ++row;
00815 label = new QLabel( i18n("&Port:"), page1 );
00816 grid->addWidget( label, row, 0 );
00817 mImap.portEdit = new KLineEdit( page1 );
00818 mImap.portEdit->setValidator( new QIntValidator(this) );
00819 label->setBuddy( mImap.portEdit );
00820 grid->addWidget( mImap.portEdit, row, 1 );
00821
00822 ++row;
00823 label = new QLabel( i18n("Prefix to fol&ders:"), page1 );
00824 grid->addWidget( label, row, 0 );
00825 mImap.prefixEdit = new KLineEdit( page1 );
00826 label->setBuddy( mImap.prefixEdit );
00827 grid->addWidget( mImap.prefixEdit, row, 1 );
00828
00829 ++row;
00830 mImap.storePasswordCheck =
00831 new QCheckBox( i18n("Sto&re IMAP password in configuration file"), page1 );
00832 grid->addMultiCellWidget( mImap.storePasswordCheck, row, row, 0, 1 );
00833
00834 if( !connected ) {
00835 ++row;
00836 mImap.autoExpungeCheck =
00837 new QCheckBox( i18n("Automaticall&y compact folders (expunges deleted messages)"), page1);
00838 grid->addMultiCellWidget( mImap.autoExpungeCheck, row, row, 0, 1 );
00839 }
00840
00841 ++row;
00842 mImap.hiddenFoldersCheck = new QCheckBox( i18n("Sho&w hidden folders"), page1);
00843 grid->addMultiCellWidget( mImap.hiddenFoldersCheck, row, row, 0, 1 );
00844
00845 if( connected ) {
00846 ++row;
00847 mImap.progressDialogCheck = new QCheckBox( i18n("Show &progress window"), page1);
00848 grid->addMultiCellWidget( mImap.progressDialogCheck, row, row, 0, 1 );
00849 }
00850
00851 ++row;
00852 mImap.subscribedFoldersCheck = new QCheckBox(
00853 i18n("Show only s&ubscribed folders"), page1);
00854 grid->addMultiCellWidget( mImap.subscribedFoldersCheck, row, row, 0, 1 );
00855
00856 ++row;
00857 mImap.locallySubscribedFoldersCheck = new QCheckBox(
00858 i18n("Show only &locally subscribed folders"), page1);
00859 grid->addMultiCellWidget( mImap.locallySubscribedFoldersCheck, row, row, 0, 1 );
00860
00861 if ( !connected ) {
00862
00863 ++row;
00864 mImap.loadOnDemandCheck = new QCheckBox(
00865 i18n("Load attach&ments on demand"), page1);
00866 QWhatsThis::add( mImap.loadOnDemandCheck,
00867 i18n("Activate this to load attachments not automatically when you select the email but only when you click on the attachment. This way also big emails are shown instantly.") );
00868 grid->addMultiCellWidget( mImap.loadOnDemandCheck, row, row, 0, 1 );
00869 }
00870
00871 if ( !connected ) {
00872
00873 ++row;
00874 mImap.listOnlyOpenCheck = new QCheckBox(
00875 i18n("List only open folders"), page1);
00876 QWhatsThis::add( mImap.listOnlyOpenCheck,
00877 i18n("Only folders that are open (expanded) in the folder tree are checked for subfolders. Use this if there are many folders on the server.") );
00878 grid->addMultiCellWidget( mImap.listOnlyOpenCheck, row, row, 0, 1 );
00879 }
00880
00881 ++row;
00882 #if 0
00883 QHBox* resourceHB = new QHBox( page1 );
00884 resourceHB->setSpacing( 11 );
00885 mImap.resourceCheck =
00886 new QCheckBox( i18n( "Account for semiautomatic resource handling" ), resourceHB );
00887 mImap.resourceClearButton =
00888 new QPushButton( i18n( "Clear" ), resourceHB );
00889 mImap.resourceClearButton->setEnabled( false );
00890 connect( mImap.resourceCheck, SIGNAL( toggled(bool) ),
00891 mImap.resourceClearButton, SLOT( setEnabled(bool) ) );
00892 QWhatsThis::add( mImap.resourceClearButton,
00893 i18n( "Delete all allocations for the resource represented by this account." ) );
00894 connect( mImap.resourceClearButton, SIGNAL( clicked() ),
00895 this, SLOT( slotClearResourceAllocations() ) );
00896 mImap.resourceClearPastButton =
00897 new QPushButton( i18n( "Clear Past" ), resourceHB );
00898 mImap.resourceClearPastButton->setEnabled( false );
00899 connect( mImap.resourceCheck, SIGNAL( toggled(bool) ),
00900 mImap.resourceClearPastButton, SLOT( setEnabled(bool) ) );
00901 QWhatsThis::add( mImap.resourceClearPastButton,
00902 i18n( "Delete all outdated allocations for the resource represented by this account." ) );
00903 connect( mImap.resourceClearPastButton, SIGNAL( clicked() ),
00904 this, SLOT( slotClearPastResourceAllocations() ) );
00905 grid->addMultiCellWidget( resourceHB, row, row, 0, 2 );
00906 #endif
00907
00908 ++row;
00909 mImap.excludeCheck =
00910 new QCheckBox( i18n("E&xclude from \"Check Mail\""), page1 );
00911 grid->addMultiCellWidget( mImap.excludeCheck, row, row, 0, 1 );
00912
00913 ++row;
00914 mImap.intervalCheck =
00915 new QCheckBox( i18n("Enable &interval mail checking"), page1 );
00916 grid->addMultiCellWidget( mImap.intervalCheck, row, row, 0, 2 );
00917 connect( mImap.intervalCheck, SIGNAL(toggled(bool)),
00918 this, SLOT(slotEnableImapInterval(bool)) );
00919 ++row;
00920 mImap.intervalLabel = new QLabel( i18n("Check inter&val:"), page1 );
00921 grid->addWidget( mImap.intervalLabel, row, 0 );
00922 mImap.intervalSpin = new KIntNumInput( page1 );
00923 mImap.intervalSpin->setRange( GlobalSettings::minimumCheckInterval(), 60, 1, FALSE );
00924 mImap.intervalSpin->setValue( 1 );
00925 mImap.intervalSpin->setSuffix( i18n( " min" ) );
00926 mImap.intervalLabel->setBuddy( mImap.intervalSpin );
00927 grid->addWidget( mImap.intervalSpin, row, 1 );
00928
00929 ++row;
00930 mImap.trashCombo = new KMFolderComboBox( page1 );
00931 mImap.trashCombo->showOutboxFolder( FALSE );
00932 grid->addWidget( mImap.trashCombo, row, 1 );
00933 grid->addWidget( new QLabel( mImap.trashCombo, i18n("&Trash folder:"), page1 ), row, 0 );
00934
00935 QWidget *page2 = new QWidget( tabWidget );
00936 tabWidget->addTab( page2, i18n("S&ecurity") );
00937 QVBoxLayout *vlay = new QVBoxLayout( page2, marginHint(), spacingHint() );
00938
00939 mImap.encryptionGroup = new QButtonGroup( 1, Qt::Horizontal,
00940 i18n("Encryption"), page2 );
00941 mImap.encryptionNone =
00942 new QRadioButton( i18n("&None"), mImap.encryptionGroup );
00943 mImap.encryptionSSL =
00944 new QRadioButton( i18n("Use &SSL for secure mail download"),
00945 mImap.encryptionGroup );
00946 mImap.encryptionTLS =
00947 new QRadioButton( i18n("Use &TLS for secure mail download"),
00948 mImap.encryptionGroup );
00949 connect(mImap.encryptionGroup, SIGNAL(clicked(int)),
00950 SLOT(slotImapEncryptionChanged(int)));
00951 vlay->addWidget( mImap.encryptionGroup );
00952
00953 mImap.authGroup = new QButtonGroup( 1, Qt::Horizontal,
00954 i18n("Authentication Method"), page2 );
00955 mImap.authUser = new QRadioButton( i18n("Clear te&xt"), mImap.authGroup );
00956 mImap.authLogin = new QRadioButton( i18n("Please translate this "
00957 "authentication method only if you have a good reason", "&LOGIN"),
00958 mImap.authGroup );
00959 mImap.authPlain = new QRadioButton( i18n("Please translate this "
00960 "authentication method only if you have a good reason", "&PLAIN"),
00961 mImap.authGroup );
00962 mImap.authCramMd5 = new QRadioButton( i18n("CRAM-MD&5"), mImap.authGroup );
00963 mImap.authDigestMd5 = new QRadioButton( i18n("&DIGEST-MD5"), mImap.authGroup );
00964 mImap.authAnonymous = new QRadioButton( i18n("&Anonymous"), mImap.authGroup );
00965 vlay->addWidget( mImap.authGroup );
00966
00967 vlay->addStretch();
00968
00969 QHBoxLayout *buttonLay = new QHBoxLayout( vlay );
00970 mImap.checkCapabilities =
00971 new QPushButton( i18n("Check &What the Server Supports"), page2 );
00972 connect(mImap.checkCapabilities, SIGNAL(clicked()),
00973 SLOT(slotCheckImapCapabilities()));
00974 buttonLay->addStretch();
00975 buttonLay->addWidget( mImap.checkCapabilities );
00976
00977
00978 mSieveConfigEditor = new SieveConfigEditor( tabWidget );
00979 mSieveConfigEditor->layout()->setMargin( KDialog::marginHint() );
00980 tabWidget->addTab( mSieveConfigEditor, i18n("&Filtering") );
00981
00982 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
00983 }
00984
00985
00986 void AccountDialog::setupSettings()
00987 {
00988 QComboBox *folderCombo = 0;
00989 int interval = mAccount->checkInterval();
00990
00991 QString accountType = mAccount->type();
00992 if( accountType == "local" )
00993 {
00994 ProcmailRCParser procmailrcParser;
00995 KMAcctLocal *acctLocal = dynamic_cast<KMAcctLocal*>(mAccount);
00996
00997 if ( acctLocal->location().isEmpty() )
00998 acctLocal->setLocation( procmailrcParser.getSpoolFilesList().first() );
00999 else
01000 mLocal.locationEdit->insertItem( acctLocal->location() );
01001
01002 if ( acctLocal->procmailLockFileName().isEmpty() )
01003 acctLocal->setProcmailLockFileName( procmailrcParser.getLockFilesList().first() );
01004 else
01005 mLocal.procmailLockFileName->insertItem( acctLocal->procmailLockFileName() );
01006
01007 mLocal.nameEdit->setText( mAccount->name() );
01008 mLocal.nameEdit->setFocus();
01009 mLocal.locationEdit->setEditText( acctLocal->location() );
01010 if (acctLocal->lockType() == mutt_dotlock)
01011 mLocal.lockMutt->setChecked(true);
01012 else if (acctLocal->lockType() == mutt_dotlock_privileged)
01013 mLocal.lockMuttPriv->setChecked(true);
01014 else if (acctLocal->lockType() == procmail_lockfile) {
01015 mLocal.lockProcmail->setChecked(true);
01016 mLocal.procmailLockFileName->setEditText(acctLocal->procmailLockFileName());
01017 } else if (acctLocal->lockType() == FCNTL)
01018 mLocal.lockFcntl->setChecked(true);
01019 else if (acctLocal->lockType() == lock_none)
01020 mLocal.lockNone->setChecked(true);
01021
01022 mLocal.intervalSpin->setValue( QMAX(1, interval) );
01023 mLocal.intervalCheck->setChecked( interval >= 1 );
01024 #if 0
01025 mLocal.resourceCheck->setChecked( mAccount->resource() );
01026 #endif
01027 mLocal.excludeCheck->setChecked( mAccount->checkExclude() );
01028 mLocal.precommand->setText( mAccount->precommand() );
01029
01030 slotEnableLocalInterval( interval >= 1 );
01031 folderCombo = mLocal.folderCombo;
01032 }
01033 else if( accountType == "pop" )
01034 {
01035 KMAcctExpPop &ap = *(KMAcctExpPop*)mAccount;
01036 mPop.nameEdit->setText( mAccount->name() );
01037 mPop.nameEdit->setFocus();
01038 mPop.loginEdit->setText( ap.login() );
01039 mPop.passwordEdit->setText( ap.passwd());
01040 mPop.hostEdit->setText( ap.host() );
01041 mPop.portEdit->setText( QString("%1").arg( ap.port() ) );
01042 mPop.usePipeliningCheck->setChecked( ap.usePipelining() );
01043 mPop.storePasswordCheck->setChecked( ap.storePasswd() );
01044 mPop.leaveOnServerCheck->setChecked( ap.leaveOnServer() );
01045 mPop.filterOnServerCheck->setChecked( ap.filterOnServer() );
01046 mPop.filterOnServerSizeSpin->setValue( ap.filterOnServerCheckSize() );
01047 mPop.intervalCheck->setChecked( interval >= 1 );
01048 mPop.intervalSpin->setValue( QMAX(1, interval) );
01049 #if 0
01050 mPop.resourceCheck->setChecked( mAccount->resource() );
01051 #endif
01052 mPop.excludeCheck->setChecked( mAccount->checkExclude() );
01053 mPop.precommand->setText( ap.precommand() );
01054 if (ap.useSSL())
01055 mPop.encryptionSSL->setChecked( TRUE );
01056 else if (ap.useTLS())
01057 mPop.encryptionTLS->setChecked( TRUE );
01058 else mPop.encryptionNone->setChecked( TRUE );
01059 if (ap.auth() == "LOGIN")
01060 mPop.authLogin->setChecked( TRUE );
01061 else if (ap.auth() == "PLAIN")
01062 mPop.authPlain->setChecked( TRUE );
01063 else if (ap.auth() == "CRAM-MD5")
01064 mPop.authCRAM_MD5->setChecked( TRUE );
01065 else if (ap.auth() == "DIGEST-MD5")
01066 mPop.authDigestMd5->setChecked( TRUE );
01067 else if (ap.auth() == "APOP")
01068 mPop.authAPOP->setChecked( TRUE );
01069 else mPop.authUser->setChecked( TRUE );
01070
01071 slotEnablePopInterval( interval >= 1 );
01072 folderCombo = mPop.folderCombo;
01073 }
01074 else if( accountType == "imap" )
01075 {
01076 KMAcctImap &ai = *(KMAcctImap*)mAccount;
01077 mImap.nameEdit->setText( mAccount->name() );
01078 mImap.nameEdit->setFocus();
01079 mImap.loginEdit->setText( ai.login() );
01080 mImap.passwordEdit->setText( ai.passwd());
01081 mImap.hostEdit->setText( ai.host() );
01082 mImap.portEdit->setText( QString("%1").arg( ai.port() ) );
01083 QString prefix = ai.prefix();
01084 if (!prefix.isEmpty() && prefix[0] == '/') prefix = prefix.mid(1);
01085 if (!prefix.isEmpty() && prefix[prefix.length() - 1] == '/')
01086 prefix = prefix.left(prefix.length() - 1);
01087 mImap.prefixEdit->setText( prefix );
01088 mImap.autoExpungeCheck->setChecked( ai.autoExpunge() );
01089 mImap.hiddenFoldersCheck->setChecked( ai.hiddenFolders() );
01090 mImap.subscribedFoldersCheck->setChecked( ai.onlySubscribedFolders() );
01091 mImap.locallySubscribedFoldersCheck->setChecked( ai.onlyLocallySubscribedFolders() );
01092 mImap.loadOnDemandCheck->setChecked( ai.loadOnDemand() );
01093 mImap.listOnlyOpenCheck->setChecked( ai.listOnlyOpenFolders() );
01094 mImap.storePasswordCheck->setChecked( ai.storePasswd() );
01095 mImap.intervalCheck->setChecked( interval >= 1 );
01096 mImap.intervalSpin->setValue( QMAX(1, interval) );
01097 #if 0
01098 mImap.resourceCheck->setChecked( ai.resource() );
01099 #endif
01100 mImap.excludeCheck->setChecked( ai.checkExclude() );
01101 mImap.intervalCheck->setChecked( interval >= 1 );
01102 mImap.intervalSpin->setValue( QMAX(1, interval) );
01103 QString trashfolder = ai.trash();
01104 if (trashfolder.isEmpty())
01105 trashfolder = kmkernel->trashFolder()->idString();
01106 mImap.trashCombo->setFolder( trashfolder );
01107 slotEnableImapInterval( interval >= 1 );
01108 if (ai.useSSL())
01109 mImap.encryptionSSL->setChecked( TRUE );
01110 else if (ai.useTLS())
01111 mImap.encryptionTLS->setChecked( TRUE );
01112 else mImap.encryptionNone->setChecked( TRUE );
01113 if (ai.auth() == "CRAM-MD5")
01114 mImap.authCramMd5->setChecked( TRUE );
01115 else if (ai.auth() == "DIGEST-MD5")
01116 mImap.authDigestMd5->setChecked( TRUE );
01117 else if (ai.auth() == "ANONYMOUS")
01118 mImap.authAnonymous->setChecked( TRUE );
01119 else if (ai.auth() == "PLAIN")
01120 mImap.authPlain->setChecked( TRUE );
01121 else if (ai.auth() == "LOGIN")
01122 mImap.authLogin->setChecked( TRUE );
01123 else mImap.authUser->setChecked( TRUE );
01124 if ( mSieveConfigEditor )
01125 mSieveConfigEditor->setConfig( ai.sieveConfig() );
01126 }
01127 else if( accountType == "cachedimap" )
01128 {
01129 KMAcctCachedImap &ai = *(KMAcctCachedImap*)mAccount;
01130 mImap.nameEdit->setText( mAccount->name() );
01131 mImap.nameEdit->setFocus();
01132 mImap.loginEdit->setText( ai.login() );
01133 mImap.passwordEdit->setText( ai.passwd());
01134 mImap.hostEdit->setText( ai.host() );
01135 mImap.portEdit->setText( QString("%1").arg( ai.port() ) );
01136 QString prefix = ai.prefix();
01137 if (!prefix.isEmpty() && prefix[0] == '/') prefix = prefix.mid(1);
01138 if (!prefix.isEmpty() && prefix[prefix.length() - 1] == '/')
01139 prefix = prefix.left(prefix.length() - 1);
01140 mImap.prefixEdit->setText( prefix );
01141 mImap.progressDialogCheck->setChecked( ai.isProgressDialogEnabled() );
01142 #if 0
01143 mImap.resourceCheck->setChecked( ai.resource() );
01144 #endif
01145 mImap.hiddenFoldersCheck->setChecked( ai.hiddenFolders() );
01146 mImap.subscribedFoldersCheck->setChecked( ai.onlySubscribedFolders() );
01147 mImap.locallySubscribedFoldersCheck->setChecked( ai.onlyLocallySubscribedFolders() );
01148 mImap.storePasswordCheck->setChecked( ai.storePasswd() );
01149 mImap.intervalCheck->setChecked( interval >= 1 );
01150 mImap.intervalSpin->setValue( QMAX(1, interval) );
01151 mImap.excludeCheck->setChecked( ai.checkExclude() );
01152 mImap.intervalCheck->setChecked( interval >= 1 );
01153 mImap.intervalSpin->setValue( QMAX(1, interval) );
01154 QString trashfolder = ai.trash();
01155 if (trashfolder.isEmpty())
01156 trashfolder = kmkernel->trashFolder()->idString();
01157 mImap.trashCombo->setFolder( trashfolder );
01158 slotEnableImapInterval( interval >= 1 );
01159 if (ai.useSSL())
01160 mImap.encryptionSSL->setChecked( TRUE );
01161 else if (ai.useTLS())
01162 mImap.encryptionTLS->setChecked( TRUE );
01163 else mImap.encryptionNone->setChecked( TRUE );
01164 if (ai.auth() == "CRAM-MD5")
01165 mImap.authCramMd5->setChecked( TRUE );
01166 else if (ai.auth() == "DIGEST-MD5")
01167 mImap.authDigestMd5->setChecked( TRUE );
01168 else if (ai.auth() == "ANONYMOUS")
01169 mImap.authAnonymous->setChecked( TRUE );
01170 else if (ai.auth() == "PLAIN")
01171 mImap.authPlain->setChecked( TRUE );
01172 else if (ai.auth() == "LOGIN")
01173 mImap.authLogin->setChecked( TRUE );
01174 else mImap.authUser->setChecked( TRUE );
01175 if ( mSieveConfigEditor )
01176 mSieveConfigEditor->setConfig( ai.sieveConfig() );
01177 }
01178 else if( accountType == "maildir" )
01179 {
01180 KMAcctMaildir *acctMaildir = dynamic_cast<KMAcctMaildir*>(mAccount);
01181
01182 mMaildir.nameEdit->setText( mAccount->name() );
01183 mMaildir.nameEdit->setFocus();
01184 mMaildir.locationEdit->setEditText( acctMaildir->location() );
01185
01186 mMaildir.intervalSpin->setValue( QMAX(1, interval) );
01187 mMaildir.intervalCheck->setChecked( interval >= 1 );
01188 #if 0
01189 mMaildir.resourceCheck->setChecked( mAccount->resource() );
01190 #endif
01191 mMaildir.excludeCheck->setChecked( mAccount->checkExclude() );
01192 mMaildir.precommand->setText( mAccount->precommand() );
01193
01194 slotEnableMaildirInterval( interval >= 1 );
01195 folderCombo = mMaildir.folderCombo;
01196 }
01197 else
01198 return;
01199
01200 if (!folderCombo) return;
01201
01202 KMFolderDir *fdir = (KMFolderDir*)&kmkernel->folderMgr()->dir();
01203 KMFolder *acctFolder = mAccount->folder();
01204 if( acctFolder == 0 )
01205 {
01206 acctFolder = (KMFolder*)fdir->first();
01207 }
01208 if( acctFolder == 0 )
01209 {
01210 folderCombo->insertItem( i18n("<none>") );
01211 }
01212 else
01213 {
01214 uint i = 0;
01215 int curIndex = -1;
01216 kmkernel->folderMgr()->createI18nFolderList(&mFolderNames, &mFolderList);
01217 while (i < mFolderNames.count())
01218 {
01219 QValueList<QGuardedPtr<KMFolder> >::Iterator it = mFolderList.at(i);
01220 KMFolder *folder = *it;
01221 if (folder->isSystemFolder())
01222 {
01223 mFolderList.remove(it);
01224 mFolderNames.remove(mFolderNames.at(i));
01225 } else {
01226 if (folder == acctFolder) curIndex = i;
01227 i++;
01228 }
01229 }
01230 mFolderNames.prepend(i18n("inbox"));
01231 mFolderList.prepend(kmkernel->inboxFolder());
01232 folderCombo->insertStringList(mFolderNames);
01233 folderCombo->setCurrentItem(curIndex + 1);
01234
01235
01236 if (folderCombo->count() == 0)
01237 folderCombo->insertItem( i18n("inbox") );
01238 }
01239 }
01240
01241
01242 void AccountDialog::slotLeaveOnServerClicked()
01243 {
01244 if ( !( mCurCapa & UIDL ) && mPop.leaveOnServerCheck->isChecked() ) {
01245 KMessageBox::information( topLevelWidget(),
01246 i18n("The server does not seem to support unique "
01247 "message numbers, but this is a "
01248 "requirement for leaving messages on the "
01249 "server.\n"
01250 "Since some servers do not correctly "
01251 "announce their capabilities you still "
01252 "have the possibility to turn leaving "
01253 "fetched messages on the server on.") );
01254 }
01255 }
01256
01257 void AccountDialog::slotFilterOnServerClicked()
01258 {
01259 if ( !( mCurCapa & TOP ) && mPop.filterOnServerCheck->isChecked() ) {
01260 KMessageBox::information( topLevelWidget(),
01261 i18n("The server does not seem to support "
01262 "fetching message headers, but this is a "
01263 "requirement for filtering messages on the "
01264 "server.\n"
01265 "Since some servers do not correctly "
01266 "announce their capabilities you still "
01267 "have the possibility to turn filtering "
01268 "messages on the server on.") );
01269 }
01270 }
01271
01272 void AccountDialog::slotPipeliningClicked()
01273 {
01274 if (mPop.usePipeliningCheck->isChecked())
01275 KMessageBox::information( topLevelWidget(),
01276 i18n("Please note that this feature can cause some POP3 servers "
01277 "that do not support pipelining to send corrupted mail;\n"
01278 "this is configurable, though, because some servers support pipelining "
01279 "but do not announce their capabilities. To check whether your POP3 server "
01280 "announces pipelining support use the \"Check What the Server "
01281 "Supports\" button at the bottom of the dialog;\n"
01282 "if your server does not announce it, but you want more speed, then "
01283 "you should do some testing first by sending yourself a batch "
01284 "of mail and downloading it."), QString::null,
01285 "pipelining");
01286 }
01287
01288
01289 void AccountDialog::slotPopEncryptionChanged(int id)
01290 {
01291 kdDebug(5006) << "slotPopEncryptionChanged( " << id << " )" << endl;
01292
01293 if ( id == SSL || mPop.portEdit->text() == "995" )
01294 mPop.portEdit->setText( ( id == SSL ) ? "995" : "110" );
01295
01296
01297 mCurCapa = ( id == TLS ) ? mCapaTLS
01298 : ( id == SSL ) ? mCapaSSL
01299 : mCapaNormal;
01300 enablePopFeatures( mCurCapa );
01301 const QButton *old = mPop.authGroup->selected();
01302 if ( !old->isEnabled() )
01303 checkHighest( mPop.authGroup );
01304 }
01305
01306
01307 void AccountDialog::slotImapEncryptionChanged(int id)
01308 {
01309 kdDebug(5006) << "slotImapEncryptionChanged( " << id << " )" << endl;
01310
01311 if ( id == SSL || mImap.portEdit->text() == "993" )
01312 mImap.portEdit->setText( ( id == SSL ) ? "993" : "143" );
01313
01314
01315 int authMethods = ( id == TLS ) ? mCapaTLS
01316 : ( id == SSL ) ? mCapaSSL
01317 : mCapaNormal;
01318 enableImapAuthMethods( authMethods );
01319 QButton *old = mImap.authGroup->selected();
01320 if ( !old->isEnabled() )
01321 checkHighest( mImap.authGroup );
01322 }
01323
01324
01325 void AccountDialog::slotCheckPopCapabilities()
01326 {
01327 if ( mPop.hostEdit->text().isEmpty() || mPop.portEdit->text().isEmpty() )
01328 {
01329 KMessageBox::sorry( this, i18n( "Please specify a server and port on "
01330 "the General tab first." ) );
01331 return;
01332 }
01333 delete mServerTest;
01334 mServerTest = new KMServerTest(POP_PROTOCOL, mPop.hostEdit->text(),
01335 mPop.portEdit->text().toInt());
01336 connect( mServerTest, SIGNAL( capabilities( const QStringList &,
01337 const QStringList & ) ),
01338 this, SLOT( slotPopCapabilities( const QStringList &,
01339 const QStringList & ) ) );
01340 mPop.checkCapabilities->setEnabled(FALSE);
01341 }
01342
01343
01344 void AccountDialog::slotCheckImapCapabilities()
01345 {
01346 if ( mImap.hostEdit->text().isEmpty() || mImap.portEdit->text().isEmpty() )
01347 {
01348 KMessageBox::sorry( this, i18n( "Please specify a server and port on "
01349 "the General tab first." ) );
01350 return;
01351 }
01352 delete mServerTest;
01353 mServerTest = new KMServerTest(IMAP_PROTOCOL, mImap.hostEdit->text(),
01354 mImap.portEdit->text().toInt());
01355 connect( mServerTest, SIGNAL( capabilities( const QStringList &,
01356 const QStringList & ) ),
01357 this, SLOT( slotImapCapabilities( const QStringList &,
01358 const QStringList & ) ) );
01359 mImap.checkCapabilities->setEnabled(FALSE);
01360 }
01361
01362
01363 unsigned int AccountDialog::popCapabilitiesFromStringList( const QStringList & l )
01364 {
01365 unsigned int capa = 0;
01366 for ( QStringList::const_iterator it = l.begin() ; it != l.end() ; ++it ) {
01367 QString cur = (*it).upper();
01368 if ( cur == "PLAIN" )
01369 capa |= Plain;
01370 else if ( cur == "LOGIN" )
01371 capa |= Login;
01372 else if ( cur == "CRAM-MD5" )
01373 capa |= CRAM_MD5;
01374 else if ( cur == "DIGEST-MD5" )
01375 capa |= Digest_MD5;
01376 else if ( cur == "APOP" )
01377 capa |= APOP;
01378 else if ( cur == "PIPELINING" )
01379 capa |= Pipelining;
01380 else if ( cur == "TOP" )
01381 capa |= TOP;
01382 else if ( cur == "UIDL" )
01383 capa |= UIDL;
01384 else if ( cur == "STLS" )
01385 capa |= STLS;
01386 }
01387 return capa;
01388 }
01389
01390
01391 void AccountDialog::slotPopCapabilities( const QStringList & capaNormal,
01392 const QStringList & capaSSL )
01393 {
01394 mPop.checkCapabilities->setEnabled( true );
01395 mCapaNormal = popCapabilitiesFromStringList( capaNormal );
01396 if ( mCapaNormal & STLS )
01397 mCapaTLS = mCapaNormal;
01398 else
01399 mCapaTLS = 0;
01400 mCapaSSL = popCapabilitiesFromStringList( capaSSL );
01401 kdDebug(5006) << "mCapaNormal = " << mCapaNormal
01402 << "; mCapaSSL = " << mCapaSSL
01403 << "; mCapaTLS = " << mCapaTLS << endl;
01404 mPop.encryptionNone->setEnabled( !capaNormal.isEmpty() );
01405 mPop.encryptionSSL->setEnabled( !capaSSL.isEmpty() );
01406 mPop.encryptionTLS->setEnabled( mCapaTLS != 0 );
01407 checkHighest( mPop.encryptionGroup );
01408 delete mServerTest;
01409 mServerTest = 0;
01410 }
01411
01412
01413 void AccountDialog::enablePopFeatures( unsigned int capa )
01414 {
01415 kdDebug(5006) << "enablePopFeatures( " << capa << " )" << endl;
01416 mPop.authPlain->setEnabled( capa & Plain );
01417 mPop.authLogin->setEnabled( capa & Login );
01418 mPop.authCRAM_MD5->setEnabled( capa & CRAM_MD5 );
01419 mPop.authDigestMd5->setEnabled( capa & Digest_MD5 );
01420 mPop.authAPOP->setEnabled( capa & APOP );
01421 if ( !( capa & Pipelining ) && mPop.usePipeliningCheck->isChecked() ) {
01422 mPop.usePipeliningCheck->setChecked( false );
01423 KMessageBox::information( topLevelWidget(),
01424 i18n("The server does not seem to support "
01425 "pipelining; therefore, this option has "
01426 "been disabled.\n"
01427 "Since some servers do not correctly "
01428 "announce their capabilities you still "
01429 "have the possibility to turn pipelining "
01430 "on. But please note that this feature can "
01431 "cause some POP servers that do not "
01432 "support pipelining to send corrupt "
01433 "messages. So before using this feature "
01434 "with important mail you should first "
01435 "test it by sending yourself a larger "
01436 "number of test messages which you all "
01437 "download in one go from the POP "
01438 "server.") );
01439 }
01440 if ( !( capa & UIDL ) && mPop.leaveOnServerCheck->isChecked() ) {
01441 mPop.leaveOnServerCheck->setChecked( false );
01442 KMessageBox::information( topLevelWidget(),
01443 i18n("The server does not seem to support unique "
01444 "message numbers, but this is a "
01445 "requirement for leaving messages on the "
01446 "server; therefore, this option has been "
01447 "disabled.\n"
01448 "Since some servers do not correctly "
01449 "announce their capabilities you still "
01450 "have the possibility to turn leaving "
01451 "fetched messages on the server on.") );
01452 }
01453 if ( !( capa & TOP ) && mPop.filterOnServerCheck->isChecked() ) {
01454 mPop.filterOnServerCheck->setChecked( false );
01455 KMessageBox::information( topLevelWidget(),
01456 i18n("The server does not seem to support "
01457 "fetching message headers, but this is a "
01458 "requirement for filtering messages on the "
01459 "server; therefore, this option has been "
01460 "disabled.\n"
01461 "Since some servers do not correctly "
01462 "announce their capabilities you still "
01463 "have the possibility to turn filtering "
01464 "messages on the server on.") );
01465 }
01466 }
01467
01468
01469 unsigned int AccountDialog::imapCapabilitiesFromStringList( const QStringList & l )
01470 {
01471 unsigned int capa = 0;
01472 for ( QStringList::const_iterator it = l.begin() ; it != l.end() ; ++it ) {
01473 QString cur = (*it).upper();
01474 if ( cur == "AUTH=PLAIN" )
01475 capa |= Plain;
01476 else if ( cur == "AUTH=LOGIN" )
01477 capa |= Login;
01478 else if ( cur == "AUTH=CRAM-MD5" )
01479 capa |= CRAM_MD5;
01480 else if ( cur == "AUTH=DIGEST-MD5" )
01481 capa |= Digest_MD5;
01482 else if ( cur == "AUTH=ANONYMOUS" )
01483 capa |= Anonymous;
01484 else if ( cur == "STARTTLS" )
01485 capa |= STARTTLS;
01486 }
01487 return capa;
01488 }
01489
01490
01491 void AccountDialog::slotImapCapabilities( const QStringList & capaNormal,
01492 const QStringList & capaSSL )
01493 {
01494 mImap.checkCapabilities->setEnabled( true );
01495 mCapaNormal = imapCapabilitiesFromStringList( capaNormal );
01496 if ( mCapaNormal & STARTTLS )
01497 mCapaTLS = mCapaNormal;
01498 else
01499 mCapaTLS = 0;
01500 mCapaSSL = imapCapabilitiesFromStringList( capaSSL );
01501 kdDebug(5006) << "mCapaNormal = " << mCapaNormal
01502 << "; mCapaSSL = " << mCapaSSL
01503 << "; mCapaTLS = " << mCapaTLS << endl;
01504 mImap.encryptionNone->setEnabled( !capaNormal.isEmpty() );
01505 mImap.encryptionSSL->setEnabled( !capaSSL.isEmpty() );
01506 mImap.encryptionTLS->setEnabled( mCapaTLS != 0 );
01507 checkHighest( mImap.encryptionGroup );
01508 delete mServerTest;
01509 mServerTest = 0;
01510 }
01511
01512
01513 void AccountDialog::enableImapAuthMethods( unsigned int capa )
01514 {
01515 kdDebug(5006) << "enableImapAuthMethods( " << capa << " )" << endl;
01516 mImap.authPlain->setEnabled( capa & Plain );
01517 mImap.authLogin->setEnabled( capa & Login );
01518 mImap.authCramMd5->setEnabled( capa & CRAM_MD5 );
01519 mImap.authDigestMd5->setEnabled( capa & Digest_MD5 );
01520 mImap.authAnonymous->setEnabled( capa & Anonymous );
01521 }
01522
01523
01524 void AccountDialog::checkHighest( QButtonGroup *btnGroup )
01525 {
01526 kdDebug(5006) << "checkHighest( " << btnGroup << " )" << endl;
01527 for ( int i = btnGroup->count() - 1; i >= 0 ; --i ) {
01528 QButton * btn = btnGroup->find( i );
01529 if ( btn && btn->isEnabled() ) {
01530 btn->animateClick();
01531 return;
01532 }
01533 }
01534 }
01535
01536
01537 void AccountDialog::slotOk()
01538 {
01539 saveSettings();
01540 accept();
01541 }
01542
01543
01544 void AccountDialog::saveSettings()
01545 {
01546 QString accountType = mAccount->type();
01547 if( accountType == "local" )
01548 {
01549 KMAcctLocal *acctLocal = dynamic_cast<KMAcctLocal*>(mAccount);
01550
01551 if (acctLocal) {
01552 mAccount->setName( mLocal.nameEdit->text() );
01553 acctLocal->setLocation( mLocal.locationEdit->currentText() );
01554 if (mLocal.lockMutt->isChecked())
01555 acctLocal->setLockType(mutt_dotlock);
01556 else if (mLocal.lockMuttPriv->isChecked())
01557 acctLocal->setLockType(mutt_dotlock_privileged);
01558 else if (mLocal.lockProcmail->isChecked()) {
01559 acctLocal->setLockType(procmail_lockfile);
01560 acctLocal->setProcmailLockFileName(mLocal.procmailLockFileName->currentText());
01561 }
01562 else if (mLocal.lockNone->isChecked())
01563 acctLocal->setLockType(lock_none);
01564 else acctLocal->setLockType(FCNTL);
01565 }
01566
01567 mAccount->setCheckInterval( mLocal.intervalCheck->isChecked() ?
01568 mLocal.intervalSpin->value() : 0 );
01569 #if 0
01570 mAccount->setResource( mLocal.resourceCheck->isChecked() );
01571 #endif
01572 mAccount->setCheckExclude( mLocal.excludeCheck->isChecked() );
01573
01574 mAccount->setPrecommand( mLocal.precommand->text() );
01575
01576 mAccount->setFolder( *mFolderList.at(mLocal.folderCombo->currentItem()) );
01577
01578 }
01579 else if( accountType == "pop" )
01580 {
01581 mAccount->setName( mPop.nameEdit->text() );
01582 mAccount->setCheckInterval( mPop.intervalCheck->isChecked() ?
01583 mPop.intervalSpin->value() : 0 );
01584 #if 0
01585 mAccount->setResource( mPop.resourceCheck->isChecked() );
01586 #endif
01587 mAccount->setCheckExclude( mPop.excludeCheck->isChecked() );
01588
01589 mAccount->setFolder( *mFolderList.at(mPop.folderCombo->currentItem()) );
01590
01591 KMAcctExpPop &epa = *(KMAcctExpPop*)mAccount;
01592 epa.setHost( mPop.hostEdit->text().stripWhiteSpace() );
01593 epa.setPort( mPop.portEdit->text().toInt() );
01594 epa.setLogin( mPop.loginEdit->text().stripWhiteSpace() );
01595 epa.setPasswd( mPop.passwordEdit->text(), true );
01596 epa.setUsePipelining( mPop.usePipeliningCheck->isChecked() );
01597 epa.setStorePasswd( mPop.storePasswordCheck->isChecked() );
01598 epa.setPasswd( mPop.passwordEdit->text(), epa.storePasswd() );
01599 epa.setLeaveOnServer( mPop.leaveOnServerCheck->isChecked() );
01600 epa.setFilterOnServer( mPop.filterOnServerCheck->isChecked() );
01601 epa.setFilterOnServerCheckSize (mPop.filterOnServerSizeSpin->value() );
01602 epa.setPrecommand( mPop.precommand->text() );
01603 epa.setUseSSL( mPop.encryptionSSL->isChecked() );
01604 epa.setUseTLS( mPop.encryptionTLS->isChecked() );
01605 if (mPop.authUser->isChecked())
01606 epa.setAuth("USER");
01607 else if (mPop.authLogin->isChecked())
01608 epa.setAuth("LOGIN");
01609 else if (mPop.authPlain->isChecked())
01610 epa.setAuth("PLAIN");
01611 else if (mPop.authCRAM_MD5->isChecked())
01612 epa.setAuth("CRAM-MD5");
01613 else if (mPop.authDigestMd5->isChecked())
01614 epa.setAuth("DIGEST-MD5");
01615 else if (mPop.authAPOP->isChecked())
01616 epa.setAuth("APOP");
01617 else epa.setAuth("AUTO");
01618 }
01619 else if( accountType == "imap" )
01620 {
01621 mAccount->setName( mImap.nameEdit->text() );
01622 mAccount->setCheckInterval( mImap.intervalCheck->isChecked() ?
01623 mImap.intervalSpin->value() : 0 );
01624 #if 0
01625 mAccount->setResource( mImap.resourceCheck->isChecked() );
01626 #endif
01627 mAccount->setCheckExclude( mImap.excludeCheck->isChecked() );
01628 mAccount->setFolder( kmkernel->imapFolderMgr()->findById(mAccount->id()) );
01629
01630 KMAcctImap &epa = *(KMAcctImap*)mAccount;
01631 epa.setHost( mImap.hostEdit->text().stripWhiteSpace() );
01632 epa.setPort( mImap.portEdit->text().toInt() );
01633 QString prefix = "/" + mImap.prefixEdit->text();
01634 if (prefix[prefix.length() - 1] != '/') prefix += "/";
01635 epa.setPrefix( prefix );
01636 epa.setLogin( mImap.loginEdit->text().stripWhiteSpace() );
01637 epa.setAutoExpunge( mImap.autoExpungeCheck->isChecked() );
01638 epa.setHiddenFolders( mImap.hiddenFoldersCheck->isChecked() );
01639 epa.setOnlySubscribedFolders( mImap.subscribedFoldersCheck->isChecked() );
01640 epa.setOnlyLocallySubscribedFolders( mImap.locallySubscribedFoldersCheck->isChecked() );
01641 epa.setLoadOnDemand( mImap.loadOnDemandCheck->isChecked() );
01642 epa.setListOnlyOpenFolders( mImap.listOnlyOpenCheck->isChecked() );
01643 epa.setStorePasswd( mImap.storePasswordCheck->isChecked() );
01644 epa.setPasswd( mImap.passwordEdit->text(), epa.storePasswd() );
01645 KMFolder *t = mImap.trashCombo->getFolder();
01646 if ( t )
01647 epa.setTrash( mImap.trashCombo->getFolder()->idString() );
01648 else
01649 epa.setTrash( kmkernel->trashFolder()->idString() );
01650 #if 0
01651 epa.setResource( mImap.resourceCheck->isChecked() );
01652 #endif
01653 epa.setCheckExclude( mImap.excludeCheck->isChecked() );
01654 epa.setUseSSL( mImap.encryptionSSL->isChecked() );
01655 epa.setUseTLS( mImap.encryptionTLS->isChecked() );
01656 if (mImap.authCramMd5->isChecked())
01657 epa.setAuth("CRAM-MD5");
01658 else if (mImap.authDigestMd5->isChecked())
01659 epa.setAuth("DIGEST-MD5");
01660 else if (mImap.authAnonymous->isChecked())
01661 epa.setAuth("ANONYMOUS");
01662 else if (mImap.authLogin->isChecked())
01663 epa.setAuth("LOGIN");
01664 else if (mImap.authPlain->isChecked())
01665 epa.setAuth("PLAIN");
01666 else epa.setAuth("*");
01667 if ( mSieveConfigEditor )
01668 epa.setSieveConfig( mSieveConfigEditor->config() );
01669 }
01670 else if( accountType == "cachedimap" )
01671 {
01672 mAccount->setName( mImap.nameEdit->text() );
01673 mAccount->setCheckInterval( mImap.intervalCheck->isChecked() ?
01674 mImap.intervalSpin->value() : 0 );
01675 #if 0
01676 mAccount->setResource( mImap.resourceCheck->isChecked() );
01677 #endif
01678 mAccount->setCheckExclude( mImap.excludeCheck->isChecked() );
01679
01680 mAccount->setFolder( kmkernel->dimapFolderMgr()->findById(mAccount->id()) );
01681 kdDebug(5006) << mAccount->name() << endl;
01682
01683
01684 KMAcctCachedImap &epa = *(KMAcctCachedImap*)mAccount;
01685 epa.setHost( mImap.hostEdit->text().stripWhiteSpace() );
01686 epa.setPort( mImap.portEdit->text().toInt() );
01687 QString prefix = "/" + mImap.prefixEdit->text();
01688 if (prefix[prefix.length() - 1] != '/') prefix += "/";
01689 epa.setPrefix( prefix );
01690 epa.setLogin( mImap.loginEdit->text().stripWhiteSpace() );
01691 epa.setProgressDialogEnabled( mImap.progressDialogCheck->isChecked() );
01692 epa.setHiddenFolders( mImap.hiddenFoldersCheck->isChecked() );
01693 epa.setOnlySubscribedFolders( mImap.subscribedFoldersCheck->isChecked() );
01694 epa.setOnlyLocallySubscribedFolders( mImap.locallySubscribedFoldersCheck->isChecked() );
01695 epa.setStorePasswd( mImap.storePasswordCheck->isChecked() );
01696 epa.setPasswd( mImap.passwordEdit->text(), epa.storePasswd() );
01697 KMFolder *t = mImap.trashCombo->getFolder();
01698 if ( t )
01699 epa.setTrash( mImap.trashCombo->getFolder()->idString() );
01700 else
01701 epa.setTrash( kmkernel->trashFolder()->idString() );
01702 #if 0
01703 epa.setResource( mImap.resourceCheck->isChecked() );
01704 #endif
01705 epa.setCheckExclude( mImap.excludeCheck->isChecked() );
01706 epa.setUseSSL( mImap.encryptionSSL->isChecked() );
01707 epa.setUseTLS( mImap.encryptionTLS->isChecked() );
01708 if (mImap.authCramMd5->isChecked())
01709 epa.setAuth("CRAM-MD5");
01710 else if (mImap.authDigestMd5->isChecked())
01711 epa.setAuth("DIGEST-MD5");
01712 else if (mImap.authAnonymous->isChecked())
01713 epa.setAuth("ANONYMOUS");
01714 else if (mImap.authLogin->isChecked())
01715 epa.setAuth("LOGIN");
01716 else if (mImap.authPlain->isChecked())
01717 epa.setAuth("PLAIN");
01718 else epa.setAuth("*");
01719 if ( mSieveConfigEditor )
01720 epa.setSieveConfig( mSieveConfigEditor->config() );
01721 }
01722 else if( accountType == "maildir" )
01723 {
01724 KMAcctMaildir *acctMaildir = dynamic_cast<KMAcctMaildir*>(mAccount);
01725
01726 if (acctMaildir) {
01727 mAccount->setName( mMaildir.nameEdit->text() );
01728 acctMaildir->setLocation( mMaildir.locationEdit->currentText() );
01729
01730 KMFolder *targetFolder = *mFolderList.at(mMaildir.folderCombo->currentItem());
01731 if ( targetFolder->location() == acctMaildir->location() ) {
01732
01733
01734
01735
01736
01737 targetFolder = kmkernel->inboxFolder();
01738 }
01739 mAccount->setFolder( targetFolder );
01740 }
01741 mAccount->setCheckInterval( mMaildir.intervalCheck->isChecked() ?
01742 mMaildir.intervalSpin->value() : 0 );
01743 #if 0
01744 mAccount->setResource( mMaildir.resourceCheck->isChecked() );
01745 #endif
01746 mAccount->setCheckExclude( mMaildir.excludeCheck->isChecked() );
01747
01748 mAccount->setPrecommand( mMaildir.precommand->text() );
01749 }
01750
01751 kmkernel->acctMgr()->writeConfig(TRUE);
01752
01753
01754
01755
01756 KMAccount* newAcct = kmkernel->acctMgr()->find(mAccount->id());
01757 if (newAcct)
01758 {
01759 if( accountType == "local" ) {
01760 newAcct->setFolder( *mFolderList.at(mLocal.folderCombo->currentItem()), true );
01761 } else if ( accountType == "pop" ) {
01762 newAcct->setFolder( *mFolderList.at(mPop.folderCombo->currentItem()), true );
01763 } else if ( accountType == "maildir" ) {
01764 newAcct->setFolder( *mFolderList.at(mMaildir.folderCombo->currentItem()), true );
01765 } else if ( accountType == "imap" ) {
01766 newAcct->setFolder( kmkernel->imapFolderMgr()->findById(mAccount->id()), true );
01767 } else if ( accountType == "cachedimap" ) {
01768 newAcct->setFolder( kmkernel->dimapFolderMgr()->findById(mAccount->id()), true );
01769 }
01770 }
01771 }
01772
01773
01774 void AccountDialog::slotLocationChooser()
01775 {
01776 static QString directory( "/" );
01777
01778 KFileDialog dialog( directory, QString::null, this, 0, true );
01779 dialog.setCaption( i18n("Choose Location") );
01780
01781 bool result = dialog.exec();
01782 if( result == false )
01783 {
01784 return;
01785 }
01786
01787 KURL url = dialog.selectedURL();
01788 if( url.isEmpty() )
01789 {
01790 return;
01791 }
01792 if( url.isLocalFile() == false )
01793 {
01794 KMessageBox::sorry( 0, i18n( "Only local files are currently supported." ) );
01795 return;
01796 }
01797
01798 mLocal.locationEdit->setEditText( url.path() );
01799 directory = url.directory();
01800 }
01801
01802 void AccountDialog::slotMaildirChooser()
01803 {
01804 static QString directory( "/" );
01805
01806 QString dir = KFileDialog::getExistingDirectory(directory, this, i18n("Choose Location"));
01807
01808 if( dir.isEmpty() )
01809 return;
01810
01811 mMaildir.locationEdit->setEditText( dir );
01812 directory = dir;
01813 }
01814
01815
01816 void AccountDialog::slotEnablePopInterval( bool state )
01817 {
01818 mPop.intervalSpin->setEnabled( state );
01819 mPop.intervalLabel->setEnabled( state );
01820 }
01821
01822 void AccountDialog::slotEnableImapInterval( bool state )
01823 {
01824 mImap.intervalSpin->setEnabled( state );
01825 mImap.intervalLabel->setEnabled( state );
01826 }
01827
01828 void AccountDialog::slotEnableLocalInterval( bool state )
01829 {
01830 mLocal.intervalSpin->setEnabled( state );
01831 mLocal.intervalLabel->setEnabled( state );
01832 }
01833
01834 void AccountDialog::slotEnableMaildirInterval( bool state )
01835 {
01836 mMaildir.intervalSpin->setEnabled( state );
01837 mMaildir.intervalLabel->setEnabled( state );
01838 }
01839
01840 void AccountDialog::slotFontChanged( void )
01841 {
01842 QString accountType = mAccount->type();
01843 if( accountType == "local" )
01844 {
01845 QFont titleFont( mLocal.titleLabel->font() );
01846 titleFont.setBold( true );
01847 mLocal.titleLabel->setFont(titleFont);
01848 }
01849 else if( accountType == "pop" )
01850 {
01851 QFont titleFont( mPop.titleLabel->font() );
01852 titleFont.setBold( true );
01853 mPop.titleLabel->setFont(titleFont);
01854 }
01855 else if( accountType == "imap" )
01856 {
01857 QFont titleFont( mImap.titleLabel->font() );
01858 titleFont.setBold( true );
01859 mImap.titleLabel->setFont(titleFont);
01860 }
01861 }
01862
01863
01864
01865 #if 0
01866 void AccountDialog::slotClearResourceAllocations()
01867 {
01868 mAccount->clearIntervals();
01869 }
01870
01871
01872 void AccountDialog::slotClearPastResourceAllocations()
01873 {
01874 mAccount->clearOldIntervals();
01875 }
01876 #endif
01877
01878 #include "accountdialog.moc"