diff --git a/configuredialog.cpp b/configuredialog.cpp index a9a00eee8..973853f00 100644 --- a/configuredialog.cpp +++ b/configuredialog.cpp @@ -4176,6 +4176,23 @@ void MiscPage::GroupwareTab::save() { GlobalSettings::setTheIMAPResourceEnabled( enabled ); GlobalSettings::setTheIMAPResourceFolderLanguage( mLanguageCombo->currentItem() ); GlobalSettings::setTheIMAPResourceFolderParent( folder? folder->idString(): "" ); + + KMAccount* account = 0; + // Didn't find an easy way to find the account for a given folder... + // Fallback: iterate over accounts to select folderId if found (as an inbox folder) + for( KMAccount *a = kmkernel->acctMgr()->first(); + a && !account; // stop when found + a = kmkernel->acctMgr()->next() ) { + if( a->folder() && a->folder()->child() ) { + KMFolderNode *node; + for (node = a->folder()->child()->first(); node; node = a->folder()->child()->next()) + if ( node && static_cast(node) == folder ) { + account = a; + break; + } + } + } + GlobalSettings::setTheIMAPResourceAccount( account ? account->id() : 0 ); } diff --git a/kmail.kcfg b/kmail.kcfg index cef70db6b..c362eb2e0 100644 --- a/kmail.kcfg +++ b/kmail.kcfg @@ -139,6 +139,12 @@ "the IMAP inbox to be the parent.</p> + + + <p>This is the ID of the account holding the IMAP resource " + "folders.</p> + + 0 <p>If you want to set the folder names of the " diff --git a/kmailicalifaceimpl.cpp b/kmailicalifaceimpl.cpp index c1a35fa00..87b9773f9 100644 --- a/kmailicalifaceimpl.cpp +++ b/kmailicalifaceimpl.cpp @@ -45,6 +45,7 @@ #include "kmmsgdict.h" #include "kmfolderimap.h" #include "globalsettings.h" +#include "kmacctmgr.h" #include @@ -644,7 +645,17 @@ void KMailICalIfaceImpl::readConfig() if( folderParent == 0 ) { // Parent folder not found. It was probably deleted. The user will have to // configure things again. - kdWarning(5006) << "Groupware folder " << parentName << " not found. Groupware functionality disabled" << endl; + kdDebug(5006) << "Groupware folder " << parentName << " not found. Groupware functionality disabled" << endl; + // Or maybe the inbox simply wasn't created on the first startup + KMAccount* account = kmkernel->acctMgr()->find( GlobalSettings::theIMAPResourceAccount() ); + Q_ASSERT( account ); + if ( account ) { + // just in case we were connected already + disconnect( account, SIGNAL( finishedCheck( bool, CheckStatus ) ), + this, SLOT( slotCheckDone() ) ); + connect( account, SIGNAL( finishedCheck( bool, CheckStatus ) ), + this, SLOT( slotCheckDone() ) ); + } mUseResourceIMAP = false; return; } else { @@ -744,6 +755,20 @@ void KMailICalIfaceImpl::readConfig() reloadFolderTree(); } +void KMailICalIfaceImpl::slotCheckDone() +{ + QString parentName = GlobalSettings::theIMAPResourceFolderParent(); + KMFolder* folderParent = kmkernel->findFolderById( parentName ); + if ( folderParent ) // cool it exists now + { + KMAccount* account = kmkernel->acctMgr()->find( GlobalSettings::theIMAPResourceAccount() ); + if ( account ) + disconnect( account, SIGNAL( finishedCheck( bool, CheckStatus ) ), + this, SLOT( slotCheckDone() ) ); + readConfig(); + } +} + void KMailICalIfaceImpl::slotRefreshCalendar() { slotRefresh( "Calendar" ); } void KMailICalIfaceImpl::slotRefreshTasks() { slotRefresh( "Task" ); } void KMailICalIfaceImpl::slotRefreshJournals() { slotRefresh( "Journal" ); } diff --git a/kmailicalifaceimpl.h b/kmailicalifaceimpl.h index 581e05f67..a52b96db3 100644 --- a/kmailicalifaceimpl.h +++ b/kmailicalifaceimpl.h @@ -141,6 +141,8 @@ private slots: void slotRefreshContacts(); void slotRefreshNotes(); + void slotCheckDone(); + private: /** Helper function for initFolders. Initializes a single folder. */ KMFolder* initFolder( KFolderTreeItem::Type itemType, const char* typeString );