Bug 261055

Summary: Option delete trashcan after close doesn't have an effect
Product: [Applications] KMail Mobile Reporter: Ludwig Reiter <ludwig.reiter>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: CLOSED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Windows CE   
OS: Microsoft Windows CE   
Latest Commit: Version Fixed In:

Description Ludwig Reiter 2010-12-23 10:54:28 UTC
Version:           unspecified (using Devel) 
OS:                Windows CE

version 20101219 svn 1207720

Reproducible: Always

Steps to Reproduce:
1. Set option delete mails from trashcan after closing on.
2. Move some mails to the trashcan.
3. Close kmail mobile.
4. Restart it.

Actual Results:  
The mails are not deleted.

Expected Results:  
The mailss in the trashcan should be deleted

Used German as language. Here trashcan is named Mülleimer.
Comment 1 Tobias Koenig 2010-12-23 15:41:37 UTC
commit 4f43a240652fc3bfd93a212d9be059876f53cd94
branch master
Author: Tobias Koenig <tokoe@kde.org>
Date:   Thu Dec 23 15:44:31 2010 +0100

    Implement 'Empty trash on exit' functionality
    
    BUG: 261055

diff --git a/mobile/mail/mainview.cpp b/mobile/mail/mainview.cpp
index 6fd855a..5a2d07c 100644
--- a/mobile/mail/mainview.cpp
+++ b/mobile/mail/mainview.cpp
@@ -159,6 +159,24 @@ MainView::MainView(QWidget* parent)
 MainView::~MainView()
 {
   delete m_grouperComparator;
+
+  const Akonadi::Collection trashCollection = CommonKernel->trashCollectionFolder();
+  if ( trashCollection.isValid() ) {
+    if ( Settings::self()->miscEmptyTrashAtExit() ) {
+      if ( trashCollection.statistics().count() > 0 ) {
+        qDebug( "Emptying trash..." );
+        Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( trashCollection, this );
+        if ( job->exec() ) {
+          const Akonadi::Item::List items = job->items();
+          if ( !items.isEmpty() ) {
+            Akonadi::ItemDeleteJob *deleteJob = new Akonadi::ItemDeleteJob( items, this );
+            deleteJob->exec();
+            qDebug( "done" );
+          }
+        }
+      }
+    }
+  }
 }
 
 void MainView::setConfigWidget( ConfigWidget *configWidget )
Comment 2 Ludwig Reiter 2011-01-18 12:59:48 UTC
test of description
version 2011-01-16 git-4d1bc61

test passed.
Closed.