File kmail_cancel_connection_with_bad_settings.diff of Package kdepim3

Index: kmail/imapaccountbase.cpp
================================================================================
--- kioslaves/imap4/imap4.cc
+++ kioslaves/imap4/imap4.cc
@@ -1951,14 +1951,14 @@
         }
       }
       if (!clientLogin (myUser, myPass, resultInfo))
-        error(KIO::ERR_COULD_NOT_LOGIN, i18n("Unable to login. Probably the "
+        error(KIO::ERR_COULD_NOT_AUTHENTICATE, i18n("Unable to login. Probably the "
         "password is wrong.\nThe server replied:\n%1").arg(resultInfo));
     }
     else
     {
 #ifdef HAVE_LIBSASL2      
       if (!clientAuthenticate (this, authInfo, myHost, myAuth, mySSL, resultInfo))
-        error(KIO::ERR_COULD_NOT_LOGIN, i18n("Unable to authenticate via %1.\n"
+        error(KIO::ERR_COULD_NOT_AUTHENTICATE, i18n("Unable to authenticate via %1.\n"
         "The server replied:\n%2").arg(myAuth).arg(resultInfo));
       else {
         myUser = authInfo.username;
--- kmail/imapaccountbase.cpp
+++ kmail/imapaccountbase.cpp
@@ -493,22 +493,22 @@
       const QString &errorMsg)
   {
     kdDebug() << k_funcinfo << endl;
-      if (aSlave != mSlave) return;
-      handleError( errorCode, errorMsg, 0, QString::null, true );
-      if ( mAskAgain )
-        makeConnection();
-      else {
-        if ( !mSlaveConnected ) {
-          mSlaveConnectionError = true;
-          mOwner->resetConnectionList( this );
-          if ( mSlave )
-          {
-            KIO::Scheduler::disconnectSlave( slave() );
-            mSlave = 0;
-          }          
-        }
-        emit connectionResult( errorCode, errorMsg );
+    if (aSlave != mSlave) return;
+    handleError( errorCode, errorMsg, 0, QString::null, true );
+    if ( mAskAgain )
+      if ( makeConnection() != ImapAccountBase::Error )
+        return;
+
+    if ( !mSlaveConnected ) {
+      mSlaveConnectionError = true;
+      mOwner->resetConnectionList( this );
+      if ( mSlave )
+      {
+        KIO::Scheduler::disconnectSlave( slave() );
+        mSlave = 0;
       }
+    }
+    emit connectionResult( errorCode, errorMsg );
   }
 
   //-----------------------------------------------------------------------------
@@ -576,7 +576,7 @@
     bool jobsKilled = true;
     switch( errorCode ) {
     case KIO::ERR_SLAVE_DIED: slaveDied(); killAllJobs( true ); break;
-    case KIO::ERR_COULD_NOT_LOGIN: // bad password
+    case KIO::ERR_COULD_NOT_AUTHENTICATE: // bad password
       mAskAgain = true;
       // fallthrough intended
     case KIO::ERR_CONNECTION_BROKEN:
@@ -584,6 +584,7 @@
       // These mean that we'll have to reconnect on the next attempt, so disconnect and set mSlave to 0.
       killAllJobs( true );
       break;
+    case KIO::ERR_COULD_NOT_LOGIN:
     case KIO::ERR_USER_CANCELED:
       killAllJobs( false );
       break;
openSUSE Build Service is sponsored by