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