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 "maildirfetchallheaders.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 MailDirFetchAllHeaders::MailDirFetchAllHeaders() 0023 : MailDir() 0024 { 0025 } 0026 0027 void MailDirFetchAllHeaders::runTest() 0028 { 0029 timer.start(); 0030 qDebug() << " Listing all headers of every folder."; 0031 auto clj = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive); 0032 clj->fetchScope().setResource(currentInstance.identifier()); 0033 clj->exec(); 0034 const Collection::List list = clj->collections(); 0035 for (const Collection &collection : list) { 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 a = item.payload<KMime::Message::Ptr>()->subject()->asUnicodeString(); 0043 } 0044 } 0045 outputStats(QStringLiteral("fullheaderlist")); 0046 } 0047 0048 #include "moc_maildirfetchallheaders.cpp"