Commit 1d6b96f4 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Port to helpers in DeVSCompliance namespace

GnuPG-bug-id: 6073
parent 732b973f
......@@ -34,7 +34,7 @@ set(KF5_MIN_VERSION "5.96.0")
set(KIDENTITYMANAGEMENT_VERSION "5.20.40")
set(KMAILTRANSPORT_VERSION "5.20.40")
set(KMIME_VERSION "5.20.40")
set(LIBKLEO_VERSION "5.20.47")
set(LIBKLEO_VERSION "5.21.41")
set(QT_REQUIRED_VERSION "5.15.2")
set(GPGME_REQUIRED_VERSION "1.16.0")
......
......@@ -17,6 +17,7 @@
#include <QGpgME/DecryptJob>
#include <QGpgME/DecryptVerifyJob>
#include <Libkleo/Compliance>
#include <Libkleo/Dn>
#include <Libkleo/KleoException>
#include <Libkleo/Stl_Util>
......@@ -270,14 +271,14 @@ static QString formatSigningInformation(const Signature &sig)
}
text += i18n("With certificate:") + QStringLiteral("<br>") + renderKey(key);
if (Kleo::gnupgIsDeVsCompliant()) {
if (DeVSCompliance::isCompliant()) {
text +=
(QStringLiteral("<br/>")
+ (sig.isDeVs()
? i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"The signature is %1", Formatting::deVsString())
"The signature is %1", DeVSCompliance::name(true))
: i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"The signature <b>is not</b> %1.", Formatting::deVsString())));
"The signature <b>is not</b> %1.", DeVSCompliance::name(true))));
}
return text;
......@@ -574,12 +575,12 @@ static QString formatDecryptionResultDetails(const DecryptionResult &res, const
QString details;
if (Kleo::gnupgIsDeVsCompliant()) {
if (DeVSCompliance::isCompliant()) {
details += ((res.isDeVs()
? i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"The decryption is %1.", Formatting::deVsString())
"The decryption is %1.", DeVSCompliance::name(true))
: i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"The decryption <b>is not</b> %1.", Formatting::deVsString()))
"The decryption <b>is not</b> %1.", DeVSCompliance::name(true)))
+ QStringLiteral("<br/>"));
}
......
......@@ -21,6 +21,7 @@
#include "utils/gui-helper.h"
#include "utils/kleo_assert.h"
#include <Libkleo/Compliance>
#include <Libkleo/Stl_Util>
#include <Libkleo/Formatting>
#include <Libkleo/SystemInfo>
......@@ -247,7 +248,7 @@ private:
void updateComplianceStatus()
{
if (!Kleo::gnupgIsDeVsCompliant()) {
if (!DeVSCompliance::isCompliant()) {
return;
}
if (q->selectedProtocol() == UnknownProtocol ||
......@@ -283,9 +284,9 @@ private:
}
ui.complianceLB.setText(de_vs
? i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"%1 communication possible.", Formatting::deVsString())
"%1 communication possible.", DeVSCompliance::name(true))
: i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"%1 communication not possible.", Formatting::deVsString()));
"%1 communication not possible.", DeVSCompliance::name(true)));
ui.complianceLB.setVisible(true);
}
......
......@@ -28,6 +28,7 @@
#include <KMessageWidget>
#include "kleopatra_debug.h"
#include <Libkleo/Compliance>
#include <Libkleo/GnuPG>
#include <Libkleo/Formatting>
#include <Libkleo/SystemInfo>
......@@ -193,9 +194,9 @@ public:
messageWidget->setToolTip(xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para>You cannot use <application>Kleopatra</application> for signing or encrypting files "
"because the <application>GnuPG</application> system used by <application>Kleopatra</application> is not %1.</para>",
Formatting::deVsString()));
DeVSCompliance::name(true)));
messageWidget->setCloseButtonVisible(false);
messageWidget->setVisible(Kleo::gnupgUsesDeVsCompliance() && !Kleo::gnupgIsDeVsCompliant());
messageWidget->setVisible(DeVSCompliance::isActive() && !DeVSCompliance::isCompliant());
vLay->addWidget(messageWidget);
setMinimumHeight(300);
......@@ -213,7 +214,7 @@ public:
bool isComplete() const override
{
if (Kleo::gnupgUsesDeVsCompliance() && !Kleo::gnupgIsDeVsCompliant()) {
if (DeVSCompliance::isActive() && !DeVSCompliance::isCompliant()) {
return false;
}
return mWidget->isComplete();
......@@ -255,12 +256,12 @@ public:
bool validatePage() override
{
if (Kleo::gnupgUsesDeVsCompliance() && !Kleo::gnupgIsDeVsCompliant()) {
if (DeVSCompliance::isActive() && !DeVSCompliance::isCompliant()) {
KMessageBox::sorry(topLevelWidget(),
xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para>Sorry! You cannot use <application>Kleopatra</application> for signing or encrypting files "
"because the <application>GnuPG</application> system used by <application>Kleopatra</application> is not %1.</para>",
Formatting::deVsString()));
DeVSCompliance::name(true)));
return false;
}
bool sign = !mWidget->signKey().isNull();
......@@ -444,8 +445,8 @@ private Q_SLOTS:
auto btn = mParent->button(QWizard::CommitButton);
if (!label.isEmpty()) {
mParent->setButtonText(QWizard::CommitButton, label);
if (Kleo::gnupgUsesDeVsCompliance()) {
const bool de_vs = Kleo::gnupgIsDeVsCompliant() && mWidget->isDeVsAndValid();
if (DeVSCompliance::isActive()) {
const bool de_vs = DeVSCompliance::isCompliant() && mWidget->isDeVsAndValid();
btn->setIcon(QIcon::fromTheme(de_vs
? QStringLiteral("security-high")
: QStringLiteral("security-medium")));
......@@ -456,9 +457,9 @@ private Q_SLOTS:
}
mParent->setLabelText(de_vs
? i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"%1 communication possible.", Formatting::deVsString())
"%1 communication possible.", DeVSCompliance::name(true))
: i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"%1 communication not possible.", Formatting::deVsString()));
"%1 communication not possible.", DeVSCompliance::name(true)));
}
} else {
mParent->setButtonText(QWizard::CommitButton, i18n("Next"));
......@@ -546,7 +547,7 @@ SignEncryptFilesWizard::SignEncryptFilesWizard(QWidget *parent, Qt::WindowFlags
{
readConfig();
const bool de_vs = Kleo::gnupgUsesDeVsCompliance();
const bool de_vs = DeVSCompliance::isActive();
#ifdef Q_OS_WIN
// Enforce modern style to avoid vista style ugliness.
setWizardStyle(QWizard::ModernStyle);
......
......@@ -26,6 +26,7 @@
#include <Libkleo/GnuPG>
#include "utils/kleo_assert.h"
#include <Libkleo/Compliance>
#include <Libkleo/Stl_Util>
#include <Libkleo/KleoException>
......@@ -393,12 +394,12 @@ void NewSignEncryptEMailController::startResolveCertificates(const std::vector<M
d->dialog->pickProtocol();
d->dialog->setConflict(conflict);
const bool compliant = !Kleo::gnupgUsesDeVsCompliance() ||
(Kleo::gnupgIsDeVsCompliant() && is_de_vs_compliant(d->sign,
d->encrypt,
senders,
recipients,
d->presetProtocol));
const bool compliant = !DeVSCompliance::isActive() ||
(DeVSCompliance::isCompliant() && is_de_vs_compliant(d->sign,
d->encrypt,
senders,
recipients,
d->presetProtocol));
if (quickMode && !conflict && compliant) {
QMetaObject::invokeMethod(this, "slotDialogAccepted", Qt::QueuedConnection);
......
......@@ -39,6 +39,7 @@
#include "utils/tags.h"
#include <Libkleo/Algorithm>
#include <Libkleo/Compliance>
#include <Libkleo/Formatting>
#include <Libkleo/Dn>
#include <Libkleo/KeyCache>
......@@ -591,7 +592,7 @@ void CertificateDetailsWidget::Private::setupCommonProperties()
}
// ui.fingerprintField->setVisible(true); // always visible
ui.smimeIssuerField->setVisible(isSMIME);
ui.complianceField->setVisible(Kleo::gnupgIsDeVsCompliant());
ui.complianceField->setVisible(DeVSCompliance::isCompliant());
ui.trustedIntroducerField->setVisible(isOpenPGP); // may be hidden again by setupPGPProperties()
ui.smimeRelatedAddresses->setVisible(isSMIME);
......@@ -620,7 +621,7 @@ void CertificateDetailsWidget::Private::setupCommonProperties()
Formatting::accessibleExpirationDate(key, i18nc("Expires", "never")));
ui.fingerprintField->setValue(Formatting::prettyID(key.primaryFingerprint()),
Formatting::accessibleHexID(key.primaryFingerprint()));
if (Kleo::gnupgIsDeVsCompliant()) {
if (DeVSCompliance::isCompliant()) {
ui.complianceField->setValue(Kleo::Formatting::complianceStringForKey(key));
}
}
......
......@@ -73,6 +73,7 @@
#include <QStatusBar>
#include <QLabel>
#include <Libkleo/Compliance>
#include <Libkleo/Formatting>
#include <Libkleo/GnuPG>
#include <Libkleo/KeyListModel>
......@@ -235,15 +236,15 @@ public:
void updateStatusBar()
{
if (Kleo::gnupgUsesDeVsCompliance()) {
if (DeVSCompliance::isActive()) {
auto statusBar = std::make_unique<QStatusBar>();
auto statusLbl = std::make_unique<QLabel>(Formatting::deVsString(Kleo::gnupgIsDeVsCompliant()));
auto statusLbl = std::make_unique<QLabel>(DeVSCompliance::name());
if (!SystemInfo::isHighContrastModeActive()) {
const auto color = KColorScheme(QPalette::Active, KColorScheme::View).foreground(
Kleo::gnupgIsDeVsCompliant() ? KColorScheme::NormalText: KColorScheme::NegativeText
DeVSCompliance::isCompliant() ? KColorScheme::NormalText: KColorScheme::NegativeText
).color();
const auto background = KColorScheme(QPalette::Active, KColorScheme::View).background(
Kleo::gnupgIsDeVsCompliant() ? KColorScheme::PositiveBackground : KColorScheme::NegativeBackground
DeVSCompliance::isCompliant() ? KColorScheme::PositiveBackground : KColorScheme::NegativeBackground
).color();
statusLbl->setStyleSheet(QStringLiteral("QLabel { color: %1; background-color: %2; }").
arg(color.name()).arg(background.name()));
......
......@@ -22,6 +22,7 @@
#include <settings.h>
#include <Libkleo/Compat>
#include <Libkleo/Compliance>
#include <Libkleo/GnuPG>
#include <KDateComboBox>
......@@ -828,7 +829,7 @@ void AdvancedSettingsDialog::fillKeySizeComboBoxen()
const KConfigGroup config(KSharedConfig::openConfig(), "CertificateCreationWizard");
QList<int> rsaKeySizes = config.readEntry(RSA_KEYSIZES_ENTRY, QList<int>() << 2048 << -3072 << 4096);
if (Kleo::gnupgUsesDeVsCompliance()) {
if (DeVSCompliance::isActive()) {
rsaKeySizes = config.readEntry(RSA_KEYSIZES_ENTRY, QList<int>() << -3072 << 4096);
}
const QList<int> dsaKeySizes = config.readEntry(DSA_KEYSIZES_ENTRY, QList<int>() << -2048);
......@@ -997,7 +998,7 @@ void AdvancedSettingsDialog::updateWidgetVisibility()
ui->ecdsaRB->setText(QStringLiteral("ECDSA/EdDSA"));
}
const bool deVsHack = Kleo::gnupgUsesDeVsCompliance();
const bool deVsHack = DeVSCompliance::isActive();
if (deVsHack) {
// GnuPG Provides no API to query which keys are compliant for
......
......@@ -14,6 +14,7 @@
#include "implementation_p.h"
#include <Libkleo/Compliance>
#include <Libkleo/Formatting>
#include <Libkleo/GnuPG>
......@@ -30,33 +31,33 @@ class DeVsComplianceCheck : public SelfTestImplementation
public:
explicit DeVsComplianceCheck()
: SelfTestImplementation(i18nc("@title %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"%1?", Formatting::deVsString()))
"%1?", DeVSCompliance::name(true)))
{
runTest();
}
void runTest()
{
m_skipped = !gnupgUsesDeVsCompliance();
m_skipped = !DeVSCompliance::isActive();
if (m_skipped) {
m_explanation =
xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para><application>GnuPG</application> is not configured for %1 communication.</para>", Formatting::deVsString());
"<para><application>GnuPG</application> is not configured for %1 communication.</para>", DeVSCompliance::name(true));
return;
}
m_passed = gnupgIsDeVsCompliant();
m_passed = DeVSCompliance::isCompliant();
if (m_passed) {
return;
}
m_error = Formatting::deVsString(m_passed);
m_error = DeVSCompliance::name(m_passed);
m_explanation =
xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para>The <application>GnuPG</application> system used by <application>Kleopatra</application> is not %1.</para>", Formatting::deVsString());
"<para>The <application>GnuPG</application> system used by <application>Kleopatra</application> is not %1.</para>", DeVSCompliance::name(true));
m_proposedFix =
xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para>Install a version of <application>GnuPG</application> that is %1.</para>", Formatting::deVsString());
"<para>Install a version of <application>GnuPG</application> that is %1.</para>", DeVSCompliance::name(true));
}
};
......
......@@ -14,6 +14,7 @@
#include <Libkleo/KleoException>
#include <Libkleo/Classify>
#include <Libkleo/Compliance>
#include <Libkleo/KeyCache>
#include <Libkleo/Formatting>
#include <Libkleo/SystemInfo>
......@@ -112,7 +113,7 @@ public:
mMessageWidget->setToolTip(xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para>You cannot use <application>Kleopatra</application> for signing or encryption "
"because the <application>GnuPG</application> system used by <application>Kleopatra</application> is not %1.</para>",
Formatting::deVsString()));
DeVSCompliance::name(true)));
mMessageWidget->setCloseButtonVisible(false);
mMessageWidget->setVisible(false);
vLay->addWidget(mMessageWidget);
......@@ -384,12 +385,12 @@ public:
void doEncryptSign()
{
if (Kleo::gnupgUsesDeVsCompliance() && !Kleo::gnupgIsDeVsCompliant()) {
if (DeVSCompliance::isActive() && !DeVSCompliance::isCompliant()) {
KMessageBox::sorry(q->topLevelWidget(),
xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para>Sorry! You cannot use <application>Kleopatra</application> for signing or encryption "
"because the <application>GnuPG</application> system used by <application>Kleopatra</application> is not %1.</para>",
Formatting::deVsString()));
DeVSCompliance::name(true)));
return;
}
......@@ -490,8 +491,8 @@ public:
mCryptBtn->setEnabled(false);
}
if (Kleo::gnupgUsesDeVsCompliance()) {
const bool de_vs = Kleo::gnupgIsDeVsCompliant() && mSigEncWidget->isDeVsAndValid();
if (DeVSCompliance::isActive()) {
const bool de_vs = DeVSCompliance::isCompliant() && mSigEncWidget->isDeVsAndValid();
mCryptBtn->setIcon(QIcon::fromTheme(de_vs
? QStringLiteral("security-high")
: QStringLiteral("security-medium")));
......@@ -502,14 +503,14 @@ public:
}
mAdditionalInfoLabel->setText(de_vs
? i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"%1 communication possible.", Formatting::deVsString())
"%1 communication possible.", DeVSCompliance::name(true))
: i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"%1 communication not possible.", Formatting::deVsString()));
"%1 communication not possible.", DeVSCompliance::name(true)));
mAdditionalInfoLabel->setVisible(true);
if (!Kleo::gnupgIsDeVsCompliant()) {
if (!DeVSCompliance::isCompliant()) {
mCryptBtn->setEnabled(false);
}
mMessageWidget->setVisible(!Kleo::gnupgIsDeVsCompliant());
mMessageWidget->setVisible(!DeVSCompliance::isCompliant());
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment