Bug 90479

Summary: dIMAP trying to select a 'noselect' folder
Product: [Unmaintained] kmail Reporter: Nick Brown <nickbroon>
Component: disconnected IMAPAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED WAITINGFORINFO    
Severity: normal CC: bjoern, heri+kde
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Nick Brown 2004-09-29 17:21:48 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:                Linux

This really just because Bug 66469 has not been reopend. :-)
I'm using kde cvs from a few hours ago. (though problem also seen with 3.3) 
 
 I can access my mail just fine using an account with type=imap (I have prefix=/Mail/). 
 If I try to use type=cachedimap (with all other details the same) I get the following error message; 
 
 --- 
 Error while reading folder Work on the server: 
 Unable to open folder Mail/Work. The server replied: SELECT failed: 
 Can't open Mail/Work: not a selectable mailbox 
 --- 
 
 I see similar messages for all sub folders of Mail. 
 
 The server is IMAP4rev1 v10.22

Here is debug output (with server name removed); 
 
 kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-23651 
 kmail: processNextCheck, remaining 1 
 kmail: for host <snip>.<snip>.com current connections=0 and limit is 0 
 kmail: connection limit reached: false 
 kmail: processing next mail check for Work 
 kmail: check mail started - connections for host <snip>.<snip>.com now is 1 
 kmail: [void KIMProxy::registeredToDCOP(const QCString&)] kwalletmanager 
 kmail: dcopService: kopete, appId: kwalletmanager 
 kmail: [void KIMProxy::registeredToDCOP(const QCString&)] anonymous-23701 
 kmail: dcopService: kopete, appId: anonymous-23701 
 kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-23701 
 kio (KIOJob): error 8 ACL 
 kio (KIOJob): error 63 Unable to open folder Mail. The server replied: SELECT failed: Can't open Mail: not a selectable mailbox 
 kmail: updateAnnotationFolderType: 
 kio (KIOJob): error 8 ANNOTATEMORE 
 kmail: processNextCheck, remaining 0 
 kmail: account Work finished check 
 kmail: connections to server <snip>.<snip>.com now 0
Comment 1 Carsten Burghardt 2004-10-01 16:20:23 UTC
I can't reproduce this with kmail from head and a uw imap server.
Can you provide an ethereal log from a sync of the disconnected account?
Comment 2 Nick Brown 2004-10-05 16:51:20 UTC
cat dimap.textdump

5 LIST "" "Mail"

* LIST (\NoSelect) "/" Mail
5 OK LIST completed

6 SELECT "Mail"

6 NO SELECT failed: Can't open Mail: not a selectable mailbox

7 LIST "" "Mail"

* LIST (\NoSelect) "/" Mail
7 OK LIST completed

I can provide a hexdump if required
Comment 3 Nick Brown 2004-10-06 17:37:15 UTC
I think the above clearly shows that cacheimap in kmail is trying to select my top level mail folder even though the server identified it as (\NoSelect).
This is against the imap RFC section 7.2.2. 
The above trace was made with kde cvs from only a few days ago.
regular imap in kmail works just fine with this account.

Can this bug be moved to "NEW", as I think this is now confirmed?
Comment 4 Nick Brown 2004-10-06 19:24:04 UTC
Here is more debug output, including the kio_imap debug output.

