Messagelib

dkimcheckauthenticationstatusjob.cpp
1 /*
2  SPDX-FileCopyrightText: 2018-2021 Laurent Montel <[email protected]>
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>
11 using namespace MessageViewer;
12 // see https://tools.ietf.org/html/rfc7601
13 DKIMCheckAuthenticationStatusJob::DKIMCheckAuthenticationStatusJob(QObject *parent)
14  : QObject(parent)
15 {
16 }
17 
18 DKIMCheckAuthenticationStatusJob::~DKIMCheckAuthenticationStatusJob() = default;
19 
20 void DKIMCheckAuthenticationStatusJob::start()
21 {
22  if (!canStart()) {
23  qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "Impossible to start job";
24  deleteLater();
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);
41  deleteLater();
42 }
43 
44 bool DKIMCheckAuthenticationStatusJob::canStart() const
45 {
46  return mHeaderParser.wasAlreadyParsed();
47 }
48 
49 void DKIMCheckAuthenticationStatusJob::setHeaderParser(const DKIMHeaderParser &headerParser)
50 {
51  mHeaderParser = headerParser;
52 }
53 
54 bool DKIMCheckAuthenticationStatusJob::useRelaxedParsing() const
55 {
56  return mUseRelaxedParsing;
57 }
58 
59 void DKIMCheckAuthenticationStatusJob::setUseRelaxedParsing(bool useRelaxedParsing)
60 {
61  mUseRelaxedParsing = useRelaxedParsing;
62 }
The DKIMHeaderParser class.
bool isEmpty() const const
void deleteLater()
void result(KJob *job)
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 23:04:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.