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 "maildirfetchunreadheaders.h" 0009 0010 #include <QDebug> 0011 0012 #include <Akonadi/CollectionFetchJob> 0013 #include <Akonadi/CollectionFetchScope> 0014 #include <Akonadi/ItemFetchJob> 0015 #include <Akonadi/ItemFetchScope> 0016 0017 #include "akonadi/messageparts.h" 0018 #include <KMime/KMimeMessage> 0019 0020 using namespace Akonadi; 0021 0022 MailDirFetchUnreadHeaders::MailDirFetchUnreadHeaders() 0023 : MailDir() 0024 { 0025 } 0026 0027 void MailDirFetchUnreadHeaders::runTest() 0028 { 0029 timer.start(); 0030 qDebug() << " Listing headers of unread messages of every folder."; 0031 auto clj3 = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive); 0032 clj3->fetchScope().setResource(currentInstance.identifier()); 0033 clj3->exec(); 0034 const Collection::List list3 = clj3->collections(); 0035 for (const Collection &collection : list3) { 0036 auto ifj = new ItemFetchJob(collection, this); 0037 ifj->fetchScope().fetchPayloadPart(MessagePart::Envelope); 0038 ifj->exec(); 0039 QString a; 0040 const auto items = ifj->items(); 0041 for (const Item &item : items) { 0042 // filter read messages 0043 if (!item.hasFlag("\\SEEN")) { 0044 a = item.payload<KMime::Message::Ptr>()->subject()->asUnicodeString(); 0045 } 0046 } 0047 } 0048 outputStats(QStringLiteral("unreadheaderlist")); 0049 } 0050 0051 #include "moc_maildirfetchunreadheaders.cpp"