Verified Commit d2990359 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Use plain old Akonadi::CollectionFetchJob

parent 05a7f93b
...@@ -19,9 +19,11 @@ ...@@ -19,9 +19,11 @@
*/ */
#include "markallmessagesasreadinfolderandsubfolderjob.h" #include "markallmessagesasreadinfolderandsubfolderjob.h"
#include <PimCommonAkonadi/FetchRecursiveCollectionsJob>
#include "kmail_debug.h" #include "kmail_debug.h"
#include <AkonadiCore/CollectionFetchJob>
#include <AkonadiCore/CollectionFetchScope>
MarkAllMessagesAsReadInFolderAndSubFolderJob::MarkAllMessagesAsReadInFolderAndSubFolderJob(QObject *parent) MarkAllMessagesAsReadInFolderAndSubFolderJob::MarkAllMessagesAsReadInFolderAndSubFolderJob(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
...@@ -39,11 +41,18 @@ void MarkAllMessagesAsReadInFolderAndSubFolderJob::setTopLevelCollection(const A ...@@ -39,11 +41,18 @@ void MarkAllMessagesAsReadInFolderAndSubFolderJob::setTopLevelCollection(const A
void MarkAllMessagesAsReadInFolderAndSubFolderJob::start() void MarkAllMessagesAsReadInFolderAndSubFolderJob::start()
{ {
if (mTopLevelCollection.isValid()) { if (mTopLevelCollection.isValid()) {
PimCommon::FetchRecursiveCollectionsJob *fetchJob = new PimCommon::FetchRecursiveCollectionsJob(this); auto fetchJob = new Akonadi::CollectionFetchJob(mTopLevelCollection, Akonadi::CollectionFetchJob::Recursive, this);
fetchJob->setTopCollection(mTopLevelCollection); fetchJob->fetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All);
connect(fetchJob, &PimCommon::FetchRecursiveCollectionsJob::fetchCollectionFailed, this, &MarkAllMessagesAsReadInFolderAndSubFolderJob::slotFetchCollectionFailed); connect(fetchJob, &Akonadi::CollectionFetchJob::finished,
connect(fetchJob, &PimCommon::FetchRecursiveCollectionsJob::fetchCollectionFinished, this, &MarkAllMessagesAsReadInFolderAndSubFolderJob::slotFetchCollectionDone); this, [this](KJob *job) {
fetchJob->start(); if (job->error()) {
qCWarning(KMAIL_LOG) << job->errorString();
slotFetchCollectionFailed();
} else {
auto fetch = static_cast<Akonadi::CollectionFetchJob*>(job);
slotFetchCollectionDone(fetch->collections());
}
});
} else { } else {
qCDebug(KMAIL_LOG()) << "Invalid toplevel collection"; qCDebug(KMAIL_LOG()) << "Invalid toplevel collection";
deleteLater(); deleteLater();
......
...@@ -19,12 +19,13 @@ ...@@ -19,12 +19,13 @@
*/ */
#include "removeduplicatemessageinfolderandsubfolderjob.h" #include "removeduplicatemessageinfolderandsubfolderjob.h"
#include <PimCommonAkonadi/FetchRecursiveCollectionsJob>
#include "kmail_debug.h" #include "kmail_debug.h"
#include <Akonadi/KMime/RemoveDuplicatesJob> #include <Akonadi/KMime/RemoveDuplicatesJob>
#include <Libkdepim/ProgressManager> #include <Libkdepim/ProgressManager>
#include <KLocalizedString> #include <KLocalizedString>
#include <KMessageBox> #include <KMessageBox>
#include <AkonadiCore/CollectionFetchJob>
#include <AkonadiCore/CollectionFetchScope>
RemoveDuplicateMessageInFolderAndSubFolderJob::RemoveDuplicateMessageInFolderAndSubFolderJob(QObject *parent, QWidget *parentWidget) RemoveDuplicateMessageInFolderAndSubFolderJob::RemoveDuplicateMessageInFolderAndSubFolderJob(QObject *parent, QWidget *parentWidget)
: QObject(parent) : QObject(parent)
...@@ -39,11 +40,18 @@ RemoveDuplicateMessageInFolderAndSubFolderJob::~RemoveDuplicateMessageInFolderAn ...@@ -39,11 +40,18 @@ RemoveDuplicateMessageInFolderAndSubFolderJob::~RemoveDuplicateMessageInFolderAn
void RemoveDuplicateMessageInFolderAndSubFolderJob::start() void RemoveDuplicateMessageInFolderAndSubFolderJob::start()
{ {
if (mTopLevelCollection.isValid()) { if (mTopLevelCollection.isValid()) {
PimCommon::FetchRecursiveCollectionsJob *fetchJob = new PimCommon::FetchRecursiveCollectionsJob(this); auto fetchJob = new Akonadi::CollectionFetchJob(mTopLevelCollection, Akonadi::CollectionFetchJob::Recursive, this);
fetchJob->setTopCollection(mTopLevelCollection); fetchJob->fetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All);
connect(fetchJob, &PimCommon::FetchRecursiveCollectionsJob::fetchCollectionFailed, this, &RemoveDuplicateMessageInFolderAndSubFolderJob::slotFetchCollectionFailed); connect(fetchJob, &Akonadi::CollectionFetchJob::result,
connect(fetchJob, &PimCommon::FetchRecursiveCollectionsJob::fetchCollectionFinished, this, &RemoveDuplicateMessageInFolderAndSubFolderJob::slotFetchCollectionDone); this, [this](KJob *job) {
fetchJob->start(); if (job->error()) {
qCWarning(KMAIL_LOG) << job->errorString();
slotFetchCollectionFailed();
} else {
auto fetch = static_cast<Akonadi::CollectionFetchJob*>(job);
slotFetchCollectionDone(fetch->collections());
}
});
} else { } else {
qCDebug(KMAIL_LOG()) << "Invalid toplevel collection"; qCDebug(KMAIL_LOG()) << "Invalid toplevel collection";
deleteLater(); deleteLater();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment