diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /kmail/kmfolderdir.cpp | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip |
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed
* Added journal read support to the CalDAV resource
* Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/kmfolderdir.cpp')
-rw-r--r-- | kmail/kmfolderdir.cpp | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/kmail/kmfolderdir.cpp b/kmail/kmfolderdir.cpp index 46aba345c..1ecab637b 100644 --- a/kmail/kmfolderdir.cpp +++ b/kmail/kmfolderdir.cpp @@ -163,6 +163,31 @@ TQString KMFolderDir::prettyURL() const return label(); } +//----------------------------------------------------------------------------- +void KMFolderDir::addDirToParent( const TQString &dirName, KMFolder *parentFolder ) +{ + KMFolderDir* folderDir = new KMFolderDir( parentFolder, this, dirName, mDirType); + folderDir->reload(); + append( folderDir ); + parentFolder->setChild( folderDir ); +} + +// Get the default folder type of the given dir type. This function should only be used when +// needing to find out what the folder type of a missing folder is. +KMFolderType dirTypeToFolderType( KMFolderDirType dirType ) +{ + switch( dirType ) { + + // Use maildir for normal folder dirs, as this function is only called when finding a dir + // without a parent folder, which can only happen with maildir-like folders + case KMStandardDir: return KMFolderTypeMaildir; + + case KMImapDir: return KMFolderTypeImap; + case KMDImapDir: return KMFolderTypeCachedImap; + case KMSearchDir: return KMFolderTypeSearch; + default: Q_ASSERT( false ); return KMFolderTypeMaildir; + } +} //----------------------------------------------------------------------------- bool KMFolderDir::reload(void) @@ -272,6 +297,7 @@ bool KMFolderDir::reload(void) } } + TQStringList dirsWithoutFolder = diList; for (folder=folderList.first(); folder; folder=folderList.next()) { for(TQStringList::Iterator it = diList.begin(); @@ -279,13 +305,36 @@ bool KMFolderDir::reload(void) ++it) if (*it == "." + folder->fileName() + ".directory") { - KMFolderDir* folderDir = new KMFolderDir( folder, this, *it, mDirType); - folderDir->reload(); - append(folderDir); - folder->setChild(folderDir); + dirsWithoutFolder.remove( *it ); + addDirToParent( *it, folder ); break; } } + + // Check if the are any dirs without an associated folder. This can happen if the user messes + // with the on-disk folder structure, see kolab issue 2972. In that case, we don't want to loose + // the subfolders as well, so we recreate the folder so the folder/dir hierachy is OK again. + if ( type() == KMDImapDir ) { + for ( TQStringList::Iterator it = dirsWithoutFolder.begin(); + it != dirsWithoutFolder.end(); ++it ) { + + // .foo.directory => foo + TQString folderName = *it; + int right = folderName.find( ".directory" ); + int left = folderName.find( "." ); + Q_ASSERT( left != -1 && right != -1 ); + folderName = folderName.mid( left + 1, right - 1 ); + + kdDebug(5006) << "Found dir without associated folder: " << ( *it ) << ", recreating the folder " << folderName << "." << endl; + + // Recreate the missing folder + KMFolder *folder = new KMFolder( this, folderName, KMFolderTypeCachedImap ); + append( folder ); + folderList.append( folder ); + + addDirToParent( *it, folder ); + } + } return TRUE; } |