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