Bug 260593 - Drafts are not saved in the draft folder which belongs to the identity
Summary: Drafts are not saved in the draft folder which belongs to the identity
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: general (show other bugs)
Version: 2.0.89
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-17 23:58 UTC by m.wege
Modified: 2010-12-31 08:50 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description m.wege 2010-12-17 23:58:05 UTC
Version:           2.0.89 (using KDE 4.5.85) 
OS:                Linux

When I save a draft, the draft is saved in the draft folder belonging to "Kmail local folders" and not in the draft folder belonging to that identity (which is a cached IMAP-account).

Reproducible: Always




OS: Linux (i686) release 2.6.37-7-generic-pae
Compiler: cc
Comment 1 m.wege 2010-12-31 01:09:52 UTC
bug is still present in 4.6. Beta 3
Comment 2 Tobias Koenig 2010-12-31 08:50:24 UTC
commit 33696c399edfe08ba7e17a12ef810107b115634f
branch master
Author: Tobias Koenig <tokoe@kde.org>
Date:   Fri Dec 31 08:52:08 2010 +0100

    Use identity specific drafts/templates folders
    
    Patch provided by Antonis Tsiapaliokas, coding style adapted.
    
    BUG: 260593

diff --git a/messagecomposer/composerviewbase.cpp b/messagecomposer/composerviewbase.cpp
index 84b6fe8..c5c2765 100644
--- a/messagecomposer/composerviewbase.cpp
+++ b/messagecomposer/composerviewbase.cpp
@@ -899,12 +899,27 @@ void Message::ComposerViewBase::saveMessage( KMime::Message::Ptr message, Messag
 {
   Akonadi::Collection target;
 
+  // preinitialize with the default collections
   if ( saveIn == MessageSender::SaveInTemplates ) {
     target = Akonadi::SpecialMailCollections::self()->defaultCollection( Akonadi::SpecialMailCollections::Templates );
   } else {
     target = Akonadi::SpecialMailCollections::self()->defaultCollection( Akonadi::SpecialMailCollections::Drafts );
   }
 
+  // overwrite with identity specific collections if available
+  const KPIMIdentities::Identity identity = identityManager()->identityForUoid( m_identityCombo->currentIdentity() );
+  if ( !identity.isNull() ) { // we have a valid identity
+    if ( saveIn == MessageSender::SaveInTemplates ) {
+      if ( !identity.templates().isEmpty() ) { // the user has specified a custom templates collection
+        target = Akonadi::Collection( identity.templates().toLongLong() );
+      }
+    } else {
+      if ( !identity.drafts().isEmpty() ) { // the user has specified a custom drafts collection
+        target = Akonadi::Collection( identity.drafts().toLongLong() );
+      }
+    }
+  }
+
   if ( !target.isValid() ) {
     kWarning() << "No default collection for" << saveIn;
     emit failed( i18n( "No default collection for %1", saveIn ) );