diff --git a/cachedimapjob.cpp b/cachedimapjob.cpp index 0149cb004..c6f3d6554 100644 --- a/cachedimapjob.cpp +++ b/cachedimapjob.cpp @@ -429,22 +429,22 @@ void CachedImapJob::slotAddNextSubfolder( KIO::Job * job ) return; } - if ( job->error() && - !static_cast((*it).parent->storage())->silentUpload() ) { - QStringList errors = job->detailedErrorStrings(); - QString myError = "

" + i18n("Error while uploading folder") + // make copy of setting, to reset it before potentially destroying 'it' + bool silentUpload = static_cast((*it).parent->storage())->silentUpload(); + static_cast((*it).parent->storage())->setSilentUpload( false ); + + if ( job->error() && !silentUpload ) { + QString myError = "

" + i18n("Error while uploading folder") + "

" + i18n("Could not make the folder %1 on the server.").arg((*it).items[0]) + "

" + i18n("This could be because you do not have permission to do this, or because the folder is already present on the server; the error message from the server communication is here:") + "

"; - KMessageBox::error( 0, myError + errors[1] + '\n' + errors[2], - errors[0] ); + mAccount->handleJobError( job->error(), job->errorText(), job, myError ); } - static_cast((*it).parent->storage())->setSilentUpload( false ); - mAccount->removeJob( it ); if( job->error() ) { delete this; return; } + mAccount->removeJob( it ); } if (mFolderList.isEmpty()) { @@ -458,7 +458,10 @@ void CachedImapJob::slotAddNextSubfolder( KIO::Job * job ) KURL url = mAccount->getUrl(); url.setPath(mFolder->imapPath() + folder->name()); - ImapAccountBase::jobData jd( url.url(), folder->folder() ); + // Associate the jobData with the parent folder, not with the child + // This is necessary in case of an error while creating the subfolder, + // so that folderComplete is called on the parent (and the sync resetted). + ImapAccountBase::jobData jd( url.url(), mFolder->folder() ); KIO::SimpleJob *simpleJob = KIO::mkdir(url); KIO::Scheduler::assignJobToSlave(mAccount->slave(), simpleJob); mAccount->insertJob(simpleJob, jd); diff --git a/kmacctcachedimap.cpp b/kmacctcachedimap.cpp index 854df50b8..6a810ac9d 100644 --- a/kmacctcachedimap.cpp +++ b/kmacctcachedimap.cpp @@ -277,6 +277,7 @@ void KMAcctCachedImap::slotAbortRequested() //----------------------------------------------------------------------------- void KMAcctCachedImap::killAllJobs( bool disconnectSlave ) { + //kdDebug(5006) << "killAllJobs: disconnectSlave=" << disconnectSlave << " " << mapJobData.count() << " jobs in map." << endl; QMap::Iterator it = mapJobData.begin(); for (it = mapJobData.begin(); it != mapJobData.end(); ++it) if ((*it).parent) diff --git a/kmfoldercachedimap.cpp b/kmfoldercachedimap.cpp index 825cba143..6043c4999 100644 --- a/kmfoldercachedimap.cpp +++ b/kmfoldercachedimap.cpp @@ -1010,7 +1010,8 @@ void KMFolderCachedImap::listMessages() { return; } - if( mAccount->makeConnection() != ImapAccountBase::Connected ) { + if( !mAccount->slave() ) { // sync aborted + resetSyncState(); emit listMessagesComplete(); emit folderComplete( this, false ); return; @@ -1132,8 +1133,7 @@ void KMFolderCachedImap::getMessagesResult( KIO::Job * job, bool lastSet ) } if( job->error() ) { - mAccount->slotSlaveError( mAccount->slave(), job->error(), - job->errorText() ); + mAccount->handleJobError( job->error(), job->errorText(), job, i18n( "Error while retrieving messages on the server: " ) + '\n' ); mContentState = imapNoInformation; emit folderComplete(this, FALSE); } else { @@ -1172,7 +1172,8 @@ void KMFolderCachedImap::setAccount(KMAcctCachedImap *aAccount) bool KMFolderCachedImap::listDirectory(bool secondStep) { mSubfolderState = imapInProgress; - if( mAccount->makeConnection() != ImapAccountBase::Connected ) { + if( !mAccount->slave() ) { // sync aborted + resetSyncState(); emit folderComplete( this, false ); return false; }