kmail: Initting systray
kdeinit: PID 31952 terminated.
kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-31952
kmail: /Mail/ readConfig: mAnnotationFolderType=
kmail: processNextCheck, remaining 1
kmail: for host edinburgh.cisco.com current connections=0 and limit is 0
kmail: connection limit reached: false
kmail: processing next mail check for Cisco
kio (KLauncher): KLauncher: Got start_service_by_desktop_name('kwalletmanager',...)
klauncher: KRun::processDesktopExec: No URLs supplied to single-URL service kwalletmanager %u
kdeinit: Got EXEC_NEW 'kwalletmanager' from launcher.
Could not load library! Trying exec....
kio (KLauncher): kwalletmanager (pid 31990) up and running.
kdeinit: Debug wait activated.
kdeinit: Got EXEC_NEW 'kio_imap4' from launcher.
kdeinit: Suspending process
kdeinit: 'gdb kdeinit 31991' to debug
kdeinit: 'kill -SIGCONT 31991' to continue
kio (KLauncher): kio_imap4 (pid 31991) up and running.
kmail: check mail started - connections for host edinburgh.cisco.com now is 1
kmail: [void KIMProxy::registeredToDCOP(const QCString&)] kwalletmanager
kmail: dcopService: kopete, appId: kwalletmanager
kmail: [void KIMProxy::registeredToDCOP(const QCString&)] anonymous-31990
kmail: dcopService: kopete, appId: anonymous-31990
kdeinit: PID 31990 terminated.
kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-31990
kio (Slave): slave failed to connect to application pid=31991 protocol=imap
kio (Slave): slave is slow... pid=31991 t=2
kio (Slave): slave failed to connect to application pid=31991 protocol=imap
kio (Slave): slave is slow... pid=31991 t=4
kio (Slave): slave failed to connect to application pid=31991 protocol=imap
kio (Slave): slave is slow... pid=31991 t=6
kio_file: Done
kdeinit: PID 31334 terminated.
IMAP4::kdemain
kio_imap: IMAP4::dispatch - command=85
kio_imap: IMAP4::dispatch - command=48
kio_imap: IMAP4::dispatch - command=49
kio_imap: IMAP4::makeLogin - checking login
kio_imap: myAuth: *
kio_imap: imapParser::parseLoop - unhandledResponse:
kio_imap: * OK edinburgh.cisco.com IMAP4rev1 v10.220 server ready
kio_imap:
kio_imap: IMAP4: setHost: capability
kio_imap: 'imap4'
kio_imap: 'imap4rev1'
kio_imap: 'namespace'
kio_imap: 'scan'
kio_imap: 'sort'
kio_imap: 'auth=login'
kio_imap: 'thread=orderedsubject'
kio_imap: IMAP4::makeLogin - attempting login
kio_imap: IMAP4::makeLogin - open_PassDlg said user=nicbrown pass=xx
kio_imap: IMAP4::dispatch - command=77
kio_imap: IMAP4Protocol::special
kio (KIOJob): error 8 ACL
kio_imap: IMAP4::dispatch - command=67
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kio_imap: IMAP4::get -  imap://nicbrown@edinburgh.cisco.com:143/Mail/;UID=0:0
kio_imap: URL: box= Mail, section= , type= , uid= 0:0, validity=
kio_imap: IMAP4::parseURL: box Mail
kio_imap: IMAP4::parseURL - return 1
kio_imap: IMAP4Protocol::assureBox - opening box
kio_imap: imapParser::sendCommand - setting current box to Mail
kio_imap: imapParser::parseResult - current box is now
kio (KIOJob): error 63 Unable to open folder Mail. The server replied: SELECT failed: Can't open Mail: not a selectable mailbox
kio_imap: IMAP4::dispatch - command=77
kio_imap: IMAP4Protocol::special
kio (KIOJob): error 8 ANNOTATEMORE
kmail: processNextCheck, remaining 0
kmail: account Cisco finished check
kmail: connections to server edinburgh.cisco.com now 0
kio_file: Done
kdeinit: PID 31333 terminated.
kparts: KPart::slotWidgetDestroyed(), deleting part unnamed
kparts: Part::~Part 0x81a9cb0
kio_imap: IMAP4::dispatch - command=50
kdecore (KConfigSkeleton): KConfigSkeleton::writeConfig()
kdecore (KConfigSkeleton): KConfigSkeleton::readConfig()
kmail: KMKernel::~KMKernel
kio (KDirWatch): KDirWatch deleted (FAM closed)
kio_imap: IMAP4::dispatch - command=51
kio_imap: IMAP4::slave_status
kio_file: Done
kdeinit: PID 30802 terminated.
Comment 5 David Faure 2004-10-06 19:31:56 UTC
On Wednesday 06 October 2004 19:24, Nick Brown wrote:
> kio_imap: IMAP4::get -  imap://nicbrown edinburgh cisco com:143/Mail/;UID=0:0
> kio_imap: URL: box= Mail, section= , type= , uid= 0:0, validity=
> kio_imap: IMAP4::parseURL: box Mail
> kio_imap: IMAP4::parseURL - return 1
> kio_imap: IMAP4Protocol::assureBox - opening box
> kio_imap: imapParser::sendCommand - setting current box to Mail
> kio_imap: imapParser::parseResult - current box is now
^^^ that's an empty string; the box name should appear after "is now ...".

> kio (KIOJob): error 63 Unable to open folder Mail. The server replied: SELECT failed: Can't open Mail: not a selectable mailbox

Would be interesting if you could enable kdDebug(7116) << "Writing: " << aStr << endl;
in IMAP4Protocol::parseWriteLine   (kdepim/kioslave/imap4/imap4.cc)

and kdDebug(7116) << result.cstr(); 
in imapParser::parseLoop (in imapparser.cc)

(then "make; make install" in kdepim/kioslave/imap4, and restart kmail)

Comment 6 Nick Brown 2004-10-06 20:07:02 UTC
With the requested debugging uncommented. And my password removed :-)

