Changeset View
Changeset View
Standalone View
Standalone View
src/utils/formatting.cpp
Show First 20 Lines • Show All 312 Lines • ▼ Show 20 Line(s) | 312 | } else { | |||
---|---|---|---|---|---|
313 | unsigned int fullyTrusted = 0; | 313 | unsigned int fullyTrusted = 0; | ||
314 | for (const auto &uid: key.userIDs()) { | 314 | for (const auto &uid: key.userIDs()) { | ||
315 | if (uid.validity() >= UserID::Validity::Full) { | 315 | if (uid.validity() >= UserID::Validity::Full) { | ||
316 | fullyTrusted++; | 316 | fullyTrusted++; | ||
317 | } | 317 | } | ||
318 | } | 318 | } | ||
319 | if (fullyTrusted == key.numUserIDs()) { | 319 | if (fullyTrusted == key.numUserIDs()) { | ||
320 | result = i18n("All identities are certified."); | 320 | result = i18n("All identities are certified."); | ||
321 | } else { | ||||
322 | result = i18np("One identity is not certified.", "%1 identities are not certified.", key.numUserIDs() - fullyTrusted); | ||||
323 | } | ||||
321 | const auto compliance = complianceStringForKey(key); | 324 | const auto compliance = complianceStringForKey(key); | ||
322 | if (!compliance.isEmpty()) { | 325 | if (!compliance.isEmpty()) { | ||
323 | result += QStringLiteral("<br>") + compliance; | 326 | result += QStringLiteral("<br>") + compliance; | ||
324 | } | 327 | } | ||
325 | } else { | | |||
326 | result = i18np("One identity is not certified.", "%1 identities are not certified.", key.numUserIDs() - fullyTrusted); | | |||
327 | } | | |||
328 | } | 328 | } | ||
329 | else { | 329 | else { | ||
330 | result = i18n("The validity cannot be checked at the moment."); | 330 | result = i18n("The validity cannot be checked at the moment."); | ||
331 | } | 331 | } | ||
332 | } | 332 | } | ||
333 | if (flags == Validity) { | 333 | if (flags == Validity) { | ||
334 | return result; | 334 | return result; | ||
335 | } | 335 | } | ||
▲ Show 20 Lines • Show All 493 Lines • ▼ Show 20 Line(s) | 824 | { | |||
829 | const QGpgME::CryptoConfigEntry *const entry = config->entry(QStringLiteral("gpg"), QStringLiteral("Configuration"), QStringLiteral("compliance")); | 829 | const QGpgME::CryptoConfigEntry *const entry = config->entry(QStringLiteral("gpg"), QStringLiteral("Configuration"), QStringLiteral("compliance")); | ||
830 | 830 | | |||
831 | if (!entry || entry->stringValue() == QStringLiteral("gnupg")) { | 831 | if (!entry || entry->stringValue() == QStringLiteral("gnupg")) { | ||
832 | return QString(); | 832 | return QString(); | ||
833 | } | 833 | } | ||
834 | return entry->stringValue(); | 834 | return entry->stringValue(); | ||
835 | } | 835 | } | ||
836 | 836 | | |||
837 | QString Formatting::complianceStringForKey(const GpgME::Key &key) | 837 | bool Formatting::isKeyDeVs(const GpgME::Key &key) | ||
838 | { | 838 | { | ||
839 | #ifdef GPGME_HAS_KEY_IS_DEVS | 839 | #ifdef GPGME_HAS_KEY_IS_DEVS | ||
840 | // There will likely be more in the future for other institutions | | |||
841 | // for now we only have DE-VS | | |||
842 | if (complianceMode() == QStringLiteral("de-vs")) { | | |||
843 | bool compliant = false; | | |||
844 | for (const auto &sub: key.subkeys()) { | 840 | for (const auto &sub: key.subkeys()) { | ||
845 | if (sub.isExpired() || sub.isRevoked()) { | 841 | if (sub.isExpired() || sub.isRevoked()) { | ||
846 | // Ignore old subkeys | 842 | // Ignore old subkeys | ||
847 | continue; | 843 | continue; | ||
848 | } | 844 | } | ||
849 | if (!sub.isDeVs()) { | 845 | if (!sub.isDeVs()) | ||
850 | compliant = false; | 846 | return false; | ||
851 | break; | | |||
852 | } | 847 | } | ||
853 | compliant = true; | 848 | return true; | ||
849 | #else | ||||
850 | return false; | ||||
851 | #endif | ||||
854 | } | 852 | } | ||
855 | if (compliant) { | 853 | | ||
854 | QString Formatting::complianceStringForKey(const GpgME::Key &key) | ||||
855 | { | ||||
856 | // There will likely be more in the future for other institutions | ||||
857 | // for now we only have DE-VS | ||||
858 | if (complianceMode() == QStringLiteral("de-vs")) { | ||||
859 | if (isKeyDeVs(key)) { | ||||
856 | return i18nc("VS-conforming is a German standard for restricted documents. For which special restrictions about algorithms apply. The string describes if a key is compliant with that..", | 860 | return i18nc("VS-conforming is a German standard for restricted documents. For which special restrictions about algorithms apply. The string describes if a key is compliant with that..", | ||
857 | "May be used for VS-compliant communication."); | 861 | "May be used for VS-compliant communication."); | ||
858 | } else { | 862 | } else { | ||
859 | return i18nc("VS-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..", | 863 | return i18nc("VS-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..", | ||
860 | "May <b>not</b> be used for VS-compliant communication."); | 864 | "May <b>not</b> be used for VS-compliant communication."); | ||
861 | } | 865 | } | ||
862 | } | 866 | } | ||
863 | #else | | |||
864 | Q_UNUSED(key); | | |||
865 | #endif | | |||
866 | return QString(); | 867 | return QString(); | ||
867 | } | 868 | } |