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 <qlayout.h>
00027 #include <qtabwidget.h>
00028 #include <qradiobutton.h>
00029 #include <qvalidator.h>
00030 #include <qlabel.h>
00031 #include <qpushbutton.h>
00032 #include <qwhatsthis.h>
00033 #include <qhbox.h>
00034 #include <qcombobox.h>
00035 #include <qheader.h>
00036 #include <qtoolbutton.h>
00037 #include <qgrid.h>
00038
00039 #include <kfiledialog.h>
00040 #include <klocale.h>
00041 #include <kdebug.h>
00042 #include <kmessagebox.h>
00043 #include <knuminput.h>
00044 #include <kseparator.h>
00045 #include <kapplication.h>
00046 #include <kmessagebox.h>
00047 #include <kprotocolinfo.h>
00048 #include <kiconloader.h>
00049 #include <kpopupmenu.h>
00050
00051 #include <netdb.h>
00052 #include <netinet/in.h>
00053
00054 #include "sieveconfig.h"
00055 #include "kmacctmaildir.h"
00056 #include "kmacctlocal.h"
00057 #include "accountmanager.h"
00058 #include "popaccount.h"
00059 #include "kmacctimap.h"
00060 #include "kmacctcachedimap.h"
00061 #include "kmfoldermgr.h"
00062 #include "kmservertest.h"
00063 #include "protocols.h"
00064 #include "folderrequester.h"
00065 #include "kmmainwidget.h"
00066 #include "kmfolder.h"
00067 #include "globalsettings.h"
00068
00069 #include <cassert>
00070 #include <stdlib.h>
00071
00072 #ifdef HAVE_PATHS_H
00073 #include <paths.h>
00074 #endif
00075
00076 #ifndef _PATH_MAILDIR
00077 #define _PATH_MAILDIR "/var/spool/mail"
00078 #endif
00079
00080 namespace KMail {
00081
00082 class ProcmailRCParser
00083 {
00084 public:
00085 ProcmailRCParser(QString fileName = QString::null);
00086 ~ProcmailRCParser();
00087
00088 QStringList getLockFilesList() const { return mLockFiles; }
00089 QStringList getSpoolFilesList() const { return mSpoolFiles; }
00090
00091 protected:
00092 void processGlobalLock(const QString&);
00093 void processLocalLock(const QString&);
00094 void processVariableSetting(const QString&, int);
00095 QString expandVars(const QString&);
00096
00097 QFile mProcmailrc;
00098 QTextStream *mStream;
00099 QStringList mLockFiles;
00100 QStringList mSpoolFiles;
00101 QAsciiDict<QString> mVars;
00102 };
00103
00104 ProcmailRCParser::ProcmailRCParser(QString fname)
00105 : mProcmailrc(fname),
00106 mStream(new QTextStream(&mProcmailrc))
00107 {
00108 mVars.setAutoDelete(true);
00109
00110
00111 mVars.insert( "HOME", new QString( QDir::homeDirPath() ) );
00112
00113 if( !fname || fname.isEmpty() ) {
00114 fname = QDir::homeDirPath() + "/.procmailrc";
00115 mProcmailrc.setName(fname);
00116 }
00117
00118 QRegExp lockFileGlobal("^LOCKFILE=", true);
00119 QRegExp lockFileLocal("^:0", true);
00120
00121 if( mProcmailrc.open(IO_ReadOnly) ) {
00122
00123 QString s;
00124
00125 while( !mStream->eof() ) {
00126
00127 s = mStream->readLine().stripWhiteSpace();
00128
00129 if( s[0] == '#' ) continue;
00130
00131 int commentPos = -1;
00132
00133 if( (commentPos = s.find('#')) > -1 ) {
00134
00135 s.truncate(commentPos);
00136 s = s.stripWhiteSpace();
00137 }
00138
00139 if( lockFileGlobal.search(s) != -1 ) {
00140 processGlobalLock(s);
00141 } else if( lockFileLocal.search(s) != -1 ) {
00142 processLocalLock(s);
00143 } else if( int i = s.find('=') ) {
00144 processVariableSetting(s,i);
00145 }
00146 }
00147
00148 }
00149 QString default_Location = getenv("MAIL");
00150
00151 if (default_Location.isNull()) {
00152 default_Location = _PATH_MAILDIR;
00153 default_Location += '/';
00154 default_Location += getenv("USER");
00155 }
00156 if ( !mSpoolFiles.contains(default_Location) )
00157 mSpoolFiles << default_Location;
00158
00159 default_Location = default_Location + ".lock";
00160 if ( !mLockFiles.contains(default_Location) )
00161 mLockFiles << default_Location;
00162 }
00163
00164 ProcmailRCParser::~ProcmailRCParser()
00165 {
00166 delete mStream;
00167 }
00168
00169 void
00170 ProcmailRCParser::processGlobalLock(const QString &s)
00171 {
00172 QString val = expandVars(s.mid(s.find('=') + 1).stripWhiteSpace());
00173 if ( !mLockFiles.contains(val) )
00174 mLockFiles << val;
00175 }
00176
00177 void
00178 ProcmailRCParser::processLocalLock(const QString &s)
00179 {
00180 QString val;
00181 int colonPos = s.findRev(':');
00182
00183 if (colonPos > 0) {
00184 val = s.mid(colonPos + 1).stripWhiteSpace();
00185
00186 if ( val.length() ) {
00187
00188
00189 val = expandVars(val);
00190 if( val[0] != '/' && mVars.find("MAILDIR") )
00191 val.insert(0, *(mVars["MAILDIR"]) + '/');
00192 }
00193
00194 }
00195
00196
00197 QString line, prevLine;
00198 do {
00199 prevLine = line;
00200 line = mStream->readLine().stripWhiteSpace();
00201 } while ( !mStream->eof() && (line[0] == '*' ||
00202 prevLine[prevLine.length() - 1] == '\\' ));
00203
00204 if( line[0] != '!' && line[0] != '|' && line[0] != '{' ) {
00205
00206
00207 line = line.stripWhiteSpace();
00208 line = expandVars(line);
00209
00210
00211 if( line[0] != '/' && mVars.find("MAILDIR") )
00212 line.insert(0, *(mVars["MAILDIR"]) + '/');
00213
00214
00215 if ( !mSpoolFiles.contains(line) )
00216 mSpoolFiles << line;
00217
00218 if( colonPos > 0 && (!val || val.isEmpty()) ) {
00219
00220
00221 val = line;
00222
00223
00224 if( mVars.find("LOCKEXT") )
00225 val += *(mVars["LOCKEXT"]);
00226 else
00227 val += ".lock";
00228 }
00229
00230 if ( !val.isNull() && !mLockFiles.contains(val) ) {
00231 mLockFiles << val;
00232 }
00233 }
00234
00235 }
00236
00237 void
00238 ProcmailRCParser::processVariableSetting(const QString &s, int eqPos)
00239 {
00240 if( eqPos == -1) return;
00241
00242 QString varName = s.left(eqPos),
00243 varValue = expandVars(s.mid(eqPos + 1).stripWhiteSpace());
00244
00245 mVars.insert(varName.latin1(), new QString(varValue));
00246 }
00247
00248 QString
00249 ProcmailRCParser::expandVars(const QString &s)
00250 {
00251 if( s.isEmpty()) return s;
00252
00253 QString expS = s;
00254
00255 QAsciiDictIterator<QString> it( mVars );
00256
00257 while ( it.current() ) {
00258 expS.replace(QString::fromLatin1("$") + it.currentKey(), *it.current());
00259 ++it;
00260 }
00261
00262 return expS;
00263 }
00264
00265
00266
00267 AccountDialog::AccountDialog( const QString & caption, KMAccount *account,
00268 QWidget *parent, const char *name, bool modal )
00269 : KDialogBase( parent, name, modal, caption, Ok|Cancel|Help, Ok, true ),
00270 mAccount( account ),
00271 mServerTest( 0 ),
00272 mCurCapa( AllCapa ),
00273 mCapaNormal( AllCapa ),
00274 mCapaSSL( AllCapa ),
00275 mCapaTLS( AllCapa ),
00276 mSieveConfigEditor( 0 )
00277 {
00278 mValidator = new QRegExpValidator( QRegExp( "[A-Za-z0-9-_:.]*" ), 0 );
00279 setHelp("receiving-mail");
00280
00281 QString accountType = mAccount->type();
00282
00283 if( accountType == "local" )
00284 {
00285 makeLocalAccountPage();
00286 }
00287 else if( accountType == "maildir" )
00288 {
00289 makeMaildirAccountPage();
00290 }
00291 else if( accountType == "pop" )
00292 {
00293 makePopAccountPage();
00294 }
00295 else if( accountType == "imap" )
00296 {
00297 makeImapAccountPage();
00298 }
00299 else if( accountType == "cachedimap" )
00300 {
00301 makeImapAccountPage(true);
00302 }
00303 else
00304 {
00305 QString msg = i18n( "Account type is not supported." );
00306 KMessageBox::information( topLevelWidget(),msg,i18n("Configure Account") );
00307 return;
00308 }
00309
00310 setupSettings();
00311 }
00312
00313 AccountDialog::~AccountDialog()
00314 {
00315 delete mValidator;
00316 mValidator = 0;
00317 delete mServerTest;
00318 mServerTest = 0;
00319 }
00320
00321 void AccountDialog::makeLocalAccountPage()
00322 {
00323 ProcmailRCParser procmailrcParser;
00324 QFrame *page = makeMainWidget();
00325 QGridLayout *topLayout = new QGridLayout( page, 12, 3, 0, spacingHint() );
00326 topLayout->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00327 topLayout->setRowStretch( 11, 10 );
00328 topLayout->setColStretch( 1, 10 );
00329
00330 mLocal.titleLabel = new QLabel( i18n("Account Type: Local Account"), page );
00331 topLayout->addMultiCellWidget( mLocal.titleLabel, 0, 0, 0, 2 );
00332 QFont titleFont( mLocal.titleLabel->font() );
00333 titleFont.setBold( true );
00334 mLocal.titleLabel->setFont( titleFont );
00335 KSeparator *hline = new KSeparator( KSeparator::HLine, page);
00336 topLayout->addMultiCellWidget( hline, 1, 1, 0, 2 );
00337
00338 QLabel *label = new QLabel( i18n("Account &name:"), page );
00339 topLayout->addWidget( label, 2, 0 );
00340 mLocal.nameEdit = new KLineEdit( page );
00341 label->setBuddy( mLocal.nameEdit );
00342 topLayout->addWidget( mLocal.nameEdit, 2, 1 );
00343
00344 label = new QLabel( i18n("File &location:"), page );
00345 topLayout->addWidget( label, 3, 0 );
00346 mLocal.locationEdit = new QComboBox( true, page );
00347 label->setBuddy( mLocal.locationEdit );
00348 topLayout->addWidget( mLocal.locationEdit, 3, 1 );
00349 mLocal.locationEdit->insertStringList(procmailrcParser.getSpoolFilesList());
00350
00351 QPushButton *choose = new QPushButton( i18n("Choo&se..."), page );
00352 choose->setAutoDefault( false );
00353 connect( choose, SIGNAL(clicked()), this, SLOT(slotLocationChooser()) );
00354 topLayout->addWidget( choose, 3, 2 );
00355
00356 QButtonGroup *group = new QButtonGroup(i18n("Locking Method"), page );
00357 group->setColumnLayout(0, Qt::Horizontal);
00358 group->layout()->setSpacing( 0 );
00359 group->layout()->setMargin( 0 );
00360 QGridLayout *groupLayout = new QGridLayout( group->layout() );
00361 groupLayout->setAlignment( Qt::AlignTop );
00362 groupLayout->setSpacing( 6 );
00363 groupLayout->setMargin( 11 );
00364
00365 mLocal.lockProcmail = new QRadioButton( i18n("Procmail loc&kfile:"), group);
00366 groupLayout->addWidget(mLocal.lockProcmail, 0, 0);
00367
00368 mLocal.procmailLockFileName = new QComboBox( true, group );
00369 groupLayout->addWidget(mLocal.procmailLockFileName, 0, 1);
00370 mLocal.procmailLockFileName->insertStringList(procmailrcParser.getLockFilesList());
00371 mLocal.procmailLockFileName->setEnabled(false);
00372
00373 QObject::connect(mLocal.lockProcmail, SIGNAL(toggled(bool)),
00374 mLocal.procmailLockFileName, SLOT(setEnabled(bool)));
00375
00376 mLocal.lockMutt = new QRadioButton(
00377 i18n("&Mutt dotlock"), group);
00378 groupLayout->addWidget(mLocal.lockMutt, 1, 0);
00379
00380 mLocal.lockMuttPriv = new QRadioButton(
00381 i18n("M&utt dotlock privileged"), group);
00382 groupLayout->addWidget(mLocal.lockMuttPriv, 2, 0);
00383
00384 mLocal.lockFcntl = new QRadioButton(
00385 i18n("&FCNTL"), group);
00386 groupLayout->addWidget(mLocal.lockFcntl, 3, 0);
00387
00388 mLocal.lockNone = new QRadioButton(
00389 i18n("Non&e (use with care)"), group);
00390 groupLayout->addWidget(mLocal.lockNone, 4, 0);
00391
00392 topLayout->addMultiCellWidget( group, 4, 4, 0, 2 );
00393
00394 #if 0
00395 QHBox* resourceHB = new QHBox( page );
00396 resourceHB->setSpacing( 11 );
00397 mLocal.resourceCheck =
00398 new QCheckBox( i18n( "Account for semiautomatic resource handling" ), resourceHB );
00399 mLocal.resourceClearButton =
00400 new QPushButton( i18n( "Clear" ), resourceHB );
00401 QWhatsThis::add( mLocal.resourceClearButton,
00402 i18n( "Delete all allocations for the resource represented by this account." ) );
00403 mLocal.resourceClearButton->setEnabled( false );
00404 connect( mLocal.resourceCheck, SIGNAL( toggled(bool) ),
00405 mLocal.resourceClearButton, SLOT( setEnabled(bool) ) );
00406 connect( mLocal.resourceClearButton, SIGNAL( clicked() ),
00407 this, SLOT( slotClearResourceAllocations() ) );
00408 mLocal.resourceClearPastButton =
00409 new QPushButton( i18n( "Clear Past" ), resourceHB );
00410 mLocal.resourceClearPastButton->setEnabled( false );
00411 connect( mLocal.resourceCheck, SIGNAL( toggled(bool) ),
00412 mLocal.resourceClearPastButton, SLOT( setEnabled(bool) ) );
00413 QWhatsThis::add( mLocal.resourceClearPastButton,
00414 i18n( "Delete all outdated allocations for the resource represented by this account." ) );
00415 connect( mLocal.resourceClearPastButton, SIGNAL( clicked() ),
00416 this, SLOT( slotClearPastResourceAllocations() ) );
00417 topLayout->addMultiCellWidget( resourceHB, 5, 5, 0, 2 );
00418 #endif
00419
00420 mLocal.includeInCheck =
00421 new QCheckBox( i18n("Include in m&anual mail check"),
00422 page );
00423 topLayout->addMultiCellWidget( mLocal.includeInCheck, 5, 5, 0, 2 );
00424
00425 mLocal.intervalCheck =
00426 new QCheckBox( i18n("Enable &interval mail checking"), page );
00427 topLayout->addMultiCellWidget( mLocal.intervalCheck, 6, 6, 0, 2 );
00428 connect( mLocal.intervalCheck, SIGNAL(toggled(bool)),
00429 this, SLOT(slotEnableLocalInterval(bool)) );
00430 mLocal.intervalLabel = new QLabel( i18n("Check inter&val:"), page );
00431 topLayout->addWidget( mLocal.intervalLabel, 7, 0 );
00432 mLocal.intervalSpin = new KIntNumInput( page );
00433 mLocal.intervalLabel->setBuddy( mLocal.intervalSpin );
00434 mLocal.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(), 10000, 1, false );
00435 mLocal.intervalSpin->setSuffix( i18n(" min") );
00436 mLocal.intervalSpin->setValue( 1 );
00437 topLayout->addWidget( mLocal.intervalSpin, 7, 1 );
00438
00439 label = new QLabel( i18n("&Destination folder:"), page );
00440 topLayout->addWidget( label, 8, 0 );
00441 mLocal.folderCombo = new QComboBox( false, page );
00442 label->setBuddy( mLocal.folderCombo );
00443 topLayout->addWidget( mLocal.folderCombo, 8, 1 );
00444
00445 label = new QLabel( i18n("&Pre-command:"), page );
00446 topLayout->addWidget( label, 9, 0 );
00447 mLocal.precommand = new KLineEdit( page );
00448 label->setBuddy( mLocal.precommand );
00449 topLayout->addWidget( mLocal.precommand, 9, 1 );
00450
00451 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
00452 }
00453
00454 void AccountDialog::makeMaildirAccountPage()
00455 {
00456 ProcmailRCParser procmailrcParser;
00457
00458 QFrame *page = makeMainWidget();
00459 QGridLayout *topLayout = new QGridLayout( page, 11, 3, 0, spacingHint() );
00460 topLayout->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00461 topLayout->setRowStretch( 11, 10 );
00462 topLayout->setColStretch( 1, 10 );
00463
00464 mMaildir.titleLabel = new QLabel( i18n("Account Type: Maildir Account"), page );
00465 topLayout->addMultiCellWidget( mMaildir.titleLabel, 0, 0, 0, 2 );
00466 QFont titleFont( mMaildir.titleLabel->font() );
00467 titleFont.setBold( true );
00468 mMaildir.titleLabel->setFont( titleFont );
00469 QFrame *hline = new QFrame( page );
00470 hline->setFrameStyle( QFrame::Sunken | QFrame::HLine );
00471 topLayout->addMultiCellWidget( hline, 1, 1, 0, 2 );
00472
00473 mMaildir.nameEdit = new KLineEdit( page );
00474 topLayout->addWidget( mMaildir.nameEdit, 2, 1 );
00475 QLabel *label = new QLabel( mMaildir.nameEdit, i18n("Account &name:"), page );
00476 topLayout->addWidget( label, 2, 0 );
00477
00478 mMaildir.locationEdit = new QComboBox( true, page );
00479 topLayout->addWidget( mMaildir.locationEdit, 3, 1 );
00480 mMaildir.locationEdit->insertStringList(procmailrcParser.getSpoolFilesList());
00481 label = new QLabel( mMaildir.locationEdit, i18n("Folder &location:"), page );
00482 topLayout->addWidget( label, 3, 0 );
00483
00484 QPushButton *choose = new QPushButton( i18n("Choo&se..."), page );
00485 choose->setAutoDefault( false );
00486 connect( choose, SIGNAL(clicked()), this, SLOT(slotMaildirChooser()) );
00487 topLayout->addWidget( choose, 3, 2 );
00488
00489 #if 0
00490 QHBox* resourceHB = new QHBox( page );
00491 resourceHB->setSpacing( 11 );
00492 mMaildir.resourceCheck =
00493 new QCheckBox( i18n( "Account for semiautomatic resource handling" ), resourceHB );
00494 mMaildir.resourceClearButton =
00495 new QPushButton( i18n( "Clear" ), resourceHB );
00496 mMaildir.resourceClearButton->setEnabled( false );
00497 connect( mMaildir.resourceCheck, SIGNAL( toggled(bool) ),
00498 mMaildir.resourceClearButton, SLOT( setEnabled(bool) ) );
00499 QWhatsThis::add( mMaildir.resourceClearButton,
00500 i18n( "Delete all allocations for the resource represented by this account." ) );
00501 connect( mMaildir.resourceClearButton, SIGNAL( clicked() ),
00502 this, SLOT( slotClearResourceAllocations() ) );
00503 mMaildir.resourceClearPastButton =
00504 new QPushButton( i18n( "Clear Past" ), resourceHB );
00505 mMaildir.resourceClearPastButton->setEnabled( false );
00506 connect( mMaildir.resourceCheck, SIGNAL( toggled(bool) ),
00507 mMaildir.resourceClearPastButton, SLOT( setEnabled(bool) ) );
00508 QWhatsThis::add( mMaildir.resourceClearPastButton,
00509 i18n( "Delete all outdated allocations for the resource represented by this account." ) );
00510 connect( mMaildir.resourceClearPastButton, SIGNAL( clicked() ),
00511 this, SLOT( slotClearPastResourceAllocations() ) );
00512 topLayout->addMultiCellWidget( resourceHB, 4, 4, 0, 2 );
00513 #endif
00514
00515 mMaildir.includeInCheck =
00516 new QCheckBox( i18n("Include in &manual mail check"), page );
00517 topLayout->addMultiCellWidget( mMaildir.includeInCheck, 4, 4, 0, 2 );
00518
00519 mMaildir.intervalCheck =
00520 new QCheckBox( i18n("Enable &interval mail checking"), page );
00521 topLayout->addMultiCellWidget( mMaildir.intervalCheck, 5, 5, 0, 2 );
00522 connect( mMaildir.intervalCheck, SIGNAL(toggled(bool)),
00523 this, SLOT(slotEnableMaildirInterval(bool)) );
00524 mMaildir.intervalLabel = new QLabel( i18n("Check inter&val:"), page );
00525 topLayout->addWidget( mMaildir.intervalLabel, 6, 0 );
00526 mMaildir.intervalSpin = new KIntNumInput( page );
00527 mMaildir.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(), 10000, 1, false );
00528 mMaildir.intervalSpin->setSuffix( i18n(" min") );
00529 mMaildir.intervalSpin->setValue( 1 );
00530 mMaildir.intervalLabel->setBuddy( mMaildir.intervalSpin );
00531 topLayout->addWidget( mMaildir.intervalSpin, 6, 1 );
00532
00533 mMaildir.folderCombo = new QComboBox( false, page );
00534 topLayout->addWidget( mMaildir.folderCombo, 7, 1 );
00535 label = new QLabel( mMaildir.folderCombo,
00536 i18n("&Destination folder:"), page );
00537 topLayout->addWidget( label, 7, 0 );
00538
00539 mMaildir.precommand = new KLineEdit( page );
00540 topLayout->addWidget( mMaildir.precommand, 8, 1 );
00541 label = new QLabel( mMaildir.precommand, i18n("&Pre-command:"), page );
00542 topLayout->addWidget( label, 8, 0 );
00543
00544 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
00545 }
00546
00547
00548 void AccountDialog::makePopAccountPage()
00549 {
00550 QFrame *page = makeMainWidget();
00551 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
00552
00553 mPop.titleLabel = new QLabel( page );
00554 mPop.titleLabel->setText( i18n("Account Type: POP Account") );
00555 QFont titleFont( mPop.titleLabel->font() );
00556 titleFont.setBold( true );
00557 mPop.titleLabel->setFont( titleFont );
00558 topLayout->addWidget( mPop.titleLabel );
00559 KSeparator *hline = new KSeparator( KSeparator::HLine, page);
00560 topLayout->addWidget( hline );
00561
00562 QTabWidget *tabWidget = new QTabWidget(page);
00563 topLayout->addWidget( tabWidget );
00564
00565 QWidget *page1 = new QWidget( tabWidget );
00566 tabWidget->addTab( page1, i18n("&General") );
00567
00568 QGridLayout *grid = new QGridLayout( page1, 16, 2, marginHint(), spacingHint() );
00569 grid->addColSpacing( 1, fontMetrics().maxWidth()*15 );
00570 grid->setRowStretch( 15, 10 );
00571 grid->setColStretch( 1, 10 );
00572
00573 QLabel *label = new QLabel( i18n("Account &name:"), page1 );
00574 grid->addWidget( label, 0, 0 );
00575 mPop.nameEdit = new KLineEdit( page1 );
00576 label->setBuddy( mPop.nameEdit );
00577 grid->addWidget( mPop.nameEdit, 0, 1 );
00578
00579 label = new QLabel( i18n("&Login:"), page1 );
00580 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>).") );
00581 grid->addWidget( label, 1, 0 );
00582 mPop.loginEdit = new KLineEdit( page1 );
00583 label->setBuddy( mPop.loginEdit );
00584 grid->addWidget( mPop.loginEdit, 1, 1 );
00585
00586 label = new QLabel( i18n("P&assword:"), page1 );
00587 grid->addWidget( label, 2, 0 );
00588 mPop.passwordEdit = new KLineEdit( page1 );
00589 mPop.passwordEdit->setEchoMode( QLineEdit::Password );
00590 label->setBuddy( mPop.passwordEdit );
00591 grid->addWidget( mPop.passwordEdit, 2, 1 );
00592
00593 label = new QLabel( i18n("Ho&st:"), page1 );
00594 grid->addWidget( label, 3, 0 );
00595 mPop.hostEdit = new KLineEdit( page1 );
00596
00597
00598 mPop.hostEdit->setValidator(mValidator);
00599 label->setBuddy( mPop.hostEdit );
00600 grid->addWidget( mPop.hostEdit, 3, 1 );
00601
00602 label = new QLabel( i18n("&Port:"), page1 );
00603 grid->addWidget( label, 4, 0 );
00604 mPop.portEdit = new KLineEdit( page1 );
00605 mPop.portEdit->setValidator( new QIntValidator(this) );
00606 label->setBuddy( mPop.portEdit );
00607 grid->addWidget( mPop.portEdit, 4, 1 );
00608
00609 mPop.storePasswordCheck =
00610 new QCheckBox( i18n("Sto&re POP password"), page1 );
00611 QWhatsThis::add( mPop.storePasswordCheck,
00612 i18n("Check this option to have KMail store "
00613 "the password.\nIf KWallet is available "
00614 "the password will be stored there which is considered "
00615 "safe.\nHowever, if KWallet is not available, "
00616 "the password will be stored in KMail's configuration "
00617 "file. The password is stored in an "
00618 "obfuscated format, but should not be "
00619 "considered secure from decryption efforts "
00620 "if access to the configuration file is obtained.") );
00621 grid->addMultiCellWidget( mPop.storePasswordCheck, 5, 5, 0, 1 );
00622
00623 mPop.leaveOnServerCheck =
00624 new QCheckBox( i18n("Lea&ve fetched messages on the server"), page1 );
00625 connect( mPop.leaveOnServerCheck, SIGNAL( clicked() ),
00626 this, SLOT( slotLeaveOnServerClicked() ) );
00627 grid->addMultiCellWidget( mPop.leaveOnServerCheck, 6, 6, 0, 1 );
00628 QHBox *afterDaysBox = new QHBox( page1 );
00629 afterDaysBox->setSpacing( KDialog::spacingHint() );
00630 mPop.leaveOnServerDaysCheck =
00631 new QCheckBox( i18n("Leave messages on the server for"), afterDaysBox );
00632 connect( mPop.leaveOnServerDaysCheck, SIGNAL( toggled(bool) ),
00633 this, SLOT( slotEnableLeaveOnServerDays(bool)) );
00634 mPop.leaveOnServerDaysSpin = new KIntNumInput( afterDaysBox );
00635 mPop.leaveOnServerDaysSpin->setRange( 1, 365, 1, false );
00636 connect( mPop.leaveOnServerDaysSpin, SIGNAL(valueChanged(int)),
00637 SLOT(slotLeaveOnServerDaysChanged(int)));
00638 mPop.leaveOnServerDaysSpin->setValue( 1 );
00639 afterDaysBox->setStretchFactor( mPop.leaveOnServerDaysSpin, 1 );
00640 grid->addMultiCellWidget( afterDaysBox, 7, 7, 0, 1 );
00641 QHBox *leaveOnServerCountBox = new QHBox( page1 );
00642 leaveOnServerCountBox->setSpacing( KDialog::spacingHint() );
00643 mPop.leaveOnServerCountCheck =
00644 new QCheckBox( i18n("Keep only the last"), leaveOnServerCountBox );
00645 connect( mPop.leaveOnServerCountCheck, SIGNAL( toggled(bool) ),
00646 this, SLOT( slotEnableLeaveOnServerCount(bool)) );
00647 mPop.leaveOnServerCountSpin = new KIntNumInput( leaveOnServerCountBox );
00648 mPop.leaveOnServerCountSpin->setRange( 1, 999999, 1, false );
00649 connect( mPop.leaveOnServerCountSpin, SIGNAL(valueChanged(int)),
00650 SLOT(slotLeaveOnServerCountChanged(int)));
00651 mPop.leaveOnServerCountSpin->setValue( 100 );
00652 grid->addMultiCellWidget( leaveOnServerCountBox, 8, 8, 0, 1 );
00653 QHBox *leaveOnServerSizeBox = new QHBox( page1 );
00654 leaveOnServerSizeBox->setSpacing( KDialog::spacingHint() );
00655 mPop.leaveOnServerSizeCheck =
00656 new QCheckBox( i18n("Keep only the last"), leaveOnServerSizeBox );
00657 connect( mPop.leaveOnServerSizeCheck, SIGNAL( toggled(bool) ),
00658 this, SLOT( slotEnableLeaveOnServerSize(bool)) );
00659 mPop.leaveOnServerSizeSpin = new KIntNumInput( leaveOnServerSizeBox );
00660 mPop.leaveOnServerSizeSpin->setRange( 1, 999999, 1, false );
00661 mPop.leaveOnServerSizeSpin->setSuffix( i18n(" MB") );
00662 mPop.leaveOnServerSizeSpin->setValue( 10 );
00663 grid->addMultiCellWidget( leaveOnServerSizeBox, 9, 9, 0, 1 );
00664 #if 0
00665 QHBox *resourceHB = new QHBox( page1 );
00666 resourceHB->setSpacing( 11 );
00667 mPop.resourceCheck =
00668 new QCheckBox( i18n( "Account for semiautomatic resource handling" ), resourceHB );
00669 mPop.resourceClearButton =
00670 new QPushButton( i18n( "Clear" ), resourceHB );
00671 mPop.resourceClearButton->setEnabled( false );
00672 connect( mPop.resourceCheck, SIGNAL( toggled(bool) ),
00673 mPop.resourceClearButton, SLOT( setEnabled(bool) ) );
00674 QWhatsThis::add( mPop.resourceClearButton,
00675 i18n( "Delete all allocations for the resource represented by this account." ) );
00676 connect( mPop.resourceClearButton, SIGNAL( clicked() ),
00677 this, SLOT( slotClearResourceAllocations() ) );
00678 mPop.resourceClearPastButton =
00679 new QPushButton( i18n( "Clear Past" ), resourceHB );
00680 mPop.resourceClearPastButton->setEnabled( false );
00681 connect( mPop.resourceCheck, SIGNAL( toggled(bool) ),
00682 mPop.resourceClearPastButton, SLOT( setEnabled(bool) ) );
00683 QWhatsThis::add( mPop.resourceClearPastButton,
00684 i18n( "Delete all outdated allocations for the resource represented by this account." ) );
00685 connect( mPop.resourceClearPastButton, SIGNAL( clicked() ),
00686 this, SLOT( slotClearPastResourceAllocations() ) );
00687 grid->addMultiCellWidget( resourceHB, 10, 10, 0, 2 );
00688 #endif
00689
00690 mPop.includeInCheck =
00691 new QCheckBox( i18n("Include in man&ual mail check"), page1 );
00692 grid->addMultiCellWidget( mPop.includeInCheck, 10, 10, 0, 1 );
00693
00694 QHBox * hbox = new QHBox( page1 );
00695 hbox->setSpacing( KDialog::spacingHint() );
00696 mPop.filterOnServerCheck =
00697 new QCheckBox( i18n("&Filter messages if they are greater than"), hbox );
00698 mPop.filterOnServerSizeSpin = new KIntNumInput ( hbox );
00699 mPop.filterOnServerSizeSpin->setEnabled( false );
00700 hbox->setStretchFactor( mPop.filterOnServerSizeSpin, 1 );
00701 mPop.filterOnServerSizeSpin->setRange( 1, 10000000, 100, false );
00702 connect(mPop.filterOnServerSizeSpin, SIGNAL(valueChanged(int)),
00703 SLOT(slotFilterOnServerSizeChanged(int)));
00704 mPop.filterOnServerSizeSpin->setValue( 50000 );
00705 grid->addMultiCellWidget( hbox, 11, 11, 0, 1 );
00706 connect( mPop.filterOnServerCheck, SIGNAL(toggled(bool)),
00707 mPop.filterOnServerSizeSpin, SLOT(setEnabled(bool)) );
00708 connect( mPop.filterOnServerCheck, SIGNAL( clicked() ),
00709 this, SLOT( slotFilterOnServerClicked() ) );
00710 QString msg = i18n("If you select this option, POP Filters will be used to "
00711 "decide what to do with messages. You can then select "
00712 "to download, delete or keep them on the server." );
00713 QWhatsThis::add( mPop.filterOnServerCheck, msg );
00714 QWhatsThis::add( mPop.filterOnServerSizeSpin, msg );
00715
00716 mPop.intervalCheck =
00717 new QCheckBox( i18n("Enable &interval mail checking"), page1 );
00718 grid->addMultiCellWidget( mPop.intervalCheck, 12, 12, 0, 1 );
00719 connect( mPop.intervalCheck, SIGNAL(toggled(bool)),
00720 this, SLOT(slotEnablePopInterval(bool)) );
00721 mPop.intervalLabel = new QLabel( i18n("Chec&k interval:"), page1 );
00722 grid->addWidget( mPop.intervalLabel, 13, 0 );
00723 mPop.intervalSpin = new KIntNumInput( page1 );
00724 mPop.intervalSpin->setRange( GlobalSettings::self()->minimumCheckInterval(), 10000, 1, false );
00725 mPop.intervalSpin->setSuffix( i18n(" min") );
00726 mPop.intervalSpin->setValue( 1 );
00727 mPop.intervalLabel->setBuddy( mPop.intervalSpin );
00728 grid->addWidget( mPop.intervalSpin, 13, 1 );
00729
00730 label = new QLabel( i18n("Des&tination folder:"), page1 );
00731 grid->addWidget( label, 14, 0 );
00732 mPop.folderCombo = new QComboBox( false, page1 );
00733 label->setBuddy( mPop.folderCombo );
00734 grid->addWidget( mPop.folderCombo, 14, 1 );
00735
00736 label = new QLabel( i18n("Pre-com&mand:"), page1 );
00737 grid->addWidget( label, 15, 0 );
00738 mPop.precommand = new KLineEdit( page1 );
00739 label->setBuddy(mPop.precommand);
00740 grid->addWidget( mPop.precommand, 15, 1 );
00741
00742 QWidget *page2 = new QWidget( tabWidget );
00743 tabWidget->addTab( page2, i18n("&Extras") );
00744 QVBoxLayout *vlay = new QVBoxLayout( page2, marginHint(), spacingHint() );
00745
00746 vlay->addSpacing( KDialog::spacingHint() );
00747
00748 QHBoxLayout *buttonLay = new QHBoxLayout( vlay );
00749 mPop.checkCapabilities =
00750 new QPushButton( i18n("Check &What the Server Supports"), page2 );
00751 connect(mPop.checkCapabilities, SIGNAL(clicked()),
00752 SLOT(slotCheckPopCapabilities()));
00753 buttonLay->addStretch();
00754 buttonLay->addWidget( mPop.checkCapabilities );
00755 buttonLay->addStretch();
00756
00757 vlay->addSpacing( KDialog::spacingHint() );
00758
00759 mPop.encryptionGroup = new QButtonGroup( 1, Qt::Horizontal,
00760 i18n("Encryption"), page2 );
00761 mPop.encryptionNone =
00762 new QRadioButton( i18n("&None"), mPop.encryptionGroup );
00763 mPop.encryptionSSL =
00764 new QRadioButton( i18n("Use &SSL for secure mail download"),
00765 mPop.encryptionGroup );
00766 mPop.encryptionTLS =
00767 new QRadioButton( i18n("Use &TLS for secure mail download"),
00768 mPop.encryptionGroup );
00769 connect(mPop.encryptionGroup, SIGNAL(clicked(int)),
00770 SLOT(slotPopEncryptionChanged(int)));
00771 vlay->addWidget( mPop.encryptionGroup );
00772
00773 mPop.authGroup = new QButtonGroup( 1, Qt::Horizontal,
00774 i18n("Authentication Method"), page2 );
00775 mPop.authUser = new QRadioButton( i18n("Clear te&xt") , mPop.authGroup,
00776 "auth clear text" );
00777 mPop.authLogin = new QRadioButton( i18n("Please translate this "
00778 "authentication method only if you have a good reason", "&LOGIN"),
00779 mPop.authGroup, "auth login" );
00780 mPop.authPlain = new QRadioButton( i18n("Please translate this "
00781 "authentication method only if you have a good reason", "&PLAIN"),
00782 mPop.authGroup, "auth plain" );
00783 mPop.authCRAM_MD5 = new QRadioButton( i18n("CRAM-MD&5"), mPop.authGroup, "auth cram-md5" );
00784 mPop.authDigestMd5 = new QRadioButton( i18n("&DIGEST-MD5"), mPop.authGroup, "auth digest-md5" );
00785 mPop.authNTLM = new QRadioButton( i18n("&NTLM"), mPop.authGroup, "auth ntlm" );
00786 mPop.authGSSAPI = new QRadioButton( i18n("&GSSAPI"), mPop.authGroup, "auth gssapi" );
00787 if ( KProtocolInfo::capabilities("pop3").contains("SASL") == 0 )
00788 {
00789 mPop.authNTLM->hide();
00790 mPop.authGSSAPI->hide();
00791 }
00792 mPop.authAPOP = new QRadioButton( i18n("&APOP"), mPop.authGroup, "auth apop" );
00793
00794 vlay->addWidget( mPop.authGroup );
00795
00796 mPop.usePipeliningCheck =
00797 new QCheckBox( i18n("&Use pipelining for faster mail download"), page2 );
00798 connect(mPop.usePipeliningCheck, SIGNAL(clicked()),
00799 SLOT(slotPipeliningClicked()));
00800 vlay->addWidget( mPop.usePipeliningCheck );
00801
00802 vlay->addStretch();
00803
00804 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
00805 }
00806
00807
00808 void AccountDialog::makeImapAccountPage( bool connected )
00809 {
00810 QFrame *page = makeMainWidget();
00811 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
00812
00813 mImap.titleLabel = new QLabel( page );
00814 if( connected )
00815 mImap.titleLabel->setText( i18n("Account Type: Disconnected IMAP Account") );
00816 else
00817 mImap.titleLabel->setText( i18n("Account Type: IMAP Account") );
00818 QFont titleFont( mImap.titleLabel->font() );
00819 titleFont.setBold( true );
00820 mImap.titleLabel->setFont( titleFont );
00821 topLayout->addWidget( mImap.titleLabel );
00822 KSeparator *hline = new KSeparator( KSeparator::HLine, page);
00823 topLayout->addWidget( hline );
00824
00825 QTabWidget *tabWidget = new QTabWidget(page);
00826 topLayout->addWidget( tabWidget );
00827
00828 QWidget *page1 = new QWidget( tabWidget );
00829 tabWidget->addTab( page1, i18n("&General") );
00830
00831 int row = -1;
00832 QGridLayout *grid = new QGridLayout( page1, 16, 2, marginHint(), spacingHint() );
00833 grid->addColSpacing( 1, fontMetrics().maxWidth()*16 );
00834
00835 ++row;
00836 QLabel *label = new QLabel( i18n("Account &name:"), page1 );
00837 grid->addWidget( label, row, 0 );
00838 mImap.nameEdit = new KLineEdit( page1 );
00839 label->setBuddy( mImap.nameEdit );
00840 grid->addWidget( mImap.nameEdit, row, 1 );
00841
00842 ++row;
00843 label = new QLabel( i18n("&Login:"), page1 );
00844 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>).") );
00845 grid->addWidget( label, row, 0 );
00846 mImap.loginEdit = new KLineEdit( page1 );
00847 label->setBuddy( mImap.loginEdit );
00848 grid->addWidget( mImap.loginEdit, row, 1 );
00849
00850 ++row;
00851 label = new QLabel( i18n("P&assword:"), page1 );
00852 grid->addWidget( label, row, 0 );
00853 mImap.passwordEdit = new KLineEdit( page1 );
00854 mImap.passwordEdit->setEchoMode( QLineEdit::Password );
00855 label->setBuddy( mImap.passwordEdit );
00856 grid->addWidget( mImap.passwordEdit, row, 1 );
00857
00858 ++row;
00859 label = new QLabel( i18n("Ho&st:"), page1 );
00860 grid->addWidget( label, row, 0 );
00861 mImap.hostEdit = new KLineEdit( page1 );
00862
00863
00864 mImap.hostEdit->setValidator(mValidator);
00865 label->setBuddy( mImap.hostEdit );
00866 grid->addWidget( mImap.hostEdit, row, 1 );
00867
00868 ++row;
00869 label = new QLabel( i18n("&Port:"), page1 );
00870 grid->addWidget( label, row, 0 );
00871 mImap.portEdit = new KLineEdit( page1 );
00872 mImap.portEdit->setValidator( new QIntValidator(this) );
00873 label->setBuddy( mImap.portEdit );
00874 grid->addWidget( mImap.portEdit, row, 1 );
00875
00876
00877 ++row;
00878 QHBox* box = new QHBox( page1 );
00879 label = new QLabel( i18n("Namespaces:"), box );
00880 QWhatsThis::add( label, i18n( "Here you see the different namespaces that your IMAP server supports."
00881 "Each namespace represents a prefix that separates groups of folders."
00882 "Namespaces allow KMail for example to display your personal folders and shared folders in one account." ) );
00883
00884 QToolButton* button = new QToolButton( box );
00885 button->setAutoRaise(true);
00886 button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
00887 button->setFixedSize( 22, 22 );
00888 button->setIconSet(
00889 KGlobal::iconLoader()->loadIconSet( "reload", KIcon::Small, 0 ) );
00890 connect( button, SIGNAL(clicked()), this, SLOT(slotReloadNamespaces()) );
00891 QWhatsThis::add( button,
00892 i18n("Reload the namespaces from the server. This overwrites any changes.") );
00893 grid->addWidget( box, row, 0 );
00894
00895
00896 QGrid* listbox = new QGrid( 3, page1 );
00897 label = new QLabel( i18n("Personal"), listbox );
00898 QWhatsThis::add( label, i18n( "Personal namespaces include your personal folders." ) );
00899 mImap.personalNS = new KLineEdit( listbox );
00900 mImap.personalNS->setReadOnly( true );
00901 mImap.editPNS = new QToolButton( listbox );
00902 mImap.editPNS->setIconSet(
00903 KGlobal::iconLoader()->loadIconSet( "edit", KIcon::Small, 0 ) );
00904 mImap.editPNS->setAutoRaise( true );
00905 mImap.editPNS->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
00906 mImap.editPNS->setFixedSize( 22, 22 );
00907 connect( mImap.editPNS, SIGNAL(clicked()), this, SLOT(slotEditPersonalNamespace()) );
00908
00909 label = new QLabel( i18n("Other Users"), listbox );
00910 QWhatsThis::add( label, i18n( "These namespaces include the folders of other users." ) );
00911 mImap.otherUsersNS = new KLineEdit( listbox );
00912 mImap.otherUsersNS->setReadOnly( true );
00913 mImap.editONS = new QToolButton( listbox );
00914 mImap.editONS->setIconSet(
00915 KGlobal::iconLoader()->loadIconSet( "edit", KIcon::Small, 0 ) );
00916 mImap.editONS->setAutoRaise( true );
00917 mImap.editONS->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
00918 mImap.editONS->setFixedSize( 22, 22 );
00919 connect( mImap.editONS, SIGNAL(clicked()), this, SLOT(slotEditOtherUsersNamespace()) );
00920
00921 label = new QLabel( i18n("Shared"), listbox );
00922 QWhatsThis::add( label, i18n( "These namespaces include the shared folders." ) );
00923 mImap.sharedNS = new KLineEdit( listbox );
00924 mImap.sharedNS->setReadOnly( true );
00925 mImap.editSNS = new QToolButton( listbox );
00926 mImap.editSNS->setIconSet(
00927 KGlobal::iconLoader()->loadIconSet( "edit", KIcon::Small, 0 ) );
00928 mImap.editSNS->setAutoRaise( true );
00929 mImap.editSNS->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
00930 mImap.editSNS->setFixedSize( 22, 22 );
00931 connect( mImap.editSNS, SIGNAL(clicked()), this, SLOT(slotEditSharedNamespace()) );
00932
00933 label->setBuddy( listbox );
00934 grid->addWidget( listbox, row, 1 );
00935
00936 ++row;
00937 mImap.storePasswordCheck =
00938 new QCheckBox( i18n("Sto&re IMAP password"), page1 );
00939 QWhatsThis::add( mImap.storePasswordCheck,
00940 i18n("Check this option to have KMail store "
00941 "the password.\nIf KWallet is available "
00942 "the password will be stored there which is considered "
00943 "safe.\nHowever, if KWallet is not available, "
00944 "the password will be stored in KMail's configuration "
00945 "file. The password is stored in an "
00946 "obfuscated format, but should not be "
00947 "considered secure from decryption efforts "
00948 "if access to the configuration file is obtained.") );
00949 grid->addMultiCellWidget( mImap.storePasswordCheck, row, row, 0, 1 );
00950
00951 if( !connected ) {
00952 ++row;
00953 mImap.autoExpungeCheck =
00954 new QCheckBox( i18n("Automaticall&y compact folders (expunges deleted messages)"), page1);
00955 grid->addMultiCellWidget( mImap.autoExpungeCheck, row, row, 0, 1 );
00956 }
00957
00958 ++row;
00959 mImap.hiddenFoldersCheck = new QCheckBox( i18n("Sho&w hidden folders"), page1);
00960 grid->addMultiCellWidget( mImap.hiddenFoldersCheck, row, row, 0, 1 );
00961
00962
00963 ++row;
00964 mImap.subscribedFoldersCheck = new QCheckBox(
00965 i18n("Show only s&ubscribed folders"), page1);
00966 grid->addMultiCellWidget( mImap.subscribedFoldersCheck, row, row, 0, 1 );
00967
00968 ++row;
00969 mImap.locallySubscribedFoldersCheck = new QCheckBox(
00970 i18n("Show only &locally subscribed folders"), page1);
00971 grid->addMultiCellWidget( mImap.locallySubscribedFoldersCheck, row, row, 0, 1 );
00972
00973 if ( !connected ) {
00974
00975 ++row;
00976 mImap.loadOnDemandCheck = new QCheckBox(
00977 i18n("Load attach&ments on demand"), page1);
00978 QWhatsThis::add( mImap.loadOnDemandCheck,
00979 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.") );
00980 grid->addMultiCellWidget( mImap.loadOnDemandCheck, row, row, 0, 1 );
00981 }
00982
00983 if ( !connected ) {
00984
00985 ++row;
00986 mImap.listOnlyOpenCheck = new QCheckBox(
00987 i18n("List only open folders"), page1);
00988 QWhatsThis::add( mImap.listOnlyOpenCheck,
00989 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.") );
00990 grid->addMultiCellWidget( mImap.listOnlyOpenCheck, row, row, 0, 1 );
00991 }
00992
00993 #if 0
00994 ++row;
00995 QHBox* resourceHB = new QHBox( page1 );
00996 resourceHB->setSpacing( 11 );
00997 mImap.resourceCheck =
00998 new QCheckBox( i18n( "Account for semiautomatic resource handling" ), resourceHB );
00999 mImap.resourceClearButton =
01000 new QPushButton( i18n( "Clear" ), resourceHB );
01001 mImap.resourceClearButton->setEnabled( false );
01002 connect( mImap.resourceCheck, SIGNAL( toggled(bool) ),
01003 mImap.resourceClearButton, SLOT( setEnabled(bool) ) );
01004 QWhatsThis::add( mImap.resourceClearButton,
01005 i18n( "Delete all allocations for the resource represented by this account." ) );
01006 connect( mImap.resourceClearButton, SIGNAL( clicked() ),
01007 this, SLOT( slotClearResourceAllocations() ) );
01008 mImap.resourceClearPastButton =
01009 new QPushButton( i18n( "Clear Past" ), resourceHB );
01010 mImap.resourceClearPastButton->setEnabled( false );
01011 connect( mImap.resourceCheck, SIGNAL( toggled(bool) ),
01012 mImap.resourceClearPastButton, SLOT( setEnabled(bool) ) );
01013 QWhatsThis::add( mImap.resourceClearPastButton,
01014 i18n( "Delete all outdated allocations for the resource represented by this account." ) );
01015 connect( mImap.resourceClearPastButton, SIGNAL( clicked() ),
01016 this, SLOT( slotClearPastResourceAllocations() ) );
01017 grid->addMultiCellWidget( resourceHB, row, row, 0, 2 );
01018 #endif
01019
01020 ++row;
01021 mImap.includeInCheck =
01022 new QCheckBox( i18n("Include in manual mail chec&k"), page1 );
01023 grid->addMultiCellWidget( mImap.includeInCheck, row, row, 0, 1 );
01024
01025 ++row;
01026 mImap.intervalCheck =
01027 new QCheckBox( i18n("Enable &interval mail checking"), page1 );
01028 grid->addMultiCellWidget( mImap.intervalCheck, row, row, 0, 2 );
01029 connect( mImap.intervalCheck, SIGNAL(toggled(bool)),
01030 this, SLOT(slotEnableImapInterval(bool)) );
01031 ++row;
01032 mImap.intervalLabel = new QLabel( i18n("Check inter&val:"), page1 );
01033 grid->addWidget( mImap.intervalLabel, row, 0 );
01034 mImap.intervalSpin = new KIntNumInput( page1 );
01035 mImap.intervalSpin->setRange( GlobalSettings::minimumCheckInterval(), 60, 1, false );
01036 mImap.intervalSpin->setValue( 1 );
01037 mImap.intervalSpin->setSuffix( i18n( " min" ) );
01038 mImap.intervalLabel->setBuddy( mImap.intervalSpin );
01039 grid->addWidget( mImap.intervalSpin, row, 1 );
01040
01041 ++row;
01042 label = new QLabel( i18n("&Trash folder:"), page1 );
01043 grid->addWidget( label, row, 0 );
01044 mImap.trashCombo = new FolderRequester( page1,
01045 kmkernel->getKMMainWidget()->folderTree() );
01046 mImap.trashCombo->setShowOutbox( false );
01047 label->setBuddy( mImap.trashCombo );
01048 grid->addWidget( mImap.trashCombo, row, 1 );
01049
01050 QWidget *page2 = new QWidget( tabWidget );
01051 tabWidget->addTab( page2, i18n("S&ecurity") );
01052 QVBoxLayout *vlay = new QVBoxLayout( page2, marginHint(), spacingHint() );
01053
01054 vlay->addSpacing( KDialog::spacingHint() );
01055
01056 QHBoxLayout *buttonLay = new QHBoxLayout( vlay );
01057 mImap.checkCapabilities =
01058 new QPushButton( i18n("Check &What the Server Supports"), page2 );
01059 connect(mImap.checkCapabilities, SIGNAL(clicked()),
01060 SLOT(slotCheckImapCapabilities()));
01061 buttonLay->addStretch();
01062 buttonLay->addWidget( mImap.checkCapabilities );
01063 buttonLay->addStretch();
01064
01065 vlay->addSpacing( KDialog::spacingHint() );
01066
01067 mImap.encryptionGroup = new QButtonGroup( 1, Qt::Horizontal,
01068 i18n("Encryption"), page2 );
01069 mImap.encryptionNone =
01070 new QRadioButton( i18n("&None"), mImap.encryptionGroup );
01071 mImap.encryptionSSL =
01072 new QRadioButton( i18n("Use &SSL for secure mail download"),
01073 mImap.encryptionGroup );
01074 mImap.encryptionTLS =
01075 new QRadioButton( i18n("Use &TLS for secure mail download"),
01076 mImap.encryptionGroup );
01077 connect(mImap.encryptionGroup, SIGNAL(clicked(int)),
01078 SLOT(slotImapEncryptionChanged(int)));
01079 vlay->addWidget( mImap.encryptionGroup );
01080
01081 mImap.authGroup = new QButtonGroup( 1, Qt::Horizontal,
01082 i18n("Authentication Method"), page2 );
01083 mImap.authUser = new QRadioButton( i18n("Clear te&xt"), mImap.authGroup );
01084 mImap.authLogin = new QRadioButton( i18n("Please translate this "
01085 "authentication method only if you have a good reason", "&LOGIN"),
01086 mImap.authGroup );
01087 mImap.authPlain = new QRadioButton( i18n("Please translate this "
01088 "authentication method only if you have a good reason", "&PLAIN"),
01089 mImap.authGroup );
01090 mImap.authCramMd5 = new QRadioButton( i18n("CRAM-MD&5"), mImap.authGroup );
01091 mImap.authDigestMd5 = new QRadioButton( i18n("&DIGEST-MD5"), mImap.authGroup );
01092 mImap.authNTLM = new QRadioButton( i18n("&NTLM"), mImap.authGroup );
01093 mImap.authGSSAPI = new QRadioButton( i18n("&GSSAPI"), mImap.authGroup );
01094 mImap.authAnonymous = new QRadioButton( i18n("&Anonymous"), mImap.authGroup );
01095 vlay->addWidget( mImap.authGroup );
01096
01097 vlay->addStretch();
01098
01099
01100 mSieveConfigEditor = new SieveConfigEditor( tabWidget );
01101 mSieveConfigEditor->layout()->setMargin( KDialog::marginHint() );
01102 tabWidget->addTab( mSieveConfigEditor, i18n("&Filtering") );
01103
01104 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
01105 }
01106
01107
01108 void AccountDialog::setupSettings()
01109 {
01110 QComboBox *folderCombo = 0;
01111 int interval = mAccount->checkInterval();
01112
01113 QString accountType = mAccount->type();
01114 if( accountType == "local" )
01115 {
01116 ProcmailRCParser procmailrcParser;
01117 KMAcctLocal *acctLocal = dynamic_cast<KMAcctLocal*>(mAccount);
01118
01119 if ( acctLocal->location().isEmpty() )
01120 acctLocal->setLocation( procmailrcParser.getSpoolFilesList().first() );
01121 else
01122 mLocal.locationEdit->insertItem( acctLocal->location() );
01123
01124 if ( acctLocal->procmailLockFileName().isEmpty() )
01125 acctLocal->setProcmailLockFileName( procmailrcParser.getLockFilesList().first() );
01126 else
01127 mLocal.procmailLockFileName->insertItem( acctLocal->procmailLockFileName() );
01128
01129 mLocal.nameEdit->setText( mAccount->name() );
01130 mLocal.nameEdit->setFocus();
01131 mLocal.locationEdit->setEditText( acctLocal->location() );
01132 if (acctLocal->lockType() == mutt_dotlock)
01133 mLocal.lockMutt->setChecked(true);
01134 else if (acctLocal->lockType() == mutt_dotlock_privileged)
01135 mLocal.lockMuttPriv->setChecked(true);
01136 else if (acctLocal->lockType() == procmail_lockfile) {
01137 mLocal.lockProcmail->setChecked(true);
01138 mLocal.procmailLockFileName->setEditText(acctLocal->procmailLockFileName());
01139 } else if (acctLocal->lockType() == FCNTL)
01140 mLocal.lockFcntl->setChecked(true);
01141 else if (acctLocal->lockType() == lock_none)
01142 mLocal.lockNone->setChecked(true);
01143
01144 mLocal.intervalSpin->setValue( QMAX(1, interval) );
01145 mLocal.intervalCheck->setChecked( interval >= 1 );
01146 #if 0
01147 mLocal.resourceCheck->setChecked( mAccount->resource() );
01148 #endif
01149 mLocal.includeInCheck->setChecked( !mAccount->checkExclude() );
01150 mLocal.precommand->setText( mAccount->precommand() );
01151
01152 slotEnableLocalInterval( interval >= 1 );
01153 folderCombo = mLocal.folderCombo;
01154 }
01155 else if( accountType == "pop" )
01156 {
01157 PopAccount &ap = *(PopAccount*)mAccount;
01158 mPop.nameEdit->setText( mAccount->name() );
01159 mPop.nameEdit->setFocus();
01160 mPop.loginEdit->setText( ap.login() );
01161 mPop.passwordEdit->setText( ap.passwd());
01162 mPop.hostEdit->setText( ap.host() );
01163 mPop.portEdit->setText( QString("%1").arg( ap.port() ) );
01164 mPop.usePipeliningCheck->setChecked( ap.usePipelining() );
01165 mPop.storePasswordCheck->setChecked( ap.storePasswd() );
01166 mPop.leaveOnServerCheck->setChecked( ap.leaveOnServer() );
01167 mPop.leaveOnServerDaysCheck->setEnabled( ap.leaveOnServer() );
01168 mPop.leaveOnServerDaysCheck->setChecked( ap.leaveOnServerDays() >= 1 );
01169 mPop.leaveOnServerDaysSpin->setValue( ap.leaveOnServerDays() >= 1 ?
01170 ap.leaveOnServerDays() : 7 );
01171 mPop.leaveOnServerCountCheck->setEnabled( ap.leaveOnServer() );
01172 mPop.leaveOnServerCountCheck->setChecked( ap.leaveOnServerCount() >= 1 );
01173 mPop.leaveOnServerCountSpin->setValue( ap.leaveOnServerCount() >= 1 ?
01174 ap.leaveOnServerCount() : 100 );
01175 mPop.leaveOnServerSizeCheck->setEnabled( ap.leaveOnServer() );
01176 mPop.leaveOnServerSizeCheck->setChecked( ap.leaveOnServerSize() >= 1 );
01177 mPop.leaveOnServerSizeSpin->setValue( ap.leaveOnServerSize() >= 1 ?
01178 ap.leaveOnServerSize() : 10 );
01179 mPop.filterOnServerCheck->setChecked( ap.filterOnServer() );
01180 mPop.filterOnServerSizeSpin->setValue( ap.filterOnServerCheckSize() );
01181 mPop.intervalCheck->setChecked( interval >= 1 );
01182 mPop.intervalSpin->setValue( QMAX(1, interval) );
01183 #if 0
01184 mPop.resourceCheck->setChecked( mAccount->resource() );
01185 #endif
01186 mPop.includeInCheck->setChecked( !mAccount->checkExclude() );
01187 mPop.precommand->setText( ap.precommand() );
01188 if (ap.useSSL())
01189 mPop.encryptionSSL->setChecked( true );
01190 else if (ap.useTLS())
01191 mPop.encryptionTLS->setChecked( true );
01192 else mPop.encryptionNone->setChecked( true );
01193 if (ap.auth() == "LOGIN")
01194 mPop.authLogin->setChecked( true );
01195 else if (ap.auth() == "PLAIN")
01196 mPop.authPlain->setChecked( true );
01197 else if (ap.auth() == "CRAM-MD5")
01198 mPop.authCRAM_MD5->setChecked( true );
01199 else if (ap.auth() == "DIGEST-MD5")
01200 mPop.authDigestMd5->setChecked( true );
01201 else if (ap.auth() == "NTLM")
01202 mPop.authNTLM->setChecked( true );
01203 else if (ap.auth() == "GSSAPI")
01204 mPop.authGSSAPI->setChecked( true );
01205 else if (ap.auth() == "APOP")
01206 mPop.authAPOP->setChecked( true );
01207 else mPop.authUser->setChecked( true );
01208
01209 slotEnableLeaveOnServerDays( mPop.leaveOnServerDaysCheck->isEnabled() ?
01210 ap.leaveOnServerDays() >= 1 : 0);
01211 slotEnableLeaveOnServerCount( mPop.leaveOnServerCountCheck->isEnabled() ?
01212 ap.leaveOnServerCount() >= 1 : 0);
01213 slotEnableLeaveOnServerSize( mPop.leaveOnServerSizeCheck->isEnabled() ?
01214 ap.leaveOnServerSize() >= 1 : 0);
01215 slotEnablePopInterval( interval >= 1 );
01216 folderCombo = mPop.folderCombo;
01217 }
01218 else if( accountType == "imap" )
01219 {
01220 KMAcctImap &ai = *(KMAcctImap*)mAccount;
01221 mImap.nameEdit->setText( mAccount->name() );
01222 mImap.nameEdit->setFocus();
01223 mImap.loginEdit->setText( ai.login() );
01224 mImap.passwordEdit->setText( ai.passwd());
01225 mImap.hostEdit->setText( ai.host() );
01226 mImap.portEdit->setText( QString("%1").arg( ai.port() ) );
01227 mImap.autoExpungeCheck->setChecked( ai.autoExpunge() );
01228 mImap.hiddenFoldersCheck->setChecked( ai.hiddenFolders() );
01229 mImap.subscribedFoldersCheck->setChecked( ai.onlySubscribedFolders() );
01230 mImap.locallySubscribedFoldersCheck->setChecked( ai.onlyLocallySubscribedFolders() );
01231 mImap.loadOnDemandCheck->setChecked( ai.loadOnDemand() );
01232 mImap.listOnlyOpenCheck->setChecked( ai.listOnlyOpenFolders() );
01233 mImap.storePasswordCheck->setChecked( ai.storePasswd() );
01234 mImap.intervalCheck->setChecked( interval >= 1 );
01235 mImap.intervalSpin->setValue( QMAX(1, interval) );
01236 #if 0
01237 mImap.resourceCheck->setChecked( ai.resource() );
01238 #endif
01239 mImap.includeInCheck->setChecked( !ai.checkExclude() );
01240 mImap.intervalCheck->setChecked( interval >= 1 );
01241 mImap.intervalSpin->setValue( QMAX(1, interval) );
01242 QString trashfolder = ai.trash();
01243 if (trashfolder.isEmpty())
01244 trashfolder = kmkernel->trashFolder()->idString();
01245 mImap.trashCombo->setFolder( trashfolder );
01246 slotEnableImapInterval( interval >= 1 );
01247 if (ai.useSSL())
01248 mImap.encryptionSSL->setChecked( true );
01249 else if (ai.useTLS())
01250 mImap.encryptionTLS->setChecked( true );
01251 else mImap.encryptionNone->setChecked( true );
01252 if (ai.auth() == "CRAM-MD5")
01253 mImap.authCramMd5->setChecked( true );
01254 else if (ai.auth() == "DIGEST-MD5")
01255 mImap.authDigestMd5->setChecked( true );
01256 else if (ai.auth() == "NTLM")
01257 mImap.authNTLM->setChecked( true );
01258 else if (ai.auth() == "GSSAPI")
01259 mImap.authGSSAPI->setChecked( true );
01260 else if (ai.auth() == "ANONYMOUS")
01261 mImap.authAnonymous->setChecked( true );
01262 else if (ai.auth() == "PLAIN")
01263 mImap.authPlain->setChecked( true );
01264 else if (ai.auth() == "LOGIN")
01265 mImap.authLogin->setChecked( true );
01266 else mImap.authUser->setChecked( true );
01267 if ( mSieveConfigEditor )
01268 mSieveConfigEditor->setConfig( ai.sieveConfig() );
01269 }
01270 else if( accountType == "cachedimap" )
01271 {
01272 KMAcctCachedImap &ai = *(KMAcctCachedImap*)mAccount;
01273 mImap.nameEdit->setText( mAccount->name() );
01274 mImap.nameEdit->setFocus();
01275 mImap.loginEdit->setText( ai.login() );
01276 mImap.passwordEdit->setText( ai.passwd());
01277 mImap.hostEdit->setText( ai.host() );
01278 mImap.portEdit->setText( QString("%1").arg( ai.port() ) );
01279 #if 0
01280 mImap.resourceCheck->setChecked( ai.resource() );
01281 #endif
01282 mImap.hiddenFoldersCheck->setChecked( ai.hiddenFolders() );
01283 mImap.subscribedFoldersCheck->setChecked( ai.onlySubscribedFolders() );
01284 mImap.locallySubscribedFoldersCheck->setChecked( ai.onlyLocallySubscribedFolders() );
01285 mImap.storePasswordCheck->setChecked( ai.storePasswd() );
01286 mImap.intervalCheck->setChecked( interval >= 1 );
01287 mImap.intervalSpin->setValue( QMAX(1, interval) );
01288 mImap.includeInCheck->setChecked( !ai.checkExclude() );
01289 mImap.intervalCheck->setChecked( interval >= 1 );
01290 mImap.intervalSpin->setValue( QMAX(1, interval) );
01291 QString trashfolder = ai.trash();
01292 if (trashfolder.isEmpty())
01293 trashfolder = kmkernel->trashFolder()->idString();
01294 mImap.trashCombo->setFolder( trashfolder );
01295 slotEnableImapInterval( interval >= 1 );
01296 if (ai.useSSL())
01297 mImap.encryptionSSL->setChecked( true );
01298 else if (ai.useTLS())
01299 mImap.encryptionTLS->setChecked( true );
01300 else mImap.encryptionNone->setChecked( true );
01301 if (ai.auth() == "CRAM-MD5")
01302 mImap.authCramMd5->setChecked( true );
01303 else if (ai.auth() == "DIGEST-MD5")
01304 mImap.authDigestMd5->setChecked( true );
01305 else if (ai.auth() == "GSSAPI")
01306 mImap.authGSSAPI->setChecked( true );
01307 else if (ai.auth() == "NTLM")
01308 mImap.authNTLM->setChecked( true );
01309 else if (ai.auth() == "ANONYMOUS")
01310 mImap.authAnonymous->setChecked( true );
01311 else if (ai.auth() == "PLAIN")
01312 mImap.authPlain->setChecked( true );
01313 else if (ai.auth() == "LOGIN")
01314 mImap.authLogin->setChecked( true );
01315 else mImap.authUser->setChecked( true );
01316 if ( mSieveConfigEditor )
01317 mSieveConfigEditor->setConfig( ai.sieveConfig() );
01318 }
01319 else if( accountType == "maildir" )
01320 {
01321 KMAcctMaildir *acctMaildir = dynamic_cast<KMAcctMaildir*>(mAccount);
01322
01323 mMaildir.nameEdit->setText( mAccount->name() );
01324 mMaildir.nameEdit->setFocus();
01325 mMaildir.locationEdit->setEditText( acctMaildir->location() );
01326
01327 mMaildir.intervalSpin->setValue( QMAX(1, interval) );
01328 mMaildir.intervalCheck->setChecked( interval >= 1 );
01329 #if 0
01330 mMaildir.resourceCheck->setChecked( mAccount->resource() );
01331 #endif
01332 mMaildir.includeInCheck->setChecked( !mAccount->checkExclude() );
01333 mMaildir.precommand->setText( mAccount->precommand() );
01334
01335 slotEnableMaildirInterval( interval >= 1 );
01336 folderCombo = mMaildir.folderCombo;
01337 }
01338 else
01339 return;
01340
01341 if ( accountType == "imap" || accountType == "cachedimap" )
01342 {
01343
01344 ImapAccountBase &ai = *(ImapAccountBase*)mAccount;
01345
01346 if ( ( ai.namespaces().isEmpty() || ai.namespaceToDelimiter().isEmpty() ) &&
01347 !ai.login().isEmpty() && !ai.passwd().isEmpty() && !ai.host().isEmpty() )
01348 {
01349 slotReloadNamespaces();
01350 } else {
01351 slotSetupNamespaces( ai.namespacesWithDelimiter() );
01352 }
01353 }
01354
01355 if (!folderCombo) return;
01356
01357 KMFolderDir *fdir = (KMFolderDir*)&kmkernel->folderMgr()->dir();
01358 KMFolder *acctFolder = mAccount->folder();
01359 if( acctFolder == 0 )
01360 {
01361 acctFolder = (KMFolder*)fdir->first();
01362 }
01363 if( acctFolder == 0 )
01364 {
01365 folderCombo->insertItem( i18n("<none>") );
01366 }
01367 else
01368 {
01369 uint i = 0;
01370 int curIndex = -1;
01371 kmkernel->folderMgr()->createI18nFolderList(&mFolderNames, &mFolderList);
01372 while (i < mFolderNames.count())
01373 {
01374 QValueList<QGuardedPtr<KMFolder> >::Iterator it = mFolderList.at(i);
01375 KMFolder *folder = *it;
01376 if (folder->isSystemFolder())
01377 {
01378 mFolderList.remove(it);
01379 mFolderNames.remove(mFolderNames.at(i));
01380 } else {
01381 if (folder == acctFolder) curIndex = i;
01382 i++;
01383 }
01384 }
01385 mFolderNames.prepend(i18n("inbox"));
01386 mFolderList.prepend(kmkernel->inboxFolder());
01387 folderCombo->insertStringList(mFolderNames);
01388 folderCombo->setCurrentItem(curIndex + 1);
01389
01390
01391 if (folderCombo->count() == 0)
01392 folderCombo->insertItem( i18n("inbox") );
01393 }
01394 }
01395
01396 void AccountDialog::slotLeaveOnServerClicked()
01397 {
01398 bool state = mPop.leaveOnServerCheck->isChecked();
01399 mPop.leaveOnServerDaysCheck->setEnabled( state );
01400 mPop.leaveOnServerCountCheck->setEnabled( state );
01401 mPop.leaveOnServerSizeCheck->setEnabled( state );
01402 if ( state ) {
01403 if ( mPop.leaveOnServerDaysCheck->isChecked() ) {
01404 slotEnableLeaveOnServerDays( state );
01405 }
01406 if ( mPop.leaveOnServerCountCheck->isChecked() ) {
01407 slotEnableLeaveOnServerCount( state );
01408 }
01409 if ( mPop.leaveOnServerSizeCheck->isChecked() ) {
01410 slotEnableLeaveOnServerSize( state );
01411 }
01412 } else {
01413 slotEnableLeaveOnServerDays( state );
01414 slotEnableLeaveOnServerCount( state );
01415 slotEnableLeaveOnServerSize( state );
01416 }
01417 if ( !( mCurCapa & UIDL ) && mPop.leaveOnServerCheck->isChecked() ) {
01418 KMessageBox::information( topLevelWidget(),
01419 i18n("The server does not seem to support unique "
01420 "message numbers, but this is a "
01421 "requirement for leaving messages on the "
01422 "server.\n"
01423 "Since some servers do not correctly "
01424 "announce their capabilities you still "
01425 "have the possibility to turn leaving "
01426 "fetched messages on the server on.") );
01427 }
01428 }
01429
01430 void AccountDialog::slotFilterOnServerClicked()
01431 {
01432 if ( !( mCurCapa & TOP ) && mPop.filterOnServerCheck->isChecked() ) {
01433 KMessageBox::information( topLevelWidget(),
01434 i18n("The server does not seem to support "
01435 "fetching message headers, but this is a "
01436 "requirement for filtering messages on the "
01437 "server.\n"
01438 "Since some servers do not correctly "
01439 "announce their capabilities you still "
01440 "have the possibility to turn filtering "
01441 "messages on the server on.") );
01442 }
01443 }
01444
01445 void AccountDialog::slotPipeliningClicked()
01446 {
01447 if (mPop.usePipeliningCheck->isChecked())
01448 KMessageBox::information( topLevelWidget(),
01449 i18n("Please note that this feature can cause some POP3 servers "
01450 "that do not support pipelining to send corrupted mail;\n"
01451 "this is configurable, though, because some servers support pipelining "
01452 "but do not announce their capabilities. To check whether your POP3 server "
01453 "announces pipelining support use the \"Check What the Server "
01454 "Supports\" button at the bottom of the dialog;\n"
01455 "if your server does not announce it, but you want more speed, then "
01456 "you should do some testing first by sending yourself a batch "
01457 "of mail and downloading it."), QString::null,
01458 "pipelining");
01459 }
01460
01461
01462 void AccountDialog::slotPopEncryptionChanged(int id)
01463 {
01464 kdDebug(5006) << "slotPopEncryptionChanged( " << id << " )" << endl;
01465
01466 if ( id == SSL || mPop.portEdit->text() == "995" )
01467 mPop.portEdit->setText( ( id == SSL ) ? "995" : "110" );
01468
01469
01470 mCurCapa = ( id == TLS ) ? mCapaTLS
01471 : ( id == SSL ) ? mCapaSSL
01472 : mCapaNormal;
01473 enablePopFeatures( mCurCapa );
01474 const QButton *old = mPop.authGroup->selected();
01475 if ( !old->isEnabled() )
01476 checkHighest( mPop.authGroup );
01477 }
01478
01479
01480 void AccountDialog::slotImapEncryptionChanged(int id)
01481 {
01482 kdDebug(5006) << "slotImapEncryptionChanged( " << id << " )" << endl;
01483
01484 if ( id == SSL || mImap.portEdit->text() == "993" )
01485 mImap.portEdit->setText( ( id == SSL ) ? "993" : "143" );
01486
01487
01488 int authMethods = ( id == TLS ) ? mCapaTLS
01489 : ( id == SSL ) ? mCapaSSL
01490 : mCapaNormal;
01491 enableImapAuthMethods( authMethods );
01492 QButton *old = mImap.authGroup->selected();
01493 if ( !old->isEnabled() )
01494 checkHighest( mImap.authGroup );
01495 }
01496
01497
01498 void AccountDialog::slotCheckPopCapabilities()
01499 {
01500 if ( mPop.hostEdit->text().isEmpty() || mPop.portEdit->text().isEmpty() )
01501 {
01502 KMessageBox::sorry( this, i18n( "Please specify a server and port on "
01503 "the General tab first." ) );
01504 return;
01505 }
01506 delete mServerTest;
01507 mServerTest = new KMServerTest(POP_PROTOCOL, mPop.hostEdit->text(),
01508 mPop.portEdit->text().toInt());
01509 connect( mServerTest, SIGNAL( capabilities( const QStringList &,
01510 const QStringList & ) ),
01511 this, SLOT( slotPopCapabilities( const QStringList &,
01512 const QStringList & ) ) );
01513 mPop.checkCapabilities->setEnabled(false);
01514 }
01515
01516
01517 void AccountDialog::slotCheckImapCapabilities()
01518 {
01519 if ( mImap.hostEdit->text().isEmpty() || mImap.portEdit->text().isEmpty() )
01520 {
01521 KMessageBox::sorry( this, i18n( "Please specify a server and port on "
01522 "the General tab first." ) );
01523 return;
01524 }
01525 delete mServerTest;
01526 mServerTest = new KMServerTest(IMAP_PROTOCOL, mImap.hostEdit->text(),
01527 mImap.portEdit->text().toInt());
01528 connect( mServerTest, SIGNAL( capabilities( const QStringList &,
01529 const QStringList & ) ),
01530 this, SLOT( slotImapCapabilities( const QStringList &,
01531 const QStringList & ) ) );
01532 mImap.checkCapabilities->setEnabled(false);
01533 }
01534
01535
01536 unsigned int AccountDialog::popCapabilitiesFromStringList( const QStringList & l )
01537 {
01538 unsigned int capa = 0;
01539 kdDebug( 5006 ) << k_funcinfo << l << endl;
01540 for ( QStringList::const_iterator it = l.begin() ; it != l.end() ; ++it ) {
01541 QString cur = (*it).upper();
01542 if ( cur == "PLAIN" )
01543 capa |= Plain;
01544 else if ( cur == "LOGIN" )
01545 capa |= Login;
01546 else if ( cur == "CRAM-MD5" )
01547 capa |= CRAM_MD5;
01548 else if ( cur == "DIGEST-MD5" )
01549 capa |= Digest_MD5;
01550 else if ( cur == "NTLM" )
01551 capa |= NTLM;
01552 else if ( cur == "GSSAPI" )
01553 capa |= GSSAPI;
01554 else if ( cur == "APOP" )
01555 capa |= APOP;
01556 else if ( cur == "PIPELINING" )
01557 capa |= Pipelining;
01558 else if ( cur == "TOP" )
01559 capa |= TOP;
01560 else if ( cur == "UIDL" )
01561 capa |= UIDL;
01562 else if ( cur == "STLS" )
01563 capa |= STLS;
01564 }
01565 return capa;
01566 }
01567
01568
01569 void AccountDialog::slotPopCapabilities( const QStringList & capaNormal,
01570 const QStringList & capaSSL )
01571 {
01572 mPop.checkCapabilities->setEnabled( true );
01573 mCapaNormal = popCapabilitiesFromStringList( capaNormal );
01574 if ( mCapaNormal & STLS )
01575 mCapaTLS = mCapaNormal;
01576 else
01577 mCapaTLS = 0;
01578 mCapaSSL = popCapabilitiesFromStringList( capaSSL );
01579 kdDebug(5006) << "mCapaNormal = " << mCapaNormal
01580 << "; mCapaSSL = " << mCapaSSL
01581 << "; mCapaTLS = " << mCapaTLS << endl;
01582 mPop.encryptionNone->setEnabled( !capaNormal.isEmpty() );
01583 mPop.encryptionSSL->setEnabled( !capaSSL.isEmpty() );
01584 mPop.encryptionTLS->setEnabled( mCapaTLS != 0 );
01585 checkHighest( mPop.encryptionGroup );
01586 delete mServerTest;
01587 mServerTest = 0;
01588 }
01589
01590
01591 void AccountDialog::enablePopFeatures( unsigned int capa )
01592 {
01593 kdDebug(5006) << "enablePopFeatures( " << capa << " )" << endl;
01594 mPop.authPlain->setEnabled( capa & Plain );
01595 mPop.authLogin->setEnabled( capa & Login );
01596 mPop.authCRAM_MD5->setEnabled( capa & CRAM_MD5 );
01597 mPop.authDigestMd5->setEnabled( capa & Digest_MD5 );
01598 mPop.authNTLM->setEnabled( capa & NTLM );
01599 mPop.authGSSAPI->setEnabled( capa & GSSAPI );
01600 mPop.authAPOP->setEnabled( capa & APOP );
01601 if ( !( capa & Pipelining ) && mPop.usePipeliningCheck->isChecked() ) {
01602 mPop.usePipeliningCheck->setChecked( false );
01603 KMessageBox::information( topLevelWidget(),
01604 i18n("The server does not seem to support "
01605 "pipelining; therefore, this option has "
01606 "been disabled.\n"
01607 "Since some servers do not correctly "
01608 "announce their capabilities you still "
01609 "have the possibility to turn pipelining "
01610 "on. But please note that this feature can "
01611 "cause some POP servers that do not "
01612 "support pipelining to send corrupt "
01613 "messages. So before using this feature "
01614 "with important mail you should first "
01615 "test it by sending yourself a larger "
01616 "number of test messages which you all "
01617 "download in one go from the POP "
01618 "server.") );
01619 }
01620 if ( !( capa & UIDL ) && mPop.leaveOnServerCheck->isChecked() ) {
01621 mPop.leaveOnServerCheck->setChecked( false );
01622 KMessageBox::information( topLevelWidget(),
01623 i18n("The server does not seem to support unique "
01624 "message numbers, but this is a "
01625 "requirement for leaving messages on the "
01626 "server; therefore, this option has been "
01627 "disabled.\n"
01628 "Since some servers do not correctly "
01629 "announce their capabilities you still "
01630 "have the possibility to turn leaving "
01631 "fetched messages on the server on.") );
01632 }
01633 if ( !( capa & TOP ) && mPop.filterOnServerCheck->isChecked() ) {
01634 mPop.filterOnServerCheck->setChecked( false );
01635 KMessageBox::information( topLevelWidget(),
01636 i18n("The server does not seem to support "
01637 "fetching message headers, but this is a "
01638 "requirement for filtering messages on the "
01639 "server; therefore, this option has been "
01640 "disabled.\n"
01641 "Since some servers do not correctly "
01642 "announce their capabilities you still "
01643 "have the possibility to turn filtering "
01644 "messages on the server on.") );
01645 }
01646 }
01647
01648
01649 unsigned int AccountDialog::imapCapabilitiesFromStringList( const QStringList & l )
01650 {
01651 unsigned int capa = 0;
01652 for ( QStringList::const_iterator it = l.begin() ; it != l.end() ; ++it ) {
01653 QString cur = (*it).upper();
01654 if ( cur == "AUTH=PLAIN" )
01655 capa |= Plain;
01656 else if ( cur == "AUTH=LOGIN" )
01657 capa |= Login;
01658 else if ( cur == "AUTH=CRAM-MD5" )
01659 capa |= CRAM_MD5;
01660 else if ( cur == "AUTH=DIGEST-MD5" )
01661 capa |= Digest_MD5;
01662 else if ( cur == "AUTH=NTLM" )
01663 capa |= NTLM;
01664 else if ( cur == "AUTH=GSSAPI" )
01665 capa |= GSSAPI;
01666 else if ( cur == "AUTH=ANONYMOUS" )
01667 capa |= Anonymous;
01668 else if ( cur == "STARTTLS" )
01669 capa |= STARTTLS;
01670 }
01671 return capa;
01672 }
01673
01674
01675 void AccountDialog::slotImapCapabilities( const QStringList & capaNormal,
01676 const QStringList & capaSSL )
01677 {
01678 mImap.checkCapabilities->setEnabled( true );
01679 mCapaNormal = imapCapabilitiesFromStringList( capaNormal );
01680 if ( mCapaNormal & STARTTLS )
01681 mCapaTLS = mCapaNormal;
01682 else
01683 mCapaTLS = 0;
01684 mCapaSSL = imapCapabilitiesFromStringList( capaSSL );
01685 kdDebug(5006) << "mCapaNormal = " << mCapaNormal
01686 << "; mCapaSSL = " << mCapaSSL
01687 << "; mCapaTLS = " << mCapaTLS << endl;
01688 mImap.encryptionNone->setEnabled( !capaNormal.isEmpty() );
01689 mImap.encryptionSSL->setEnabled( !capaSSL.isEmpty() );
01690 mImap.encryptionTLS->setEnabled( mCapaTLS != 0 );
01691 checkHighest( mImap.encryptionGroup );
01692 delete mServerTest;
01693 mServerTest = 0;
01694 }
01695
01696 void AccountDialog::slotLeaveOnServerDaysChanged ( int value )
01697 {
01698 mPop.leaveOnServerDaysSpin->setSuffix( i18n(" day", " days", value) );
01699 }
01700
01701
01702 void AccountDialog::slotLeaveOnServerCountChanged ( int value )
01703 {
01704 mPop.leaveOnServerCountSpin->setSuffix( i18n(" message", " messages", value) );
01705 }
01706
01707
01708 void AccountDialog::slotFilterOnServerSizeChanged ( int value )
01709 {
01710 mPop.filterOnServerSizeSpin->setSuffix( i18n(" byte", " bytes", value) );
01711 }
01712
01713
01714 void AccountDialog::enableImapAuthMethods( unsigned int capa )
01715 {
01716 kdDebug(5006) << "enableImapAuthMethods( " << capa << " )" << endl;
01717 mImap.authPlain->setEnabled( capa & Plain );
01718 mImap.authLogin->setEnabled( capa & Login );
01719 mImap.authCramMd5->setEnabled( capa & CRAM_MD5 );
01720 mImap.authDigestMd5->setEnabled( capa & Digest_MD5 );
01721 mImap.authNTLM->setEnabled( capa & NTLM );
01722 mImap.authGSSAPI->setEnabled( capa & GSSAPI );
01723 mImap.authAnonymous->setEnabled( capa & Anonymous );
01724 }
01725
01726
01727 void AccountDialog::checkHighest( QButtonGroup *btnGroup )
01728 {
01729 kdDebug(5006) << "checkHighest( " << btnGroup << " )" << endl;
01730 for ( int i = btnGroup->count() - 1; i >= 0 ; --i ) {
01731 QButton * btn = btnGroup->find( i );
01732 if ( btn && btn->isEnabled() ) {
01733 btn->animateClick();
01734 return;
01735 }
01736 }
01737 }
01738
01739
01740 void AccountDialog::slotOk()
01741 {
01742 saveSettings();
01743 accept();
01744 }
01745
01746
01747 void AccountDialog::saveSettings()
01748 {
01749 QString accountType = mAccount->type();
01750 if( accountType == "local" )
01751 {
01752 KMAcctLocal *acctLocal = dynamic_cast<KMAcctLocal*>(mAccount);
01753
01754 if (acctLocal) {
01755 mAccount->setName( mLocal.nameEdit->text() );
01756 acctLocal->setLocation( mLocal.locationEdit->currentText() );
01757 if (mLocal.lockMutt->isChecked())
01758 acctLocal->setLockType(mutt_dotlock);
01759 else if (mLocal.lockMuttPriv->isChecked())
01760 acctLocal->setLockType(mutt_dotlock_privileged);
01761 else if (mLocal.lockProcmail->isChecked()) {
01762 acctLocal->setLockType(procmail_lockfile);
01763 acctLocal->setProcmailLockFileName(mLocal.procmailLockFileName->currentText());
01764 }
01765 else if (mLocal.lockNone->isChecked())
01766 acctLocal->setLockType(lock_none);
01767 else acctLocal->setLockType(FCNTL);
01768 }
01769
01770 mAccount->setCheckInterval( mLocal.intervalCheck->isChecked() ?
01771 mLocal.intervalSpin->value() : 0 );
01772 #if 0
01773 mAccount->setResource( mLocal.resourceCheck->isChecked() );
01774 #endif
01775 mAccount->setCheckExclude( !mLocal.includeInCheck->isChecked() );
01776
01777 mAccount->setPrecommand( mLocal.precommand->text() );
01778
01779 mAccount->setFolder( *mFolderList.at(mLocal.folderCombo->currentItem()) );
01780
01781 }
01782 else if( accountType == "pop" )
01783 {
01784 mAccount->setName( mPop.nameEdit->text() );
01785 mAccount->setCheckInterval( mPop.intervalCheck->isChecked() ?
01786 mPop.intervalSpin->value() : 0 );
01787 #if 0
01788 mAccount->setResource( mPop.resourceCheck->isChecked() );
01789 #endif
01790 mAccount->setCheckExclude( !mPop.includeInCheck->isChecked() );
01791
01792 mAccount->setFolder( *mFolderList.at(mPop.folderCombo->currentItem()) );
01793
01794 initAccountForConnect();
01795 PopAccount &epa = *(PopAccount*)mAccount;
01796 epa.setUsePipelining( mPop.usePipeliningCheck->isChecked() );
01797 epa.setLeaveOnServer( mPop.leaveOnServerCheck->isChecked() );
01798 epa.setLeaveOnServerDays( mPop.leaveOnServerCheck->isChecked() ?
01799 ( mPop.leaveOnServerDaysCheck->isChecked() ?
01800 mPop.leaveOnServerDaysSpin->value() : -1 ) : 0);
01801 epa.setLeaveOnServerCount( mPop.leaveOnServerCheck->isChecked() ?
01802 ( mPop.leaveOnServerCountCheck->isChecked() ?
01803 mPop.leaveOnServerCountSpin->value() : -1 ) : 0 );
01804 epa.setLeaveOnServerSize( mPop.leaveOnServerCheck->isChecked() ?
01805 ( mPop.leaveOnServerSizeCheck->isChecked() ?
01806 mPop.leaveOnServerSizeSpin->value() : -1 ) : 0 );
01807 epa.setFilterOnServer( mPop.filterOnServerCheck->isChecked() );
01808 epa.setFilterOnServerCheckSize (mPop.filterOnServerSizeSpin->value() );
01809 epa.setPrecommand( mPop.precommand->text() );
01810 }
01811 else if( accountType == "imap" )
01812 {
01813 mAccount->setName( mImap.nameEdit->text() );
01814 mAccount->setCheckInterval( mImap.intervalCheck->isChecked() ?
01815 mImap.intervalSpin->value() : 0 );
01816 #if 0
01817 mAccount->setResource( mImap.resourceCheck->isChecked() );
01818 #endif
01819 mAccount->setCheckExclude( !mImap.includeInCheck->isChecked() );
01820 mAccount->setFolder( kmkernel->imapFolderMgr()->findById(mAccount->id()) );
01821
01822 initAccountForConnect();
01823 KMAcctImap &epa = *(KMAcctImap*)mAccount;
01824 epa.setAutoExpunge( mImap.autoExpungeCheck->isChecked() );
01825 epa.setHiddenFolders( mImap.hiddenFoldersCheck->isChecked() );
01826 epa.setOnlySubscribedFolders( mImap.subscribedFoldersCheck->isChecked() );
01827 epa.setOnlyLocallySubscribedFolders( mImap.locallySubscribedFoldersCheck->isChecked() );
01828 epa.setLoadOnDemand( mImap.loadOnDemandCheck->isChecked() );
01829 epa.setListOnlyOpenFolders( mImap.listOnlyOpenCheck->isChecked() );
01830 KMFolder *t = mImap.trashCombo->folder();
01831 if ( t )
01832 epa.setTrash( mImap.trashCombo->folder()->idString() );
01833 else
01834 epa.setTrash( kmkernel->trashFolder()->idString() );
01835 #if 0
01836 epa.setResource( mImap.resourceCheck->isChecked() );
01837 #endif
01838 epa.setCheckExclude( !mImap.includeInCheck->isChecked() );
01839 if ( mSieveConfigEditor )
01840 epa.setSieveConfig( mSieveConfigEditor->config() );
01841 }
01842 else if( accountType == "cachedimap" )
01843 {
01844 mAccount->setName( mImap.nameEdit->text() );
01845 mAccount->setCheckInterval( mImap.intervalCheck->isChecked() ?
01846 mImap.intervalSpin->value() : 0 );
01847 #if 0
01848 mAccount->setResource( mImap.resourceCheck->isChecked() );
01849 #endif
01850 mAccount->setCheckExclude( !mImap.includeInCheck->isChecked() );
01851
01852 mAccount->setFolder( kmkernel->dimapFolderMgr()->findById(mAccount->id()) );
01853
01854
01855 initAccountForConnect();
01856 KMAcctCachedImap &epa = *(KMAcctCachedImap*)mAccount;
01857 epa.setHiddenFolders( mImap.hiddenFoldersCheck->isChecked() );
01858 epa.setOnlySubscribedFolders( mImap.subscribedFoldersCheck->isChecked() );
01859 epa.setOnlyLocallySubscribedFolders( mImap.locallySubscribedFoldersCheck->isChecked() );
01860 epa.setStorePasswd( mImap.storePasswordCheck->isChecked() );
01861 epa.setPasswd( mImap.passwordEdit->text(), epa.storePasswd() );
01862 KMFolder *t = mImap.trashCombo->folder();
01863 if ( t )
01864 epa.setTrash( mImap.trashCombo->folder()->idString() );
01865 else
01866 epa.setTrash( kmkernel->trashFolder()->idString() );
01867 #if 0
01868 epa.setResource( mImap.resourceCheck->isChecked() );
01869 #endif
01870 epa.setCheckExclude( !mImap.includeInCheck->isChecked() );
01871 if ( mSieveConfigEditor )
01872 epa.setSieveConfig( mSieveConfigEditor->config() );
01873 }
01874 else if( accountType == "maildir" )
01875 {
01876 KMAcctMaildir *acctMaildir = dynamic_cast<KMAcctMaildir*>(mAccount);
01877
01878 if (acctMaildir) {
01879 mAccount->setName( mMaildir.nameEdit->text() );
01880 acctMaildir->setLocation( mMaildir.locationEdit->currentText() );
01881
01882 KMFolder *targetFolder = *mFolderList.at(mMaildir.folderCombo->currentItem());
01883 if ( targetFolder->location() == acctMaildir->location() ) {
01884
01885
01886
01887
01888
01889 targetFolder = kmkernel->inboxFolder();
01890 }
01891 mAccount->setFolder( targetFolder );
01892 }
01893 mAccount->setCheckInterval( mMaildir.intervalCheck->isChecked() ?
01894 mMaildir.intervalSpin->value() : 0 );
01895 #if 0
01896 mAccount->setResource( mMaildir.resourceCheck->isChecked() );
01897 #endif
01898 mAccount->setCheckExclude( !mMaildir.includeInCheck->isChecked() );
01899
01900 mAccount->setPrecommand( mMaildir.precommand->text() );
01901 }
01902
01903 if ( accountType == "imap" || accountType == "cachedimap" )
01904 {
01905
01906 ImapAccountBase &ai = *(ImapAccountBase*)mAccount;
01907
01908 ImapAccountBase::nsMap map;
01909 ImapAccountBase::namespaceDelim delimMap;
01910 ImapAccountBase::nsDelimMap::Iterator it;
01911 ImapAccountBase::namespaceDelim::Iterator it2;
01912 for ( it = mImap.nsMap.begin(); it != mImap.nsMap.end(); ++it ) {
01913 QStringList list;
01914 for ( it2 = it.data().begin(); it2 != it.data().end(); ++it2 ) {
01915 list << it2.key();
01916 delimMap[it2.key()] = it2.data();
01917 }
01918 map[it.key()] = list;
01919 }
01920 ai.setNamespaces( map );
01921 ai.setNamespaceToDelimiter( delimMap );
01922 }
01923
01924 kmkernel->acctMgr()->writeConfig( true );
01925
01926
01927
01928
01929 KMAccount* newAcct = kmkernel->acctMgr()->find(mAccount->id());
01930 if (newAcct)
01931 {
01932 if( accountType == "local" ) {
01933 newAcct->setFolder( *mFolderList.at(mLocal.folderCombo->currentItem()), true );
01934 } else if ( accountType == "pop" ) {
01935 newAcct->setFolder( *mFolderList.at(mPop.folderCombo->currentItem()), true );
01936 } else if ( accountType == "maildir" ) {
01937 newAcct->setFolder( *mFolderList.at(mMaildir.folderCombo->currentItem()), true );
01938 } else if ( accountType == "imap" ) {
01939 newAcct->setFolder( kmkernel->imapFolderMgr()->findById(mAccount->id()), true );
01940 } else if ( accountType == "cachedimap" ) {
01941 newAcct->setFolder( kmkernel->dimapFolderMgr()->findById(mAccount->id()), true );
01942 }
01943 }
01944 }
01945
01946
01947 void AccountDialog::slotLocationChooser()
01948 {
01949 static QString directory( "/" );
01950
01951 KFileDialog dialog( directory, QString::null, this, 0, true );
01952 dialog.setCaption( i18n("Choose Location") );
01953
01954 bool result = dialog.exec();
01955 if( result == false )
01956 {
01957 return;
01958 }
01959
01960 KURL url = dialog.selectedURL();
01961 if( url.isEmpty() )
01962 {
01963 return;
01964 }
01965 if( url.isLocalFile() == false )
01966 {
01967 KMessageBox::sorry( 0, i18n( "Only local files are currently supported." ) );
01968 return;
01969 }
01970
01971 mLocal.locationEdit->setEditText( url.path() );
01972 directory = url.directory();
01973 }
01974
01975 void AccountDialog::slotMaildirChooser()
01976 {
01977 static QString directory( "/" );
01978
01979 QString dir = KFileDialog::getExistingDirectory(directory, this, i18n("Choose Location"));
01980
01981 if( dir.isEmpty() )
01982 return;
01983
01984 mMaildir.locationEdit->setEditText( dir );
01985 directory = dir;
01986 }
01987
01988 void AccountDialog::slotEnableLeaveOnServerDays( bool state )
01989 {
01990 if ( state && !mPop.leaveOnServerDaysCheck->isEnabled()) return;
01991 mPop.leaveOnServerDaysSpin->setEnabled( state );
01992 }
01993
01994 void AccountDialog::slotEnableLeaveOnServerCount( bool state )
01995 {
01996 if ( state && !mPop.leaveOnServerCountCheck->isEnabled()) return;
01997 mPop.leaveOnServerCountSpin->setEnabled( state );
01998 return;
01999 }
02000
02001 void AccountDialog::slotEnableLeaveOnServerSize( bool state )
02002 {
02003 if ( state && !mPop.leaveOnServerSizeCheck->isEnabled()) return;
02004 mPop.leaveOnServerSizeSpin->setEnabled( state );
02005 return;
02006 }
02007
02008 void AccountDialog::slotEnablePopInterval( bool state )
02009 {
02010 mPop.intervalSpin->setEnabled( state );
02011 mPop.intervalLabel->setEnabled( state );
02012 }
02013
02014 void AccountDialog::slotEnableImapInterval( bool state )
02015 {
02016 mImap.intervalSpin->setEnabled( state );
02017 mImap.intervalLabel->setEnabled( state );
02018 }
02019
02020 void AccountDialog::slotEnableLocalInterval( bool state )
02021 {
02022 mLocal.intervalSpin->setEnabled( state );
02023 mLocal.intervalLabel->setEnabled( state );
02024 }
02025
02026 void AccountDialog::slotEnableMaildirInterval( bool state )
02027 {
02028 mMaildir.intervalSpin->setEnabled( state );
02029 mMaildir.intervalLabel->setEnabled( state );
02030 }
02031
02032 void AccountDialog::slotFontChanged( void )
02033 {
02034 QString accountType = mAccount->type();
02035 if( accountType == "local" )
02036 {
02037 QFont titleFont( mLocal.titleLabel->font() );
02038 titleFont.setBold( true );
02039 mLocal.titleLabel->setFont(titleFont);
02040 }
02041 else if( accountType == "pop" )
02042 {
02043 QFont titleFont( mPop.titleLabel->font() );
02044 titleFont.setBold( true );
02045 mPop.titleLabel->setFont(titleFont);
02046 }
02047 else if( accountType == "imap" )
02048 {
02049 QFont titleFont( mImap.titleLabel->font() );
02050 titleFont.setBold( true );
02051 mImap.titleLabel->setFont(titleFont);
02052 }
02053 }
02054
02055
02056
02057 #if 0
02058 void AccountDialog::slotClearResourceAllocations()
02059 {
02060 mAccount->clearIntervals();
02061 }
02062
02063
02064 void AccountDialog::slotClearPastResourceAllocations()
02065 {
02066 mAccount->clearOldIntervals();
02067 }
02068 #endif
02069
02070 void AccountDialog::slotReloadNamespaces()
02071 {
02072 if ( mAccount->type() == "imap" || mAccount->type() == "cachedimap" )
02073 {
02074 initAccountForConnect();
02075 mImap.personalNS->setText( i18n("Fetching Namespaces...") );
02076 mImap.otherUsersNS->setText( QString::null );
02077 mImap.sharedNS->setText( QString::null );
02078 ImapAccountBase* ai = static_cast<ImapAccountBase*>( mAccount );
02079 connect( ai, SIGNAL( namespacesFetched( const ImapAccountBase::nsDelimMap& ) ),
02080 this, SLOT( slotSetupNamespaces( const ImapAccountBase::nsDelimMap& ) ) );
02081 connect( ai, SIGNAL( connectionResult(int, const QString&) ),
02082 this, SLOT( slotConnectionResult(int, const QString&) ) );
02083 ai->getNamespaces();
02084 }
02085 }
02086
02087 void AccountDialog::slotConnectionResult( int errorCode, const QString& )
02088 {
02089 if ( errorCode > 0 ) {
02090 ImapAccountBase* ai = static_cast<ImapAccountBase*>( mAccount );
02091 disconnect( ai, SIGNAL( namespacesFetched( const ImapAccountBase::nsDelimMap& ) ),
02092 this, SLOT( slotSetupNamespaces( const ImapAccountBase::nsDelimMap& ) ) );
02093 disconnect( ai, SIGNAL( connectionResult(int, const QString&) ),
02094 this, SLOT( slotConnectionResult(int, const QString&) ) );
02095 mImap.personalNS->setText( QString::null );
02096 }
02097 }
02098
02099 void AccountDialog::slotSetupNamespaces( const ImapAccountBase::nsDelimMap& map )
02100 {
02101 disconnect( this, SLOT( slotSetupNamespaces( const ImapAccountBase::nsDelimMap& ) ) );
02102 mImap.personalNS->setText( QString::null );
02103 mImap.otherUsersNS->setText( QString::null );
02104 mImap.sharedNS->setText( QString::null );
02105 mImap.nsMap = map;
02106
02107 ImapAccountBase::namespaceDelim ns = map[ImapAccountBase::PersonalNS];
02108 ImapAccountBase::namespaceDelim::ConstIterator it;
02109 if ( !ns.isEmpty() ) {
02110 mImap.personalNS->setText( namespaceListToString( ns.keys() ) );
02111 mImap.editPNS->setEnabled( true );
02112 } else {
02113 mImap.editPNS->setEnabled( false );
02114 }
02115 ns = map[ImapAccountBase::OtherUsersNS];
02116 if ( !ns.isEmpty() ) {
02117 mImap.otherUsersNS->setText( namespaceListToString( ns.keys() ) );
02118 mImap.editONS->setEnabled( true );
02119 } else {
02120 mImap.editONS->setEnabled( false );
02121 }
02122 ns = map[ImapAccountBase::SharedNS];
02123 if ( !ns.isEmpty() ) {
02124 mImap.sharedNS->setText( namespaceListToString( ns.keys() ) );
02125 mImap.editSNS->setEnabled( true );
02126 } else {
02127 mImap.editSNS->setEnabled( false );
02128 }
02129 }
02130
02131 const QString AccountDialog::namespaceListToString( const QStringList& list )
02132 {
02133 QStringList myList = list;
02134 for ( QStringList::Iterator it = myList.begin(); it != myList.end(); ++it ) {
02135 if ( (*it).isEmpty() ) {
02136 (*it) = "<" + i18n("Empty") + ">";
02137 }
02138 }
02139 return myList.join(",");
02140 }
02141
02142 void AccountDialog::initAccountForConnect()
02143 {
02144 QString type = mAccount->type();
02145 if ( type == "local" )
02146 return;
02147
02148 NetworkAccount &na = *(NetworkAccount*)mAccount;
02149
02150 if ( type == "pop" ) {
02151 na.setHost( mPop.hostEdit->text().stripWhiteSpace() );
02152 na.setPort( mPop.portEdit->text().toInt() );
02153 na.setLogin( mPop.loginEdit->text().stripWhiteSpace() );
02154 na.setStorePasswd( mPop.storePasswordCheck->isChecked() );
02155 na.setPasswd( mPop.passwordEdit->text(), na.storePasswd() );
02156 na.setUseSSL( mPop.encryptionSSL->isChecked() );
02157 na.setUseTLS( mPop.encryptionTLS->isChecked() );
02158 if (mPop.authUser->isChecked())
02159 na.setAuth("USER");
02160 else if (mPop.authLogin->isChecked())
02161 na.setAuth("LOGIN");
02162 else if (mPop.authPlain->isChecked())
02163 na.setAuth("PLAIN");
02164 else if (mPop.authCRAM_MD5->isChecked())
02165 na.setAuth("CRAM-MD5");
02166 else if (mPop.authDigestMd5->isChecked())
02167 na.setAuth("DIGEST-MD5");
02168 else if (mPop.authNTLM->isChecked())
02169 na.setAuth("NTLM");
02170 else if (mPop.authGSSAPI->isChecked())
02171 na.setAuth("GSSAPI");
02172 else if (mPop.authAPOP->isChecked())
02173 na.setAuth("APOP");
02174 else na.setAuth("AUTO");
02175 }
02176 else if ( type == "imap" || type == "cachedimap" ) {
02177 na.setHost( mImap.hostEdit->text().stripWhiteSpace() );
02178 na.setPort( mImap.portEdit->text().toInt() );
02179 na.setLogin( mImap.loginEdit->text().stripWhiteSpace() );
02180 na.setStorePasswd( mImap.storePasswordCheck->isChecked() );
02181 na.setPasswd( mImap.passwordEdit->text(), na.storePasswd() );
02182 na.setUseSSL( mImap.encryptionSSL->isChecked() );
02183 na.setUseTLS( mImap.encryptionTLS->isChecked() );
02184 if (mImap.authCramMd5->isChecked())
02185 na.setAuth("CRAM-MD5");
02186 else if (mImap.authDigestMd5->isChecked())
02187 na.setAuth("DIGEST-MD5");
02188 else if (mImap.authNTLM->isChecked())
02189 na.setAuth("NTLM");
02190 else if (mImap.authGSSAPI->isChecked())
02191 na.setAuth("GSSAPI");
02192 else if (mImap.authAnonymous->isChecked())
02193 na.setAuth("ANONYMOUS");
02194 else if (mImap.authLogin->isChecked())
02195 na.setAuth("LOGIN");
02196 else if (mImap.authPlain->isChecked())
02197 na.setAuth("PLAIN");
02198 else na.setAuth("*");
02199 }
02200 }
02201
02202 void AccountDialog::slotEditPersonalNamespace()
02203 {
02204 NamespaceEditDialog dialog( this, ImapAccountBase::PersonalNS, &mImap.nsMap );
02205 if ( dialog.exec() == QDialog::Accepted ) {
02206 slotSetupNamespaces( mImap.nsMap );
02207 }
02208 }
02209
02210 void AccountDialog::slotEditOtherUsersNamespace()
02211 {
02212 NamespaceEditDialog dialog( this, ImapAccountBase::OtherUsersNS, &mImap.nsMap );
02213 if ( dialog.exec() == QDialog::Accepted ) {
02214 slotSetupNamespaces( mImap.nsMap );
02215 }
02216 }
02217
02218 void AccountDialog::slotEditSharedNamespace()
02219 {
02220 NamespaceEditDialog dialog( this, ImapAccountBase::SharedNS, &mImap.nsMap );
02221 if ( dialog.exec() == QDialog::Accepted ) {
02222 slotSetupNamespaces( mImap.nsMap );
02223 }
02224 }
02225
02226 NamespaceLineEdit::NamespaceLineEdit( QWidget* parent )
02227 : KLineEdit( parent )
02228 {
02229 }
02230
02231 void NamespaceLineEdit::setText( const QString& text )
02232 {
02233 mLastText = text;
02234 KLineEdit::setText( text );
02235 }
02236
02237 NamespaceEditDialog::NamespaceEditDialog( QWidget *parent,
02238 ImapAccountBase::imapNamespace type, ImapAccountBase::nsDelimMap* map )
02239 : KDialogBase( parent, "edit_namespace", false, QString::null,
02240 Ok|Cancel, Ok, true ), mType( type ), mNamespaceMap( map )
02241 {
02242 QVBox *page = makeVBoxMainWidget();
02243
02244 QString ns;
02245 if ( mType == ImapAccountBase::PersonalNS ) {
02246 ns = i18n("Personal");
02247 } else if ( mType == ImapAccountBase::OtherUsersNS ) {
02248 ns = i18n("Other Users");
02249 } else {
02250 ns = i18n("Shared");
02251 }
02252 setCaption( i18n("Edit Namespace '%1'").arg(ns) );
02253 QGrid* grid = new QGrid( 2, page );
02254
02255 mBg = new QButtonGroup( 0 );
02256 connect( mBg, SIGNAL( clicked(int) ), this, SLOT( slotRemoveEntry(int) ) );
02257 mDelimMap = mNamespaceMap->find( mType ).data();
02258 ImapAccountBase::namespaceDelim::Iterator it;
02259 for ( it = mDelimMap.begin(); it != mDelimMap.end(); ++it ) {
02260 NamespaceLineEdit* edit = new NamespaceLineEdit( grid );
02261 edit->setText( it.key() );
02262 QToolButton* button = new QToolButton( grid );
02263 button->setIconSet(
02264 KGlobal::iconLoader()->loadIconSet( "editdelete", KIcon::Small, 0 ) );
02265 button->setAutoRaise( true );
02266 button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
02267 button->setFixedSize( 22, 22 );
02268 mLineEditMap[ mBg->insert( button ) ] = edit;
02269 }
02270 }
02271
02272 void NamespaceEditDialog::slotRemoveEntry( int id )
02273 {
02274 if ( mLineEditMap.contains( id ) ) {
02275
02276 NamespaceLineEdit* edit = mLineEditMap[id];
02277 mDelimMap.remove( edit->text() );
02278 if ( edit->isModified() ) {
02279 mDelimMap.remove( edit->lastText() );
02280 }
02281 mLineEditMap.remove( id );
02282 delete edit;
02283 }
02284 if ( mBg->find( id ) ) {
02285
02286 delete mBg->find( id );
02287 }
02288 adjustSize();
02289 }
02290
02291 void NamespaceEditDialog::slotOk()
02292 {
02293 QMap<int, NamespaceLineEdit*>::Iterator it;
02294 for ( it = mLineEditMap.begin(); it != mLineEditMap.end(); ++it ) {
02295 NamespaceLineEdit* edit = it.data();
02296 if ( edit->isModified() ) {
02297
02298 mDelimMap[edit->text()] = mDelimMap[edit->lastText()];
02299 mDelimMap.remove( edit->lastText() );
02300 }
02301 }
02302 mNamespaceMap->replace( mType, mDelimMap );
02303 KDialogBase::slotOk();
02304 }
02305
02306 }
02307
02308 #include "accountdialog.moc"