kio (KLauncher): KLauncher: Got start_service_by_desktop_path('/home/kdedev/install/share/applications/kde/KMail.desktop', ...)
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kdeinit: Got EXT_EXEC 'kmail' from launcher.
Could not load library! Trying exec....
kio (KLauncher): kmail (pid 3599) up and running.
kmail: KMKernel::KMKernel
kdecore (KConfigSkeleton): Creating KConfigSkeleton (0x81504e8)
kdecore (KConfigSkeleton): KConfigSkeleton::readConfig()
libkdenetwork: creating new pgp object
libkdenetwork: Kpgp: gpg found
kmail: No Qt-native utf-7 codec found; registering QUtf7Codec from libkdenetwork
kmail: instantating KPIM::IdentityManager
kmail: Identity::readConfig(): UOID = 1866629463 for identity named "Cisco"
kmail: /Mail/ readConfig: mAnnotationFolderType=
kmail: pPopFilter set
kio (KIOJob): Starting kio_uiserver
kio (KLauncher): KLauncher: Got start_service_by_desktop_path('kio_uiserver.desktop', ...)
kdeinit: Got EXEC_NEW 'kio_uiserver' from launcher.
kio (KLauncher): kio_uiserver (pid 3986) up and running.
kio (KIOJob): startServiceByDesktopPath returned 0
kio (KIOJob): kio_uiserver registered
kio (UIServer): UIServer::newJob observerAppId=kmail. Giving id=1
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kio (KIOJob): stat file:/home/kdedev/.kde/share/apps/kmail/dimap/.85436054.directory
kio (KIOJob): stat file:/home/kdedev/.kde/share/apps/kmail/dimap/85436054/new/
kdeinit: Got EXEC_NEW 'kio_file' from launcher.
kio (KLauncher): kio_file (pid 3993) up and running.
kdeinit: Got EXEC_NEW 'kio_file' from launcher.
kio (KLauncher): kio_file (pid 3994) up and running.
kio_file: Starting 3994
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kio_file: FileProtocol::stat details=1
kio_file: ========= LIST file:/home/kdedev/.kde/share/apps/kmail/dimap/85436054/new/ =========
kio_file: ============= COMPLETED LIST ============
kio (KDirWatch): Available methods: Stat, FAM
kio_file: =============== BYE ===========
kdeinit: PID 3986 terminated.
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kio (UIServer): UIServer::totalFiles 1 0
kio (UIServer): UIServer::totalDirs 1 1
kio_file: Starting 3993
kio (UIServer): UIServer::jobFinished id=1
kio (UIServer): UIServer::newJob observerAppId=kmail. Giving id=2
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kio_file: FileProtocol::stat details=1
kio (KIOJob): stat file:/home/kdedev/.kde/share/apps/kmail/dimap/85436054/cur/
kio_file: FileProtocol::stat details=1
kio (KIOJob): error 11 /home/kdedev/.kde/share/apps/kmail/dimap/.85436054.directory
kio_file: ========= LIST file:/home/kdedev/.kde/share/apps/kmail/dimap/85436054/cur/ =========
kio_file: ============= COMPLETED LIST ============
kio_file: =============== BYE ===========
kio (UIServer): UIServer::totalFiles 2 0
kio (UIServer): UIServer::totalDirs 2 1
kio (UIServer): UIServer::jobFinished id=2
kio (UIServer): UIServer::newJob observerAppId=kmail. Giving id=3
kio (KIOJob): stat file:/home/kdedev/.kde/share/apps/kmail/dimap/85436054/tmp/
kio_file: FileProtocol::stat details=1
kio_file: ========= LIST file:/home/kdedev/.kde/share/apps/kmail/dimap/85436054/tmp/ =========
kio_file: ============= COMPLETED LIST ============
kio_file: =============== BYE ===========
kio (UIServer): UIServer::totalFiles 3 0
kio (UIServer): UIServer::totalDirs 3 1
kio (UIServer): UIServer::jobFinished id=3
kio (UIServer): UIServer::newJob observerAppId=kmail. Giving id=4
kio (KIOJob): stat file:/home/kdedev/.kde/share/apps/kmail/dimap/85436054
kio_file: FileProtocol::stat details=1
kio_file: ========= LIST file:/home/kdedev/.kde/share/apps/kmail/dimap/85436054=========
kio_file: ============= COMPLETED LIST ============
kio_file: =============== BYE ===========
kmail: WARNING: Can not find parent folder
kmail: 85436054 readConfig: mAnnotationFolderType=
kio (UIServer): UIServer::totalFiles 4 0
kio (UIServer): UIServer::totalDirs 4 1
kio (UIServer): UIServer::jobFinished id=4
kmail: [void KMKernel::readConfig()] 120000
kmail: KMailApplication::newInstance()
kmail: KMKernel::openReader called
QSplitter::panner 1 I
    QSplitter::panner 2 I
