Messagelib

dkimcheckauthenticationstatusjob.cpp
1/*
2 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "dkimcheckauthenticationstatusjob.h"
8#include "dkimauthenticationstatusinfo.h"
9#include "messageviewer_dkimcheckerdebug.h"
10#include <KMime/Message>
11using namespace MessageViewer;
12// see https://tools.ietf.org/html/rfc7601
13DKIMCheckAuthenticationStatusJob::DKIMCheckAuthenticationStatusJob(QObject *parent)
14 : QObject(parent)
15{
16}
17
18DKIMCheckAuthenticationStatusJob::~DKIMCheckAuthenticationStatusJob() = default;
19
20void DKIMCheckAuthenticationStatusJob::start()
21{
22 if (!canStart()) {
23 qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "Impossible to start job";
25 Q_EMIT result({});
26 return;
27 }
28
29 const QString strAuthenticationHeader = QStringLiteral("authentication-results");
30 QString str = mHeaderParser.headerType(strAuthenticationHeader);
31 DKIMAuthenticationStatusInfo info;
32 while (!str.isEmpty()) {
33 if (!info.parseAuthenticationStatus(str, mUseRelaxedParsing)) {
34 break;
35 }
36 str = mHeaderParser.headerType(strAuthenticationHeader);
37 }
38
39 // qDebug() << "result info: " << info;
40 Q_EMIT result(info);
42}
43
44bool DKIMCheckAuthenticationStatusJob::canStart() const
45{
46 return mHeaderParser.wasAlreadyParsed();
47}
48
49void DKIMCheckAuthenticationStatusJob::setHeaderParser(const DKIMHeaderParser &headerParser)
50{
51 mHeaderParser = headerParser;
52}
53
54bool DKIMCheckAuthenticationStatusJob::useRelaxedParsing() const
55{
56 return mUseRelaxedParsing;
57}
58
59void DKIMCheckAuthenticationStatusJob::setUseRelaxedParsing(bool useRelaxedParsing)
60{
61 mUseRelaxedParsing = useRelaxedParsing;
62}
63
64#include "moc_dkimcheckauthenticationstatusjob.cpp"
The DKIMHeaderParser class.
Q_EMITQ_EMIT
void deleteLater()
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.