diff --git a/CMakeLists.txt b/CMakeLists.txt index 8528583a4..5ce8a9b49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,204 +1,204 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) set(RELEASE_SERVICE_VERSION_MAJOR "22") set(RELEASE_SERVICE_VERSION_MINOR "03") set(RELEASE_SERVICE_VERSION_MICRO "70") # The RELEASE_SERVICE_VERSION is used by Gpg4win to add the Gpg4win version if (NOT RELEASE_SERVICE_VERSION) set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}") endif() if(RELEASE_SERVICE_VERSION_MICRO LESS 10) set(KDE_APPLICATIONS_COMPACT_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}${RELEASE_SERVICE_VERSION_MINOR}0${RELEASE_SERVICE_VERSION_MICRO}") else() set(KDE_APPLICATIONS_COMPACT_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}${RELEASE_SERVICE_VERSION_MINOR}${RELEASE_SERVICE_VERSION_MICRO}") endif() set(KLEOPATRA_VERSION_MAJOR "3") set(KLEOPATRA_VERSION_MINOR "1") set(KLEOPATRA_VERSION_MICRO "19") set(kleopatra_version "${KLEOPATRA_VERSION_MAJOR}.${KLEOPATRA_VERSION_MINOR}.${KLEOPATRA_VERSION_MICRO}.${KDE_APPLICATIONS_COMPACT_VERSION}") # The following is for Windows set(kleopatra_version_win "${KLEOPATRA_VERSION_MAJOR}.${KLEOPATRA_VERSION_MINOR}.${KLEOPATRA_VERSION_MICRO}") set(kleopatra_fileversion_win "${KLEOPATRA_VERSION_MAJOR},${KLEOPATRA_VERSION_MINOR},${KLEOPATRA_VERSION_MICRO},0") project(kleopatra VERSION ${kleopatra_version}) option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF) # Standalone build. Find / include everything necessary. set(KF5_MIN_VERSION "5.88.0") set(KMIME_VERSION "5.19.40") set(LIBKLEO_VERSION "5.19.42") set(QT_REQUIRED_VERSION "5.15.2") set(GPGME_REQUIRED_VERSION "1.13.1") set(BOOST_REQUIRED_VERSION "1.58") if (WIN32) set(KF5_WANT_VERSION "5.70.0") set(KMIME_WANT_VERSION "5.12.0") else () set(KF5_WANT_VERSION ${KF5_MIN_VERSION}) set(KMIME_WANT_VERSION ${KMIME_VERSION}) endif () find_package(ECM ${KF5_WANT_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddTests) include(GenerateExportHeader) include(ECMGenerateHeaders) include(FeatureSummary) include(CheckFunctionExists) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) # Find KF5 packages find_package(KF5WidgetsAddons ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5CoreAddons ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5I18n ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5IconThemes ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5ItemModels ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5WindowSystem ${KF5_WANT_VERSION} CONFIG REQUIRED) find_package(KF5DocTools ${KF5_WANT_VERSION} CONFIG) find_package(KF5Crash ${KF5_WANT_VERSION} REQUIRED) set_package_properties(KF5DocTools PROPERTIES DESCRIPTION "Documentation tools" PURPOSE "Required to generate Kleopatra documentation." TYPE OPTIONAL) # Optional packages if (WIN32) # Only a replacement available for Windows so this # is required on other platforms. find_package(KF5DBusAddons ${KF5_WANT_VERSION} CONFIG) set_package_properties(KF5DBusAddons PROPERTIES DESCRIPTION "Support library to work with DBus" PURPOSE "DBus session integration" URL "https://inqlude.org/libraries/kdbusaddons.html" TYPE OPTIONAL) else() find_package(KF5DBusAddons ${KF5_WANT_VERSION} CONFIG REQUIRED) set(_kleopatra_dbusaddons_libs KF5::DBusAddons) endif() set(HAVE_QDBUS ${Qt5DBus_FOUND}) find_package(Gpgmepp ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED) if (Gpgmepp_VERSION VERSION_GREATER_EQUAL "1.16.0") set(GPGMEPP_SUPPORTS_TRUST_SIGNATURES 1) endif() find_package(QGpgme ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED) if (QGpgme_VERSION VERSION_GREATER_EQUAL "1.16.0") set(QGPGME_SUPPORTS_TRUST_SIGNATURES 1) set(QGPGME_SUPPORTS_SIGNATURE_EXPIRATION 1) endif() if (QGpgme_VERSION VERSION_GREATER_EQUAL "1.16.1") set(QGPGME_SUPPORTS_CHANGING_EXPIRATION_OF_COMPLETE_KEY 1) set(QGPGME_CRYPTOCONFIGENTRY_HAS_DEFAULT_VALUE 1) endif() # Kdepimlibs packages find_package(KF5Libkleo ${LIBKLEO_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_WANT_VERSION} CONFIG REQUIRED) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport) find_package(Assuan2 REQUIRED) find_package(Boost ${BOOST_REQUIRED_VERSION} MODULE REQUIRED) find_path(Boost_TOPOLOGICAL_SORT_DIR NAMES boost/graph/topological_sort.hpp PATHS ${Boost_INCLUDE_DIRS}) if(NOT Boost_TOPOLOGICAL_SORT_DIR) message(FATAL_ERROR "The Boost Topological_sort header was NOT found. Should be part of Boost graph module.") endif() set(kleopatra_release FALSE) if(NOT kleopatra_release) find_package(Git) if(GIT_FOUND) execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE rc ERROR_QUIET) if(rc EQUAL 0) execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --oneline --format=%h ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE Kleopatra_WC_REVISION) string(REGEX REPLACE "\n" "" Kleopatra_WC_REVISION "${Kleopatra_WC_REVISION}") execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --oneline --format=%cI ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE Kleopatra_WC_LAST_CHANGED_DATE) string(REGEX REPLACE "^([0-9]+)-([0-9]+)-([0-9]+)T([0-9]+):([0-9]+):([0-9]+).*$" "\\1\\2\\3T\\4\\5\\6" Kleopatra_WC_LAST_CHANGED_DATE "${Kleopatra_WC_LAST_CHANGED_DATE}") set(kleopatra_version "${kleopatra_version}+git${Kleopatra_WC_LAST_CHANGED_DATE}~${Kleopatra_WC_REVISION}") endif() endif() endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version-kleopatra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version-kleopatra.h) include (ConfigureChecks.cmake) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-kleopatra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kleopatra.h) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIRS} ${ASSUAN2_INCLUDES} ) add_definitions(-D_ASSUAN_ONLY_GPG_ERRORS) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00) -add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055800) +add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055900) if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces -Wno-parentheses -Wno-ignored-qualifiers") endif() add_definitions(-DQT_NO_EMIT) remove_definitions(-DQT_NO_FOREACH) kde_enable_exceptions() option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" OFF) set(COMPILE_WITH_UNITY_CMAKE_SUPPORT OFF) if (USE_UNITY_CMAKE_SUPPORT) set(COMPILE_WITH_UNITY_CMAKE_SUPPORT ON) endif() add_subdirectory(pics) add_subdirectory(src) if(BUILD_TESTING) add_subdirectory(tests) add_subdirectory(autotests) endif() ecm_qt_install_logging_categories( EXPORT KLEOPATRA FILE kleopatra.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) ki18n_install(po) if(KF5DocTools_FOUND) kdoctools_install(po) add_subdirectory(doc) endif() feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/aboutdata.cpp b/src/aboutdata.cpp index 0f4c300aa..9d926901e 100644 --- a/src/aboutdata.cpp +++ b/src/aboutdata.cpp @@ -1,109 +1,131 @@ /* aboutdata.cpp This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2001, 2002, 2004 Klarälvdalens Datakonsult AB SPDX-License-Identifier: GPL-2.0-or-later */ #include #include #include "aboutdata.h" #include #include - +#include "ki18n_version.h" +#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0) +#include +#undef I18N_NOOP +#define I18N_NOOP kli18n +#endif static const char kleopatra_version[] = KLEOPATRA_VERSION_STRING; struct about_data { +#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0) const char *name; const char *desc; +#else + const KLazyLocalizedString name; + const KLazyLocalizedString desc; +#endif const char *email; const char *web; }; static const about_data authors[] = { - { "Andre Heinecke", I18N_NOOP("Current Maintainer"), "aheinecke@gnupg.org", nullptr }, - { "Marc Mutz", I18N_NOOP("Former Maintainer"), "mutz@kde.org", nullptr }, - { "Steffen Hansen", I18N_NOOP("Former Maintainer"), "hansen@kde.org", nullptr }, - { "Matthias Kalle Dalheimer", I18N_NOOP("Original Author"), "kalle@kde.org", nullptr }, + { I18N_NOOP("Andre Heinecke"), I18N_NOOP("Current Maintainer"), "aheinecke@gnupg.org", nullptr }, + { I18N_NOOP("Marc Mutz"), I18N_NOOP("Former Maintainer"), "mutz@kde.org", nullptr }, + { I18N_NOOP("Steffen Hansen"), I18N_NOOP("Former Maintainer"), "hansen@kde.org", nullptr }, + { I18N_NOOP("Matthias Kalle Dalheimer"), I18N_NOOP("Original Author"), "kalle@kde.org", nullptr }, }; static const about_data credits[] = { { I18N_NOOP("David Faure"), I18N_NOOP("Backend configuration framework, KIO integration"), "faure@kde.org", nullptr }, { I18N_NOOP("Michel Boyer de la Giroday"), I18N_NOOP("Key-state dependent colors and fonts in the certificates list"), "michel@klaralvdalens-datakonsult.se", nullptr }, { I18N_NOOP("Thomas Moenicke"), I18N_NOOP("Artwork"), "tm@php-qt.org", nullptr }, { I18N_NOOP("Frank Osterfeld"), I18N_NOOP("Resident gpgme/win wrangler, UI Server commands and dialogs"), "osterfeld@kde.org", nullptr }, { I18N_NOOP("Karl-Heinz Zimmer"), I18N_NOOP("DN display ordering support, infrastructure"), "khz@kde.org", nullptr }, { I18N_NOOP("Laurent Montel"), I18N_NOOP("Qt5 port, general code maintenance"), "montel@kde.org", nullptr }, }; AboutData::AboutData() : KAboutData(QStringLiteral("kleopatra"), i18n("Kleopatra"), #ifdef Q_OS_WIN Kleo::gpg4winVersion(), Kleo::gpg4winDescription(), #else QLatin1String(kleopatra_version), i18n("Certificate Manager and Unified Crypto GUI"), #endif KAboutLicense::GPL, i18n("(c) 2002 Steffen\u00A0Hansen, Matthias\u00A0Kalle\u00A0" "Dalheimer, Klar\u00E4lvdalens\u00A0" "Datakonsult\u00A0" "AB\n" "(c) 2004, 2007, 2008, 2009 Marc\u00A0Mutz, Klar\u00E4lvdalens\u00A0" "Datakonsult\u00A0" "AB") + QLatin1Char('\n') + i18n("(c) 2010-2021 The Kleopatra developers, g10 Code GmbH, Intevation GmbH") #ifdef Q_OS_WIN , Kleo::gpg4winLongDescription() #endif ) { using ::authors; using ::credits; +#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0) for (unsigned int i = 0; i < sizeof authors / sizeof * authors; ++i) { addAuthor(i18n(authors[i].name), i18n(authors[i].desc), QLatin1String(authors[i].email), QLatin1String(authors[i].web)); } for (unsigned int i = 0; i < sizeof credits / sizeof * credits; ++i) { addCredit(i18n(credits[i].name), i18n(credits[i].desc), QLatin1String(credits[i].email), QLatin1String(credits[i].web)); } +#else + for (unsigned int i = 0; i < sizeof authors / sizeof * authors; ++i) { + addAuthor(KLocalizedString(authors[i].name).toString(), KLocalizedString(authors[i].desc).toString(), + QLatin1String(authors[i].email), QLatin1String(authors[i].web)); + } + for (unsigned int i = 0; i < sizeof credits / sizeof * credits; ++i) { + addCredit(KLocalizedString(credits[i].name).toString(), KLocalizedString(credits[i].desc).toString(), + QLatin1String(credits[i].email), QLatin1String(credits[i].web)); + } +#endif + const auto backendVersions = Kleo::backendVersionInfo(); if (!backendVersions.empty()) { setOtherText(i18nc("Preceeds a list of applications/libraries used by Kleopatra", "Uses:") + QLatin1String{"
  • "} + backendVersions.join(QLatin1String{"
  • "}) + QLatin1String{"
"} + otherText()); } #ifdef Q_OS_WIN setBugAddress("https://dev.gnupg.org/u/rgpg4win"); #endif } diff --git a/src/commands/deletecertificatescommand.cpp b/src/commands/deletecertificatescommand.cpp index 3e8763206..f6948ee1f 100644 --- a/src/commands/deletecertificatescommand.cpp +++ b/src/commands/deletecertificatescommand.cpp @@ -1,429 +1,450 @@ /* -*- mode: c++; c-basic-offset:4 -*- deleteCertificatescommand.cpp This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB SPDX-License-Identifier: GPL-2.0-or-later */ #include #include "deletecertificatescommand.h" #include "command_p.h" #include #include #include #include #include #include #include #include #include #include #include #include #include - +#include "ki18n_version.h" +#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0) +#include +#undef I18N_NOOP +#define I18N_NOOP kli18n +#define I18N_NOOP_EMPTY KLazyLocalizedString() +#else +#define I18N_NOOP_EMPTY "" +#endif using namespace GpgME; using namespace Kleo; using namespace Kleo::Dialogs; using namespace QGpgME; class DeleteCertificatesCommand::Private : public Command::Private { friend class ::Kleo::DeleteCertificatesCommand; DeleteCertificatesCommand *q_func() const { return static_cast(q); } public: explicit Private(DeleteCertificatesCommand *qq, KeyListController *c); ~Private() override; void startDeleteJob(GpgME::Protocol protocol); void cancelJobs(); void pgpDeleteResult(const GpgME::Error &); void cmsDeleteResult(const GpgME::Error &); void showErrorsAndFinish(); bool canDelete(GpgME::Protocol proto) const { if (const auto cbp = (proto == GpgME::OpenPGP ? QGpgME::openpgp() : QGpgME::smime())) if (DeleteJob *const job = cbp->deleteJob()) { job->slotCancel(); return true; } return false; } void ensureDialogCreated() { if (dialog) { return; } dialog = new DeleteCertificatesDialog; applyWindowID(dialog); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setWindowTitle(i18nc("@title:window", "Delete Certificates")); connect(dialog, SIGNAL(accepted()), q_func(), SLOT(slotDialogAccepted())); connect(dialog, SIGNAL(rejected()), q_func(), SLOT(slotDialogRejected())); } void ensureDialogShown() { if (dialog) { dialog->show(); } } void slotDialogAccepted(); void slotDialogRejected() { canceled(); } private: QPointer dialog; QPointer cmsJob, pgpJob; GpgME::Error cmsError, pgpError; std::vector cmsKeys, pgpKeys; }; DeleteCertificatesCommand::Private *DeleteCertificatesCommand::d_func() { return static_cast(d.get()); } const DeleteCertificatesCommand::Private *DeleteCertificatesCommand::d_func() const { return static_cast(d.get()); } #define d d_func() #define q q_func() DeleteCertificatesCommand::Private::Private(DeleteCertificatesCommand *qq, KeyListController *c) : Command::Private(qq, c) { } DeleteCertificatesCommand::Private::~Private() {} DeleteCertificatesCommand::DeleteCertificatesCommand(KeyListController *p) : Command(new Private(this, p)) { } DeleteCertificatesCommand::DeleteCertificatesCommand(QAbstractItemView *v, KeyListController *p) : Command(v, new Private(this, p)) { } DeleteCertificatesCommand::~DeleteCertificatesCommand() {} namespace { enum Action { Nothing = 0, Failure = 1, ClearCMS = 2, ClearPGP = 4 }; // const unsigned int errorCase = // openpgp.empty() << 3U | d->canDelete( OpenPGP ) << 2U | // cms.empty() << 1U | d->canDelete( CMS ) << 0U ; static const struct { +#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0) const char *text; +#else + const KLazyLocalizedString text; +#endif Action actions; } deletionErrorCases[16] = { // if havePGP // if cantPGP // if haveCMS { I18N_NOOP("Neither the OpenPGP nor the CMS " "backends support certificate deletion.\n" "Check your installation."), Failure }, // cantCMS { I18N_NOOP("The OpenPGP backend does not support " "certificate deletion.\n" "Check your installation.\n" "Only the selected CMS certificates " "will be deleted."), ClearPGP }, // canCMS // if !haveCMS { I18N_NOOP("The OpenPGP backend does not support " "certificate deletion.\n" "Check your installation."), Failure }, { I18N_NOOP("The OpenPGP backend does not support " "certificate deletion.\n" "Check your installation."), Failure }, // if canPGP // if haveCMS { I18N_NOOP("The CMS backend does not support " "certificate deletion.\n" "Check your installation.\n" "Only the selected OpenPGP certificates " "will be deleted."), ClearCMS }, // cantCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // canCMS // if !haveCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // cantCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // canCMS // if !havePGP // if cantPGP // if haveCMS { I18N_NOOP("The CMS backend does not support " "certificate deletion.\n" "Check your installation."), Failure }, // cantCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // canCMS // if !haveCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // cantCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // canCMS // if canPGP // if haveCMS { I18N_NOOP("The CMS backend does not support " "certificate deletion.\n" "Check your installation."), Failure }, // cantCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // canCMS // if !haveCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // cantCMS { - nullptr, + I18N_NOOP_EMPTY, Nothing }, // canCMS }; } // anon namespace void DeleteCertificatesCommand::doStart() { std::vector selected = d->keys(); if (selected.empty()) { d->finished(); return; } std::sort(selected.begin(), selected.end(), _detail::ByFingerprint()); // Calculate the closure of the selected keys (those that need to // be deleted with them, though not selected themselves): std::vector toBeDeleted = KeyCache::instance()->findSubjects(selected); std::sort(toBeDeleted.begin(), toBeDeleted.end(), _detail::ByFingerprint()); std::vector unselected; unselected.reserve(toBeDeleted.size()); std::set_difference(toBeDeleted.begin(), toBeDeleted.end(), selected.begin(), selected.end(), std::back_inserter(unselected), _detail::ByFingerprint()); d->ensureDialogCreated(); d->dialog->setSelectedKeys(selected); d->dialog->setUnselectedKeys(unselected); d->ensureDialogShown(); } void DeleteCertificatesCommand::Private::slotDialogAccepted() { std::vector keys = dialog->keys(); Q_ASSERT(!keys.empty()); auto pgpBegin = keys.begin(); auto pgpEnd = std::stable_partition(pgpBegin, keys.end(), [](const GpgME::Key &key) { return key.protocol() != GpgME::CMS; }); auto cmsBegin = pgpEnd; auto cmsEnd = keys.end(); std::vector openpgp(pgpBegin, pgpEnd); std::vector cms(cmsBegin, cmsEnd); const unsigned int errorCase = openpgp.empty() << 3U | canDelete(OpenPGP) << 2U | cms.empty() << 1U | canDelete(CMS) << 0U; if (const unsigned int actions = deletionErrorCases[errorCase].actions) { +#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0) information(i18n(deletionErrorCases[errorCase].text), (actions & Failure) - ? i18n("Certificate Deletion Failed") - : i18n("Certificate Deletion Problem")); + ? i18n("Certificate Deletion Failed") + : i18n("Certificate Deletion Problem")); +#else + information(KLocalizedString(deletionErrorCases[errorCase].text).toString(), + (actions & Failure) + ? i18n("Certificate Deletion Failed") + : i18n("Certificate Deletion Problem")); +#endif + + if (actions & ClearCMS) { cms.clear(); } if (actions & ClearPGP) { openpgp.clear(); } if (actions & Failure) { canceled(); return; } } Q_ASSERT(!openpgp.empty() || !cms.empty()); pgpKeys.swap(openpgp); cmsKeys.swap(cms); if (!pgpKeys.empty()) { startDeleteJob(GpgME::OpenPGP); } if (!cmsKeys.empty()) { startDeleteJob(GpgME::CMS); } if ((pgpKeys.empty() || pgpError.code()) && (cmsKeys.empty() || cmsError.code())) { showErrorsAndFinish(); } } void DeleteCertificatesCommand::Private::startDeleteJob(GpgME::Protocol protocol) { Q_ASSERT(protocol != GpgME::UnknownProtocol); const std::vector &keys = protocol == CMS ? cmsKeys : pgpKeys; const auto backend = (protocol == GpgME::OpenPGP) ? QGpgME::openpgp() : QGpgME::smime(); Q_ASSERT(backend); std::unique_ptr job(new MultiDeleteJob(backend)); if (protocol == CMS) connect(job.get(), SIGNAL(result(GpgME::Error,GpgME::Key)), q_func(), SLOT(cmsDeleteResult(GpgME::Error))); else connect(job.get(), SIGNAL(result(GpgME::Error,GpgME::Key)), q_func(), SLOT(pgpDeleteResult(GpgME::Error))); connect(job.get(), &Job::progress, q, &Command::progress); if (const Error err = job->start(keys, true /*allowSecretKeyDeletion*/)) { (protocol == CMS ? cmsError : pgpError) = err; } else { (protocol == CMS ? cmsJob : pgpJob) = job.release(); } } void DeleteCertificatesCommand::Private::showErrorsAndFinish() { Q_ASSERT(!pgpJob); Q_ASSERT(!cmsJob); if (pgpError || cmsError) { QString pgpErrorString; if (pgpError) { pgpErrorString = i18n("OpenPGP backend: %1", QString::fromLocal8Bit(pgpError.asString())); } QString cmsErrorString; if (cmsError) { cmsErrorString = i18n("CMS backend: %1", QString::fromLocal8Bit(cmsError.asString())); } const QString msg = i18n("