QSplitter::panner 2 I
QSplitter::panner 2 I
kmail: Initting systray
kdeinit: PID 3599 terminated.
kmail: [void KIMProxy::registeredToDCOP(const QCString&)] kio_uiserver
kmail: dcopService: kopete, appId: kio_uiserver
kmail: [void KIMProxy::registeredToDCOP(const QCString&)] anonymous-3986
kmail: dcopService: kopete, appId: anonymous-3986
kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-3986
kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-3599
kmail: /Mail/ readConfig: mAnnotationFolderType=
kmail: processNextCheck, remaining 1
kmail: for host edinburgh.cisco.com current connections=0 and limit is 0
kmail: connection limit reached: false
kmail: processing next mail check for Cisco
kio (KLauncher): KLauncher: Got start_service_by_desktop_name('kwalletmanager',...)
klauncher: KRun::processDesktopExec: No URLs supplied to single-URL service kwalletmanager %u
kdeinit: Got EXEC_NEW 'kwalletmanager' from launcher.
Could not load library! Trying exec....
kio (KLauncher): kwalletmanager (pid 4041) up and running.
kdeinit: Got EXEC_NEW 'kio_imap4' from launcher.
kio (KLauncher): kio_imap4 (pid 4042) up and running.
kmail: check mail started - connections for host edinburgh.cisco.com now is 1
IMAP4::kdemain
kmail: [void KIMProxy::registeredToDCOP(const QCString&)] kwalletmanager
kmail: dcopService: kopete, appId: kwalletmanager
kmail: [void KIMProxy::registeredToDCOP(const QCString&)] anonymous-4041
kmail: dcopService: kopete, appId: anonymous-4041
kio_imap: IMAP4::dispatch - command=85
kio_imap: IMAP4::dispatch - command=48
kio_imap: IMAP4::dispatch - command=49
kio_imap: IMAP4::makeLogin - checking login
kio_imap: myAuth: *
kio_imap: * OK edinburgh.cisco.com IMAP4rev1 v10.220 server ready
kio_imap: imapParser::parseLoop - unhandledResponse:
kio_imap: * OK edinburgh.cisco.com IMAP4rev1 v10.220 server ready
kio_imap:
kio_imap: Writing: 0 CAPABILITY
kio_imap:
kio_imap: * CAPABILITY IMAP4 IMAP4REV1 NAMESPACE SCAN SORT AUTH=LOGIN THREAD=ORDEREDSUBJECT
kio_imap: 0 OK CAPABILITY completed
kio_imap: IMAP4: setHost: capability
kio_imap: 'imap4'
kio_imap: 'imap4rev1'
kio_imap: 'namespace'
kio_imap: 'scan'
kio_imap: 'sort'
kio_imap: 'auth=login'
kio_imap: 'thread=orderedsubject'
kio_imap: IMAP4::makeLogin - attempting login
kio_imap: IMAP4::makeLogin - open_PassDlg said user=nicbrown pass=xx
kio_imap: Writing: 1 LOGIN "nicbrown" XXXXX[Removed]XXXXX 
kio_imap:
kio_imap: 1 OK LOGIN completed
kio_imap: IMAP4::dispatch - command=77
kio_imap: IMAP4Protocol::special
kio (KIOJob): error 8 ACL
kio_imap: IMAP4::dispatch - command=67
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kio_imap: IMAP4::get -  imap://nicbrown@edinburgh.cisco.com:143/Mail/;UID=0:0
kio_imap: URL: box= Mail, section= , type= , uid= 0:0, validity=
kio_imap: IMAP4::parseURL: box Mail
kio_imap: Writing: 2 LIST "" "Mail"
kio_imap:
kio_imap: * LIST (\NoSelect) "/" Mail
kio_imap: 2 OK LIST completed
kio_imap: IMAP4::parseURL - return 1
kio_imap: IMAP4Protocol::assureBox - opening box
kio_imap: imapParser::sendCommand - setting current box to Mail
kio_imap: Writing: 3 SELECT "Mail"
kio_imap:
kio_imap: 3 NO SELECT failed: Can't open Mail: not a selectable mailbox
kio_imap: imapParser::parseResult - current box is now
kio_imap: Writing: 4 LIST "" "Mail"
kio_imap:
kio_imap: * LIST (\NoSelect) "/" Mail
kio_imap: 4 OK LIST completed
kio (KIOJob): error 63 Unable to open folder Mail. The server replied: SELECT failed: Can't open Mail: not a selectable mailbox
kio_imap: IMAP4::dispatch - command=77
kio_imap: IMAP4Protocol::special
kio (KIOJob): error 8 ANNOTATEMORE
kmail: processNextCheck, remaining 0
kmail: account Cisco finished check
kmail: connections to server edinburgh.cisco.com now 0
kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-4041
kdeinit: PID 4041 terminated.
kparts: KPart::slotWidgetDestroyed(), deleting part unnamed
kparts: Part::~Part 0x81b2d20
kio_imap: IMAP4::dispatch - command=50
kio_imap: Writing: 5 LOGOUT
kio_imap:
kio_imap: * BYE edinburgh.cisco.com IMAP4rev1 server terminating connection
kio_imap: 5 OK LOGOUT completed
kdecore (KConfigSkeleton): KConfigSkeleton::writeConfig()
kdecore (KConfigSkeleton): KConfigSkeleton::readConfig()
kmail: KMKernel::~KMKernel
kio (KDirWatch): KDirWatch deleted (FAM closed)
kio_imap: IMAP4::dispatch - command=51
kio_imap: IMAP4::slave_status
Comment 7 Nick Brown 2004-10-07 18:26:23 UTC
Can this now have its status changed from "UNCONFIRMED" to "NEW" as I think I've provide plenty evidence of the problem.
I'm no IMAP expert, but it appears kmail is trying to SELECT a name that the server has informed it is "\noselect"
Comment 8 David Faure 2004-10-07 20:31:31 UTC
> IMAP4::get -  imap://nicbrown edinburgh cisco com:143/Mail/;UID=0:0

