From 068dd703debbcdf68a255bb07c1c2f2723cf1900 Mon Sep 17 00:00:00 2001 From: Till Adam Date: Sat, 17 Jul 2004 16:13:52 +0000 Subject: [PATCH] Make sure that folders which are to be created on the server during startup while there is no connected slave yet are stored in a list and created once the slave signals that it is connected. Fixes creation of missing imap resource folders with online imap. svn path=/trunk/kdepim/; revision=330332 --- kmfolderimap.cpp | 26 ++++++++++++++++++++++++-- kmfolderimap.h | 8 ++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/kmfolderimap.cpp b/kmfolderimap.cpp index 477ea0a50..0c461dbf1 100644 --- a/kmfolderimap.cpp +++ b/kmfolderimap.cpp @@ -1317,10 +1317,24 @@ void KMFolderImap::slotGetMessagesResult(KIO::Job * job) //----------------------------------------------------------------------------- void KMFolderImap::createFolder(const QString &name) { + if ( mAccount->makeConnection() == ImapAccountBase::Error ) { + kdWarning(5006) << "KMFolderImap::createFolder - got no connection" << endl; + return; + } else if ( mAccount->makeConnection() == ImapAccountBase::Connecting ) { + // We'll wait for the connectionResult signal from the account. + kdDebug(5006) << "KMFolderImap::createFolder - waiting for connection" << endl; + + if ( mFoldersPendingCreation.isEmpty() ) { + // first folder, connect + connect( mAccount, SIGNAL( connectionResult(int, const QString&) ), + this, SLOT( slotCreatePendingFolders() ) ); + } + mFoldersPendingCreation << name; + return; + } KURL url = mAccount->getUrl(); url.setPath(imapPath() + name); - if ( mAccount->makeConnection() != ImapAccountBase::Connected ) - return; + KIO::SimpleJob *job = KIO::mkdir(url); KIO::Scheduler::assignJobToSlave(mAccount->slave(), job); ImapAccountBase::jobData jd( url.url(), folder() ); @@ -1829,4 +1843,12 @@ void KMFolderImap::setAlreadyRemoved( bool removed ) } } +void KMFolderImap::slotCreatePendingFolders() +{ + QStringList::Iterator it = mFoldersPendingCreation.begin(); + for ( ; it != mFoldersPendingCreation.end(); ++it ) { + createFolder( *it ); + } +} + #include "kmfolderimap.moc" diff --git a/kmfolderimap.h b/kmfolderimap.h index cd5bd9eac..8b50d40e2 100644 --- a/kmfolderimap.h +++ b/kmfolderimap.h @@ -409,6 +409,13 @@ protected slots: */ void slotProcessNewMail( int errorCode, const QString& errorMsg ); + /** + * Is connected when there are folders to be created on startup and the + * account is still connecting. Once the account emits the connected + * signal this slot is called and the folders created. + */ + void slotCreatePendingFolders(); + protected: QString mImapPath; ulong mLastUid; @@ -428,6 +435,7 @@ private: bool mAlreadyRemoved; ProgressItem *mMailCheckProgressItem; ProgressItem *mListDirProgressItem; + QStringList mFoldersPendingCreation; }; #endif // kmfolderimap_h