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

Replace Formatting::deVsString with DeVSCompliance::name

GnuPG-bug-id: 6073
parent c0179b08
......@@ -856,11 +856,11 @@ public:
if (de_vs) {
mComplianceLbl->setText(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()));
DeVSCompliance::name(true)));
} else {
mComplianceLbl->setText(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()));
DeVSCompliance::name(true)));
}
mComplianceLbl->setVisible(true);
}
......
......@@ -16,7 +16,10 @@
#include "gnupg.h"
#include "systeminfo.h"
#include <libkleo/keyfiltermanager.h>
#include <KColorScheme>
#include <KLocalizedString>
#include <QPushButton>
......@@ -66,3 +69,17 @@ void Kleo::DeVSCompliance::decorate(QPushButton *button, bool compliant)
}
}
}
QString Kleo::DeVSCompliance::name()
{
return name(isCompliant());
}
QString Kleo::DeVSCompliance::name(bool compliant)
{
const auto filterId = compliant ? QStringLiteral("de-vs-filter") : QStringLiteral("not-de-vs-filter");
if (auto filter = KeyFilterManager::instance()->keyFilterByID(filterId)) {
return filter->name();
}
return compliant ? i18n("VS-NfD compliant") : i18n("Not VS-NfD compliant");
}
......@@ -13,6 +13,7 @@
#include "kleo_export.h"
class QPushButton;
class QString;
namespace Kleo::DeVSCompliance
{
......@@ -46,4 +47,22 @@ KLEO_EXPORT void decorate(QPushButton *button);
*/
KLEO_EXPORT void decorate(QPushButton *button, bool compliant);
/**
* \overload
*
* Returns a localized name for the compliance or non-compliance depending on
* the state of compliance.
*/
KLEO_EXPORT QString name();
/**
* Returns a localized name for the compliance or non-compliance depending on
* the value of \p compliant.
*
* \note The localized name is taken from the de-vs-filter filter resp. the
* not-de-vs-filter. This allows the customization of the name for different
* users because VS-NfD compliance is called differently in different
* environments, e.g. NATO RESTRICTED or EU RESTRICTED.
*/
KLEO_EXPORT QString name(bool compliant);
}
......@@ -19,7 +19,6 @@
#include <libkleo/dn.h>
#include <libkleo/keycache.h>
#include <libkleo/keyfiltermanager.h>
#include <libkleo/keygroup.h>
#include <KEmailAddress>
......@@ -1159,13 +1158,13 @@ QString Formatting::complianceStringForKey(const GpgME::Key &key)
if (uidsHaveFullValidity(key) && isKeyDeVs(key)) {
return i18nc("%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"May be used for %1 communication.",
deVsString());
DeVSCompliance::name(true));
} else {
return i18nc(
"VS-NfD-conforming is a German standard for restricted documents. For which special restrictions about algorithms apply. The string describes "
"if a key is compliant to that..",
"May <b>not</b> be used for %1 communication.",
deVsString());
DeVSCompliance::name(true));
}
}
return QString();
......@@ -1176,7 +1175,7 @@ QString Formatting::complianceStringShort(const GpgME::Key &key)
const bool keyValidityChecked = (key.keyListMode() & GpgME::Validate);
if (keyValidityChecked && Formatting::uidsHaveFullValidity(key)) {
if (DeVSCompliance::isCompliant() && Formatting::isKeyDeVs(key)) {
return QStringLiteral("★ ") + deVsString(true);
return QStringLiteral("★ ") + DeVSCompliance::name(true);
}
return i18nc("As in all user IDs are valid.", "certified");
}
......@@ -1261,11 +1260,7 @@ QString Formatting::origin(int o)
QString Formatting::deVsString(bool compliant)
{
const auto filter = KeyFilterManager::instance()->keyFilterByID(compliant ? QStringLiteral("de-vs-filter") : QStringLiteral("not-de-vs-filter"));
if (!filter) {
return compliant ? i18n("VS-NfD compliant") : i18n("Not VS-NfD compliant");
}
return filter->name();
return DeVSCompliance::name(compliant);
}
namespace
......
......@@ -154,14 +154,11 @@ KLEO_DEPRECATED_EXPORT QString complianceMode();
/* Is the given key in compliance with CO_DE_VS? */
KLEO_EXPORT bool isKeyDeVs(const GpgME::Key &key);
/* Localized string describing the name of the VS-NfD Compliance filter. If
* compliant is false the name of the not Compliant filter.
*
* This is required to make the string configurable which is
* a common request from users because VS-NfD compliance is called
* differently in different environments. E.g NATO RESTRICTED or
* EU RESTRICTED. */
KLEO_EXPORT QString deVsString(bool compliant = true);
/**
* Use Kleo::DeVSCompliance::name(bool) instead.
*/
KLEO_DEPRECATED_EXPORT QString deVsString(bool compliant = true);
/* A sentence if the key confirms to the current compliance mode */
KLEO_EXPORT QString complianceStringForKey(const GpgME::Key &key);
......
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