OK, kio_imap returns message/directory when noselect is set and noinferiors is NOT set.
But it seems kmail ignores that.

It only has code for message/digest, which is returned when both noselect 
and noinferiors are set.

Ah, hmm, wait, this might be as simple as this fix:

===================================================================
RCS file: /home/kde/kdepim/kmail/kmfoldercachedimap.cpp,v
retrieving revision 1.125.2.27
diff -u -p -r1.125.2.27 kmfoldercachedimap.cpp
--- kmfoldercachedimap.cpp      7 Oct 2004 11:16:14 -0000       1.125.2.27
+++ kmfoldercachedimap.cpp      7 Oct 2004 18:30:30 -0000
@@ -1520,7 +1520,7 @@ void KMFolderCachedImap::listDirectory2(
       //               << "\nSetting imapPath " << mSubfolderPaths[i] << endl;
       // Write folder settings
       f->setAccount(mAccount);
-      f->setNoContent(mSubfolderMimeTypes[i] == "inode/directory");
+      f->setNoContent(mSubfolderMimeTypes[i] == "inode/directory" || mSubfolderMimeTypes[i] == "message/directory");
       f->setNoChildren(mSubfolderMimeTypes[i] == "message/digest");
       f->setImapPath(mSubfolderPaths[i]);
     }

Can you try it?
Thanks.

If this works, kmfolderimap.cpp:709 might need the same fix, for online imap.

Comment 9 Nick Brown 2004-10-07 22:57:56 UTC
> OK, kio_imap returns message/directory when noselect is set and noinferiors is NOT set. 

Are you sure?
In the code below it appear that it returns inode/directory if noselect is set and noinferior is not set.

I'll try your fix anyway and let you know.

imap4.cc:2056
<snip>
 if (!item.noSelect ())
      {
        atom.m_uds = UDS_MIME_TYPE;
        if (!item.noInferiors ())
        {
          atom.m_str = "message/directory";
        } else {
          atom.m_str = "message/digest";
        }
        atom.m_long = 0;
        entry.append (atom);
        mailboxName += '/';

        // explicitly set this as a directory for KFileDialog
        atom.m_uds = UDS_FILE_TYPE;
        atom.m_str = QString::null;
        atom.m_long = S_IFDIR;
        entry.append (atom);
      }
      else if (!item.noInferiors ())
      {
        atom.m_uds = UDS_MIME_TYPE;
        atom.m_str = "inode/directory";
        atom.m_long = 0;
        entry.append (atom);
        mailboxName += '/';

        // explicitly set this as a directory for KFileDialog
        atom.m_uds = UDS_FILE_TYPE;
        atom.m_str = QString::null;
        atom.m_long = S_IFDIR;
        entry.append (atom);
      }
      else
      {
        atom.m_uds = UDS_MIME_TYPE;
        atom.m_str = "unknown/unknown";
        atom.m_long = 0;
        entry.append (atom);
      }
</snip>
Comment 10 David Faure 2004-10-07 23:02:17 UTC
> In the code below it appear that it returns inode/directory if noselect is set and noinferior is not set.

You're right, the double-negation in the if() confused me [this isn't my code].

Then this is just a "NoContent" folder (from the kmail point of view). So kmail knows
it has no mail in it. However it needs to be listed (to find its children). So the bug would
be in kio_imap4, which should list a folder without selecting it first. Carsten? :)