An error occurred while trying to delete " "the certificate:

" "

%1

", pgpError ? cmsError ? pgpErrorString + QLatin1String("
") + cmsErrorString : pgpErrorString : cmsErrorString); error(msg, i18n("Certificate Deletion Failed")); } else if (!pgpError.isCanceled() && !cmsError.isCanceled()) { std::vector keys = pgpKeys; keys.insert(keys.end(), cmsKeys.begin(), cmsKeys.end()); KeyCache::mutableInstance()->remove(keys); } finished(); } void DeleteCertificatesCommand::doCancel() { d->cancelJobs(); } void DeleteCertificatesCommand::Private::pgpDeleteResult(const Error &err) { pgpError = err; pgpJob = nullptr; if (!cmsJob) { showErrorsAndFinish(); } } void DeleteCertificatesCommand::Private::cmsDeleteResult(const Error &err) { cmsError = err; cmsJob = nullptr; if (!pgpJob) { showErrorsAndFinish(); } } void DeleteCertificatesCommand::Private::cancelJobs() { if (cmsJob) { cmsJob->slotCancel(); } if (pgpJob) { pgpJob->slotCancel(); } } #undef d #undef q #include "moc_deletecertificatescommand.cpp" diff --git a/src/kwatchgnupg/aboutdata.cpp b/src/kwatchgnupg/aboutdata.cpp index 4bfb4a63c..8b6c4eaff 100644 --- a/src/kwatchgnupg/aboutdata.cpp +++ b/src/kwatchgnupg/aboutdata.cpp @@ -1,37 +1,54 @@ /* aboutdata.cpp This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2004 Klarälvdalens Datakonsult AB SPDX-License-Identifier: GPL-2.0-or-later */ #include #include "aboutdata.h" #include +#include "ki18n_version.h" +#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0) +#include +#undef I18N_NOOP +#define I18N_NOOP kli18n +#endif struct about_data { +#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0) const char *name; const char *desc; +#else + const KLazyLocalizedString name; + const KLazyLocalizedString desc; +#endif const char *email; const char *web; }; static const about_data authors[] = { { I18N_NOOP("Steffen Hansen"), I18N_NOOP("Original Author"), "hansen@kde.org", nullptr }, }; AboutData::AboutData() : KAboutData(QStringLiteral("kwatchgnupg"), i18n("KWatchGnuPG"), QStringLiteral(KWATCHGNUPG_VERSION_STRING), i18n("GnuPG log viewer"), KAboutLicense::GPL, i18n("(c) 2004 Klar\xC3\xA4lvdalens Datakonsult AB\n")) { using ::authors; //using ::credits; - for (unsigned int i = 0; i < sizeof authors / sizeof * authors; ++i) + for (unsigned int i = 0; i < sizeof authors / sizeof * authors; ++i) { +#if KI18N_VERSION < QT_VERSION_CHECK(5, 89, 0) addAuthor(i18n(authors[i].name), i18n(authors[i].desc), QLatin1String(authors[i].email), QLatin1String(authors[i].web)); +#else + addAuthor(KLocalizedString(authors[i].name).toString(), KLocalizedString(authors[i].desc).toString(), + QLatin1String(authors[i].email), QLatin1String(authors[i].web)); +#endif + } }