diff --git a/CMakeLists.txt b/CMakeLists.txt index 0484a3a0d..e9cf9bdf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,219 +1,219 @@ # SPDX-FileCopyrightText: none # SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16 FATAL_ERROR) set(RELEASE_SERVICE_VERSION_MAJOR "22") set(RELEASE_SERVICE_VERSION_MINOR "07") 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 "21") 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.92.0") set(KMIME_VERSION "5.20.40") -set(LIBKLEO_VERSION "5.20.40") +set(LIBKLEO_VERSION "5.20.41") set(QT_REQUIRED_VERSION "5.15.2") set(GPGME_REQUIRED_VERSION "1.15.0") 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) include(ECMDeprecationSettings) # 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 ${Qt${QT_MAJOR_VERSION}DBus_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.17.0") set(QGPGME_SUPPORTS_CHANGING_EXPIRATION_OF_COMPLETE_KEY 1) set(QGPGME_CRYPTOCONFIGENTRY_HAS_DEFAULT_VALUE 1) set(QGPGME_SUPPORTS_WKDLOOKUP 1) set(QGPGME_SUPPORTS_IMPORT_WITH_FILTER 1) set(QGPGME_SUPPORTS_IMPORT_WITH_KEY_ORIGIN 1) set(QGPGME_SUPPORTS_SECRET_KEY_EXPORT 1) set(QGPGME_SUPPORTS_SECRET_SUBKEY_EXPORT 1) set(QGPGME_SUPPORTS_RECEIVING_KEYS_BY_KEY_ID 1) endif() if (QGpgme_VERSION VERSION_GREATER_EQUAL "1.17.2") set(QGPGME_SUPPORTS_KEY_REVOCATION 1) endif() # Kdepimlibs packages find_package(KF5Libkleo ${LIBKLEO_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_WANT_VERSION} CONFIG REQUIRED) find_package(Qt${QT_MAJOR_VERSION} ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport) find_package(Assuan2 REQUIRED) 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} ${ASSUAN2_INCLUDES} ) add_definitions(-D_ASSUAN_ONLY_GPG_ERRORS) ecm_set_disabled_deprecation_versions(QT 5.14.0 KF 5.93.0) 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) # Disable the use of QStringBuilder for operator+ to prevent crashes when # returning the result of concatenating string temporaries in lambdas. We do # this for example in some std::transform expressions. # This is a known issue: https://bugreports.qt.io/browse/QTBUG-47066 # Alternatively, one would always have to remember to force the lambdas to # return a QString instead of QStringBuilder, but that's just too easy to # forget and, unfortunately, the compiler doesn't issue a warning if one forgets # this. So, it's just too dangerous. # One can still use QStringBuilder explicitly with the operator% if necessary. remove_definitions(-DQT_USE_FAST_OPERATOR_PLUS) remove_definitions(-DQT_USE_QSTRINGBUILDER) 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/CMakeLists.txt b/src/CMakeLists.txt index 9d2cfe274..3b0be5f68 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,391 +1,390 @@ # SPDX-FileCopyrightText: none # SPDX-License-Identifier: BSD-3-Clause add_subdirectory(icons) add_subdirectory(mimetypes) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) if (NOT DISABLE_KWATCHGNUPG) add_subdirectory(kwatchgnupg) endif() add_subdirectory(libkleopatraclient) add_subdirectory(conf) add_subdirectory(kconf_update) if(WIN32) set(_kleopatra_extra_uiserver_SRCS uiserver/uiserver_win.cpp) set(_kleopatra_extra_SRCS utils/gnupg-registry.c selftest/registrycheck.cpp utils/windowsprocessdevice.cpp utils/userinfo_win.cpp ) else() set(_kleopatra_extra_uiserver_SRCS uiserver/uiserver_unix.cpp) set(_kleopatra_extra_SRCS) endif() set(_kleopatra_uiserver_SRCS uiserver/sessiondata.cpp uiserver/uiserver.cpp ${_kleopatra_extra_uiserver_SRCS} uiserver/assuanserverconnection.cpp uiserver/echocommand.cpp uiserver/decryptverifycommandemailbase.cpp uiserver/decryptverifycommandfilesbase.cpp uiserver/signcommand.cpp uiserver/signencryptfilescommand.cpp uiserver/prepencryptcommand.cpp uiserver/prepsigncommand.cpp uiserver/encryptcommand.cpp uiserver/selectcertificatecommand.cpp uiserver/importfilescommand.cpp uiserver/createchecksumscommand.cpp uiserver/verifychecksumscommand.cpp selftest/uiservercheck.cpp ) if(ASSUAN2_FOUND) include_directories(${ASSUAN2_INCLUDES}) set(_kleopatra_uiserver_extra_libs ${ASSUAN2_LIBRARIES}) else() include_directories(${ASSUAN_INCLUDES}) if(WIN32) set(_kleopatra_uiserver_extra_libs ${ASSUAN_VANILLA_LIBRARIES}) else() set(_kleopatra_uiserver_extra_libs ${ASSUAN_PTHREAD_LIBRARIES}) endif() endif() if(HAVE_GPG_ERR_SOURCE_KLEO) add_definitions(-DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_KLEO) add_definitions(-DGPGMEPP_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_KLEO) else() add_definitions(-DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_USER_1) add_definitions(-DGPGMEPP_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_USER_1) endif() ki18n_wrap_ui(_kleopatra_uiserver_SRCS crypto/gui/signingcertificateselectionwidget.ui) set(_kleopatra_SRCS utils/gui-helper.cpp utils/filedialog.cpp utils/kdpipeiodevice.cpp utils/headerview.cpp utils/scrollarea.cpp utils/dragqueen.cpp utils/multivalidator.cpp utils/systemtrayicon.cpp utils/path-helper.cpp utils/input.cpp utils/output.cpp utils/validation.cpp utils/wsastarter.cpp utils/iodevicelogger.cpp utils/log.cpp utils/action_data.cpp utils/types.cpp utils/archivedefinition.cpp utils/auditlog.cpp utils/clipboardmenu.cpp utils/kuniqueservice.cpp utils/tags.cpp utils/writecertassuantransaction.cpp utils/keyparameters.cpp utils/userinfo.cpp selftest/selftest.cpp selftest/enginecheck.cpp selftest/gpgconfcheck.cpp selftest/gpgagentcheck.cpp selftest/libkleopatrarccheck.cpp selftest/compliancecheck.cpp ${_kleopatra_extra_SRCS} view/errorlabel.cpp view/htmllabel.cpp view/keylistcontroller.cpp view/keytreeview.cpp view/searchbar.cpp view/smartcardwidget.cpp view/openpgpkeycardwidget.cpp view/padwidget.cpp view/pgpcardwidget.cpp view/pivcardwidget.cpp view/p15cardwidget.cpp view/netkeywidget.cpp view/nullpinwidget.cpp view/tabwidget.cpp view/keycacheoverlay.cpp view/urllabel.cpp view/waitwidget.cpp view/welcomewidget.cpp dialogs/certificateselectiondialog.cpp dialogs/certifywidget.cpp dialogs/expirydialog.cpp dialogs/lookupcertificatesdialog.cpp dialogs/ownertrustdialog.cpp dialogs/selftestdialog.cpp dialogs/certifycertificatedialog.cpp dialogs/revokecertificationwidget.cpp dialogs/revokecertificationdialog.cpp dialogs/adduseriddialog.cpp dialogs/deletecertificatesdialog.cpp dialogs/setinitialpindialog.cpp dialogs/certificatedetailsdialog.cpp dialogs/certificatedetailswidget.cpp dialogs/trustchainwidget.cpp dialogs/weboftrustwidget.cpp dialogs/weboftrustdialog.cpp dialogs/exportdialog.cpp dialogs/subkeyswidget.cpp dialogs/gencardkeydialog.cpp dialogs/updatenotification.cpp dialogs/pivcardapplicationadministrationkeyinputdialog.cpp dialogs/certificatedetailsinputwidget.cpp dialogs/createcsrforcardkeydialog.cpp dialogs/groupdetailsdialog.cpp dialogs/editgroupdialog.cpp dialogs/revokekeydialog.cpp crypto/controller.cpp crypto/certificateresolver.cpp crypto/sender.cpp crypto/recipient.cpp crypto/task.cpp crypto/taskcollection.cpp crypto/decryptverifytask.cpp crypto/decryptverifyemailcontroller.cpp crypto/decryptverifyfilescontroller.cpp crypto/autodecryptverifyfilescontroller.cpp crypto/encryptemailtask.cpp crypto/encryptemailcontroller.cpp crypto/newsignencryptemailcontroller.cpp crypto/signencrypttask.cpp crypto/signencryptfilescontroller.cpp crypto/signemailtask.cpp crypto/signemailcontroller.cpp crypto/createchecksumscontroller.cpp crypto/verifychecksumscontroller.cpp crypto/gui/wizard.cpp crypto/gui/wizardpage.cpp crypto/gui/certificateselectionline.cpp crypto/gui/certificatelineedit.cpp crypto/gui/signingcertificateselectionwidget.cpp crypto/gui/signingcertificateselectiondialog.cpp crypto/gui/resultitemwidget.cpp crypto/gui/resultlistwidget.cpp crypto/gui/resultpage.cpp crypto/gui/newresultpage.cpp crypto/gui/signencryptfileswizard.cpp crypto/gui/signencryptemailconflictdialog.cpp crypto/gui/decryptverifyoperationwidget.cpp crypto/gui/decryptverifyfileswizard.cpp crypto/gui/decryptverifyfilesdialog.cpp crypto/gui/objectspage.cpp crypto/gui/resolverecipientspage.cpp crypto/gui/signerresolvepage.cpp crypto/gui/encryptemailwizard.cpp crypto/gui/signemailwizard.cpp crypto/gui/signencryptwidget.cpp crypto/gui/signencryptwizard.cpp crypto/gui/unknownrecipientwidget.cpp crypto/gui/verifychecksumsdialog.cpp commands/command.cpp commands/gnupgprocesscommand.cpp commands/detailscommand.cpp commands/exportcertificatecommand.cpp commands/exportgroupscommand.cpp commands/importcertificatescommand.cpp commands/importcertificatefromfilecommand.cpp commands/importcertificatefromclipboardcommand.cpp commands/importcertificatefromdatacommand.cpp commands/importcertificatefromkeyservercommand.cpp commands/lookupcertificatescommand.cpp commands/reloadkeyscommand.cpp commands/refreshx509certscommand.cpp commands/refreshopenpgpcertscommand.cpp commands/deletecertificatescommand.cpp commands/decryptverifyfilescommand.cpp commands/signencryptfilescommand.cpp commands/signencryptfoldercommand.cpp commands/encryptclipboardcommand.cpp commands/signclipboardcommand.cpp commands/decryptverifyclipboardcommand.cpp commands/clearcrlcachecommand.cpp commands/dumpcrlcachecommand.cpp commands/dumpcertificatecommand.cpp commands/importcrlcommand.cpp commands/changeexpirycommand.cpp commands/changeownertrustcommand.cpp commands/changeroottrustcommand.cpp commands/changepassphrasecommand.cpp commands/certifycertificatecommand.cpp commands/revokecertificationcommand.cpp commands/selftestcommand.cpp commands/exportsecretkeycommand.cpp commands/exportsecretkeycommand_old.cpp commands/exportsecretsubkeycommand.cpp commands/exportopenpgpcertstoservercommand.cpp commands/adduseridcommand.cpp commands/newcertificatecommand.cpp commands/setinitialpincommand.cpp commands/learncardkeyscommand.cpp commands/checksumcreatefilescommand.cpp commands/checksumverifyfilescommand.cpp commands/exportpaperkeycommand.cpp commands/importpaperkeycommand.cpp commands/genrevokecommand.cpp commands/keytocardcommand.cpp commands/cardcommand.cpp commands/pivgeneratecardkeycommand.cpp commands/changepincommand.cpp commands/authenticatepivcardapplicationcommand.cpp commands/setpivcardapplicationadministrationkeycommand.cpp commands/certificatetopivcardcommand.cpp commands/importcertificatefrompivcardcommand.cpp commands/createopenpgpkeyfromcardkeyscommand.cpp commands/createcsrforcardkeycommand.cpp commands/revokekeycommand.cpp ${_kleopatra_uiserver_files} conf/configuredialog.cpp conf/groupsconfigdialog.cpp conf/groupsconfigpage.cpp conf/groupsconfigwidget.cpp newcertificatewizard/listwidget.cpp newcertificatewizard/newcertificatewizard.cpp smartcard/readerstatus.cpp smartcard/card.cpp smartcard/openpgpcard.cpp smartcard/netkeycard.cpp smartcard/pivcard.cpp smartcard/p15card.cpp smartcard/keypairinfo.cpp smartcard/utils.cpp smartcard/deviceinfowatcher.cpp accessibility/accessiblerichtextlabel.cpp accessibility/accessiblewidgetfactory.cpp aboutdata.cpp systrayicon.cpp kleopatraapplication.cpp mainwindow.cpp main.cpp kleopatra.qrc ) if(WIN32) configure_file (versioninfo.rc.in versioninfo.rc) set(_kleopatra_SRCS ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc ${_kleopatra_SRCS}) endif() set (_kleopatra_SRCS conf/kleopageconfigdialog.cpp ${_kleopatra_SRCS}) ecm_qt_declare_logging_category(_kleopatra_SRCS HEADER kleopatra_debug.h IDENTIFIER KLEOPATRA_LOG CATEGORY_NAME org.kde.pim.kleopatra DESCRIPTION "kleopatra (kleopatra)" OLD_CATEGORY_NAMES log_kleopatra EXPORT KLEOPATRA ) if(KLEO_MODEL_TEST) add_definitions(-DKLEO_MODEL_TEST) set(_kleopatra_SRCS ${_kleopatra_SRCS} models/modeltest.cpp) endif() ki18n_wrap_ui(_kleopatra_SRCS dialogs/ownertrustdialog.ui dialogs/selectchecklevelwidget.ui dialogs/selftestdialog.ui - dialogs/adduseriddialog.ui dialogs/setinitialpindialog.ui dialogs/trustchainwidget.ui dialogs/subkeyswidget.ui newcertificatewizard/listwidget.ui newcertificatewizard/chooseprotocolpage.ui newcertificatewizard/enterdetailspage.ui newcertificatewizard/keycreationpage.ui newcertificatewizard/resultpage.ui newcertificatewizard/advancedsettingsdialog.ui ) kconfig_add_kcfg_files(_kleopatra_SRCS kcfg/tooltippreferences.kcfgc kcfg/emailoperationspreferences.kcfgc kcfg/fileoperationspreferences.kcfgc kcfg/smimevalidationpreferences.kcfgc kcfg/tagspreferences.kcfgc kcfg/settings.kcfgc ) file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/*-apps-kleopatra.png") ecm_add_app_icon(_kleopatra_SRCS ICONS ${ICONS_SRCS}) add_executable(kleopatra_bin ${_kleopatra_SRCS} ${_kleopatra_uiserver_SRCS}) # For the ConfigureDialog & KCMs target_link_libraries(kleopatra_bin kcm_kleopatra_static) #if (COMPILE_WITH_UNITY_CMAKE_SUPPORT) # set_target_properties(kleopatra_bin PROPERTIES UNITY_BUILD ON) #endif() set_target_properties(kleopatra_bin PROPERTIES OUTPUT_NAME kleopatra) if (WIN32) set(_kleopatra_platform_libs "secur32") endif () target_link_libraries(kleopatra_bin Gpgmepp QGpgme ${_kleopatra_extra_libs} KF5::Libkleo KF5::Mime KF5::I18n KF5::XmlGui KF5::IconThemes KF5::WindowSystem KF5::CoreAddons KF5::ItemModels KF5::Crash Qt${QT_MAJOR_VERSION}::Network Qt${QT_MAJOR_VERSION}::PrintSupport # Printing secret keys ${_kleopatra_uiserver_extra_libs} ${_kleopatra_dbusaddons_libs} kleopatraclientcore ${_kleopatra_platform_libs} ) install(TARGETS kleopatra_bin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install( PROGRAMS data/org.kde.kleopatra.desktop data/kleopatra_import.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) install(FILES data/org.kde.kleopatra.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) install( PROGRAMS data/kleopatra_signencryptfiles.desktop data/kleopatra_signencryptfolders.desktop data/kleopatra_decryptverifyfiles.desktop data/kleopatra_decryptverifyfolders.desktop DESTINATION ${KDE_INSTALL_DATADIR}/kio/servicemenus ) diff --git a/src/commands/adduseridcommand.cpp b/src/commands/adduseridcommand.cpp index 9c40738c3..6e8e62e1b 100644 --- a/src/commands/adduseridcommand.cpp +++ b/src/commands/adduseridcommand.cpp @@ -1,238 +1,236 @@ /* -*- mode: c++; c-basic-offset:4 -*- commands/adduseridcommand.cpp This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB SPDX-License-Identifier: GPL-2.0-or-later */ #include #include "adduseridcommand.h" #include "command_p.h" #include "dialogs/adduseriddialog.h" #include #include #include #include #include #include "kleopatra_debug.h" using namespace Kleo; using namespace Kleo::Commands; -using namespace Kleo::Dialogs; using namespace GpgME; class AddUserIDCommand::Private : public Command::Private { friend class ::Kleo::Commands::AddUserIDCommand; AddUserIDCommand *q_func() const { return static_cast(q); } public: explicit Private(AddUserIDCommand *qq, KeyListController *c); ~Private() override; void init(); private: void slotDialogAccepted(); void slotDialogRejected(); void slotResult(const Error &err); private: void ensureDialogCreated(); void createJob(); void showErrorDialog(const Error &error); void showSuccessDialog(); private: GpgME::Key key; QPointer dialog; QPointer job; }; AddUserIDCommand::Private *AddUserIDCommand::d_func() { return static_cast(d.get()); } const AddUserIDCommand::Private *AddUserIDCommand::d_func() const { return static_cast(d.get()); } #define d d_func() #define q q_func() AddUserIDCommand::Private::Private(AddUserIDCommand *qq, KeyListController *c) : Command::Private(qq, c), key(), dialog(), job() { } AddUserIDCommand::Private::~Private() { qCDebug(KLEOPATRA_LOG); if (dialog) { delete dialog; } } AddUserIDCommand::AddUserIDCommand(KeyListController *c) : Command(new Private(this, c)) { d->init(); } AddUserIDCommand::AddUserIDCommand(QAbstractItemView *v, KeyListController *c) : Command(v, new Private(this, c)) { d->init(); } AddUserIDCommand::AddUserIDCommand(const GpgME::Key &key) : Command(key, new Private(this, nullptr)) { d->init(); } void AddUserIDCommand::Private::init() { } AddUserIDCommand::~AddUserIDCommand() { qCDebug(KLEOPATRA_LOG); } void AddUserIDCommand::doStart() { const std::vector keys = d->keys(); if (keys.size() != 1 || keys.front().protocol() != GpgME::OpenPGP || !keys.front().hasSecret()) { d->finished(); return; } d->key = keys.front(); d->ensureDialogCreated(); Q_ASSERT(d->dialog); const UserID uid = d->key.userID(0); d->dialog->setName(QString::fromUtf8(uid.name())); d->dialog->setEmail(Formatting::prettyEMail(uid.email(), uid.id())); - d->dialog->setComment(QString::fromUtf8(uid.comment())); d->dialog->show(); } void AddUserIDCommand::Private::slotDialogAccepted() { Q_ASSERT(dialog); createJob(); if (!job) { finished(); } - else if (const Error err = job->start(key, dialog->name(), dialog->email(), dialog->comment())) { + else if (const Error err = job->start(key, dialog->name(), dialog->email())) { showErrorDialog(err); finished(); } } void AddUserIDCommand::Private::slotDialogRejected() { Q_EMIT q->canceled(); finished(); } void AddUserIDCommand::Private::slotResult(const Error &err) { if (err.isCanceled()) ; else if (err) { showErrorDialog(err); } else { showSuccessDialog(); } finished(); } void AddUserIDCommand::doCancel() { qCDebug(KLEOPATRA_LOG); if (d->job) { d->job->slotCancel(); } } void AddUserIDCommand::Private::ensureDialogCreated() { if (dialog) { return; } dialog = new AddUserIDDialog; applyWindowID(dialog); connect(dialog, SIGNAL(accepted()), q, SLOT(slotDialogAccepted())); connect(dialog, SIGNAL(rejected()), q, SLOT(slotDialogRejected())); } void AddUserIDCommand::Private::createJob() { Q_ASSERT(!job); const auto backend = (key.protocol() == GpgME::OpenPGP) ? QGpgME::openpgp() : QGpgME::smime(); if (!backend) { return; } QGpgME::AddUserIDJob *const j = backend->addUserIDJob(); if (!j) { return; } connect(j, &QGpgME::Job::progress, q, &Command::progress); connect(j, SIGNAL(result(GpgME::Error)), q, SLOT(slotResult(GpgME::Error))); job = j; } void AddUserIDCommand::Private::showErrorDialog(const Error &err) { error(xi18nc("@info", "An error occurred while trying to add the user-id: " "%1", QString::fromLocal8Bit(err.asString())), i18nc("@title:window", "Add User-ID Error")); } void AddUserIDCommand::Private::showSuccessDialog() { information(i18nc("@info", "User-ID successfully added."), i18nc("@title:window", "Add User-ID Succeeded")); } #undef d #undef q #include "moc_adduseridcommand.cpp" diff --git a/src/commands/createopenpgpkeyfromcardkeyscommand.cpp b/src/commands/createopenpgpkeyfromcardkeyscommand.cpp index 87bef07a9..7b39e96a4 100644 --- a/src/commands/createopenpgpkeyfromcardkeyscommand.cpp +++ b/src/commands/createopenpgpkeyfromcardkeyscommand.cpp @@ -1,222 +1,221 @@ /* -*- mode: c++; c-basic-offset:4 -*- commands/createopenpgpkeyfromcardkeyscommand.cpp This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2020 g10 Code GmbH SPDX-FileContributor: Ingo Klöcker SPDX-License-Identifier: GPL-2.0-or-later */ #include #include "createopenpgpkeyfromcardkeyscommand.h" #include "cardcommand_p.h" #include "dialogs/adduseriddialog.h" #include "smartcard/netkeycard.h" #include "smartcard/openpgpcard.h" #include "smartcard/pivcard.h" #include "smartcard/readerstatus.h" #include #include #include #include #include #include #include #include #include "kleopatra_debug.h" using namespace Kleo; using namespace Kleo::Commands; -using namespace Kleo::Dialogs; using namespace Kleo::SmartCard; using namespace GpgME; using namespace QGpgME; class CreateOpenPGPKeyFromCardKeysCommand::Private : public CardCommand::Private { friend class ::Kleo::Commands::CreateOpenPGPKeyFromCardKeysCommand; CreateOpenPGPKeyFromCardKeysCommand *q_func() const { return static_cast(q); } public: explicit Private(CreateOpenPGPKeyFromCardKeysCommand *qq, const std::string &serialNumber, const std::string &appName, QWidget *parent); ~Private() override; private: void start(); void slotDialogAccepted(); void slotDialogRejected(); void slotResult(const Error &err); void ensureDialogCreated(); private: std::string appName; QPointer dialog; }; CreateOpenPGPKeyFromCardKeysCommand::Private *CreateOpenPGPKeyFromCardKeysCommand::d_func() { return static_cast(d.get()); } const CreateOpenPGPKeyFromCardKeysCommand::Private *CreateOpenPGPKeyFromCardKeysCommand::d_func() const { return static_cast(d.get()); } #define d d_func() #define q q_func() CreateOpenPGPKeyFromCardKeysCommand::Private::Private(CreateOpenPGPKeyFromCardKeysCommand *qq, const std::string &serialNumber, const std::string &appName_, QWidget *parent) : CardCommand::Private(qq, serialNumber, parent) , appName(appName_) { } CreateOpenPGPKeyFromCardKeysCommand::Private::~Private() { } void CreateOpenPGPKeyFromCardKeysCommand::Private::start() { if (appName != NetKeyCard::AppName && appName != OpenPGPCard::AppName && appName != PIVCard::AppName) { qCWarning(KLEOPATRA_LOG) << "CreateOpenPGPKeyFromCardKeysCommand does not support card application" << QString::fromStdString(appName); finished(); return; } const auto card = ReaderStatus::instance()->getCard(serialNumber(), appName); if (!card) { error(i18n("Failed to find the smartcard with the serial number: %1", QString::fromStdString(serialNumber()))); finished(); return; } const auto signingKeyGrip = card->keyInfo(card->signingKeyRef()).grip; const Key signingKey = KeyCache::instance()->findSubkeyByKeyGrip(signingKeyGrip, OpenPGP).parent(); if (!signingKey.isNull()) { const QString message = i18nc("@info", "