Comment 11 Carsten Burghardt 2004-10-08 13:49:19 UTC
David Faure sagte:
>> In the code below it appear that it returns inode/directory if noselect
>> is set and noinferior is not set.
>
> You're right, the double-negation in the if() confused me [this isn't my
> code].
>
> Then this is just a "NoContent" folder (from the kmail point of view). So
> kmail knows
> it has no mail in it. However it needs to be listed (to find its
> children). So the bug would
> be in kio_imap4, which should list a folder without selecting it first.
> Carsten? :)

I don't know where the "select" comes from as this is not needed (and not
used afaik) for a listing. This problem is not present in online imap so
this has to be kmail - dimap specific. BTW, I already tested this with a
UW imap and could not reproduce the error.

Comment 12 David Faure 2004-10-08 15:02:24 UTC
> I don't know where the "select" comes from as this is not needed (and not
> used afaik) for a listing. This problem is not present in online imap so
> this has to be kmail - dimap specific.

Hmm, the request is IMAP4::get -  imap://nicbrown edinburgh cisco com:143/Mail/;UID=0:0
Looking at cachedimapjob, this seems to be called from CachedImapJob::checkUidValidity.
But this isn't called for noContent folders... (kmfoldercachedimap.cpp:637)
Nick, can you check if that line calls checkUidValidity for the problematic folder?
Use e.g. 
  kdDebug() << location() << " calling checkUidValidity ##########" << endl;
to see which folder it's about - it's normal to call it for the other folders.

Another way is to enable the kdDebug in KMFolderCachedImap::newState
to see exactly which steps of the sync process happen.

Comment 13 Nick Brown 2004-10-08 15:20:58 UTC
Will do.
I'm a newbie when it comes to kmail and kde code, but I'll also run it under gdb and see if I can't find the bug myself, can you point me to a good place for an intial break point for sync/checkmail button press?
Comment 14 David Faure 2004-10-08 15:31:11 UTC
> Will do.
> I'm a newbie when it comes to kmail and kde code, but I'll also run it under gdb and see if I can't find the bug myself, can you point me to a good place for an intial break point for sync/checkmail button press?

Personally I prefer to use kdDebug to print out what's happening, rather than using gdb.
If you do want to use gdb, the breakpoint for a cachedimap check would be KMFolderCachedImap::serverSyncInternal,
but then you have to understand more of the code (e.g. the fact that every operation is asynchronous,
so serverSyncInternal is called back after each operation finishes). Plus it will be hit for every folder...
(break on KMFolderCachedImap::serverSync itself to get to the right folder first, then).

It's imho much faster to just print out the state changes and see what's happening.

Comment 15 Nick Brown 2004-10-08 17:18:04 UTC
Here the debug log with both the suggest debugs added.

kmail: KMKernel::KMKernel
kdecore (KConfigSkeleton): Creating KConfigSkeleton (0x814c248)
kdecore (KConfigSkeleton): KConfigSkeleton::readConfig()
libkdenetwork: creating new pgp object
libkdenetwork: Kpgp: gpg found
kmail: No Qt-native utf-7 codec found; registering QUtf7Codec from libkdenetwork
kmail: instantating KPIM::IdentityManager
kmail: Identity::readConfig(): UOID = 1866629463 for identity named "Cisco"
kmail: pPopFilter set
kmail: /Mail/ readConfig: mAnnotationFolderType=
kmail: [void KMKernel::readConfig()] 120000
kmail: KMailApplication::newInstance()
kmail: KMKernel::openReader called
QSplitter::panner 1 I
    QSplitter::panner 2 I
