[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    [PATCH] delete dead folders
From:       Carsten Burghardt <burghardt () kde ! org>
Date:       2003-11-13 22:52:06
[Download RAW message or body]

Hi,

I just had the problem that the creation of an imap folder failed. The folder 
was then an entry in kmailrc with an empty imappath. The result was that no 
mailcheck on this account ended and the folder was not removed. The attached 
patch fixes this.
OK to commit?

Regards,

Carsten

["folderdelete.diff" (text/x-diff)]

Index: imapaccountbase.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/imapaccountbase.cpp,v
retrieving revision 1.28
diff -u -3 -p -r1.28 imapaccountbase.cpp
--- imapaccountbase.cpp	9 Nov 2003 11:40:02 -0000	1.28
+++ imapaccountbase.cpp	13 Nov 2003 22:46:05 -0000
@@ -444,7 +444,6 @@ namespace KMail {
     {
       slotSlaveError( mSlave, job->error(),
           job->errorString() );
-      if (job->error() == KIO::ERR_SLAVE_DIED) slaveDied();
     } else {
       emit subscriptionChanged(
           static_cast<KIO::SimpleJob*>(job)->url().path(), (*it).onlySubscribed );
Index: kmacctimap.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmacctimap.cpp,v
retrieving revision 1.144
diff -u -3 -p -r1.144 kmacctimap.cpp
--- kmacctimap.cpp	8 Nov 2003 14:19:35 -0000	1.144
+++ kmacctimap.cpp	13 Nov 2003 22:46:05 -0000
@@ -315,7 +315,16 @@ void KMAcctImap::processNewMail(bool int
         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--;
+            disconnect(imapFolder, SIGNAL(numUnreadMsgsChanged(KMFolder*)),
+                this, SLOT(postProcessNewMail(KMFolder*)));
+            // just in case the folder is gone
+            slotUpdateFolderList();
+          }
         }
       }
     }
Index: kmfolderimap.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmfolderimap.cpp,v
retrieving revision 1.143
diff -u -3 -p -r1.143 kmfolderimap.cpp
--- kmfolderimap.cpp	8 Nov 2003 14:19:35 -0000	1.143
+++ kmfolderimap.cpp	13 Nov 2003 22:46:06 -0000
@@ -1360,22 +1360,28 @@ void KMFolderImap::slotSetStatusResult(K
 
 
 //-----------------------------------------------------------------------------
-void KMFolderImap::processNewMail(bool)
+bool KMFolderImap::processNewMail(bool)
 {
    // a little safety
-  if ( !mAccount ) return;
+  if ( !mAccount ) 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()) 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;
 }
 
 
@@ -1403,9 +1409,9 @@ void KMFolderImap::slotStatResult(KIO::J
         } else {
           mGuessedUnreadMsgs = (*it).m_long;
         }
-        emit numUnreadMsgsChanged( this );
       }
     }
+    emit numUnreadMsgsChanged( this );
   }
   mAccount->displayProgress();
 }
Index: kmfolderimap.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmfolderimap.h,v
retrieving revision 1.52
diff -u -3 -p -r1.52 kmfolderimap.h
--- kmfolderimap.h	12 Oct 2003 14:11:06 -0000	1.52
+++ kmfolderimap.h	13 Nov 2003 22:46:06 -0000
@@ -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,


_______________________________________________
KMail Developers mailing list
kmail@kde.org
https://mail.kde.org/mailman/listinfo/kmail

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic