From cbd9095da73ec5236b41f7001237ecec8201fd96 Mon Sep 17 00:00:00 2001 From: Carsten Burghardt Date: Mon, 17 Nov 2003 17:40:53 +0000 Subject: [PATCH] Remove broken imap folders with an empty imappath because they block the new-mail check and therefore the retrieval of headers. Add some debug statements for critical parts. svn path=/trunk/kdepim/; revision=267771 --- kmacctimap.cpp | 9 ++++++++- kmfolderimap.cpp | 28 ++++++++++++++++++++++------ kmfolderimap.h | 3 ++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/kmacctimap.cpp b/kmacctimap.cpp index e742c918c..dd5f27a74 100644 --- a/kmacctimap.cpp +++ b/kmacctimap.cpp @@ -315,7 +315,14 @@ void KMAcctImap::processNewMail(bool interactive) else { connect(imapFolder, SIGNAL(numUnreadMsgsChanged(KMFolder*)), this, SLOT(postProcessNewMail(KMFolder*))); - imapFolder->processNewMail(interactive); + bool ok = imapFolder->processNewMail(interactive); + if (!ok) + { + // there was an error so cancel + mCountRemainChecks--; + // just in case the folder is gone + slotUpdateFolderList(); + } } } } diff --git a/kmfolderimap.cpp b/kmfolderimap.cpp index 3f08befd2..08cf37d4b 100644 --- a/kmfolderimap.cpp +++ b/kmfolderimap.cpp @@ -594,16 +594,20 @@ void KMFolderImap::slotListResult( QStringList mSubfolderNames, //----------------------------------------------------------------------------- void KMFolderImap::checkValidity() { - kdDebug(5006) << "KMFolderImap::checkValidity of: " << fileName() << endl; + kdDebug(5006) << "KMFolderImap::checkValidity of: " << imapPath() << endl; KURL url = mAccount->getUrl(); url.setPath(imapPath() + ";UID=0:0"); if (!mAccount->makeConnection()) { + kdWarning(5006) << "KMFolderImap::checkValidity - got no connection" << endl; emit folderComplete(this, FALSE); return; } // Only check once at a time. - if (mCheckingValidity) return; + if (mCheckingValidity) { + kdDebug(5006) << "KMFolderImap::checkValidity - already checking" << endl; + return; + } ImapAccountBase::jobData jd( url.url(), this ); KIO::SimpleJob *job = KIO::get(url, FALSE, FALSE); KIO::Scheduler::assignJobToSlave(mAccount->slave(), job); @@ -1361,22 +1365,34 @@ void KMFolderImap::slotSetStatusResult(KIO::Job * job) //----------------------------------------------------------------------------- -void KMFolderImap::processNewMail(bool) +bool KMFolderImap::processNewMail(bool) { // a little safety - if ( !mAccount ) return; + if ( !mAccount ) { + kdWarning(5006) << "KMFolderImap::processNewMail - account is null!" << endl; + return false; + } + if (imapPath().isEmpty()) { + kdWarning(5006) << "KMFolderImap::processNewMail - imapPath of " << name() << " is empty!" << endl; + kmkernel->imapFolderMgr()->remove(this); + return false; + } KURL url = mAccount->getUrl(); if (mReadOnly) url.setPath(imapPath() + ";SECTION=UIDNEXT"); else url.setPath(imapPath() + ";SECTION=UNSEEN"); - if (!mAccount->makeConnection()) return; + if (!mAccount->makeConnection()) { + kdWarning(5006) << "KMFolderImap::processNewMail - got no connection!" << endl; + return false; + } KIO::SimpleJob *job = KIO::stat(url, FALSE); KIO::Scheduler::assignJobToSlave(mAccount->slave(), job); ImapAccountBase::jobData jd(url.url()); mAccount->insertJob(job, jd); connect(job, SIGNAL(result(KIO::Job *)), SLOT(slotStatResult(KIO::Job *))); + return true; } @@ -1404,9 +1420,9 @@ void KMFolderImap::slotStatResult(KIO::Job * job) } else { mGuessedUnreadMsgs = (*it).m_long; } - emit numUnreadMsgsChanged( this ); } } + emit numUnreadMsgsChanged( this ); } mAccount->displayProgress(); } diff --git a/kmfolderimap.h b/kmfolderimap.h index 4da10c7e4..784844cca 100644 --- a/kmfolderimap.h +++ b/kmfolderimap.h @@ -193,8 +193,9 @@ public: /** * Refresh the number of unseen mails + * Returns false in an error condition */ - void processNewMail(bool interactive); + bool processNewMail(bool interactive); /** * Tell the folder, this it is selected and shall also display new mails,