From cff1d99c91f80ce7d4aedda1adfabd2542636eee Mon Sep 17 00:00:00 2001 From: George Staikos Date: Fri, 11 May 2001 05:10:38 +0000 Subject: [PATCH] GUI: uhhh huhuhhuhu uhhhhhh huhuhh hey beavis huhuhu mmnmnmnmn nyyyy yeah butthead? uhhh huhuh Some dumbass added SSL support for imap. nnnnyyyyeeeeeeee heheheheh dumbass. you said ass uhh hhuhh uhhh yeah. dumbass. AAAIIIIIIiI AM THE GREAT KMAILIO. I NEED SUPPORT FOR KIO_SMTP. svn path=/trunk/kdenetwork/kmail/; revision=96328 --- accountdialog.cpp | 35 +++++++++++++++++++++++++++++++++-- accountdialog.h | 2 ++ kmacctimap.cpp | 13 ++++++++++++- kmacctimap.h | 5 +++++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/accountdialog.cpp b/accountdialog.cpp index b808ac337..62dcb4f76 100644 --- a/accountdialog.cpp +++ b/accountdialog.cpp @@ -475,7 +475,7 @@ void AccountDialog::makePopAccountPage() void AccountDialog::makeImapAccountPage() { QFrame *page = makeMainWidget(); - QGridLayout *topLayout = new QGridLayout( page, 13, 2, 0, spacingHint() ); + QGridLayout *topLayout = new QGridLayout( page, 14, 2, 0, spacingHint() ); topLayout->addColSpacing( 1, fontMetrics().maxWidth()*15 ); topLayout->setRowStretch( 12, 10 ); topLayout->setColStretch( 1, 10 ); @@ -533,6 +533,11 @@ void AccountDialog::makeImapAccountPage() new QCheckBox( i18n("Store IMAP password in configuration file"), page ); topLayout->addMultiCellWidget( mImap.storePasswordCheck, 10, 10, 0, 1 ); + mImap.useSSLCheck = + new QCheckBox( i18n("Use SSL for secure mail download"), page ); + topLayout->addMultiCellWidget( mImap.useSSLCheck, 11, 11, 0, 1 ); + connect(mImap.useSSLCheck, SIGNAL(clicked()), this, SLOT(slotImapSSLChanged())); + QButtonGroup *group = new QButtonGroup( 1, Qt::Horizontal, i18n("Authentication method"), page ); mImap.authAuto = new QRadioButton( i18n("Clear text"), group ); @@ -540,7 +545,7 @@ void AccountDialog::makeImapAccountPage() "authentification method only, if you have a good reason", "LOGIN"), group ); mImap.authCramMd5 = new QRadioButton( i18n("CRAM-MD5"), group ); mImap.authAnonymous = new QRadioButton( i18n("Anonymous"), group ); - topLayout->addMultiCellWidget( group, 11, 11, 0, 1 ); + topLayout->addMultiCellWidget( group, 12, 12, 0, 1 ); connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged())); } @@ -614,6 +619,7 @@ void AccountDialog::setupSettings() mImap.autoExpungeCheck->setChecked( ai.autoExpunge() ); mImap.hiddenFoldersCheck->setChecked( ai.hiddenFolders() ); mImap.storePasswordCheck->setChecked( ai.storePasswd() ); + mImap.useSSLCheck->setChecked( ai.useSSL() ); if (ai.auth() == "CRAM-MD5") mImap.authCramMd5->setChecked( TRUE ); else if (ai.auth() == "ANONYMOUS") @@ -665,6 +671,30 @@ void AccountDialog::setupSettings() } +void AccountDialog::slotImapSSLChanged() +{ + if (mImap.useSSLCheck->isChecked()) { + struct servent *serv = getservbyname("imaps", "tcp"); + if (serv) { + QString x; + x.sprintf("%u", ntohs(serv->s_port)); + mImap.portEdit->setText(x); + } else { + mImap.portEdit->setText("995"); + } + } else { + struct servent *serv = getservbyname("imap", "tcp"); + if (serv) { + QString x; + x.sprintf("%u", ntohs(serv->s_port)); + mImap.portEdit->setText(x); + } else { + mImap.portEdit->setText("110"); + } + } +} + + void AccountDialog::slotSSLChanged() { if (mPop.useSSLCheck->isChecked()) { @@ -771,6 +801,7 @@ void AccountDialog::saveSettings() epa.setLogin( mImap.loginEdit->text() ); epa.setAutoExpunge( mImap.autoExpungeCheck->isChecked() ); epa.setHiddenFolders( mImap.hiddenFoldersCheck->isChecked() ); + epa.setUseSSL( mImap.useSSLCheck->isChecked() ); epa.setStorePasswd( mImap.storePasswordCheck->isChecked() ); epa.setPasswd( mImap.passwordEdit->text(), epa.storePasswd() ); diff --git a/accountdialog.h b/accountdialog.h index 43790332f..e2768dbe1 100644 --- a/accountdialog.h +++ b/accountdialog.h @@ -92,6 +92,7 @@ class AccountDialog : public KDialogBase QCheckBox *autoExpungeCheck; QCheckBox *hiddenFoldersCheck; QCheckBox *storePasswordCheck; + QCheckBox *useSSLCheck; QRadioButton *authAuto; QRadioButton *authLogin; QRadioButton *authCramMd5; @@ -105,6 +106,7 @@ class AccountDialog : public KDialogBase void slotEnableLocalInterval( bool state ); void slotFontChanged(); void slotSSLChanged(); + void slotImapSSLChanged(); private: void makeLocalAccountPage(); diff --git a/kmacctimap.cpp b/kmacctimap.cpp index 0d84ebfbd..9ae9cb3b9 100644 --- a/kmacctimap.cpp +++ b/kmacctimap.cpp @@ -105,6 +105,7 @@ void KMAcctImap::init(void) mPrefix = "/"; mAutoExpunge = TRUE; mHiddenFolders = FALSE; + mUseSSL = FALSE; } //----------------------------------------------------------------------------- @@ -125,6 +126,7 @@ void KMAcctImap::pseudoAssign(KMAccount* account) setHiddenFolders(acct->hiddenFolders()); setStorePasswd(acct->storePasswd()); setPasswd(acct->passwd(), acct->storePasswd()); + setUseSSL(acct->useSSL()); } @@ -132,7 +134,7 @@ void KMAcctImap::pseudoAssign(KMAccount* account) KURL KMAcctImap::getUrl() { KURL url; - url.setProtocol(QString("imap")); + url.setProtocol(mUseSSL ? QString("imaps") : QString("imap")); url.setUser(mLogin + ";AUTH=" + mAuth); url.setPass(decryptStr(mPasswd)); url.setHost(mHost); @@ -970,6 +972,7 @@ void KMAcctImap::readConfig(KConfig& config) mPrefix = config.readEntry("prefix", "/"); mAutoExpunge = config.readBoolEntry("auto-expunge", TRUE); mHiddenFolders = config.readBoolEntry("hidden-folders", FALSE); + mUseSSL = config.readBoolEntry("use-ssl", FALSE); } @@ -989,6 +992,7 @@ void KMAcctImap::writeConfig(KConfig& config) config.writeEntry("prefix", mPrefix); config.writeEntry("auto-expunge", mAutoExpunge); config.writeEntry("hidden-folders", mHiddenFolders); + config.writeEntry("use-ssl", mUseSSL); } @@ -1026,6 +1030,13 @@ void KMAcctImap::setStorePasswd(bool b) } +//----------------------------------------------------------------------------- +void KMAcctImap::setUseSSL(bool b) +{ + mUseSSL = b; +} + + //----------------------------------------------------------------------------- void KMAcctImap::setLogin(const QString& aLogin) { diff --git a/kmacctimap.h b/kmacctimap.h index d6a0c59c2..768b85a76 100644 --- a/kmacctimap.h +++ b/kmacctimap.h @@ -120,6 +120,10 @@ public: bool hiddenFolders() { return mHiddenFolders; } virtual void setHiddenFolders(bool); + /** Use SSL or not */ + bool useSSL() { return mUseSSL; } + virtual void setUseSSL(bool); + /** List a directory and add the contents to a KMFolderTreeItem */ void listDirectory(KMFolderTreeItem * fti, bool secondStep = FALSE); @@ -200,6 +204,7 @@ protected: unsigned short int mPort; bool mStorePasswd; bool mAutoExpunge; + bool mUseSSL; bool mHiddenFolders; bool gotMsgs; bool mProgressEnabled;