diff options
Diffstat (limited to 'kmail/kmtransport.cpp')
-rw-r--r-- | kmail/kmtransport.cpp | 108 |
1 files changed, 79 insertions, 29 deletions
diff --git a/kmail/kmtransport.cpp b/kmail/kmtransport.cpp index 764c17206..6012d756b 100644 --- a/kmail/kmtransport.cpp +++ b/kmail/kmtransport.cpp @@ -76,13 +76,28 @@ void KMTransportInfo::readConfig(int id) user = config->readEntry("user"); mPasswd = KMAccount::decryptStr(config->readEntry("pass")); precommand = config->readPathEntry("precommand"); - encryption = config->readEntry("encryption"); authType = config->readEntry("authtype"); auth = config->readBoolEntry("auth"); mStorePasswd = config->readBoolEntry("storepass"); specifyHostname = config->readBoolEntry("specifyHostname", false); localHostname = config->readEntry("localHostname"); + // COMPAT: Previous versions of KMail stored encryption as a string. + // TODO(mio): Write upgrade script to convert these to match KMTransportInfo::EncryptionMode. + TQString encryptionString = config->readEntry("encryption"); + if (encryptionString == "TLS") // TLS => STARTTLS + { + encryption = STARTTLSEncryption; + } + else if (encryptionString == "SSL") // SSL => SSL/TLS + { + encryption = TLSEncryption; + } + else + { + encryption = NoEncryption; + } + if ( !storePasswd() ) return; @@ -116,13 +131,27 @@ void KMTransportInfo::writeConfig(int id) config->writeEntry("port", port); config->writeEntry("user", user); config->writePathEntry("precommand", precommand); - config->writeEntry("encryption", encryption); config->writeEntry("authtype", authType); config->writeEntry("auth", auth); config->writeEntry("storepass", storePasswd()); config->writeEntry("specifyHostname", specifyHostname); config->writeEntry("localHostname", localHostname); + // COMPAT: Previous versions of KMail stored encryption as a string. + // TODO(mio): Write upgrade script and change this to write integer. + switch (encryption) + { + case TLSEncryption: + config->writeEntry("encryption", "SSL"); // SSL => SSL/TLS + break; + case STARTTLSEncryption: + config->writeEntry("encryption", "TLS"); // TLS => STARTTLS + break; + case NoEncryption: + config->writeEntry("encryption", "NONE"); + break; + } + if ( storePasswd() ) { // write password into the wallet if possible and necessary bool passwdStored = false; @@ -287,7 +316,7 @@ KMTransportDialog::KMTransportDialog( const TQString & caption, : KDialogBase( parent, name, modal, caption, Ok|Cancel, Ok, true ), mServerTest( 0 ), mTransportInfo( transportInfo ), - mAuthNone( AllAuth ), mAuthSSL( AllAuth ), mAuthTLS( AllAuth ) + mAuthNone( AllAuth ), mAuthTLS( AllAuth ), mAuthSTARTTLS( AllAuth ) { assert(transportInfo != 0); @@ -498,14 +527,16 @@ void KMTransportDialog::makeSmtpPage() TQWidget *page2 = new TQWidget( tabWidget ); tabWidget->addTab( page2, i18n("S&ecurity") ); TQVBoxLayout *vlay = new TQVBoxLayout( page2, spacingHint() ); + + // TODO(mio): RFC 8134 - Use TLS by default. mSmtp.encryptionGroup = new TQButtonGroup( 1, TQt::Horizontal, i18n("Encryption"), page2 ); mSmtp.encryptionNone = new TQRadioButton( i18n("&None"), mSmtp.encryptionGroup ); - mSmtp.encryptionSSL = - new TQRadioButton( i18n("&SSL"), mSmtp.encryptionGroup ); mSmtp.encryptionTLS = - new TQRadioButton( i18n("&TLS"), mSmtp.encryptionGroup ); + new TQRadioButton( i18n("SSL/&TLS"), mSmtp.encryptionGroup ); + mSmtp.encryptionSTARTTLS = + new TQRadioButton( i18n("&STARTTLS"), mSmtp.encryptionGroup ); connect(mSmtp.encryptionGroup, TQ_SIGNAL(clicked(int)), TQ_SLOT(slotSmtpEncryptionChanged(int))); vlay->addWidget( mSmtp.encryptionGroup ); @@ -558,10 +589,10 @@ void KMTransportDialog::setupSettings() mSmtp.specifyHostnameCheck->setChecked(mTransportInfo->specifyHostname); mSmtp.localHostnameEdit->setText(mTransportInfo->localHostname); - if (mTransportInfo->encryption == "TLS") + if (mTransportInfo->encryption == KMTransportInfo::STARTTLSEncryption) + mSmtp.encryptionSTARTTLS->setChecked(true); + else if (mTransportInfo->encryption == KMTransportInfo::TLSEncryption) mSmtp.encryptionTLS->setChecked(true); - else if (mTransportInfo->encryption == "SSL") - mSmtp.encryptionSSL->setChecked(true); else mSmtp.encryptionNone->setChecked(true); if (mTransportInfo->authType == "LOGIN") @@ -601,8 +632,18 @@ void KMTransportDialog::saveSettings() mTransportInfo->specifyHostname = mSmtp.specifyHostnameCheck->isChecked(); mTransportInfo->localHostname = mSmtp.localHostnameEdit->text().stripWhiteSpace(); - mTransportInfo->encryption = (mSmtp.encryptionTLS->isChecked()) ? "TLS" : - (mSmtp.encryptionSSL->isChecked()) ? "SSL" : "NONE"; + if (mSmtp.encryptionSTARTTLS->isChecked()) + { + mTransportInfo->encryption = KMTransportInfo::STARTTLSEncryption; + } + else if (mSmtp.encryptionTLS->isChecked()) + { + mTransportInfo->encryption = KMTransportInfo::TLSEncryption; + } + else + { + mTransportInfo->encryption = KMTransportInfo::NoEncryption; + } mTransportInfo->authType = (mSmtp.authLogin->isChecked()) ? "LOGIN" : (mSmtp.authCramMd5->isChecked()) ? "CRAM-MD5" : @@ -652,13 +693,22 @@ void KMTransportDialog::slotRequiresAuthClicked() void KMTransportDialog::slotSmtpEncryptionChanged(int id) { kdDebug(5006) << "KMTransportDialog::slotSmtpEncryptionChanged( " << id << " )" << endl; - // adjust SSL port: - if (id == SSL || mSmtp.portEdit->text() == "465") - mSmtp.portEdit->setText((id == SSL) ? "465" : "25"); + switch (id) + { + case KMTransportInfo::TLSEncryption: + mSmtp.portEdit->setText("465"); // RFC8314 - 3.3 + break; + case KMTransportInfo::STARTTLSEncryption: + mSmtp.portEdit->setText("587"); // RFC6409 - 3.1 / RFC 8314 - 3.3 + break; + default: + mSmtp.portEdit->setText("25"); + break; + } // switch supported auth methods: TQButton * old = mSmtp.authGroup->selected(); - int authMethods = id == TLS ? mAuthTLS : id == SSL ? mAuthSSL : mAuthNone ; + int authMethods = id == KMTransportInfo::STARTTLSEncryption ? mAuthSTARTTLS : id == KMTransportInfo::TLSEncryption ? mAuthTLS : mAuthNone ; enableAuthMethods( authMethods ); if ( !old->isEnabled() ) checkHighest( mSmtp.authGroup ); @@ -746,34 +796,34 @@ void KMTransportDialog::checkHighest(TQButtonGroup *btnGroup) void KMTransportDialog::slotSmtpCapabilities( const TQStringList & capaNormal, - const TQStringList & capaSSL, + const TQStringList & capaTLS, const TQString & authNone, - const TQString & authSSL, - const TQString & authTLS ) + const TQString & authTLS, + const TQString & authSTARTTLS ) { mSmtp.checkCapabilities->setEnabled( true ); kdDebug(5006) << "KMTransportDialog::slotSmtpCapabilities( ..., " - << authNone << ", " << authSSL << ", " << authTLS << " )" << endl; + << authNone << ", " << authTLS << ", " << authSTARTTLS << " )" << endl; mSmtp.encryptionNone->setEnabled( !capaNormal.isEmpty() ); - mSmtp.encryptionSSL->setEnabled( !capaSSL.isEmpty() ); - mSmtp.encryptionTLS->setEnabled( capaNormal.findIndex("STARTTLS") != -1 ); - if ( authNone.isEmpty() && authSSL.isEmpty() && authTLS.isEmpty() ) { + mSmtp.encryptionTLS->setEnabled( !capaTLS.isEmpty() ); + mSmtp.encryptionSTARTTLS->setEnabled( capaNormal.findIndex("STARTTLS") != -1 ); + if ( authNone.isEmpty() && authTLS.isEmpty() && authSTARTTLS.isEmpty() ) { // slave doesn't seem to support "* AUTH METHODS" metadata (or server can't do AUTH) mAuthNone = authMethodsFromStringList( capaNormal ); - if ( mSmtp.encryptionTLS->isEnabled() ) - mAuthTLS = mAuthNone; + if ( mSmtp.encryptionSTARTTLS->isEnabled() ) + mAuthSTARTTLS = mAuthNone; else - mAuthTLS = 0; - mAuthSSL = authMethodsFromStringList( capaSSL ); + mAuthSTARTTLS = 0; + mAuthTLS = authMethodsFromStringList( capaTLS ); } else { mAuthNone = authMethodsFromString( authNone ); - mAuthSSL = authMethodsFromString( authSSL ); mAuthTLS = authMethodsFromString( authTLS ); + mAuthSTARTTLS = authMethodsFromString( authSTARTTLS ); } kdDebug(5006) << "mAuthNone = " << mAuthNone - << "; mAuthSSL = " << mAuthSSL - << "; mAuthTLS = " << mAuthTLS << endl; + << "; mAuthTLS = " << mAuthTLS + << "; mAuthSTARTTLS = " << mAuthSTARTTLS << endl; checkHighest( mSmtp.encryptionGroup ); delete mServerTest; mServerTest = 0; |