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