There is already an OpenPGP key corresponding to the signing key on this card:

%1

" "

Do you still want to create an OpenPGP key for the card keys?

", Formatting::summaryLine(signingKey)); const auto choice = KMessageBox::warningContinueCancel(parentWidgetOrView(), message, i18nc("@title:window", "Create OpenPGP Key"), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), QString(), KMessageBox::Notify); if (choice != KMessageBox::Continue) { finished(); return; } } ensureDialogCreated(); dialog->setWindowTitle(i18n("Enter User ID")); dialog->setName(card->cardHolder()); dialog->show(); } void CreateOpenPGPKeyFromCardKeysCommand::Private::slotDialogAccepted() { const Error err = ReaderStatus::switchCardAndApp(serialNumber(), appName); if (err) { finished(); return; } const auto backend = openpgp(); if (!backend) { finished(); return; } QuickJob *const job = backend->quickJob(); if (!job) { finished(); return; } connect(job, SIGNAL(result(GpgME::Error)), q, SLOT(slotResult(GpgME::Error))); - const QString userID = Formatting::prettyNameAndEMail(OpenPGP, QString(), dialog->name(), dialog->email(), dialog->comment()); + const QString userID = Formatting::prettyNameAndEMail(OpenPGP, QString(), dialog->name(), dialog->email()); const QDateTime expires = QDateTime(); const unsigned int flags = GPGME_CREATE_FORCE; job->startCreate(userID, "card", expires, Key(), flags); } void CreateOpenPGPKeyFromCardKeysCommand::Private::slotDialogRejected() { canceled(); } void CreateOpenPGPKeyFromCardKeysCommand::Private::slotResult(const Error &err) { if (err.isCanceled()) { // do nothing } else if (err) { error(i18nc("@info", "Creating an OpenPGP key from the card keys failed: %1", QString::fromUtf8(err.asString())), i18nc("@title", "Error")); } else { information(i18nc("@info", "Successfully generated an OpenPGP key from the card keys."), i18nc("@title", "Success")); } finished(); } void CreateOpenPGPKeyFromCardKeysCommand::Private::ensureDialogCreated() { if (dialog) { return; } dialog = new AddUserIDDialog; applyWindowID(dialog); dialog->setAttribute(Qt::WA_DeleteOnClose); connect(dialog, SIGNAL(accepted()), q, SLOT(slotDialogAccepted())); connect(dialog, SIGNAL(rejected()), q, SLOT(slotDialogRejected())); } CreateOpenPGPKeyFromCardKeysCommand::CreateOpenPGPKeyFromCardKeysCommand(const std::string &serialNumber, const std::string &appName, QWidget *parent) : CardCommand(new Private(this, serialNumber, appName, parent)) { } CreateOpenPGPKeyFromCardKeysCommand::~CreateOpenPGPKeyFromCardKeysCommand() { } // static bool CreateOpenPGPKeyFromCardKeysCommand::isSupported() { return !(engineInfo(GpgEngine).engineVersion() < "2.3.0"); } void CreateOpenPGPKeyFromCardKeysCommand::doStart() { d->start(); } void CreateOpenPGPKeyFromCardKeysCommand::doCancel() { } #undef d #undef q #include "moc_createopenpgpkeyfromcardkeyscommand.cpp" diff --git a/src/dialogs/adduseriddialog.cpp b/src/dialogs/adduseriddialog.cpp index ea16c20da..3a055198e 100644 --- a/src/dialogs/adduseriddialog.cpp +++ b/src/dialogs/adduseriddialog.cpp @@ -1,339 +1,180 @@ /* -*- mode: c++; c-basic-offset:4 -*- dialogs/adduseriddialog.cpp This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB + SPDX-FileCopyrightText: 2022 g10 Code GmbH + SPDX-FileContributor: Ingo Klöcker SPDX-License-Identifier: GPL-2.0-or-later */ #include #include "adduseriddialog.h" -#include "ui_adduseriddialog.h" - -#include - -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include #include "kleopatra_debug.h" -#include - using namespace Kleo; -using namespace Kleo::Dialogs; namespace { -struct Line { - QString attr; - QString label; - QString regex; - QLineEdit *edit = nullptr; -}; -} - -static QString pgpLabel(const QString &attr) +QString buildUserId(const QString &name, const QString &email) { - if (attr == QLatin1String("NAME")) { - return i18n("Name"); - } else if (attr == QLatin1String("COMMENT")) { - return i18n("Comment"); - } else if (attr == QLatin1String("EMAIL")) { - return i18n("EMail"); - } - return QString(); + if (name.isEmpty()) { + return email; + } else if (email.isEmpty()) { + return name; + } else { + return QStringLiteral("%1 <%2>").arg(name, email); + } } - -static QString attributeLabel(const QString &attr, bool pgp) -{ - if (attr.isEmpty()) { - return QString(); - } - const QString label = /*pgp ?*/ pgpLabel(attr) /*: Kleo::DNAttributeMapper::instance()->name2label( attr )*/; - if (!label.isEmpty()) - if (pgp) { - return label; - } else - return i18nc("Format string for the labels in the \"Your Personal Data\" page", - "%1 (%2)", label, attr); - else { - return attr; - } -} - -static QString attributeFromKey(QString key) -{ - return key.remove(QLatin1Char('!')); -} - -static int row_index_of(QWidget *w, QGridLayout *l) -{ - const int idx = l->indexOf(w); - int r, c, rs, cs; - l->getItemPosition(idx, &r, &c, &rs, &cs); - return r; -} - -static QLineEdit *adjust_row(QGridLayout *l, int row, const QString &label, const QString &preset, QValidator *validator, bool readonly, bool required) -{ - Q_ASSERT(l); - Q_ASSERT(row >= 0); - Q_ASSERT(row < l->rowCount()); - - auto lb = qobject_cast(l->itemAtPosition(row, 0)->widget()); - Q_ASSERT(lb); - auto le = qobject_cast(l->itemAtPosition(row, 1)->widget()); - Q_ASSERT(le); - auto reqLB = qobject_cast(l->itemAtPosition(row, 2)->widget()); - Q_ASSERT(reqLB); - - lb->setText(i18nc("interpunctation for labels", "%1:", label)); - le->setText(preset); - reqLB->setText(required ? i18n("(required)") : i18n("(optional)")); - delete le->validator(); - if (validator) { - if (!validator->parent()) { - validator->setParent(le); - } - le->setValidator(validator); - } - - le->setReadOnly(readonly && le->hasAcceptableInput()); - - lb->show(); - le->show(); - reqLB->show(); - - return le; } class AddUserIDDialog::Private { - friend class ::Kleo::Dialogs::AddUserIDDialog; + friend class ::Kleo::AddUserIDDialog; AddUserIDDialog *const q; + + struct { + QLineEdit *nameEdit; + QLineEdit *emailEdit; + QLabel *resultLabel; + QDialogButtonBox *buttonBox; + } ui; + public: explicit Private(AddUserIDDialog *qq) - : q(qq), - ui(q) + : q{qq} { - } + q->setWindowTitle(i18nc("title:window", "Add User ID")); -private: - void slotUserIDChanged(); + auto mainLayout = new QVBoxLayout{q}; -private: - bool isComplete() const; + mainLayout->addWidget(new QLabel{i18n("Enter the name and/or the email address to use for the user ID."), q}); -private: - struct UI : public Ui_AddUserIDDialog { + auto gridLayout = new QGridLayout; + int row = -1; - QVector lineList; + { + auto label = new QLabel{i18nc("@label", "Name:"), q}; + ui.nameEdit = new QLineEdit{q}; + label->setBuddy(ui.nameEdit); + + row++; + gridLayout->addWidget(label, row, 0, 1, 1); + gridLayout->addWidget(ui.nameEdit, row, 1, 1, 1); + } + connect(ui.nameEdit, &QLineEdit::textChanged, + q, [this]() { onNameChanged(); }); - explicit UI(AddUserIDDialog *qq) - : Ui_AddUserIDDialog() { - setupUi(qq); - - // ### this code is mostly the same as the one in - // ### newcertificatewizard. Find some time to factor them - // ### into a single copy. - - // hide the stuff - nameLB->hide(); - nameLE->hide(); - nameRequiredLB->hide(); - - emailLB->hide(); - emailLE->hide(); - emailRequiredLB->hide(); - - commentLB->hide(); - commentLE->hide(); - commentRequiredLB->hide(); - - // set errorLB to have a fixed height of two lines: - errorLB->setText(QStringLiteral("2
1")); - errorLB->setFixedHeight(errorLB->minimumSizeHint().height()); - errorLB->clear(); - - const KConfigGroup config(KSharedConfig::openConfig(), "CertificateCreationWizard"); - const QStringList attrOrder = config.readEntry("OpenPGPAttributeOrder", - QStringList() << QStringLiteral("NAME") << QStringLiteral("EMAIL") << QStringLiteral("COMMENT")); - - QMap lines; - - for (const QString &rawKey : attrOrder) { - const QString key = rawKey.trimmed().toUpper(); - const QString attr = attributeFromKey(key); - if (attr.isEmpty()) { - continue; - } - const QString preset = config.readEntry(attr); - const bool required = key.endsWith(QLatin1Char('!')); - const bool readonly = config.isEntryImmutable(attr); - const QString label = config.readEntry(attr + QLatin1String("_label"), - attributeLabel(attr, true)); - const QString regex = config.readEntry(attr + QLatin1String("_regex")); - - int row; - QValidator *validator = nullptr; - if (attr == QLatin1String("EMAIL")) { - validator = regex.isEmpty() ? Validation::email() : Validation::email(QRegExp(regex)); - row = row_index_of(emailLE, gridLayout); - } else if (attr == QLatin1String("NAME")) { - validator = regex.isEmpty() ? Validation::pgpName() : Validation::pgpName(QRegExp(regex)); - row = row_index_of(nameLE, gridLayout); - } else if (attr == QLatin1String("COMMENT")) { - validator = regex.isEmpty() ? Validation::pgpComment() : Validation::pgpComment(QRegExp(regex)); - row = row_index_of(commentLE, gridLayout); - } else { - continue; - } - - QLineEdit *le = adjust_row(gridLayout, row, label, preset, validator, readonly, required); - - const Line line = { key, label, regex, le }; - lines[row] = line; - } - - std::copy(lines.begin(), lines.end(), std::back_inserter(lineList)); - - QObject::connect(nameLE, SIGNAL(textChanged(QString)), qq, SLOT(slotUserIDChanged())); - QObject::connect(emailLE, SIGNAL(textChanged(QString)), qq, SLOT(slotUserIDChanged())); - QObject::connect(commentLE, SIGNAL(textChanged(QString)), qq, SLOT(slotUserIDChanged())); + auto label = new QLabel{i18nc("@label", "Email:"), q}; + ui.emailEdit = new QLineEdit{q}; + label->setBuddy(ui.emailEdit); + + row++; + gridLayout->addWidget(label, row, 0, 1, 1); + gridLayout->addWidget(ui.emailEdit, row, 1, 1, 1); } + connect(ui.emailEdit, &QLineEdit::textChanged, + q, [this]() { onEmailChanged(); }); + + mainLayout->addLayout(gridLayout); + + mainLayout->addWidget(new KSeparator{Qt::Horizontal, q}); - QPushButton *okPB() const { - return buttonBox->button(QDialogButtonBox::Ok); + auto label = new QLabel{i18n("This is how the new user ID will be stored in the certificate:"), q}; + mainLayout->addWidget(label); + } + { + ui.resultLabel = new QLabel{q}; + ui.resultLabel->setMinimumSize(300, 0); + ui.resultLabel->setAlignment(Qt::AlignCenter); + ui.resultLabel->setTextFormat(Qt::PlainText); + QFont font; + font.setBold(true); + font.setWeight(75); + ui.resultLabel->setFont(font); + + mainLayout->addWidget(ui.resultLabel); } - } ui; -}; -AddUserIDDialog::AddUserIDDialog(QWidget *p) - : QDialog(p), d(new Private(this)) -{ - // explicitly trigger an update after setup is complete - d->slotUserIDChanged(); -} + mainLayout->addWidget(new KSeparator{Qt::Horizontal, q}); -AddUserIDDialog::~AddUserIDDialog() {} + mainLayout->addStretch(1); -void AddUserIDDialog::setName(const QString &name) -{ - d->ui.nameLE->setText(name); -} + ui.buttonBox = new QDialogButtonBox{QDialogButtonBox::Ok | QDialogButtonBox::Cancel, q}; -QString AddUserIDDialog::name() const -{ - return d->ui.nameLE->text().trimmed(); -} + mainLayout->addWidget(ui.buttonBox); -void AddUserIDDialog::setEmail(const QString &email) -{ - d->ui.emailLE->setText(email); -} + connect(ui.buttonBox, &QDialogButtonBox::accepted, q, &QDialog::accept); + connect(ui.buttonBox, &QDialogButtonBox::rejected, q, &QDialog::reject); -QString AddUserIDDialog::email() const -{ - return d->ui.emailLE->text().trimmed(); -} + updateResultLabel(); + } -void AddUserIDDialog::setComment(const QString &comment) -{ - d->ui.commentLE->setText(comment); -} + QString name() const + { + return ui.nameEdit->text().trimmed(); + } + + QString email() const + { + return ui.emailEdit->text().trimmed(); + } + +private: + void onNameChanged() + { + updateResultLabel(); + } + + void onEmailChanged() + { + updateResultLabel(); + } + + void updateResultLabel() + { + ui.resultLabel->setText(buildUserId(name(), email())); + } +}; -QString AddUserIDDialog::comment() const +AddUserIDDialog::AddUserIDDialog(QWidget *parent, Qt::WindowFlags f) + : QDialog{parent, f} + , d(new Private{this}) { - return d->ui.commentLE->text().trimmed(); } -static bool has_intermediate_input(const QLineEdit *le) +AddUserIDDialog::~AddUserIDDialog() = default; + +void AddUserIDDialog::setName(const QString &name) { - QString text = le->text(); - int pos = le->cursorPosition(); - const QValidator *const v = le->validator(); - return !v || v->validate(text, pos) == QValidator::Intermediate; + d->ui.nameEdit->setText(name); } -static bool requirementsAreMet(const QVector &list, QString &error) +QString AddUserIDDialog::name() const { - bool allEmpty = true; - for (const Line &line : list) { - const QLineEdit *le = line.edit; - if (!le) { - continue; - } - const QString key = line.attr; - qCDebug(KLEOPATRA_LOG) << "requirementsAreMet(): checking \"" << key << "\" against \"" << le->text() << "\":"; - if (le->text().trimmed().isEmpty()) { - if (key.endsWith(QLatin1Char('!'))) { - if (line.regex.isEmpty()) { - error = xi18nc("@info", "%1 is required, but empty.", line.label); - } else - error = xi18nc("@info", "%1 is required, but empty." - "Local Admin rule: %2", line.label, line.regex); - return false; - } - } else if (has_intermediate_input(le)) { - if (line.regex.isEmpty()) { - error = xi18nc("@info", "%1 is incomplete.", line.label); - } else - error = xi18nc("@info", "%1 is incomplete." - "Local Admin rule: %2", line.label, line.regex); - return false; - } else if (!le->hasAcceptableInput()) { - if (line.regex.isEmpty()) { - error = xi18nc("@info", "%1 is invalid.", line.label); - } else - error = xi18nc("@info", "%1 is invalid." - "Local Admin rule: %2", line.label, line.regex); - return false; - } else { - allEmpty = false; - } - } - return !allEmpty; + return d->name(); } -bool AddUserIDDialog::Private::isComplete() const +void AddUserIDDialog::setEmail(const QString &email) { - QString error; - const bool ok = requirementsAreMet(ui.lineList, error); - ui.errorLB->setText(error); - return ok; + d->ui.emailEdit->setText(email); } -void AddUserIDDialog::Private::slotUserIDChanged() +QString AddUserIDDialog::email() const { - ui.okPB()->setEnabled(isComplete()); - - const QString name = q->name(); - const QString email = q->email(); - const QString comment = q->comment(); - - QStringList parts; - if (!name.isEmpty()) { - parts.push_back(name); - } - if (!comment.isEmpty()) { - parts.push_back(QLatin1Char('(') + comment + QLatin1Char(')')); - } - if (!email.isEmpty()) { - parts.push_back(QLatin1Char('<') + email + QLatin1Char('>')); - } - - ui.resultLB->setText(parts.join(QLatin1Char(' '))); + return d->email(); } - -#include "moc_adduseriddialog.cpp" diff --git a/src/dialogs/adduseriddialog.h b/src/dialogs/adduseriddialog.h index b9d3ea630..92778e4f2 100644 --- a/src/dialogs/adduseriddialog.h +++ b/src/dialogs/adduseriddialog.h @@ -1,50 +1,39 @@ /* -*- mode: c++; c-basic-offset:4 -*- - dialogs/addUserIDdialog.h + dialogs/adduseriddialog.h This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB + SPDX-FileCopyrightText: 2022 g10 Code GmbH + SPDX-FileContributor: Ingo Klöcker SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include -#include - -class QString; +#include namespace Kleo { -namespace Dialogs -{ class AddUserIDDialog : public QDialog { Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QString email READ email WRITE setEmail) - Q_PROPERTY(QString comment READ comment WRITE setComment) public: - explicit AddUserIDDialog(QWidget *parent = nullptr); + explicit AddUserIDDialog(QWidget *parent = nullptr, Qt::WindowFlags f = {}); ~AddUserIDDialog() override; void setName(const QString &name); QString name() const; void setEmail(const QString &email); QString email() const; - void setComment(const QString &comment); - QString comment() const; - private: class Private; - kdtools::pimpl_ptr d; - Q_PRIVATE_SLOT(d, void slotUserIDChanged()) + const std::unique_ptr d; }; -} -} - +} // namespace Kleo diff --git a/src/dialogs/adduseriddialog.ui b/src/dialogs/adduseriddialog.ui deleted file mode 100644 index d2fea3ede..000000000 --- a/src/dialogs/adduseriddialog.ui +++ /dev/null @@ -1,210 +0,0 @@ - - AddUserIDDialog - - - Add New User-ID - - - - - - nameLE - - - - - - - - - - emailLE - - - - - - - - - - commentLE - - - - - - - - - - Qt::Horizontal - - - - - - - This is how the new User-ID will be stored in the certificate: - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 114 - 114 - 114 - - - - - - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - 300 - 0 - - - - - 75 - true - - - - Qt::PlainText - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - - - - - - - - - - - - - - - buttonBox - accepted() - AddUserIDDialog - accept() - - - 236 - 203 - - - 157 - 212 - - - - - buttonBox - rejected() - AddUserIDDialog - reject() - - - 325 - 203 - - - 286 - 212 - - - - - - slotUserIDChanged() - -