QSplitter::panner 2 I
QSplitter::panner 2 I
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kmail: Initting systray
[kdedev@edin-comm-vl10-dhcp17 kdedev]$ kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-18455
kmail: /Mail/ readConfig: mAnnotationFolderType=
kmail: processNextCheck, remaining 1
kmail: for host edinburgh.cisco.com current connections=0 and limit is 0
kmail: connection limit reached: false
kmail: processing next mail check for Cisco
kmail: [void KMFolderCachedImap::newState(int, const QString&)] 0x8169fe0 0 Synchronizing
kio (KLauncher): KLauncher: Got start_service_by_desktop_name('kwalletmanager', ...)
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
klauncher: KRun::processDesktopExec: No URLs supplied to single-URL service kwalletmanager %u
kdeinit: Got EXEC_NEW 'kwalletmanager' from launcher.
Could not load library! Trying exec....
kio (KLauncher): kwalletmanager (pid 18493) up and running.
kdeinit: Got EXEC_NEW 'kio_imap4' from launcher.
kio (KLauncher): kio_imap4 (pid 18494) up and running.
kmail: [void KMFolderCachedImap::newState(int, const QString&)] 0x8169fe0 0 Connecting to edinburgh.cisco.com
kmail: check mail started - connections for host edinburgh.cisco.com now is 1
kmail: [void KIMProxy::registeredToDCOP(const QCString&)] kwalletmanager
kmail: dcopService: kopete, appId: kwalletmanager
kmail: [void KIMProxy::registeredToDCOP(const QCString&)] anonymous-18493
kmail: dcopService: kopete, appId: anonymous-18493
IMAP4::kdemain
kio_imap: IMAP4::dispatch - command=85
kio_imap: IMAP4::dispatch - command=48
kio_imap: IMAP4::dispatch - command=49
kio_imap: IMAP4::makeLogin - checking login
kio_imap: myAuth: *
kdeinit: PID 18493 terminated.
kmail: [void KIMProxy::unregisteredFromDCOP(const QCString&)] anonymous-18493
kio_imap: * OK edinburgh.cisco.com IMAP4rev1 v10.220 server ready
kio_imap: imapParser::parseLoop - unhandledResponse:
kio_imap: * OK edinburgh.cisco.com IMAP4rev1 v10.220 server ready
kio_imap:
kio_imap: Writing: 0 CAPABILITY
kio_imap:
kio_imap: * CAPABILITY IMAP4 IMAP4REV1 NAMESPACE SCAN SORT AUTH=LOGIN THREAD=ORDEREDSUBJECT
kio_imap: 0 OK CAPABILITY completed
kio_imap: IMAP4: setHost: capability
kio_imap: 'imap4'
kio_imap: 'imap4rev1'
kio_imap: 'namespace'
kio_imap: 'scan'
kio_imap: 'sort'
kio_imap: 'auth=login'
kio_imap: 'thread=orderedsubject'
kio_imap: IMAP4::makeLogin - attempting login
kio_imap: IMAP4::makeLogin - open_PassDlg said user=nicbrown pass=xx
kio_imap: Writing: 1 LOGIN "nicbrown" XXXXX[Removed]XXXXX
kio_imap:
kio_imap: 1 OK LOGIN completed
kmail: [void KMFolderCachedImap::newState(int, const QString&)] 0x8169fe0 5 Checking permissions
kio_imap: IMAP4::dispatch - command=77
kio_imap: IMAP4Protocol::special
kio (KIOJob): error 8 ACL
kmail: /home/kdedev/.kde/share/apps/kmail/dimap/85436054 calling checkUidValidity##########
kmail: [void KMFolderCachedImap::newState(int, const QString&)] 0x8169fe0 10 Checking folder validity
kio_imap: IMAP4::dispatch - command=67
kio (KSycoca): Trying to open ksycoca from /var/tmp/kdecache-kdedev/ksycoca
kio_imap: IMAP4::get -  imap://nicbrown@edinburgh.cisco.com:143/Mail/;UID=0:0
kio_imap: URL: box= Mail, section= , type= , uid= 0:0, validity=
kio_imap: IMAP4::parseURL: box Mail
kio_imap: Writing: 2 LIST "" "Mail"
kio_imap:
kio_imap: * LIST (\NoSelect) "/" Mail
kio_imap: 2 OK LIST completed
kio_imap: IMAP4::parseURL - return 1
kio_imap: IMAP4Protocol::assureBox - opening box
kio_imap: imapParser::sendCommand - setting current box to Mail
kio_imap: Writing: 3 SELECT "Mail"
kio_imap:
kio_imap: 3 NO SELECT failed: Can't open Mail: not a selectable mailbox
kio_imap: imapParser::parseResult - current box is now
kio_imap: Writing: 4 LIST "" "Mail"
kio_imap:
kio_imap: * LIST (\NoSelect) "/" Mail
kio_imap: 4 OK LIST completed
kio (KIOJob): error 63 Unable to open folder Mail. The server replied: SELECT failed: Can't open Mail: not a selectable mailbox
kmail: /Mail/: updateAnnotationFolderType: '', was ( ) => mAnnotationFolderTypeChanged set to TRUE
kmail: [void KMFolderCachedImap::newState(int, const QString&)] 0x8169fe0 95 Retrieving annotations
kio_imap: IMAP4::dispatch - command=77
kio_imap: IMAP4Protocol::special
kio (KIOJob): error 8 ANNOTATEMORE
kmail: [void KMFolderCachedImap::newState(int, const QString&)] 0x8169fe0 98 Updating cache file
kmail: [void KMFolderCachedImap::newState(int, const QString&)] 0x8169fe0 100 Synchronization done
kmail: processNextCheck, remaining 0
kmail: account Cisco finished check
kmail: connections to server edinburgh.cisco.com now 0
kparts: KPart::slotWidgetDestroyed(), deleting part unnamed
kparts: Part::~Part 0x81a16e8
kio_imap: IMAP4::dispatch - command=50
kio_imap: Writing: 5 LOGOUT
kio_imap:
kio_imap: * BYE edinburgh.cisco.com IMAP4rev1 server terminating connection
kio_imap: 5 OK LOGOUT completed
kdecore (KConfigSkeleton): KConfigSkeleton::writeConfig()
kdecore (KConfigSkeleton): KConfigSkeleton::readConfig()
kmail: KMKernel::~KMKernel
kio_imap: IMAP4::dispatch - command=51
kio_imap: IMAP4::slave_status
Comment 16 David Faure 2004-10-11 00:31:16 UTC
On Sunday 10 October 2004 17:33, Carsten Burghardt wrote:
> Hi David,
> 
> this bug seems to be related to 90479 as all folders are selected and this 
> seems to block the listing of the subscribed folders somehow. It works fine 
> with online imap.
> Can I help you with debugging somehow?

