File indexing completed on 2024-12-22 04:52:51
0001 /* 0002 SPDX-FileCopyrightText: 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br> 0003 based on kdepimlibs/akonadi/tests/benchmarker.cpp wrote by Robert Zwerus <arzie@dds.nl> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "maildirremovereadmessages.h" 0009 #include <QDebug> 0010 0011 #include <Akonadi/CollectionFetchJob> 0012 #include <Akonadi/CollectionFetchScope> 0013 #include <Akonadi/ItemDeleteJob> 0014 #include <Akonadi/ItemFetchJob> 0015 0016 using namespace Akonadi; 0017 0018 MailDirRemoveReadMessages::MailDirRemoveReadMessages() 0019 : MailDir() 0020 { 0021 } 0022 0023 void MailDirRemoveReadMessages::runTest() 0024 { 0025 timer.start(); 0026 qDebug() << " Removing read messages from every folder."; 0027 auto clj4 = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive); 0028 clj4->fetchScope().setResource(currentInstance.identifier()); 0029 clj4->exec(); 0030 const Collection::List list4 = clj4->collections(); 0031 for (const Collection &collection : list4) { 0032 auto ifj = new ItemFetchJob(collection, this); 0033 ifj->exec(); 0034 const auto items = ifj->items(); 0035 for (const Item &item : items) { 0036 // delete read messages 0037 if (item.hasFlag("\\SEEN")) { 0038 auto idj = new ItemDeleteJob(item, this); 0039 idj->exec(); 0040 } 0041 } 0042 } 0043 outputStats(QStringLiteral("removereaditems")); 0044 } 0045 0046 #include "moc_maildirremovereadmessages.cpp"