Messagelib

dkimstoreresultjob.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "dkimstoreresultjob.h"
8#include "dkimresultattribute.h"
9#include "messageviewer_dkimcheckerdebug.h"
10#include <Akonadi/ItemModifyJob>
11
12using namespace MessageViewer;
13DKIMStoreResultJob::DKIMStoreResultJob(QObject *parent)
14 : QObject(parent)
15{
16}
17
18DKIMStoreResultJob::~DKIMStoreResultJob() = default;
19
20void DKIMStoreResultJob::start()
21{
22 if (!canStart()) {
23 qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "Impossible to store dkim result";
25 return;
26 }
27 auto attr = mItem.attribute<MessageViewer::DKIMResultAttribute>(Akonadi::Item::AddIfMissing);
28 attr->setError(static_cast<int>(mResult.error));
29 attr->setWarning(static_cast<int>(mResult.warning));
30 attr->setStatus(static_cast<int>(mResult.status));
31 auto modify = new Akonadi::ItemModifyJob(mItem);
32 modify->setIgnorePayload(true);
33 modify->disableRevisionCheck();
34 connect(modify, &KJob::result, this, &DKIMStoreResultJob::slotModifyItemDone);
35}
36
37void DKIMStoreResultJob::slotModifyItemDone(KJob *job)
38{
39 if (job->error()) {
40 qCDebug(MESSAGEVIEWER_DKIMCHECKER_LOG) << "DKIMStoreResultJob: modify item failed " << job->errorString();
41 }
43}
44
45bool DKIMStoreResultJob::canStart() const
46{
47 if (mItem.isValid() && mResult.isValid()) {
48 return true;
49 }
50 return false;
51}
52
53void DKIMStoreResultJob::setResult(const DKIMCheckSignatureJob::CheckSignatureResult &checkResult)
54{
55 mResult = checkResult;
56}
57
58void DKIMStoreResultJob::setItem(const Akonadi::Item &item)
59{
60 mItem = item;
61}
62
63#include "moc_dkimstoreresultjob.cpp"
const T * attribute() const
bool isValid() const
virtual QString errorString() const
int error() const
void result(KJob *job)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.