Well I know where the bug comes from, so the debugging part is done, but I could
use your help on the "how to fix it" part :)

The problem is that for any subfolder, kmfoldercachedimap knows it's "\noselect"
when listing that folder's parent. It will then setNoContent(), and will skip
mail-related operations on that folder.

But the problem here is that the *toplevel* folder is \noselect. So there's no
listing during which kmail can learn about that.

I guess we need a way to enquire for the toplevel folder's attributes before
processing it. How do you do it with online imap? Some kind of ::stat() ?

Comment 17 Nick Brown 2004-10-19 16:12:43 UTC
Did anyone figure out how out to get the toplevel folders attributes if its marked "\noselect"?
(I'm still trying to familiarize myself with the kmail code :-)
Comment 18 David Faure 2004-10-19 20:16:03 UTC
> Did anyone figure out how out to get the toplevel folders attributes if its marked "\noselect"?

Carsten and I seem to interpret differently this bug report.
Is it about the toplevel folder, the one which is named after the [d]IMAP account,
or is it about the folder (called "Mail") which is inside?

He lacks time to look into this issue apparently, and I lack knowledge about prefix usage,
so please bear with me so I can understand the issue.

In the following ascii art "*" denotes a toplevel folder, and "-" a child of that folder.

Is it like:
* My Account
  - Mail
  - Other folders (which are in fact /Mail/Foo I guess?)

(and the problem is when listing "Mail")

or like
* My Account (which has a path of "/Mail")
  - Other folders (/Mail/Foo)
?

IIRC you said it works with online imap. But do both online imap and dimap show the same
structure in the folder tree?

Comment 19 Nick Brown 2004-10-20 12:06:58 UTC
It is the top level folder "/Mail" which is the root of my
account. All my mail folders are within this toplevel folder. (It
folder actually maps to the fs as /home/nicbrown/Mail/)

Online imap works just fine, and shows the structure;

*My account ("/Mail" which is /home/nicbrown/Mail/)
- inbox (which is /var/spool/mail/nicbrown)
- Sent
- Deleted Messages
- Drafts
- Work
-- Unix
-- Cisco
- Personal
-- Linux ("/Mail/Personal/Linux" which is
/home/nicbrown/Mail/Personal/Linux)
-- Fun

I have no idea what the folder tree looks like for this account with
dimap is as it fails on the top level folder :-)

In the kmailrc prefix=/Mail/ when using both imap and dimap.
Comment 20 Carsten Burghardt 2004-10-21 14:04:39 UTC
Interesting: I tested dimap with a UW imap and prefix and the prefixed folder 
was not selected so I got no error. So it's even server specific. Puh, I'll 
see what I can do.

Comment 21 Nick Brown 2004-12-16 23:27:20 UTC
Its been a while, but I just rebuilt KDE CVS head from today and this problem is still present.
Comment 22 Nick Brown 2005-11-15 19:29:41 UTC
So I still see this error even with Kmail 1.9 which uses names spaces.

Error while reading folder Work on the server: 
  Unable to open folder Mail/Work. The server replied: SELECT failed: 
  Can't open Mail/Work: not a selectable mailbox 

My uw imap server is 2004.357.

I have in my config;

<snip>
[Account 4]
0="#mh/","#mhinbox","~/Mail"
Folder=
Id=1762082881
Name=Test
Namespace:#mh/=/
Namespace:#mhinbox=
Namespace:~/Mail=/
Type=cachedimap
</snip>

I suspect that this may relate to the following mozilla imap bug;
https://bugzilla.mozilla.org/show_bug.cgi?id=166885
Comment 23 Dennis Schridde 2009-05-01 19:56:43 UTC
Close this? It's really old...