kmail Library API Documentation

accountdialog.cpp

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