File indexing completed on 2025-01-19 04:46:51

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "dkimadvancedwidget.h"
0008 #include "dkimauthenticationverifiedserverdialog.h"
0009 #include <KLocalizedString>
0010 #include <MessageViewer/MessageViewerSettings>
0011 #include <QCheckBox>
0012 #include <QComboBox>
0013 #include <QFormLayout>
0014 #include <QPushButton>
0015 
0016 DKIMAdvancedWidget::DKIMAdvancedWidget(QWidget *parent)
0017     : QWidget(parent)
0018     , mSha1Policy(new QComboBox(this))
0019     , mCheckDKIMWhenOnlyTesting(new QCheckBox(i18n("Still verify the signature, if a domain is only testing DKIM"), this))
0020     , mUseAuthenticationResultRelaxedParser(new QCheckBox(i18n("Use relaxed parsing when reading \"Authentication-Result\" header"), this))
0021     , mSmallKeyPolicy(new QComboBox(this))
0022 {
0023     auto mainLayout = new QFormLayout(this);
0024     mainLayout->setObjectName(QLatin1StringView("mainLayout"));
0025 
0026     mCheckDKIMWhenOnlyTesting->setObjectName(QLatin1StringView("kcfg_VerifySignatureWhenOnlyTest"));
0027     mainLayout->addRow(mCheckDKIMWhenOnlyTesting);
0028 
0029     mUseAuthenticationResultRelaxedParser->setObjectName(QLatin1StringView("kcfg_UseRelaxedParsingAuthenticationResults"));
0030     mainLayout->addRow(mUseAuthenticationResultRelaxedParser);
0031 
0032     mSha1Policy->setObjectName(QLatin1StringView("kcfg_PolicyRsaSha1"));
0033     mSha1Policy->addItems({i18n("Nothing"), i18n("Warning"), i18n("Error")});
0034     mainLayout->addRow(i18n("Treat RSA-SHA1 sign algorithm as:"), mSha1Policy);
0035 
0036     mSmallKeyPolicy->setObjectName(QLatin1StringView("kcfg_PublicRsaTooSmall"));
0037     mSmallKeyPolicy->addItems({i18n("Nothing"), i18n("Warning"), i18n("Error")});
0038     mainLayout->addRow(i18n("Treat small Key as:"), mSmallKeyPolicy);
0039 
0040     auto configureServer = new QPushButton(i18n("Configure"), this);
0041     configureServer->setObjectName(QLatin1StringView("configure_button"));
0042     connect(configureServer, &QPushButton::clicked, this, &DKIMAdvancedWidget::slotConfigureAuthenticationServer);
0043     mainLayout->addRow(i18n("Authentication Server verified:"), configureServer);
0044 }
0045 
0046 DKIMAdvancedWidget::~DKIMAdvancedWidget() = default;
0047 
0048 void DKIMAdvancedWidget::slotConfigureAuthenticationServer()
0049 {
0050     DKIMAuthenticationVerifiedServerDialog dlg(this);
0051     dlg.exec();
0052 }
0053 
0054 #include "moc_dkimadvancedwidget.cpp"