diff --git a/CMakeLists.txt b/CMakeLists.txt index 2302c4772..968b19d8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,101 +1,101 @@ cmake_minimum_required(VERSION 3.5) -set(PIM_VERSION "5.15.40") +set(PIM_VERSION "5.15.41") project(libkleo VERSION ${PIM_VERSION}) set(KF5_MIN_VERSION "5.72.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(LIBRARY_NAMELINK) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(FeatureSummary) include(ECMQtDeclareLoggingCategory) include(ECMAddTests) set(LIBKLEO_LIB_VERSION ${PIM_VERSION}) set(QT_REQUIRED_VERSION "5.13.0") set(KDEPIMTEXTEDIT_VERSION "5.15.40") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets) find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Completion ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ItemModels ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5PimTextEdit ${KDEPIMTEXTEDIT_VERSION} CONFIG) set(GPGMEPP_LIB_VERSION "1.11.1") find_package(Gpgmepp ${GPGMEPP_LIB_VERSION} CONFIG REQUIRED) set_package_properties(Gpgmepp PROPERTIES DESCRIPTION "GpgME++ Library" URL "https://www.gnupg.org" TYPE REQUIRED PURPOSE "GpgME++ is required for OpenPGP support") find_package(QGpgme ${GPGMEPP_LIB_VERSION} CONFIG REQUIRED) message(STATUS "GPGME Version ${Gpgmepp_VERSION}") find_package(Boost 1.34.0) set_package_properties(Boost PROPERTIES DESCRIPTION "Boost C++ Libraries" URL "https://www.boost.org" TYPE REQUIRED PURPOSE "Boost is required for building most KDEPIM applications") set_package_properties(KF5PimTextEdit PROPERTIES DESCRIPTION "A textedit with PIM-specific features." URL "https://commits.kde.org/kpimtextedit" TYPE OPTIONAL PURPOSE "Improved audit log viewer.") ecm_setup_version(PROJECT VARIABLE_PREFIX LIBKLEO VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/libkleo_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5LibkleoConfigVersion.cmake" SOVERSION 5 ) ########### Targets ########### add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0) #add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054900) remove_definitions(-DQT_NO_CAST_FROM_ASCII ) add_definitions(-DQT_NO_EMIT) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) ########### CMake Config Files ########### set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Libkleo") configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5LibkleoConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5LibkleoConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5LibkleoConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5LibkleoConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5LibkleoTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5LibkleoTargets.cmake NAMESPACE KF5::) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libkleo_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) add_subdirectory(src) ecm_qt_install_logging_categories( EXPORT LIBKLEO FILE libkleo.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/libkleopatrarc-win32.desktop b/src/libkleopatrarc-win32.desktop index 5edd36ce5..2e82a50f7 100644 --- a/src/libkleopatrarc-win32.desktop +++ b/src/libkleopatrarc-win32.desktop @@ -1,632 +1,634 @@ [Archive Definition #0] extensions-openpgp=tar extensions-cms=tar.gz,tgz id=tar Name=TAR (PGP®-compatible) Name[ar]=‏TAR (متوافق مع PGP®) Name[ca]=TAR (compatible amb PGP®) Name[ca@valencia]=TAR (compatible amb PGP®) Name[cs]=TAR (PGP® kompatibilní) Name[da]=TAR (PGP®-kompatibel) Name[de]=TAR (PGP®-kompatibel) Name[en_GB]=TAR (PGP®-compatible) Name[es]=TAR (compatible PGP®) Name[et]=TAR (PGP® ühilduv) Name[fi]=TAR (PGP-yhteensopiva) Name[fr]=TAR (compatible PGP®) Name[gl]=TAR (compatíbel con PGP®) Name[ia]=TAR (compatibile con PGP®) Name[it]=TAR (compatibile PGP®) Name[ja]=TAR (PGP® 互換) Name[ko]=TAR(PGP® 호환) Name[nb]=TAR (PGP®-kompatibel) Name[nl]=TAR (PGP®-compatible) Name[nn]=TAR (PGP®-kompatibel) Name[pl]=TAR (zgodny z PGP®) Name[pt]=TAR (compatível com o PGP®) Name[pt_BR]=TAR (compatível com PGP®) Name[ru]=TAR (PGP®-совместимый) Name[sk]=TAR (PGP® kompatibilné) Name[sl]=TAR (združljiv s PGP®) Name[sr]=тар (ПГП®-сагласно) Name[sr@ijekavian]=тар (ПГП®-сагласно) Name[sr@ijekavianlatin]=tar (PGP®-saglasno) Name[sr@latin]=tar (PGP®-saglasno) Name[sv]=TAR (fungerar med PGP®) Name[tr]=TAR (PGP®-uyumlu) Name[uk]=TAR (сумісні з PGP®) Name[x-test]=xxTAR (PGP®-compatible)xx Name[zh_CN]=TAR(PGP® 兼容) Name[zh_TW]=TAR (相容 PGP®) pack-command-openpgp=0|%I/gpgtar --openpgp --skip-crypto --output - --encrypt -T- --null -- pack-command-cms=0|%I/gpgtar --cms --skip-crypto --output - --encrypt -T- --null -- unpack-command-openpgp=%I/gpgtar --openpgp --skip-crypto --set-filename %f --decrypt -- - unpack-command-cms=%I/gpgtar --cms --skip-crypto --set-filename %f --decrypt -- - [Checksum Definition #0] file-patterns=sha256sum.txt,.*\\\\.sha256,.*\\\\.sha2 output-file=sha256sum.txt id=sha256sum Name=sha256sum Name[ar]=تدقيق SHA256 Name[ca]=sha256sum Name[ca@valencia]=sha256sum Name[cs]=sha256sum Name[da]=sha256sum Name[de]=sha256sum Name[en_GB]=sha256sum Name[es]=sha256sum Name[et]=sha256sum Name[fi]=sha256sum Name[fr]=sha256sum Name[gl]=sha256sum Name[ia]=sha256sum Name[it]=sha256sum Name[ja]=sha256sum Name[ko]=sha256sum Name[nb]=sha256sum Name[nl]=sha256sum Name[pl]=sha256sum Name[pt]=sha256sum Name[pt_BR]=sha256sum Name[ru]=sha256sum Name[sk]=sha256sum Name[sl]=sha256sum Name[sr]=СХА‑256 сума Name[sr@ijekavian]=СХА‑256 сума Name[sr@ijekavianlatin]=SHA‑256 suma Name[sr@latin]=SHA‑256 suma Name[sv]=SHA256-summa Name[tr]=sha256sum Name[uk]=sha256sum Name[x-test]=xxsha256sumxx Name[zh_CN]=sha256sum Name[zh_TW]=sha256sum create-command=0|%I/sha256sum -0 - verify-command=%I/sha256sum -c [Checksum Definition #1] file-patterns=sha1sum.txt,.*\\\\.sha1 output-file=sha1sum.txt id=sha1sum Name=sha1sum Name[ar]=تدقيق SHA1 Name[ca]=sha1sum Name[ca@valencia]=sha1sum Name[cs]=sha1sum Name[da]=sha1sum Name[de]=sha1sum Name[en_GB]=sha1sum Name[es]=sha1sum Name[et]=sha1sum Name[fi]=sha1sum Name[fr]=sha1sum Name[gl]=sha1sum Name[ia]=sha1sum Name[it]=sha1sum Name[ja]=sha1sum Name[ko]=sha1sum Name[nb]=sha1sum Name[nl]=sha1sum Name[nn]=sha1sum Name[pl]=sha1sum Name[pt]=sha1sum Name[pt_BR]=sha1sum Name[ru]=sha1sum Name[sk]=sha1sum Name[sl]=sha1sum Name[sr]=СХА‑1 сума Name[sr@ijekavian]=СХА‑1 сума Name[sr@ijekavianlatin]=SHA‑1 suma Name[sr@latin]=SHA‑1 suma Name[sv]=SHA1-summa Name[tr]=sha1sum Name[uk]=sha1sum Name[x-test]=xxsha1sumxx Name[zh_CN]=sha1sum Name[zh_TW]=sha1sum create-command=0|%I/sha1sum -0 - verify-command=%I/sha1sum -c [Checksum Definition #2] file-patterns=md5sum.txt,.*\\\\.md5 output-file=md5sum.txt id=md5sum Name=md5sum Name[ar]=تدقيق MD5 Name[ca]=md5sum Name[ca@valencia]=md5sum Name[cs]=md5sum Name[da]=md5sum Name[de]=md5sum Name[en_GB]=md5sum Name[es]=md5sum Name[et]=md5sum Name[fi]=md5sum Name[fr]=md5sum Name[gl]=md5sum Name[ia]=md5sum Name[it]=md5sum Name[ja]=md5sum Name[ko]=md5sum Name[nb]=md5sum Name[nl]=md5sum Name[nn]=md5sum Name[pl]=md5sum Name[pt]=md5sum Name[pt_BR]=md5sum Name[ru]=md5sum Name[sk]=md5sum Name[sl]=md5sum Name[sr]=МД5 сума Name[sr@ijekavian]=МД5 сума Name[sr@ijekavianlatin]=MD5 suma Name[sr@latin]=MD5 suma Name[sv]=MD5-summa Name[tr]=md5sum Name[uk]=md5sum Name[x-test]=xxmd5sumxx Name[zh_CN]=md5sum Name[zh_TW]=md5sum create-command=0|%I/md5sum -0 - verify-command=%I/md5sum -c [Key Filter #0] was-validated=false Name=Not Validated Key Name[ar]=ليس مفتاحًا متحقّقًا منه Name[ca]=Clau no validada Name[ca@valencia]=Clau no validada Name[cs]=Neověřený klíč Name[da]=Ikke godkendt nøgle Name[de]=Ungeprüfter Schlüssel Name[en_GB]=Not Validated Key Name[es]=Clave no validada Name[et]=Võtme ehtsus kontrollimatu Name[fi]=Varmistamaton avain Name[fr]=Clé non validée Name[gl]=Non hai chave validada Name[ia]=Clave non validate Name[it]=Chiave non convalidata Name[ja]=検証されていない鍵 Name[ko]=검증되지 않은 키 Name[nb]=Nøkkel ikke sjekket for gyldighet Name[nl]=Geen gevalideerde sleutel Name[nn]=Ikkje-validert nøkkel Name[pl]=Niesprawdzony klucz Name[pt]=Chave Não Validada Name[pt_BR]=Chave não validada Name[ru]=Непроверенный ключ Name[sk]=Neoverený kľúč Name[sl]=Nepreverjen ključ Name[sr]=Неоверени кључ Name[sr@ijekavian]=Неовјерени кључ Name[sr@ijekavianlatin]=Neovjereni ključ Name[sr@latin]=Neovereni ključ Name[sv]=Nyckeln har inte validerats Name[tr]=Geçerli Olmayan Anahtar Name[uk]=Неперевірений ключ Name[x-test]=xxNot Validated Keyxx Name[zh_CN]=未校验的密钥 Name[zh_TW]=無已驗證的金鑰 [Key Filter #1] was-validated=true is-expired=true is-revoked=false foreground-color=255,0,0 Name=Expired Key Name[ar]=مفتاح منقضي Name[ca]=Clau expirada Name[ca@valencia]=Clau expirada Name[cs]=Klíč s prošlou platností Name[da]=Udløbet nøgle Name[de]=Abgelaufener Schlüssel Name[en_GB]=Expired Key Name[es]=Clave expirada Name[et]=Aegunud võti Name[fi]=Vanhentunut avain Name[fr]=Clé expirée Name[gl]=Chave caducada Name[ia]=Clave expirate Name[it]=Chiave scaduta Name[ja]=期限切れの鍵 Name[ko]=만료된 키 Name[nb]=Utgått nøkkel Name[nl]=Verlopen sleutel Name[nn]=Forelda nøkkel Name[pl]=Klucz, który utracił ważność Name[pt]=Chave Expirada Name[pt_BR]=Chave expirada Name[ru]=Устаревший ключ Name[sk]=Vypršaný kľúč Name[sl]=Pretečen ključ Name[sr]=Истекли кључ Name[sr@ijekavian]=Истекли кључ Name[sr@ijekavianlatin]=Istekli ključ Name[sr@latin]=Istekli ključ Name[sv]=Utgången nyckel Name[tr]=Süresi Dolmuş Anahtar Name[uk]=Застарілий ключ Name[x-test]=xxExpired Keyxx Name[zh_CN]=过期密钥 Name[zh_TW]=過期的金鑰 [Key Filter #2] was-validated=true is-revoked=true Name=Revoked Key Name[ar]=مفتاح مسحوب Name[ca]=Clau revocada Name[ca@valencia]=Clau revocada Name[cs]=Odvolaný klíč Name[da]=Fjernet nøgle Name[de]=Widerrufener Schlüssel Name[en_GB]=Revoked Key Name[es]=Clave revocada Name[et]=Tühistatud võti Name[fi]=Peruttu avain Name[fr]=Clé révoquée Name[gl]=Chave revogada Name[ia]=Clave revocate Name[it]=Chiave revocata Name[ja]=破棄された鍵 Name[ko]=취소된 키 Name[nb]=Tilbakekalt nøkkel Name[nl]=Ingetrokken sleutel Name[nn]=Tilbakekalla nøkkel Name[pl]=Odwołany klucz Name[pt]=Chave Revogada Name[pt_BR]=Chave revogada Name[ru]=Отозванный ключ Name[sk]=Kľúč so zrušenou platnosťou Name[sl]=Preklican ključ Name[sr]=Опозвани кључ Name[sr@ijekavian]=Опозвани кључ Name[sr@ijekavianlatin]=Opozvani ključ Name[sr@latin]=Opozvani ključ Name[sv]=Återkallad nyckel Name[tr]=İptal Edilmiş Anahtar Name[uk]=Анульований ключ Name[x-test]=xxRevoked Keyxx Name[zh_CN]=吊销的密钥 Name[zh_TW]=已撤回的金鑰 [Key Filter #3] was-validated=true is-root-certificate=true is-validity=ultimate Name=Trusted Root Certificate Name[ar]=شهادة جذر موثوقة Name[ca]=Certificat arrel de confiança Name[ca@valencia]=Certificat arrel de confiança Name[cs]=Důvěryhodný kořenový certifikát Name[da]=Root-certifikat der stoles på Name[de]=Vertrauenswürdiges Wurzelzertifikat Name[en_GB]=Trusted Root Certificate Name[es]=Certificado raíz confiable Name[et]=Usaldusväärne juursertifikaat Name[fi]=Luotettu juurivarmenne Name[fr]=Certificat racine de confiance Name[gl]=Certificado raíz autenticado Name[ia]=Certificato de radice con fide Name[it]=Certificato radice affidabile Name[ja]=信頼されたルート証明書 Name[ko]=신뢰하는 루트 인증 기관 Name[nb]=Tiltrodd rot-sertifikat Name[nl]=Vertrouwd hoofdcertificaat Name[nn]=Tiltrudd rotsertifikat Name[pl]=Zaufany główny certyfikat Name[pt]=Certificado de Raiz Fidedigno Name[pt_BR]=Certificado raiz confiável Name[ru]=Доверенный корневой сертификат Name[sk]=Dôveryhodný koreňový certifikát Name[sl]=Zaupanja vredno korensko potrdilo Name[sr]=Поуздани корени сертификат Name[sr@ijekavian]=Поуздани корјени сертификат Name[sr@ijekavianlatin]=Pouzdani korjeni sertifikat Name[sr@latin]=Pouzdani koreni sertifikat Name[sv]=Pålitligt rotcertifikat Name[tr]=Güvenilir Kök Sertifikası Name[uk]=Кореневий сертифікат з довірою Name[x-test]=xxTrusted Root Certificatexx Name[zh_CN]=可信任的根证书 Name[zh_TW]=信任的根憑證 background-color=95,135,255 font-bold=true [Key Filter #4] was-validated=true is-root-certificate=true is-not-validity=ultimate Name=Not Trusted Root Certificate Name[ar]=شهادة جذر غير موثوقة Name[ca]=Certificat arrel sense confiança Name[ca@valencia]=Certificat arrel sense confiança Name[cs]=Nedůvěryhodný kořenový certifikát Name[da]=Root-certifikat der ikke stoles på Name[de]=Nicht vertrauenswürdiges Wurzelzertifikat Name[en_GB]=Not Trusted Root Certificate Name[es]=Certificado raíz no confiable Name[et]=Ebausaldusväärne juursertifikaat Name[fi]=Ei-luotettu juurivarmenne Name[fr]=Certificat racine non fiable Name[gl]=Certificado raíz non autenticado Name[ia]=Certificato de radice sin fide Name[it]=Certificato radice non affidabile Name[ja]=信頼されてないルート証明書 Name[ko]=신뢰하지 않는 루트 인증 기관 Name[nb]=Ikke tiltrodd rot-sertifikat Name[nl]=Niet vertrouwd hoofdcertificaat Name[nn]=Ikkje tiltrudd rotsertifikat Name[pl]=Niezaufany główny certyfikat Name[pt]=Certificado de Raiz Não Fidedigno Name[pt_BR]=Certificado raiz não confiável Name[ru]=Недоверенный корневой сертификат Name[sk]=Nedôveryhodný koreňový certifikát Name[sl]=Korensko potrdilo, ki ni zaupanja vredno Name[sr]=Непоуздани корени сертификат Name[sr@ijekavian]=Непоуздани корјени сертификат Name[sr@ijekavianlatin]=Nepouzdani korjeni sertifikat Name[sr@latin]=Nepouzdani koreni sertifikat Name[sv]=Opålitligt rotcertifikat Name[tr]=Güvenilmeyen Kök Sertifikası Name[uk]=Кореневий сертифікат без довіри Name[x-test]=xxNot Trusted Root Certificatexx Name[zh_CN]=未信任的根证书 Name[zh_TW]=不被信任的根憑證 [Key Filter #5] was-validated=true is-qualified=true font-bold=true Name=Keys for Qualified Signatures Name[ar]=مفاتيح لشهادات مؤهّلة Name[ca]=Claus per a les signatures qualificades Name[ca@valencia]=Claus per a les signatures qualificades Name[cs]=Klíče kvalifikovaných podpisů Name[da]=Nøgler til kvalificerede signaturer Name[de]=Schlüssel für qualifizierte Signaturen Name[en_GB]=Keys for Qualified Signatures Name[es]=Claves para firmas cualificadas Name[et]=Kvalifitseeritud allkirjade võtmed Name[fi]=Hyväksyttyjen allekirjoitusten avaimet Name[fr]=Clés pour les signatures qualifiées Name[gl]=Chaves para sinaturas cualificadas Name[ia]=Claves pro signaturas qualificate Name[it]=Chiavi per le firme qualificate Name[ja]=適格電子署名用の鍵 Name[ko]=신뢰하는 서명에 사용할 키 Name[nb]=Nøkler for kvalifiserte signaturer Name[nl]=Sleutels voor gekwalificeerde ondertekeningen Name[nn]=Nøklar for kvalifiserte signaturar Name[pl]=Klucze do podpisów kwalifikowanych Name[pt]=Chaves para as Assinaturas Qualificadas Name[pt_BR]=Chaves para assinaturas qualificadas Name[ru]=Ключи для подписывания Name[sk]=Kľúče pre kvalifikované podpisy Name[sl]=Ključi za kvalificirane podpise Name[sr]=Кључеви за важеће потписе Name[sr@ijekavian]=Кључеви за важеће потписе Name[sr@ijekavianlatin]=Ključevi za važeće potpise Name[sr@latin]=Ključevi za važeće potpise Name[sv]=Nycklar för kvalificerade signaturer Name[tr]=Yetkilendirilmiş İmzalar için Anahtarlar Name[uk]=Ключі підписів обмеженого використання Name[x-test]=xxKeys for Qualified Signaturesxx Name[zh_CN]=合格签名的密钥 Name[zh_TW]=合格簽證的金鑰 [Key Filter #6] was-validated=true Name=Other Keys Name[ar]=مفاتيح أخرى Name[ca]=Altres claus Name[ca@valencia]=Altres claus Name[cs]=Ostatní klíče Name[da]=Andre nøgler Name[de]=Andere Schlüssel Name[en_GB]=Other Keys Name[es]=Otras claves Name[et]=Muud võtmed Name[fi]=Muut avaimet Name[fr]=Autres clés Name[gl]=Outras chaves Name[ia]=Altere claves Name[it]=Altre chiavi Name[ja]=その他の鍵 Name[ko]=다른 키 Name[nb]=Andre nøkler Name[nl]=Andere sleutels Name[nn]=Andre nøklar Name[pl]=Inne klucze Name[pt]=Outras 'Cache' Name[pt_BR]=Outras chaves Name[ru]=Другие ключи Name[sk]=Ostatné kľuče Name[sl]=Drugi ključi Name[sr]=Остали кључеви Name[sr@ijekavian]=Остали кључеви Name[sr@ijekavianlatin]=Ostali ključevi Name[sr@latin]=Ostali ključevi Name[sv]=Andra nycklar Name[tr]=Diğer Anahtarlar Name[uk]=Інші ключі Name[x-test]=xxOther Keysxx Name[zh_CN]=其它密钥 Name[zh_TW]=其他金鑰 [Key Filter #7] is-cardkey=true Name=Smartcard Key Name[ar]=مفتاح بطاقة ذكيّة Name[ca]=Clau de targeta intel·ligent Name[ca@valencia]=Clau de targeta intel·ligent Name[cs]=Klíč SmartCard Name[da]=Smartcard-nøgle Name[de]=Smartcard-Zertifikat Name[en_GB]=Smartcard Key Name[es]=Clave de tarjeta inteligente Name[et]=Kiipkaardi võti Name[fi]=Smartcard-avain Name[fr]=Clé SmartCard Name[gl]=Chave de smartcard Name[ia]=Clave de carta intelligente Name[it]=Chiave smartcard Name[ja]=スマートカードの鍵 Name[ko]=스마트카드 키 Name[nb]=Smartkort-nøkkel Name[nl]=Smartcard-sleutel Name[nn]=Smartkort-nøkkel Name[pl]=Klucz na karcie inteligentnej Name[pt]=Chave do 'Smartcard' Name[pt_BR]=Chave do Smartcard Name[ru]=Ключ смарт-карты Name[sk]=Smartcard kľúč Name[sl]=Ključ na pametni kartici Name[sr]=Кључ смарт-картица Name[sr@ijekavian]=Кључ смарт-картица Name[sr@ijekavianlatin]=Ključ smart-kartica Name[sr@latin]=Ključ smart-kartica Name[sv]=Smartkortsnyckel Name[tr]=Akıllı Kart Anahtarı Name[uk]=Ключ картки пам’яті Name[x-test]=xxSmartcard Keyxx Name[zh_CN]=智能卡密钥 Name[zh_TW]=智慧卡金鑰 icon=smartcard [Key Filter #8] is-openpgp-key=true Name=OpenPGP Certificates Name[ar]=شهادات OpenPGP Name[ca]=Certificats OpenPGP Name[ca@valencia]=Certificats OpenPGP Name[cs]=Certifikáty OpenPGP Name[da]=OpenPGP-certifikater Name[de]=OpenPGP-Zertifikate Name[en_GB]=OpenPGP Certificates Name[es]=Certificados OpenPGP Name[et]=OpenPGP sertifikaadid Name[fi]=OpenPGP-varmenteet Name[fr]=Certificats OpenPGP Name[gl]=Certificados OpenPGP Name[ia]=Certificatos de OpenPGP Name[it]=Certificati OpenPGP Name[ko]=OpenPGP 인증서 Name[nl]=OpenPGP-certificaten Name[pl]=Certyfikaty OpenPGP Name[pt]=Certificados do OpenPGP Name[pt_BR]=Certificados OpenPGP Name[ru]=Сертификаты OpenPGP Name[sk]=Certifikáty OpenPGP Name[sl]=Potrdila OpenPGP Name[sr]=ОпенПГП сертификати Name[sr@ijekavian]=ОпенПГП сертификати Name[sr@ijekavianlatin]=OpenPGP sertifikati Name[sr@latin]=OpenPGP sertifikati Name[sv]=OpenPGP-certifikat Name[tr]=OpenPGP Sertifikaları Name[uk]=Сертифікати OpenPGP Name[x-test]=xxOpenPGP Certificatesxx Name[zh_CN]=OpenPGP 证书 Name[zh_TW]=OpenPGP 憑證 [Key Filter #9] is-openpgp-key=false Name=X509 Certificates Name[ar]=شهادات X509 Name[ca]=Certificats X509 Name[ca@valencia]=Certificats X509 Name[cs]=Certifikáty X509 Name[da]=X509-certifikater Name[de]=X509-Zertifikate Name[en_GB]=X509 Certificates Name[es]=Certificados X509 Name[et]=X509 sertifikaadid Name[fi]=X509-varmenteet Name[fr]=Certificats X509 Name[gl]=Certificados X509 Name[ia]=Certificatos X.509 Name[it]=Certificati X509 Name[ko]=X509 인증서 Name[nl]=X509-certificaten Name[pl]=Certyfikaty X509 Name[pt]=Certificados X509 Name[pt_BR]=Certificados X.509 Name[ru]=Сертификаты X.509 Name[sk]=Certifikáty X509 Name[sl]=Potrdila X509 Name[sr]=Икс.509 сертификати Name[sr@ijekavian]=Икс.509 сертификати Name[sr@ijekavianlatin]=X.509 sertifikati Name[sr@latin]=X.509 sertifikati Name[sv]=X509-certifikat Name[tr]=X509 Sertifikaları Name[uk]=Сертифікати X509 Name[x-test]=xxX509 Certificatesxx Name[zh_CN]=X509 证书 Name[zh_TW]=X509 憑證 # Filters that filter for is-de-vs # are only shown in compliance mode # de-vs [Key Filter #10] is-de-vs=true +id=de-vs-filter Name=VS-NfD Compliant Name[ca]=Compatible amb VS-NfD Name[ca@valencia]=Compatible amb VS-NfD Name[cs]=Splňující VS-NfD Name[de]=VS-NfD-konform Name[en_GB]=VS-NfD Compliant Name[es]=Compatible con VS-NfD Name[et]=VS-NfD ühilduv Name[fi]=VS-NfD-yhteensopiva Name[fr]=Compatible VS-NfD Name[gl]=Cumpre con VS-NfD Name[ia]=Conforme a VS-NfD Name[it]=Conforme allo standard VS-NfD Name[ko]=VS-NfD 적합 Name[nl]=VS-NfD Compliant Name[pl]=Zgodny z VS-NfD Name[pt]=Compatível com o VS-NfD Name[pt_BR]=Compatível com VS-NfD Name[ru]=Уровень «VS-NfD» (секретно — только для служебного пользования) Name[sk]=Zhodný s VS-NfD Name[sl]=Združljiv z VS-NfD Name[sv]=Stöder VS-NfD Name[uk]=Сумісний із VS-NfD Name[x-test]=xxVS-NfD Compliantxx Name[zh_TW]=相容 VS-NfD background-color=213,250,226 [Key Filter #11] is-de-vs=false +id=not-de-vs-filter Name=Not VS-NfD Compliant Name[ca]=No compatible amb VS-NfD Name[ca@valencia]=No compatible amb VS-NfD Name[cs]=Nesplňující VS-NfD Name[de]=Nicht VS-NfD-konform Name[en_GB]=Not VS-NfD Compliant Name[es]=No compatible con VS-NfD Name[et]=VS-NfD ühildumatu Name[fi]=Ei VS-NfD-yhteensopiva Name[fr]=Incompatible VS-NfD Name[gl]=Non cumpre con VS-NfD Name[ia]=Non conforme a VS-NfD Name[it]=Non conforme allo standard VS-NfD Name[ko]=VS-NfD 부적합 Name[nl]=Niet VS-NfD Compliant Name[pl]=Niezgodny z VS-NfD Name[pt]=Incompatível com o VS-NfD Name[pt_BR]=Não compatível com VS-NfD Name[ru]=Не соотвествует уровеню «VS-NfD» (секретно — только для служебного пользования) Name[sk]=Nezhodný s VS-NfD Name[sl]=Nezdružljiv z VS-NfD Name[sv]=Stöder inte VS-NfD Name[uk]=Несумісний із VS-NfD Name[x-test]=xxNot VS-NfD Compliantxx Name[zh_TW]=不相容 VS-NfD background-color=250,233,235 diff --git a/src/ui/newkeyapprovaldialog.cpp b/src/ui/newkeyapprovaldialog.cpp index 717fae9a9..c9d510313 100644 --- a/src/ui/newkeyapprovaldialog.cpp +++ b/src/ui/newkeyapprovaldialog.cpp @@ -1,771 +1,771 @@ /* -*- c++ -*- newkeyapprovaldialog.cpp This file is part of libkleopatra, the KDE keymanagement library Copyright (c) 2018 Intevation GmbH Libkleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Libkleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include "newkeyapprovaldialog.h" #include "kleo/defaultkeyfilter.h" #include "keyselectioncombo.h" #include "progressdialog.h" #include "utils/formatting.h" #include "libkleo_debug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace Kleo; namespace { class OpenPGPFilter: public DefaultKeyFilter { public: OpenPGPFilter() : DefaultKeyFilter() { setIsOpenPGP(DefaultKeyFilter::Set); setCanEncrypt(DefaultKeyFilter::Set); } }; static std::shared_ptr s_pgpFilter = std::shared_ptr (new OpenPGPFilter); class OpenPGPSignFilter: public DefaultKeyFilter { public: OpenPGPSignFilter() : DefaultKeyFilter() { /* Also list unusable keys to make it transparent why they are unusable */ setDisabled(DefaultKeyFilter::NotSet); setRevoked(DefaultKeyFilter::NotSet); setExpired(DefaultKeyFilter::NotSet); setCanSign(DefaultKeyFilter::Set); setHasSecret(DefaultKeyFilter::Set); setIsOpenPGP(DefaultKeyFilter::Set); } }; static std::shared_ptr s_pgpSignFilter = std::shared_ptr (new OpenPGPSignFilter); class SMIMEFilter: public DefaultKeyFilter { public: SMIMEFilter(): DefaultKeyFilter() { setIsOpenPGP(DefaultKeyFilter::NotSet); setCanEncrypt(DefaultKeyFilter::Set); } }; static std::shared_ptr s_smimeFilter = std::shared_ptr (new SMIMEFilter); class SMIMESignFilter: public DefaultKeyFilter { public: SMIMESignFilter(): DefaultKeyFilter() { setDisabled(DefaultKeyFilter::NotSet); setRevoked(DefaultKeyFilter::NotSet); setExpired(DefaultKeyFilter::NotSet); setCanSign(DefaultKeyFilter::Set); setIsOpenPGP(DefaultKeyFilter::NotSet); setHasSecret(DefaultKeyFilter::Set); } }; static std::shared_ptr s_smimeSignFilter = std::shared_ptr (new SMIMESignFilter); static std::shared_ptr s_defaultFilter= std::shared_ptr (new DefaultKeyFilter); class SignFilter: public DefaultKeyFilter { public: SignFilter(): DefaultKeyFilter() { setHasSecret(DefaultKeyFilter::Set); } }; static std::shared_ptr s_signFilter = std::shared_ptr (new SignFilter); /* Some decoration and a button to remove the filter for a keyselectioncombo */ class ComboWidget: public QWidget { Q_OBJECT public: explicit ComboWidget(KeySelectionCombo *combo): mCombo(combo), mFilterBtn(new QPushButton), mFromOverride(GpgME::UnknownProtocol) { auto hLay = new QHBoxLayout(this); auto infoBtn = new QPushButton; infoBtn->setIcon(QIcon::fromTheme(QStringLiteral("help-contextual"))); infoBtn->setIconSize(QSize(22,22)); infoBtn->setFlat(true); hLay->addWidget(infoBtn); hLay->addWidget(combo, 1); hLay->addWidget(mFilterBtn, 0); connect(infoBtn, &QPushButton::clicked, this, [this, infoBtn] () { QToolTip::showText(infoBtn->mapToGlobal(QPoint()) + QPoint(infoBtn->width(), 0), mCombo->currentData(Qt::ToolTipRole).toString(), infoBtn, QRect(), 30000); }); // Assume that combos start out with a filter mFilterBtn->setIcon(QIcon::fromTheme(QStringLiteral("kt-remove-filters"))); mFilterBtn->setToolTip(i18n("Remove Filter")); // FIXME: This is ugly to enforce but otherwise the // icon is broken. combo->setMinimumHeight(22); mFilterBtn->setMinimumHeight(23); connect(mFilterBtn, &QPushButton::clicked, this, [this] () { const QString curFilter = mCombo->idFilter(); if (curFilter.isEmpty()) { mCombo->setIdFilter(mLastIdFilter); mLastIdFilter = QString(); mFilterBtn->setIcon(QIcon::fromTheme(QStringLiteral("kt-remove-filters"))); mFilterBtn->setToolTip(i18n("Remove Filter")); } else { mLastIdFilter = curFilter; mFilterBtn->setIcon(QIcon::fromTheme(QStringLiteral("kt-add-filters"))); mFilterBtn->setToolTip(i18n("Add Filter")); mCombo->setIdFilter(QString()); } }); } KeySelectionCombo *combo() { return mCombo; } GpgME::Protocol fromOverride() const { return mFromOverride; } void setFromOverride(GpgME::Protocol proto) { mFromOverride = proto; } private: KeySelectionCombo *mCombo; QPushButton *mFilterBtn; QString mLastIdFilter; GpgME::Protocol mFromOverride; }; static enum GpgME::UserID::Validity keyValidity(const GpgME::Key &key) { enum GpgME::UserID::Validity validity = GpgME::UserID::Validity::Unknown; for (const auto &uid: key.userIDs()) { if (validity == GpgME::UserID::Validity::Unknown || validity > uid.validity()) { validity = uid.validity(); } } return validity; } static bool key_has_addr(const GpgME::Key &key, const QString &addr) { for (const auto &uid: key.userIDs()) { if (QString::fromStdString(uid.addrSpec()).toLower() == addr.toLower()) { return true; } } return false; } } // namespace class NewKeyApprovalDialog::Private { private: enum Action { Unset, GenerateKey, IgnoreKey, }; public: Private(NewKeyApprovalDialog *pub, GpgME::Protocol forcedProtocol, GpgME::Protocol presetProtocol, const QString &sender, bool allowMixed): mProto(forcedProtocol), mSender(sender), mAllowMixed(allowMixed), q(pub) { // We do the translation here to avoid having the same string multiple times. mGenerateTooltip = i18nc("@info:tooltip for a 'Generate new key pair' action " "in a combobox when a user does not yet have an OpenPGP or S/MIME key.", "Generate a new key using your E-Mail address.

" "The key is necessary to decrypt and sign E-Mails. " "You will be asked for a passphrase to protect this key and the protected key " "will be stored in your home directory."); mMainLay = new QVBoxLayout; QDialogButtonBox *btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); mOkButton = btnBox->button(QDialogButtonBox::Ok); QObject::connect (btnBox, &QDialogButtonBox::accepted, q, [this] () { accepted(); }); QObject::connect (btnBox, &QDialogButtonBox::rejected, q, &QDialog::reject); mScrollArea = new QScrollArea; mScrollArea->setWidget(new QWidget); mScrollLayout = new QVBoxLayout; mScrollArea->widget()->setLayout(mScrollLayout); mScrollArea->setWidgetResizable(true); mScrollArea->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow); mScrollArea->setFrameStyle(QFrame::NoFrame); mScrollLayout->setContentsMargins(0, 0, 0, 0); q->setWindowTitle(i18nc("@title:window", "Security approval")); auto fmtLayout = new QHBoxLayout; mFormatBtns = new QButtonGroup; auto pgpBtn = new QRadioButton(i18n("OpenPGP")); auto smimeBtn = new QRadioButton(i18n("S/MIME")); mFormatBtns->addButton(pgpBtn, 1); mFormatBtns->addButton(smimeBtn, 2); mFormatBtns->setExclusive(true); fmtLayout->addStretch(-1); fmtLayout->addWidget(pgpBtn); fmtLayout->addWidget(smimeBtn); mMainLay->addLayout(fmtLayout); // Handle force / preset if (forcedProtocol == GpgME::OpenPGP) { pgpBtn->setChecked(true); pgpBtn->setVisible(false); smimeBtn->setVisible(false); } else if (forcedProtocol == GpgME::CMS) { smimeBtn->setChecked(true); pgpBtn->setVisible(false); smimeBtn->setVisible(false); } else if (presetProtocol == GpgME::CMS) { smimeBtn->setChecked(true); } else if (!mAllowMixed) { pgpBtn->setChecked(true); } else if (mAllowMixed) { smimeBtn->setVisible(false); pgpBtn->setVisible(false); } updateFilter(); QObject::connect (mFormatBtns, static_cast (&QButtonGroup::buttonToggled), q, [this](QAbstractButton *, bool) { updateFilter(); }); mMainLay->addWidget(mScrollArea); mComplianceLbl = new QLabel; mComplianceLbl->setVisible(false); auto btnLayout = new QHBoxLayout; btnLayout->addWidget(mComplianceLbl); btnLayout->addWidget(btnBox); mMainLay->addLayout(btnLayout); q->setLayout(mMainLay); } void generateKey(KeySelectionCombo *combo) { const auto &addr = combo->property("address").toString(); auto job = new QGpgME::DefaultKeyGenerationJob(q); auto progress = new Kleo::ProgressDialog(job, i18n("Generating key for '%1'...", addr) + QStringLiteral("\n\n") + i18n("This can take several minutes."), q); progress->setWindowFlags(progress->windowFlags() & ~Qt::WindowContextHelpButtonHint); progress->setWindowTitle(i18nc("@title:window", "Key generation")); progress->setModal(true); progress->setAutoClose(true); progress->setMinimumDuration(0); progress->setValue(0); mRunningJobs << job; connect (job, &QGpgME::DefaultKeyGenerationJob::result, q, [this, job, combo] (const GpgME::KeyGenerationResult &result) { handleKeyGenResult(result, job, combo); }); job->start(addr, QString()); return; } void handleKeyGenResult(const GpgME::KeyGenerationResult &result, QGpgME::Job *job, KeySelectionCombo *combo) { mLastError = result.error(); if (!mLastError || mLastError.isCanceled()) { combo->setDefaultKey(QString::fromLatin1(result.fingerprint()), GpgME::OpenPGP); connect (combo, &KeySelectionCombo::keyListingFinished, q, [this, job] () { mRunningJobs.removeAll(job); }); combo->refreshKeys(); } else { mRunningJobs.removeAll(job); } } void checkAccepted() { if (mLastError || mLastError.isCanceled()) { KMessageBox::error(q, QString::fromLocal8Bit(mLastError.asString()), i18n("Operation Failed")); mRunningJobs.clear(); return; } if (!mRunningJobs.empty()) { return; } /* Save the keys */ bool isPGP = mFormatBtns->checkedId() == 1; bool isSMIME = mFormatBtns->checkedId() == 2; mAcceptedEnc.clear(); mAcceptedSig.clear(); for (const auto combo: qAsConst(mEncCombos)) { const auto &addr = combo->property("address").toString(); const auto &key = combo->currentKey(); if (!combo->isVisible()) { continue; } if (isSMIME && key.protocol() != GpgME::CMS) { continue; } if (isPGP && key.protocol() != GpgME::OpenPGP) { continue; } if (mAcceptedEnc.contains(addr)) { mAcceptedEnc[addr].push_back(key); } else { std::vector vec; vec.push_back(key); mAcceptedEnc.insert(addr, vec); } } for (const auto combo: qAsConst(mSigningCombos)) { const auto key = combo->currentKey(); if (!combo->isVisible()) { continue; } if (isSMIME && key.protocol() != GpgME::CMS) { continue; } if (isPGP && key.protocol() != GpgME::OpenPGP) { continue; } mAcceptedSig.push_back(combo->currentKey()); } q->accept(); } void accepted() { // We can assume everything was validly resolved, otherwise // the OK button would have been disabled. // Handle custom items now. for (auto combo: qAsConst(mAllCombos)) { auto act = combo->currentData(Qt::UserRole).toInt(); if (act == GenerateKey) { generateKey(combo); // Only generate once return; } } checkAccepted(); } void updateFilter() { bool isPGP = mFormatBtns->checkedId() == 1; bool isSMIME = mFormatBtns->checkedId() == 2; if (isSMIME) { mCurEncFilter = s_smimeFilter; mCurSigFilter = s_smimeSignFilter; } else if (isPGP) { mCurEncFilter = s_pgpFilter; mCurSigFilter = s_pgpSignFilter; } else { mCurEncFilter = s_defaultFilter; mCurSigFilter = s_signFilter; } for (auto combo: qAsConst(mSigningCombos)) { combo->setKeyFilter(mCurSigFilter); auto widget = qobject_cast (combo->parentWidget()); if (!widget) { qCDebug(LIBKLEO_LOG) << "Failed to find signature combo widget"; continue; } widget->setVisible(widget->fromOverride() == GpgME::UnknownProtocol || ((isSMIME && widget->fromOverride() == GpgME::CMS) || (isPGP && widget->fromOverride() == GpgME::OpenPGP))); } for (auto combo: qAsConst(mEncCombos)) { combo->setKeyFilter(mCurEncFilter); auto widget = qobject_cast (combo->parentWidget()); if (!widget) { qCDebug(LIBKLEO_LOG) << "Failed to find combo widget"; continue; } widget->setVisible(widget->fromOverride() == GpgME::UnknownProtocol || ((isSMIME && widget->fromOverride() == GpgME::CMS) || (isPGP && widget->fromOverride() == GpgME::OpenPGP))); } } ComboWidget *createSigningCombo(const QString &addr, const GpgME::Key &key) { auto combo = new KeySelectionCombo(); combo->setKeyFilter(mCurSigFilter); if (!key.isNull()) { combo->setDefaultKey(QString::fromLatin1(key.primaryFingerprint()), key.protocol()); } if (key.isNull() && mProto != GpgME::CMS) { combo->appendCustomItem(QIcon::fromTheme(QStringLiteral("document-new")), i18n("Generate a new key pair"), GenerateKey, mGenerateTooltip); } combo->appendCustomItem(QIcon::fromTheme(QStringLiteral("emblem-unavailable")), i18n("Don't confirm identity and integrity"), IgnoreKey, i18nc("@info:tooltip for not selecting a key for signing.", "The E-Mail will not be cryptographically signed.")); mSigningCombos << combo; mAllCombos << combo; combo->setProperty("address", addr); connect(combo, &KeySelectionCombo::currentKeyChanged, q, [this] () { updateOkButton(); }); connect(combo, QOverload::of(&QComboBox::currentIndexChanged), q, [this] () { updateOkButton(); }); return new ComboWidget(combo); } void addSigningKeys(const QMap > &resolved, const QStringList &unresolved) { if (resolved.empty() && unresolved.empty()) { return; } for (const QString &addr: resolved.keys()) { auto group = new QGroupBox(i18nc("Caption for signing key selection", "Confirm identity '%1' as:", addr)); group->setAlignment(Qt::AlignLeft); mScrollLayout->addWidget(group); auto sigLayout = new QVBoxLayout; group->setLayout(sigLayout); for (const auto &key: resolved[addr]) { auto comboWidget = createSigningCombo(addr, key); if (key_has_addr (key, addr)) { comboWidget->combo()->setIdFilter(addr); } if (resolved[addr].size() > 1) { comboWidget->setFromOverride(key.protocol()); } sigLayout->addWidget(comboWidget); } } for (const QString &addr: qAsConst(unresolved)) { auto group = new QGroupBox(i18nc("Caption for signing key selection, no key found", "No key found for the address '%1':", addr)); group->setAlignment(Qt::AlignLeft); mScrollLayout->addWidget(group); auto sigLayout = new QHBoxLayout; group->setLayout(sigLayout); auto comboWidget = createSigningCombo(addr, GpgME::Key()); comboWidget->combo()->setIdFilter(addr); sigLayout->addWidget(comboWidget); } } void addEncryptionAddr(const QString &addr, const std::vector &keys, QGridLayout *encGrid) { encGrid->addWidget(new QLabel(addr), encGrid->rowCount(), 0); for (const auto &key: keys) { auto combo = new KeySelectionCombo(false); combo->setKeyFilter(mCurEncFilter); if (!key.isNull()) { combo->setDefaultKey(QString::fromLatin1(key.primaryFingerprint()), key.protocol()); } if (mSender == addr && key.isNull()) { combo->appendCustomItem(QIcon::fromTheme(QStringLiteral("document-new")), i18n("Generate a new key pair"), GenerateKey, mGenerateTooltip); } combo->appendCustomItem(QIcon::fromTheme(QStringLiteral("emblem-unavailable")), i18n("No key. Recipient will be unable to decrypt."), IgnoreKey, i18nc("@info:tooltip for No Key selected for a specific recipient.", "Do not select a key for this recipient.

" "The recipient will receive the encrypted E-Mail, but it can only " "be decrypted with the other keys selected in this dialog.")); if (key.isNull() || key_has_addr (key, addr)) { combo->setIdFilter(addr); } connect(combo, &KeySelectionCombo::currentKeyChanged, q, [this] () { updateOkButton(); }); connect(combo, QOverload::of(&QComboBox::currentIndexChanged), q, [this] () { updateOkButton(); }); mEncCombos << combo; mAllCombos << combo; combo->setProperty("address", addr); auto comboWidget = new ComboWidget(combo); if (keys.size() > 1) { comboWidget->setFromOverride(key.protocol()); } encGrid->addWidget(comboWidget, encGrid->rowCount(), 0, 1, 2); } } void addEncryptionKeys(const QMap > &resolved, const QStringList &unresolved) { if (resolved.empty() && unresolved.empty()) { return; } auto group = new QGroupBox(i18n("Encrypt to:")); group->setAlignment(Qt::AlignLeft); auto encGrid = new QGridLayout; group->setLayout(encGrid); mScrollLayout->addWidget(group); for (const QString &addr: resolved.keys()) { addEncryptionAddr(addr, resolved[addr], encGrid); } std::vector dummy; dummy.push_back(GpgME::Key()); for (const QString &addr: unresolved) { addEncryptionAddr(addr, dummy, encGrid); } encGrid->setColumnStretch(1, -1); mScrollLayout->addStretch(-1); } void updateOkButton() { static QString origOkText = mOkButton->text(); bool isGenerate = false; bool isAllIgnored = true; // Check if generate is selected. for (auto combo: mAllCombos) { auto act = combo->currentData(Qt::UserRole).toInt(); if (act == GenerateKey) { mOkButton->setText(i18n("Generate")); isGenerate = true; } if (act != IgnoreKey) { isAllIgnored = false; } } // If we don't encrypt the ok button is always enabled. But otherwise // we only enable it if we encrypt to at least one recipient. if (!mEncCombos.size()) { mOkButton->setEnabled(true); } else { mOkButton->setEnabled(!isAllIgnored); } if (!isGenerate) { mOkButton->setText(origOkText); } if (Formatting::complianceMode() != QLatin1String("de-vs")) { return; } // Handle compliance bool de_vs = true; bool isPGP = mFormatBtns->checkedId() == 1; bool isSMIME = mFormatBtns->checkedId() == 2; for (const auto combo: qAsConst(mEncCombos)) { const auto &key = combo->currentKey(); if (!combo->isVisible()) { continue; } if (isSMIME && key.protocol() != GpgME::CMS) { continue; } if (isPGP && key.protocol() != GpgME::OpenPGP) { continue; } if (!Formatting::isKeyDeVs(key) || keyValidity(key) < GpgME::UserID::Validity::Full) { de_vs = false; break; } } if (de_vs) { for (const auto combo: qAsConst(mSigningCombos)) { const auto key = combo->currentKey(); if (!combo->isVisible()) { continue; } if (isSMIME && key.protocol() != GpgME::CMS) { continue; } if (isPGP && key.protocol() != GpgME::OpenPGP) { continue; } if (!Formatting::isKeyDeVs(key) || keyValidity(key) < GpgME::UserID::Validity::Full) { de_vs = false; break; } } } mOkButton->setIcon(QIcon::fromTheme(de_vs ? QStringLiteral("security-high") : QStringLiteral("security-medium"))); mOkButton->setStyleSheet(QStringLiteral("background-color: ") + (de_vs ? QStringLiteral("#D5FAE2") // KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::PositiveBackground).color().name() : QStringLiteral("#FAE9EB"))); //KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NegativeBackground).color().name())); mComplianceLbl->setText(de_vs - ? i18nc("VS-NfD-conforming is a German standard for restricted documents for which special restrictions about algorithms apply. The string states that all cryptographic operations necessary for the communication are compliant with that.", - "VS-NfD-compliant communication possible.") - : i18nc("VS-NfD-conforming is a German standard for restricted documents for which special restrictions about algorithms apply. The string states that all cryptographic operations necessary for the communication are compliant with that.", - "VS-NfD-compliant communication not possible.")); + ? 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()) + : 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())); mComplianceLbl->setVisible(true); } void selectionChanged() { bool isPGP = false; bool isCMS = false; for (const auto combo: mEncCombos) { isPGP |= combo->currentKey().protocol() == GpgME::OpenPGP; isCMS |= combo->currentKey().protocol() == GpgME::CMS; if (isPGP && isCMS) { break; } } } ~Private() {} GpgME::Protocol mProto; QList mSigningCombos; QList mEncCombos; QList mAllCombos; QScrollArea *mScrollArea; QVBoxLayout *mScrollLayout; QPushButton *mOkButton; QVBoxLayout *mMainLay; QButtonGroup *mFormatBtns; std::shared_ptr mCurSigFilter; std::shared_ptr mCurEncFilter; QString mSender; bool mAllowMixed; NewKeyApprovalDialog *q; QList mRunningJobs; GpgME::Error mLastError; QLabel *mComplianceLbl; QMap > mAcceptedEnc; std::vector mAcceptedSig; QString mGenerateTooltip; }; NewKeyApprovalDialog::NewKeyApprovalDialog(const QMap > &resolvedSigningKeys, const QMap > &resolvedRecp, const QStringList &unresolvedSigKeys, const QStringList &unresolvedRecp, const QString &sender, bool allowMixed, GpgME::Protocol forcedProtocol, GpgME::Protocol presetProtocol, QWidget *parent, Qt::WindowFlags f): QDialog(parent, f), d(new Private(this, forcedProtocol, presetProtocol, sender, allowMixed)) { d->addSigningKeys(resolvedSigningKeys, unresolvedSigKeys); d->addEncryptionKeys(resolvedRecp, unresolvedRecp); d->updateFilter(); d->updateOkButton(); const auto size = sizeHint(); const auto desk = QApplication::desktop()->screenGeometry(this); resize(QSize(desk.width() / 3, qMin(size.height(), desk.height() / 2))); } std::vector NewKeyApprovalDialog::signingKeys() { return d->mAcceptedSig; } QMap > NewKeyApprovalDialog::encryptionKeys() { return d->mAcceptedEnc; } #include "newkeyapprovaldialog.moc" diff --git a/src/utils/formatting.cpp b/src/utils/formatting.cpp index e98527f41..058a61642 100644 --- a/src/utils/formatting.cpp +++ b/src/utils/formatting.cpp @@ -1,1074 +1,1084 @@ /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; -*- utils/formatting.cpp This file is part of Kleopatra, the KDE keymanager Copyright (c) 2007 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include "formatting.h" #include "kleo/dn.h" +#include "kleo/keyfiltermanager.h" #include #include #include #include #include #include #include #include #include #include // for Qt::escape #include #include #include #include "models/keycache.h" using namespace GpgME; using namespace Kleo; // // Name // QString Formatting::prettyName(int proto, const char *id, const char *name_, const char *comment_) { if (proto == OpenPGP) { const QString name = QString::fromUtf8(name_); if (name.isEmpty()) { return QString(); } const QString comment = QString::fromUtf8(comment_); if (comment.isEmpty()) { return name; } return QStringLiteral("%1 (%2)").arg(name, comment); } if (proto == CMS) { const DN subject(id); const QString cn = subject[QStringLiteral("CN")].trimmed(); if (cn.isEmpty()) { return subject.prettyDN(); } return cn; } return QString(); } QString Formatting::prettyNameAndEMail(int proto, const char *id, const char *name_, const char *email_, const char *comment_) { return prettyNameAndEMail(proto, QString::fromUtf8(id), QString::fromUtf8(name_), prettyEMail(email_, id), QString::fromUtf8(comment_)); } QString Formatting::prettyNameAndEMail(int proto, const QString &id, const QString &name, const QString &email, const QString &comment) { if (proto == OpenPGP) { if (name.isEmpty()) { if (email.isEmpty()) { return QString(); } else if (comment.isEmpty()) { return QStringLiteral("<%1>").arg(email); } else { return QStringLiteral("(%2) <%1>").arg(email, comment); } } if (email.isEmpty()) { if (comment.isEmpty()) { return name; } else { return QStringLiteral("%1 (%2)").arg(name, comment); } } if (comment.isEmpty()) { return QStringLiteral("%1 <%2>").arg(name, email); } else { return QStringLiteral("%1 (%3) <%2>").arg(name, email, comment); } } if (proto == CMS) { const DN subject(id); const QString cn = subject[QStringLiteral("CN")].trimmed(); if (cn.isEmpty()) { return subject.prettyDN(); } return cn; } return QString(); } QString Formatting::prettyUserID(const UserID &uid) { if (uid.parent().protocol() == OpenPGP) { return prettyNameAndEMail(uid); } const QByteArray id = QByteArray(uid.id()).trimmed(); if (id.startsWith('<')) { return prettyEMail(uid.email(), uid.id()); } if (id.startsWith('(')) // ### parse uri/dns: { return QString::fromUtf8(uid.id()); } else { return DN(uid.id()).prettyDN(); } } QString Formatting::prettyKeyID(const char *id) { if (!id) { return QString(); } return QLatin1String("0x") + QString::fromLatin1(id).toUpper(); } QString Formatting::prettyNameAndEMail(const UserID &uid) { return prettyNameAndEMail(uid.parent().protocol(), uid.id(), uid.name(), uid.email(), uid.comment()); } QString Formatting::prettyNameAndEMail(const Key &key) { return prettyNameAndEMail(key.userID(0)); } QString Formatting::prettyName(const Key &key) { return prettyName(key.userID(0)); } QString Formatting::prettyName(const UserID &uid) { return prettyName(uid.parent().protocol(), uid.id(), uid.name(), uid.comment()); } QString Formatting::prettyName(const UserID::Signature &sig) { return prettyName(OpenPGP, sig.signerUserID(), sig.signerName(), sig.signerComment()); } // // EMail // QString Formatting::prettyEMail(const Key &key) { for (unsigned int i = 0, end = key.numUserIDs(); i < end; ++i) { const QString email = prettyEMail(key.userID(i)); if (!email.isEmpty()) { return email; } } return QString(); } QString Formatting::prettyEMail(const UserID &uid) { return prettyEMail(uid.email(), uid.id()); } QString Formatting::prettyEMail(const UserID::Signature &sig) { return prettyEMail(sig.signerEmail(), sig.signerUserID()); } QString Formatting::prettyEMail(const char *email_, const char *id) { QString email, name, comment; if (email_ && KEmailAddress::splitAddress(QString::fromUtf8(email_), name, email, comment) == KEmailAddress::AddressOk) { return email; } else { return DN(id)[QStringLiteral("EMAIL")].trimmed(); } } // // Tooltip // namespace { static QString protect_whitespace(QString s) { static const QLatin1Char SP(' '), NBSP('\xA0'); return s.replace(SP, NBSP); } template QString format_row(const QString &field, const T_arg &arg) { return QStringLiteral("%1:%2").arg(protect_whitespace(field), arg); } QString format_row(const QString &field, const QString &arg) { return QStringLiteral("%1:%2").arg(protect_whitespace(field), arg.toHtmlEscaped()); } QString format_row(const QString &field, const char *arg) { return format_row(field, QString::fromUtf8(arg)); } QString format_keytype(const Key &key) { const Subkey subkey = key.subkey(0); if (key.hasSecret()) { return i18n("%1-bit %2 (secret key available)", subkey.length(), QLatin1String(subkey.publicKeyAlgorithmAsString())); } else { return i18n("%1-bit %2", subkey.length(), QLatin1String(subkey.publicKeyAlgorithmAsString())); } } QString format_subkeytype(const Subkey &subkey) { const auto algo = subkey.publicKeyAlgorithm(); if (algo == Subkey::AlgoECC || algo == Subkey::AlgoECDSA || algo == Subkey::AlgoECDH || algo == Subkey::AlgoEDDSA) { return QString::fromStdString(subkey.algoName()); } return i18n("%1-bit %2", subkey.length(), QLatin1String(subkey.publicKeyAlgorithmAsString())); } QString format_keyusage(const Key &key) { QStringList capabilities; if (key.canReallySign()) { if (key.isQualified()) { capabilities.push_back(i18n("Signing (Qualified)")); } else { capabilities.push_back(i18n("Signing")); } } if (key.canEncrypt()) { capabilities.push_back(i18n("Encryption")); } if (key.canCertify()) { capabilities.push_back(i18n("Certifying User-IDs")); } if (key.canAuthenticate()) { capabilities.push_back(i18n("SSH Authentication")); } return capabilities.join(QLatin1String(", ")); } QString format_subkeyusage(const Subkey &subkey) { QStringList capabilities; if (subkey.canSign()) { if (subkey.isQualified()) { capabilities.push_back(i18n("Signing (Qualified)")); } else { capabilities.push_back(i18n("Signing")); } } if (subkey.canEncrypt()) { capabilities.push_back(i18n("Encryption")); } if (subkey.canCertify()) { capabilities.push_back(i18n("Certifying User-IDs")); } if (subkey.canAuthenticate()) { capabilities.push_back(i18n("SSH Authentication")); } return capabilities.join(QLatin1String(", ")); } static QString time_t2string(time_t t) { QDateTime dt; dt.setTime_t(t); return QLocale().toString(dt, QLocale::ShortFormat); } static QString make_red(const QString &txt) { return QLatin1String("") + txt.toHtmlEscaped() + QLatin1String(""); } } QString Formatting::toolTip(const Key &key, int flags) { if (flags == 0 || (key.protocol() != CMS && key.protocol() != OpenPGP)) { return QString(); } const Subkey subkey = key.subkey(0); QString result; if (flags & Validity) { if (key.protocol() == OpenPGP || (key.keyListMode() & Validate)) if (key.isRevoked()) { result = make_red(i18n("Revoked")); } else if (key.isExpired()) { result = make_red(i18n("Expired")); } else if (key.isDisabled()) { result = i18n("Disabled"); } else { unsigned int fullyTrusted = 0; for (const auto &uid: key.userIDs()) { if (uid.validity() >= UserID::Validity::Full) { fullyTrusted++; } } if (fullyTrusted == key.numUserIDs()) { result = i18n("All User-IDs are certified."); const auto compliance = complianceStringForKey(key); if (!compliance.isEmpty()) { result += QStringLiteral("
") + compliance; } } else { result = i18np("One User-ID is not certified.", "%1 User-IDs are not certified.", key.numUserIDs() - fullyTrusted); } } else { result = i18n("The validity cannot be checked at the moment."); } } if (flags == Validity) { return result; } result += QLatin1String(""); if (key.protocol() == CMS) { if (flags & SerialNumber) { result += format_row(i18n("Serial number"), key.issuerSerial()); } if (flags & Issuer) { result += format_row(i18n("Issuer"), key.issuerName()); } } if (flags & UserIDs) { const std::vector uids = key.userIDs(); if (!uids.empty()) result += format_row(key.protocol() == CMS ? i18n("Subject") : i18n("User-ID"), prettyUserID(uids.front())); if (uids.size() > 1) for (std::vector::const_iterator it = uids.begin() + 1, end = uids.end(); it != end; ++it) if (!it->isRevoked() && !it->isInvalid()) { result += format_row(i18n("a.k.a."), prettyUserID(*it)); } } if (flags & ExpiryDates) { result += format_row(i18n("Created"), time_t2string(subkey.creationTime())); if (key.isExpired()) { result += format_row(i18n("Expired"), time_t2string(subkey.expirationTime())); } else if (!subkey.neverExpires()) { result += format_row(i18n("Expires"), time_t2string(subkey.expirationTime())); } } if (flags & CertificateType) { result += format_row(i18n("Type"), format_keytype(key)); } if (flags & CertificateUsage) { result += format_row(i18n("Usage"), format_keyusage(key)); } if (flags & KeyID) { result += format_row(i18n("Key-ID"), QString::fromLatin1(key.shortKeyID())); } if (flags & Fingerprint) { result += format_row(i18n("Fingerprint"), key.primaryFingerprint()); } if (flags & OwnerTrust) { if (key.protocol() == OpenPGP) { result += format_row(i18n("Certification trust"), ownerTrustShort(key)); } else if (key.isRoot()) { result += format_row(i18n("Trusted issuer?"), key.userID(0).validity() == UserID::Ultimate ? i18n("Yes") : /* else */ i18n("No")); } } if (flags & StorageLocation) { if (const char *card = subkey.cardSerialNumber()) { result += format_row(i18n("Stored"), i18nc("stored...", "on SmartCard with serial no. %1", QString::fromUtf8(card))); } else { result += format_row(i18n("Stored"), i18nc("stored...", "on this computer")); } } if (flags & Subkeys) { for (const auto &sub: key.subkeys()) { result += QLatin1String("
"); result += format_row(i18n("Subkey"), sub.fingerprint()); if (sub.isRevoked()) { result += format_row(i18n("Status"), i18n("Revoked")); } else if (sub.isExpired()) { result += format_row(i18n("Status"), i18n("Expired")); } if (flags & ExpiryDates) { result += format_row(i18n("Created"), time_t2string(sub.creationTime())); if (key.isExpired()) { result += format_row(i18n("Expired"), time_t2string(sub.expirationTime())); } else if (!subkey.neverExpires()) { result += format_row(i18n("Expires"), time_t2string(sub.expirationTime())); } } if (flags & CertificateType) { result += format_row(i18n("Type"), format_subkeytype(sub)); } if (flags & CertificateUsage) { result += format_row(i18n("Usage"), format_subkeyusage(sub)); } if (flags & StorageLocation) { if (const char *card = sub.cardSerialNumber()) { result += format_row(i18n("Stored"), i18nc("stored...", "on SmartCard with serial no. %1", QString::fromUtf8(card))); } else { result += format_row(i18n("Stored"), i18nc("stored...", "on this computer")); } } } } result += QLatin1String("
"); return result; } // // Creation and Expiration // namespace { static QDate time_t2date(time_t t) { if (!t) { return QDate(); } QDateTime dt; dt.setTime_t(t); return dt.date(); } static QString date2string(const QDate &date) { return QLocale().toString(date, QLocale::ShortFormat); } template QString expiration_date_string(const T &tee) { return tee.neverExpires() ? QString() : date2string(time_t2date(tee.expirationTime())); } template QDate creation_date(const T &tee) { return time_t2date(tee.creationTime()); } template QDate expiration_date(const T &tee) { return time_t2date(tee.expirationTime()); } } QString Formatting::dateString(time_t t) { return date2string(time_t2date(t)); } QString Formatting::expirationDateString(const Key &key) { return expiration_date_string(key.subkey(0)); } QString Formatting::expirationDateString(const Subkey &subkey) { return expiration_date_string(subkey); } QString Formatting::expirationDateString(const UserID::Signature &sig) { return expiration_date_string(sig); } QDate Formatting::expirationDate(const Key &key) { return expiration_date(key.subkey(0)); } QDate Formatting::expirationDate(const Subkey &subkey) { return expiration_date(subkey); } QDate Formatting::expirationDate(const UserID::Signature &sig) { return expiration_date(sig); } QString Formatting::creationDateString(const Key &key) { return date2string(creation_date(key.subkey(0))); } QString Formatting::creationDateString(const Subkey &subkey) { return date2string(creation_date(subkey)); } QString Formatting::creationDateString(const UserID::Signature &sig) { return date2string(creation_date(sig)); } QDate Formatting::creationDate(const Key &key) { return creation_date(key.subkey(0)); } QDate Formatting::creationDate(const Subkey &subkey) { return creation_date(subkey); } QDate Formatting::creationDate(const UserID::Signature &sig) { return creation_date(sig); } // // Types // QString Formatting::displayName(Protocol p) { if (p == CMS) { return i18nc("X.509/CMS encryption standard", "X.509"); } if (p == OpenPGP) { return i18n("OpenPGP"); } return i18nc("Unknown encryption protocol", "Unknown"); } QString Formatting::type(const Key &key) { return displayName(key.protocol()); } QString Formatting::type(const Subkey &subkey) { return QString::fromUtf8(subkey.publicKeyAlgorithmAsString()); } // // Status / Validity // QString Formatting::ownerTrustShort(const Key &key) { return ownerTrustShort(key.ownerTrust()); } QString Formatting::ownerTrustShort(Key::OwnerTrust trust) { switch (trust) { case Key::Unknown: return i18nc("unknown trust level", "unknown"); case Key::Never: return i18n("untrusted"); case Key::Marginal: return i18nc("marginal trust", "marginal"); case Key::Full: return i18nc("full trust", "full"); case Key::Ultimate: return i18nc("ultimate trust", "ultimate"); case Key::Undefined: return i18nc("undefined trust", "undefined"); default: Q_ASSERT(!"unexpected owner trust value"); break; } return QString(); } QString Formatting::validityShort(const Subkey &subkey) { if (subkey.isRevoked()) { return i18n("revoked"); } if (subkey.isExpired()) { return i18n("expired"); } if (subkey.isDisabled()) { return i18n("disabled"); } if (subkey.isInvalid()) { return i18n("invalid"); } return i18nc("as in good/valid signature", "good"); } QString Formatting::validityShort(const UserID &uid) { if (uid.isRevoked()) { return i18n("revoked"); } if (uid.isInvalid()) { return i18n("invalid"); } switch (uid.validity()) { case UserID::Unknown: return i18nc("unknown trust level", "unknown"); case UserID::Undefined: return i18nc("undefined trust", "undefined"); case UserID::Never: return i18n("untrusted"); case UserID::Marginal: return i18nc("marginal trust", "marginal"); case UserID::Full: return i18nc("full trust", "full"); case UserID::Ultimate: return i18nc("ultimate trust", "ultimate"); } return QString(); } QString Formatting::validityShort(const UserID::Signature &sig) { switch (sig.status()) { case UserID::Signature::NoError: if (!sig.isInvalid()) { /* See RFC 4880 Section 5.2.1 */ switch (sig.certClass()) { case 0x10: /* Generic */ case 0x11: /* Persona */ case 0x12: /* Casual */ case 0x13: /* Positive */ return i18n("valid"); case 0x30: return i18n("revoked"); default: return i18n("class %1", sig.certClass()); } } Q_FALLTHROUGH(); // fall through: case UserID::Signature::GeneralError: return i18n("invalid"); case UserID::Signature::SigExpired: return i18n("expired"); case UserID::Signature::KeyExpired: return i18n("certificate expired"); case UserID::Signature::BadSignature: return i18nc("fake/invalid signature", "bad"); case UserID::Signature::NoPublicKey: { /* GnuPG returns the same error for no public key as for expired * or revoked certificates. */ const auto key = KeyCache::instance()->findByKeyIDOrFingerprint (sig.signerKeyID()); if (key.isNull()) { return i18n("no public key"); } else if (key.isExpired()) { return i18n("key expired"); } else if (key.isRevoked()) { return i18n("key revoked"); } else if (key.isDisabled()) { return i18n("key disabled"); } /* can't happen */ return QStringLiteral("unknown"); } } return QString(); } QIcon Formatting::validityIcon(const UserID::Signature &sig) { switch (sig.status()) { case UserID::Signature::NoError: if (!sig.isInvalid()) { /* See RFC 4880 Section 5.2.1 */ switch (sig.certClass()) { case 0x10: /* Generic */ case 0x11: /* Persona */ case 0x12: /* Casual */ case 0x13: /* Positive */ return QIcon::fromTheme(QStringLiteral("emblem-success")); case 0x30: return QIcon::fromTheme(QStringLiteral("emblem-error")); default: return QIcon(); } } Q_FALLTHROUGH(); // fall through: case UserID::Signature::BadSignature: case UserID::Signature::GeneralError: return QIcon::fromTheme(QStringLiteral("emblem-error")); case UserID::Signature::SigExpired: case UserID::Signature::KeyExpired: return QIcon::fromTheme(QStringLiteral("emblem-information")); case UserID::Signature::NoPublicKey: return QIcon::fromTheme(QStringLiteral("emblem-question")); } return QIcon(); } QString Formatting::formatKeyLink(const Key &key) { if (key.isNull()) { return QString(); } return QStringLiteral("%2").arg(QLatin1String(key.primaryFingerprint()), Formatting::prettyName(key)); } QString Formatting::formatForComboBox(const GpgME::Key &key) { const QString name = prettyName(key); QString mail = prettyEMail(key); if (!mail.isEmpty()) { mail = QLatin1Char('<') + mail + QLatin1Char('>'); } return i18nc("name, email, key id", "%1 %2 (%3)", name, mail, QLatin1String(key.shortKeyID())).simplified(); } namespace { static QString keyToString(const Key &key) { Q_ASSERT(!key.isNull()); const QString email = Formatting::prettyEMail(key); const QString name = Formatting::prettyName(key); if (name.isEmpty()) { return email; } else if (email.isEmpty()) { return name; } else { return QStringLiteral("%1 <%2>").arg(name, email); } } } const char *Formatting::summaryToString(const Signature::Summary summary) { if (summary & Signature::Red) { return "RED"; } if (summary & Signature::Green) { return "GREEN"; } return "YELLOW"; } QString Formatting::signatureToString(const Signature &sig, const Key &key) { if (sig.isNull()) { return QString(); } const bool red = (sig.summary() & Signature::Red); const bool valid = (sig.summary() & Signature::Valid); if (red) if (key.isNull()) if (const char *fpr = sig.fingerprint()) { return i18n("Bad signature by unknown certificate %1: %2", QString::fromLatin1(fpr), QString::fromLocal8Bit(sig.status().asString())); } else { return i18n("Bad signature by an unknown certificate: %1", QString::fromLocal8Bit(sig.status().asString())); } else { return i18n("Bad signature by %1: %2", keyToString(key), QString::fromLocal8Bit(sig.status().asString())); } else if (valid) if (key.isNull()) if (const char *fpr = sig.fingerprint()) { return i18n("Good signature by unknown certificate %1.", QString::fromLatin1(fpr)); } else { return i18n("Good signature by an unknown certificate."); } else { return i18n("Good signature by %1.", keyToString(key)); } else if (key.isNull()) if (const char *fpr = sig.fingerprint()) { return i18n("Invalid signature by unknown certificate %1: %2", QString::fromLatin1(fpr), QString::fromLocal8Bit(sig.status().asString())); } else { return i18n("Invalid signature by an unknown certificate: %1", QString::fromLocal8Bit(sig.status().asString())); } else { return i18n("Invalid signature by %1: %2", keyToString(key), QString::fromLocal8Bit(sig.status().asString())); } } // // ImportResult // QString Formatting::importMetaData(const Import &import, const QStringList &ids) { const QString result = importMetaData(import); if (result.isEmpty()) { return QString(); } else return result + QLatin1Char('\n') + i18n("This certificate was imported from the following sources:") + QLatin1Char('\n') + ids.join(QLatin1Char('\n')); } QString Formatting::importMetaData(const Import &import) { if (import.isNull()) { return QString(); } if (import.error().isCanceled()) { return i18n("The import of this certificate was canceled."); } if (import.error()) return i18n("An error occurred importing this certificate: %1", QString::fromLocal8Bit(import.error().asString())); const unsigned int status = import.status(); if (status & Import::NewKey) return (status & Import::ContainedSecretKey) ? i18n("This certificate was new to your keystore. The secret key is available.") : i18n("This certificate is new to your keystore."); QStringList results; if (status & Import::NewUserIDs) { results.push_back(i18n("New user-ids were added to this certificate by the import.")); } if (status & Import::NewSignatures) { results.push_back(i18n("New signatures were added to this certificate by the import.")); } if (status & Import::NewSubkeys) { results.push_back(i18n("New subkeys were added to this certificate by the import.")); } return results.empty() ? i18n("The import contained no new data for this certificate. It is unchanged.") : results.join(QLatin1Char('\n')); } // // Overview in CertificateDetailsDialog // QString Formatting::formatOverview(const Key &key) { return toolTip(key, AllOptions); } QString Formatting::usageString(const Subkey &sub) { QStringList usageStrings; if (sub.canCertify()) { usageStrings << i18n("Certify"); } if (sub.canSign()) { usageStrings << i18n("Sign"); } if (sub.canEncrypt()) { usageStrings << i18n("Encrypt"); } if (sub.canAuthenticate()) { usageStrings << i18n("Authenticate"); } return usageStrings.join(QLatin1String(", ")); } QString Formatting::summaryLine(const Key &key) { return keyToString(key) + QLatin1Char(' ') + i18nc("(validity, protocol, creation date)", "(%1, %2, created: %3)", Formatting::complianceStringShort(key), displayName(key.protocol()), Formatting::creationDateString(key)); } // Icon for certificate selection indication QIcon Formatting::iconForUid(const UserID &uid) { switch (uid.validity()) { case UserID::Ultimate: case UserID::Full: case UserID::Marginal: return QIcon::fromTheme(QStringLiteral("emblem-success")); case UserID::Never: return QIcon::fromTheme(QStringLiteral("emblem-error")); case UserID::Undefined: case UserID::Unknown: default: return QIcon::fromTheme(QStringLiteral("emblem-information")); } } QString Formatting::validity(const UserID &uid) { switch (uid.validity()) { case UserID::Ultimate: return i18n("The certificate is marked as your own."); case UserID::Full: return i18n("The certificate belongs to this recipient."); case UserID::Marginal: return i18n("The trust model indicates marginally that the certificate belongs to this recipient."); case UserID::Never: return i18n("This certificate should not be used."); case UserID::Undefined: case UserID::Unknown: default: return i18n("There is no indication that this certificate belongs to this recipient."); } } bool Formatting::uidsHaveFullValidity(const GpgME::Key &key) { bool oneValid = false; for (const auto &uid: key.userIDs()) { if (uid.isRevoked()) { /* Skip revoked uids */ continue; } if (uid.validity() < UserID::Validity::Full) { return false; } /* Only return true if we have found at least one * valid uid. E.g. if all uids are revoked we do * not want to return true here. */ oneValid = true; } return oneValid; } QString Formatting::complianceMode() { const QGpgME::CryptoConfig *const config = QGpgME::cryptoConfig(); if (!config) { return QString(); } const QGpgME::CryptoConfigEntry *const entry = config->entry(QStringLiteral("gpg"), QStringLiteral("Configuration"), QStringLiteral("compliance")); if (!entry || entry->stringValue() == QLatin1String("gnupg")) { return QString(); } return entry->stringValue(); } bool Formatting::isKeyDeVs(const GpgME::Key &key) { for (const auto &sub: key.subkeys()) { if (sub.isExpired() || sub.isRevoked()) { // Ignore old subkeys continue; } if (!sub.isDeVs()) { return false; } } return true; } QString Formatting::complianceStringForKey(const GpgME::Key &key) { // There will likely be more in the future for other institutions // for now we only have DE-VS if (complianceMode() == QLatin1String("de-vs")) { if (uidsHaveFullValidity(key) && isKeyDeVs(key)) { - 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 with that..", - "May be used for VS-NfD-compliant communication."); + 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()); } 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 not be used for VS-NfD-compliant communication."); + "May not be used for %1 communication.", deVsString()); } } return QString(); } QString Formatting::complianceStringShort(const GpgME::Key &key) { if (Formatting::uidsHaveFullValidity(key)) { if (complianceMode() == QLatin1String("de-vs") && Formatting::isKeyDeVs(key)) { - return QStringLiteral("★ ") + - i18nc("VS-NfD-conforming is a German standard for restricted documents for which special restrictions about algorithms apply. The string states that a key is compliant with that.", - "VS-NfD-compliant"); + return QStringLiteral("★ ") + deVsString(true); } return i18nc("As in all user IDs are valid.", "certified"); } if (key.isExpired()) { return i18n("expired"); } if (key.isRevoked()) { return i18n("revoked"); } if (key.isDisabled()) { return i18n("disabled"); } if (key.isInvalid()) { return i18n("invalid"); } return i18nc("As in not all user IDs are valid.", "not certified"); } QString Formatting::prettyID(const char *id) { if (!id) { return QString(); } QString ret = QString::fromLatin1(id).toUpper().replace(QRegularExpression(QStringLiteral("(....)")), QStringLiteral("\\1 ")).trimmed(); // For the standard 10 group fingerprint let us use a double space in the // middle to increase readability if (ret.size() == 49) { ret.insert(24, QLatin1Char(' ')); } return ret; } QString Formatting::origin(int o) { switch (o) { case Key::OriginKS: return i18n("Keyserver"); case Key::OriginDane: return QStringLiteral("DANE"); case Key::OriginWKD: return QStringLiteral("WKD"); case Key::OriginURL: return QStringLiteral("URL"); case Key::OriginFile: return i18n("File import"); case Key::OriginSelf: return i18n("Generated"); case Key::OriginOther: case Key::OriginUnknown: default: return i18n("Unknown"); } } + +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(); +} diff --git a/src/utils/formatting.h b/src/utils/formatting.h index 7169e18cf..3531fed82 100644 --- a/src/utils/formatting.h +++ b/src/utils/formatting.h @@ -1,167 +1,175 @@ /* -*- mode: c++; c-basic-offset:4 -*- utils/formatting.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2007 Klarälvdalens Datakonsult AB Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #ifndef __KLEOPATRA_UTILS_FORMATTING_H__ #define __KLEOPATRA_UTILS_FORMATTING_H__ #include #include class QString; class QStringList; class QDate; class QIcon; namespace GpgME { class Import; } namespace Kleo { namespace Formatting { KLEO_EXPORT QString prettyNameAndEMail(int proto, const char *id, const char *name, const char *email, const char *comment); KLEO_EXPORT QString prettyNameAndEMail(int proto, const QString &id, const QString &name, const QString &email, const QString &comment); KLEO_EXPORT QString prettyNameAndEMail(const GpgME::Key &key); KLEO_EXPORT QString prettyNameAndEMail(const GpgME::UserID &key); KLEO_EXPORT QString prettyUserID(const GpgME::UserID &uid); KLEO_EXPORT QString prettyKeyID(const char *id); KLEO_EXPORT QString prettyName(int proto, const char *id, const char *name, const char *comment); KLEO_EXPORT QString prettyName(const GpgME::Key &key); KLEO_EXPORT QString prettyName(const GpgME::UserID &uid); KLEO_EXPORT QString prettyName(const GpgME::UserID::Signature &sig); KLEO_EXPORT QString prettyEMail(const char *email, const char *id); KLEO_EXPORT QString prettyEMail(const GpgME::Key &key); KLEO_EXPORT QString prettyEMail(const GpgME::UserID &uid); KLEO_EXPORT QString prettyEMail(const GpgME::UserID::Signature &sig); /* Formats a fingerprint or keyid into groups of four */ KLEO_EXPORT QString prettyID(const char *id); enum ToolTipOption { KeyID = 0x001, Validity = 0x002, StorageLocation = 0x004, SerialNumber = 0x008, Issuer = 0x010, Subject = 0x020, ExpiryDates = 0x040, CertificateType = 0x080, CertificateUsage = 0x100, Fingerprint = 0x200, UserIDs = 0x400, OwnerTrust = 0x800, Subkeys = 0x1000, AllOptions = 0xffff }; KLEO_EXPORT QString toolTip(const GpgME::Key &key, int opts); KLEO_EXPORT QString expirationDateString(const GpgME::Key &key); KLEO_EXPORT QString expirationDateString(const GpgME::Subkey &subkey); KLEO_EXPORT QString expirationDateString(const GpgME::UserID::Signature &sig); KLEO_EXPORT QDate expirationDate(const GpgME::Key &key); KLEO_EXPORT QDate expirationDate(const GpgME::Subkey &subkey); KLEO_EXPORT QDate expirationDate(const GpgME::UserID::Signature &sig); KLEO_EXPORT QString creationDateString(const GpgME::Key &key); KLEO_EXPORT QString creationDateString(const GpgME::Subkey &subkey); KLEO_EXPORT QString creationDateString(const GpgME::UserID::Signature &sig); KLEO_EXPORT QDate creationDate(const GpgME::Key &key); KLEO_EXPORT QDate creationDate(const GpgME::Subkey &subkey); KLEO_EXPORT QDate creationDate(const GpgME::UserID::Signature &sig); /* Convert a GPGME style time to a localized string */ KLEO_EXPORT QString dateString(time_t t); KLEO_EXPORT QString displayName(GpgME::Protocol prot); KLEO_EXPORT QString type(const GpgME::Key &key); KLEO_EXPORT QString type(const GpgME::Subkey &subkey); KLEO_EXPORT QString ownerTrustShort(const GpgME::Key &key); KLEO_EXPORT QString ownerTrustShort(GpgME::Key::OwnerTrust trust); KLEO_EXPORT QString validityShort(const GpgME::Subkey &subkey); KLEO_EXPORT QString validityShort(const GpgME::UserID &uid); KLEO_EXPORT QString validityShort(const GpgME::UserID::Signature &sig); KLEO_EXPORT QIcon validityIcon(const GpgME::UserID::Signature &sig); /* A sentence about the validity of the UserID */ KLEO_EXPORT QString validity(const GpgME::UserID &uid); KLEO_EXPORT QString formatForComboBox(const GpgME::Key &key); KLEO_EXPORT QString formatKeyLink(const GpgME::Key &key); KLEO_EXPORT QString signatureToString(const GpgME::Signature &sig, const GpgME::Key &key); KLEO_EXPORT const char *summaryToString(const GpgME::Signature::Summary summary); KLEO_EXPORT QString importMetaData(const GpgME::Import &import); KLEO_EXPORT QString importMetaData(const GpgME::Import &import, const QStringList &sources); KLEO_EXPORT QString formatOverview(const GpgME::Key &key); KLEO_EXPORT QString usageString(const GpgME::Subkey &subkey); KLEO_EXPORT QString summaryLine(const GpgME::Key &key); KLEO_EXPORT QIcon iconForUid(const GpgME::UserID &uid); /* Is the key valid i.e. are all uids fully trusted? */ KLEO_EXPORT bool uidsHaveFullValidity(const GpgME::Key &key); /* The compliance mode of the gnupg system. Empty if compliance * mode is not set. */ KLEO_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 enviornments. E.g NATO RESTRICTED or + * EU RESTRICTED. */ +KLEO_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); /* A single word for use in keylists to describe the validity of the * given key, including any conformance statements relevant to the * current conformance mode. */ KLEO_EXPORT QString complianceStringShort(const GpgME::Key &key); /* The origin of the key mapped to a localized string */ KLEO_EXPORT QString origin(int o); } } #endif /* __KLEOPATRA_UTILS_FORMATTING_H__ */