Bug 60516 - KMail Cached IMAP Subscription Bug
Summary: KMail Cached IMAP Subscription Bug
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-30 09:43 UTC by Josh Berry
Modified: 2007-09-14 12:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Berry 2003-06-30 09:43:56 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 3.2.3 
OS:          Linux

I am using courier-imapd as my mail server.  As you may know, Courier makes all IMAP folders subfolders of INBOX.  Ordinarily, my folder tree looks like this:

Server
  INBOX
    Admin
    News
    ...

If I set the "Prefix to Folders" to INBOX, my tree appears as it should (i.e. like this:)

Server [which is also my INBOX]
  Admin
  News
  ...

However, when I bring up the "Subscribe" dialog, KMail goes into some sort of infinite loop, causing the inbox (and its subfolders) to appear an infinite amount of times in the folder list on the left side of the dialog.
Comment 1 Carsten Burghardt 2003-06-30 19:43:15 UTC
Subject: Re:  New: KMail Cached IMAP Subscription Bug

On Monday 30 June 2003 09:43, Joshua J.Berry wrote:
> However, when I bring up the "Subscribe" dialog, KMail goes into some sort
> of infinite loop, causing the inbox (and its subfolders) to appear an
> infinite amount of times in the folder list on the left side of the dialog.

Strange - I thought that I already fixed this. But ok, let me check it.

Comment 2 Josh Berry 2003-07-07 07:18:04 UTC
This bug also seems to be affecting Disconnected IMAP, as the synchronization
routine goes into an infinite loop, constantly asking if I want to reset certain
folders (such as INBOX) to the initial sync state (where the old state was
either 10 or 12).
Comment 3 Carsten Burghardt 2003-07-07 09:18:08 UTC
These two are not related code-wise but it
Comment 4 Josh Berry 2003-07-07 10:01:51 UTC
I tried your suggestion ("INBOX." instead of "INBOX" or nothing), and restarted
Kontact.  (This is still using Disconnected IMAP.)

It now sits there for several minutes (doing apparently nothing), and eventually
gives me the message "Folder 'INBOX.' is not in initial sync state (was in state
2). Reset and sync anyway?" (or something similar).  I say Yes, and it
immediately finishes synchronizing (i.e. without doing any subfolders), but all
my folders under INBOX went away.  However, they still show up in the
Subscription dialog (with the appropriate folders checked).

Thanks for the help and suggestions.
Comment 5 Carsten Burghardt 2003-07-07 21:14:12 UTC
I tried this only with normal (online) imap so far. Independent from that "INBOX." is the correct 
prefix because this is your personal namespace in courier (and also in cyrus). 
Comment 6 Carsten Burghardt 2003-07-31 21:37:15 UTC
Subject: kdepim/kmail

CVS commit by burghard: 

Fix loop with courier and personal namespace.
CCMAIL: 60516-done@bugs.kde.org


  M +27 -23    subscriptiondialog.cpp   1.7


--- kdepim/kmail/subscriptiondialog.cpp  #1.6:1.7
@@ -55,4 +55,5 @@ void SubscriptionDialog::slotListDirecto
   GroupItem *parent = 0;
   mLoading = true;
+  ImapAccountBase* ai = static_cast<ImapAccountBase*>(mAcct);
 
   if (!onlySubscribed)
@@ -86,16 +87,18 @@ void SubscriptionDialog::slotListDirecto
     {
       bool create = true;
-      if (parent)
+      QListViewItem *start = folderTree()->firstChild();
+      if ( parent )
+        start = parent->firstChild();
+      if ( start )
       {
-        for ( QListViewItem *it = parent->firstChild() ;
-            it ; it = it->nextSibling() )
+        for ( QListViewItem *it = start; it; it = it->nextSibling() )
         {
           // check if this item already exists in this hierarchy
           item = static_cast<GroupItem*>(it);
-          if (item->info().path == mSubfolderPaths[i])
+          if ( item->info().path == mSubfolderPaths[i] )
             create = false;
         }
       }
-      if (create)
+      if ( create )
       {
         KGroupInfo info(mSubfolderNames[i]);
@@ -110,10 +113,9 @@ void SubscriptionDialog::slotListDirecto
           item = new GroupItem(folderTree(), info, this, true);
       }
-      if (item)
-      {
-        // reset
+      if ( item ) // reset
         item->setOn(false);
-      }
-    } else {
+
+    } else 
+    {
       // find the item
       QListViewItemIterator it( groupView );
@@ -129,18 +131,17 @@ void SubscriptionDialog::slotListDirecto
       }
     }
-    if (mSubfolderMimeTypes[i] == "message/directory" ||
-        mSubfolderMimeTypes[i] == "inode/directory")
+    if ( mSubfolderMimeTypes[i] == "message/directory" ||
+         mSubfolderMimeTypes[i] == "inode/directory" )
     {
       // descend
-      static_cast<ImapAccountBase*>(mAcct)->listDirectory(mSubfolderPaths[i],
-          onlySubscribed);
+      bool secondStep = (mSubfolderPaths[i] == ai->prefix()) ? true : false;
+      static_cast<ImapAccountBase*>(mAcct)->listDirectory( mSubfolderPaths[i],
+          onlySubscribed, secondStep );
     }
   }
-  if (jobData.inboxOnly)
-  {
-    ImapAccountBase* ai = static_cast<ImapAccountBase*>(mAcct);
-    ai->listDirectory(ai->prefix(), false, true);
-    ai->listDirectory(ai->prefix(), true, true);
-  }
+  if ( jobData.inboxOnly )
+    ai->listDirectory( ai->prefix(), onlySubscribed, true );
+  
+  // active buttons and stuff
   slotLoadingComplete();
 }
@@ -171,11 +172,14 @@ void SubscriptionDialog::slotSave()
 void SubscriptionDialog::slotLoadFolders()
 {
+  // clear the views
   KSubscription::slotLoadFolders();
-  if ( !account())
+  if ( !account() )
     return;
   ImapAccountBase* ai = static_cast<ImapAccountBase*>(account());
+  if ( ai->prefix().isEmpty() )
+    return;
   // get folders
-  ai->listDirectory(ai->prefix(), false);
-  ai->listDirectory(ai->prefix(), true);
+  ai->listDirectory( ai->prefix(), false );
+  ai->listDirectory( ai->prefix(), true );
 }