File indexing completed on 2025-03-09 04:54:28
0001 /* 0002 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "dkimcheckauthenticationstatusjob.h" 0008 #include "dkimauthenticationstatusinfo.h" 0009 #include "messageviewer_dkimcheckerdebug.h" 0010 #include <KMime/Message> 0011 using namespace MessageViewer; 0012 // see https://tools.ietf.org/html/rfc7601 0013 DKIMCheckAuthenticationStatusJob::DKIMCheckAuthenticationStatusJob(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 DKIMCheckAuthenticationStatusJob::~DKIMCheckAuthenticationStatusJob() = default; 0019 0020 void DKIMCheckAuthenticationStatusJob::start() 0021 { 0022 if (!canStart()) { 0023 qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "Impossible to start job"; 0024 deleteLater(); 0025 Q_EMIT result({}); 0026 return; 0027 } 0028 0029 const QString strAuthenticationHeader = QStringLiteral("authentication-results"); 0030 QString str = mHeaderParser.headerType(strAuthenticationHeader); 0031 DKIMAuthenticationStatusInfo info; 0032 while (!str.isEmpty()) { 0033 if (!info.parseAuthenticationStatus(str, mUseRelaxedParsing)) { 0034 break; 0035 } 0036 str = mHeaderParser.headerType(strAuthenticationHeader); 0037 } 0038 0039 // qDebug() << "result info: " << info; 0040 Q_EMIT result(info); 0041 deleteLater(); 0042 } 0043 0044 bool DKIMCheckAuthenticationStatusJob::canStart() const 0045 { 0046 return mHeaderParser.wasAlreadyParsed(); 0047 } 0048 0049 void DKIMCheckAuthenticationStatusJob::setHeaderParser(const DKIMHeaderParser &headerParser) 0050 { 0051 mHeaderParser = headerParser; 0052 } 0053 0054 bool DKIMCheckAuthenticationStatusJob::useRelaxedParsing() const 0055 { 0056 return mUseRelaxedParsing; 0057 } 0058 0059 void DKIMCheckAuthenticationStatusJob::setUseRelaxedParsing(bool useRelaxedParsing) 0060 { 0061 mUseRelaxedParsing = useRelaxedParsing; 0062 } 0063 0064 #include "moc_dkimcheckauthenticationstatusjob.cpp"