From 9fb3eb0d87645159a8968603a7b3d38217829d63 Mon Sep 17 00:00:00 2001 From: Carsten Burghardt Date: Sun, 7 Aug 2005 15:40:39 +0000 Subject: [PATCH] Now that kmail also knows the correct delimiter (from the namespace code) use it and transfer the correct new folder path to the kioslave. And make the code that defaults the type of moved uw imap folders actually work :-) Make sure you also update the imap4 kioslave. svn path=/branches/KDE/3.5/kdepim/; revision=443851 --- imapaccountbase.cpp | 11 +++++++---- kmfolderimap.cpp | 18 +++++++++++++++--- newfolderdialog.cpp | 2 +- renamejob.cpp | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/imapaccountbase.cpp b/imapaccountbase.cpp index 78aceb397..3db66e8c1 100644 --- a/imapaccountbase.cpp +++ b/imapaccountbase.cpp @@ -745,8 +745,13 @@ namespace KMail { QStringList::Iterator strit; for ( strit = it.data().begin(); strit != it.data().end(); ++strit ) { + QString ns = *strit; + if ( ns.endsWith("/") || ns.endsWith(".") ) { + // strip delimiter for the comparison + ns = ns.left( ns.length()-1 ); + } // first ignore an empty prefix as it would match always - if ( !(*strit).isEmpty() && path.find( *strit ) != -1 ) { + if ( !ns.isEmpty() && path.find( ns ) != -1 ) { return (*strit); } } @@ -783,9 +788,7 @@ namespace KMail { QString ImapAccountBase::delimiterForFolder( FolderStorage* storage ) { QString prefix = namespaceForFolder( storage ); - QString delim; - if ( mNamespaceToDelimiter.contains(prefix) ) - delim = mNamespaceToDelimiter[prefix]; + QString delim = delimiterForNamespace( prefix ); return delim; } diff --git a/kmfolderimap.cpp b/kmfolderimap.cpp index 8213abfe6..c21cc3cd6 100644 --- a/kmfolderimap.cpp +++ b/kmfolderimap.cpp @@ -1614,18 +1614,30 @@ void KMFolderImap::slotGetMessagesResult(KIO::Job * job) void KMFolderImap::createFolder(const QString &name, const QString& parentPath, bool askUser) { + kdDebug(5006) << "KMFolderImap::createFolder - name=" << name << ",parent=" << + parentPath << ",askUser=" << askUser << endl; if ( mAccount->makeConnection() != ImapAccountBase::Connected ) { kdWarning(5006) << "KMFolderImap::createFolder - got no connection" << endl; return; } KURL url = mAccount->getUrl(); QString parent = ( parentPath.isEmpty() ? imapPath() : parentPath ); - if ( !parent.endsWith("/") ) { - parent += "/"; + if ( parent.endsWith("/") ) { + // strip / (which kmail uses this internally) + parent = parent.left( parent.length()-1 ); + } + QString delim = mAccount->delimiterForFolder( this ); + if ( delim.isEmpty() ) { + // better be safe + delim = "/"; + } + if ( !parent.endsWith(delim) ) { + // add the correct delimiter + parent += delim; } QString path = parent + name; if ( askUser ) { - path += ";INFO=ASKUSER"; + path += "/;INFO=ASKUSER"; } url.setPath( path ); diff --git a/newfolderdialog.cpp b/newfolderdialog.cpp index 348b70895..e7310804f 100644 --- a/newfolderdialog.cpp +++ b/newfolderdialog.cpp @@ -249,7 +249,7 @@ void NewFolderDialog::slotOk() QString imapPath, parent; if ( mNamespacesComboBox ) { // create folder with namespace - parent = mNamespacesComboBox->currentText(); + parent = anAccount->addPathToNamespace( mNamespacesComboBox->currentText() ); imapPath = anAccount->addPathToNamespace( parent ) + fldName; } KMFolderImap* newStorage = static_cast( newFolder->storage() ); diff --git a/renamejob.cpp b/renamejob.cpp index c0ede7dd1..5cffb2a66 100644 --- a/renamejob.cpp +++ b/renamejob.cpp @@ -125,7 +125,7 @@ void RenameJob::execute() this, SLOT( slotMoveMessages() ) ); KMFolderImap* imapFolder = static_cast(mNewParent->owner()->storage()); - imapFolder->createFolder( mNewName, false ); + imapFolder->createFolder( mNewName, QString::null, false ); } else if ( mNewParent->type() == KMDImapDir ) { KMFolderCachedImap* newStorage = static_cast(mNewFolder->storage());