akondi-mime5/akonadi-mime5/autotests/benchmarker/maildir/maildirremovereadmessages.cpp
Ward from fusion-voyager-3 a8e7e301c1
Some checks failed
PikaOS Package Build & Release (Canary) (amd64-v3) / build (push) Failing after 12s
fixx akondi
2024-08-05 17:19:50 +03:00

45 lines
1.3 KiB
C++

/*
SPDX-FileCopyrightText: 2009 Igor Trindade Oliveira <igor_trindade@yahoo.com.br>
based on kdepimlibs/akonadi/tests/benchmarker.cpp wrote by Robert Zwerus <arzie@dds.nl>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "maildirremovereadmessages.h"
#include <QDebug>
#include <Akonadi/CollectionFetchJob>
#include <Akonadi/CollectionFetchScope>
#include <Akonadi/ItemDeleteJob>
#include <Akonadi/ItemFetchJob>
using namespace Akonadi;
MailDirRemoveReadMessages::MailDirRemoveReadMessages()
: MailDir()
{
}
void MailDirRemoveReadMessages::runTest()
{
timer.start();
qDebug() << " Removing read messages from every folder.";
auto clj4 = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive);
clj4->fetchScope().setResource(currentInstance.identifier());
clj4->exec();
const Collection::List list4 = clj4->collections();
for (const Collection &collection : list4) {
auto ifj = new ItemFetchJob(collection, this);
ifj->exec();
const auto items = ifj->items();
for (const Item &item : items) {
// delete read messages
if (item.hasFlag("\\SEEN")) {
auto idj = new ItemDeleteJob(item, this);
idj->exec();
}
}
}
outputStats(QStringLiteral("removereaditems"));
}