Mailcommon

collectionexpiryjob.cpp
1/*
2 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "collectionexpiryjob.h"
8#include "mailcommon_debug.h"
9#include "util/mailutil.h"
10
11#include <Akonadi/CollectionModifyJob>
12
13using namespace MailCommon;
14
15CollectionExpiryJob::CollectionExpiryJob(QObject *parent)
16 : QObject(parent)
17{
18}
19
20CollectionExpiryJob::~CollectionExpiryJob() = default;
21
22void CollectionExpiryJob::start()
23{
24 if (mCollection.isValid()) {
25 auto job = new Akonadi::CollectionModifyJob(mCollection, this);
26 connect(job, &Akonadi::CollectionModifyJob::result, this, &CollectionExpiryJob::slotCollectionModified);
27 } else {
28 qCWarning(MAILCOMMON_LOG) << "Collection is not valid";
30 }
31}
32
33void CollectionExpiryJob::setCollection(const Akonadi::Collection &collection)
34{
35 mCollection = collection;
36}
37
38void CollectionExpiryJob::setExpireNow(bool expireNow)
39{
40 mExpireNow = expireNow;
41}
42
43void CollectionExpiryJob::slotCollectionModified(KJob *job)
44{
45 if (job->error()) {
46 qCWarning(MAILCOMMON_LOG) << " Error when we modified collection";
48 return;
49 }
50
51 // trigger immediate expiry if there is something to do
52 if (mExpireNow) {
54 if (modifiedJob) {
55 MailCommon::Util::expireOldMessages(modifiedJob->collection(), true /*immediate*/);
56 } else {
57 qCWarning(MAILCOMMON_LOG) << " invalid pointer";
58 }
59 }
61}
62
63#include "moc_collectionexpiryjob.cpp"
bool isValid() const
int error() const
void result(KJob *job)
The filter dialog.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:18:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.