diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a9d45cda1..43eec815dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,281 +1,281 @@ project(kdepim) cmake_minimum_required(VERSION 3.1) option(KDEPIM_SUPERBUILD "Build standalone apps (experimental not used for distro)" FALSE) if (KDEPIM_SUPERBUILD) # Remove it when splitted # This CMakeLists.txt is a "superbuild" for the frameworks. # This means it can be used to build them all standalone one-by-one. # This is useful to compile all them with one command. # use mkdir build && cd build && cmake -DKDEPIM_SUPERBUILD=TRUE ../ && make -j8 sb_all include(SuperBuild.cmake) sb_add_project(kmail) sb_add_project(grantleeeditor) sb_add_project(korganizer) sb_add_project(sieveeditor) sb_add_project(storageservicemanager) sb_add_project(akregator) sb_add_project(importwizard) sb_add_project(kaddressbook) sb_add_project(mboximporter) sb_add_project(knotes) sb_add_project(ktnef) sb_add_project(pimsettingexporter) sb_add_project(kalarm) sb_add_project(blogilo) sb_add_project(kontact) sb_add_project(akonadiconsole) sb_add_project(console) sb_add_project(accountwizard) # doc must be a subdir of kdepim or packagers will kill us # Need to move in subdirectory add_subdirectory(doc) sb_end() else() if (POLICY CMP0063) cmake_policy(SET CMP0063 NEW) endif() set(LIBRARY_NAMELINK LIBRARY NAMELINK_SKIP) # we need some parts of the ECM CMake helpers set(KF5_VERSION "5.23.0") find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${kdepim_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH}) include(ECMOptionalAddSubdirectory) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddTests) include(ECMMarkNonGuiExecutable) include(GenerateExportHeader) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(FeatureSummary) include(CheckFunctionExists) include(ECMGeneratePriFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) # KDEPIM_VERSION # Version scheme: "x.y.z build". # # x is the version number. # y is the major release number. # z is the minor release number. # # "x.y.z" follow the kdelibs version kdepim is released with. # # If "z" is 0, the version is "x.y" # # KDEPIM_DEV_VERSION is empty for final versions. # For development versions "build" is something like "pre", "alpha1", "alpha2", "beta1", "beta2", "rc1", "rc2". # # Examples in chronological order: # 3.0, 3.0.1, 3.1 alpha1, 3.1 beta1, 3.1 beta2, 3.1 rc1, 3.1, 3.1.1, 3.2 pre, 3.2 alpha1 # Do NOT add quote set(KDEPIM_DEV_VERSION pre) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_VERSION_NUMBER "5.3.40") set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(AKONADI_MIMELIB_VERSION "5.3.40") set(AKONADI_CONTACT_VERSION "5.3.40") set(KCONTACTS_LIB_VERSION "5.3.42") set(KCALENDARCORE_LIB_VERSION "5.3.40") set(IDENTITYMANAGEMENT_LIB_VERSION "5.3.41") set(KLDAP_LIB_VERSION "5.3.40") set(KMAILTRANSPORT_LIB_VERSION "5.3.40") set(CALENDARUTILS_LIB_VERSION "5.3.40") set(KHOLIDAYS_LIB_VERSION "5.3.40") set(KTNEF_LIB_VERSION "5.3.40") set(KIMAP_LIB_VERSION "5.3.40") set(KMBOX_LIB_VERSION "5.3.40") set(AKONADICALENDAR_LIB_VERSION "5.3.40") set(SYNDICATION_LIB_VERSION "5.3.40") set(GPGMEPP_LIB_VERSION "5.3.40") set(KONTACTINTERFACE_LIB_VERSION "5.3.40") set(AKONADIKALARM_LIB_VERSION "5.3.40") set(KMIME_LIB_VERSION "5.3.40") set(XMLRPCCLIENT_LIB_VERSION "5.3.40") set(KBLOG_LIB_VERSION "5.3.40") set(KPIMTEXTEDIT_LIB_VERSION "5.3.41") set(AKONADI_VERSION "5.3.40") set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}") set(KDEPIM_LIB_SOVERSION "5") set(AKONADINOTES_LIB_VERSION "5.3.40") set(QT_REQUIRED_VERSION "5.6.0") option(KDEPIM_ENTERPRISE_BUILD "Enable features specific to the enterprise branch, which are normally disabled. Also, it disables many components not needed for Kontact such as the Kolab client." FALSE) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Sql Concurrent UiTools WebEngine WebEngineWidgets) find_package(Qt5X11Extras NO_MODULE) find_package(Grantlee5 "5.1" CONFIG REQUIRED) set(LIBGRAVATAR_VERSION_LIB "5.3.40") set(LIBMAILIMPORTER_VERSION_LIB "5.3.40") set(MAILCOMMON_LIB_VERSION_LIB "5.3.41") set(KDEPIM_APPS_LIB_VERSION_LIB "5.3.40") set(MESSAGELIB_LIB_VERSION_LIB "5.3.44") - set(LIBKLEO_LIB_VERSION_LIB "5.3.40") + set(LIBKLEO_LIB_VERSION_LIB "5.3.42") set(LIBGRANTLEETHEME_LIB_VERSION_LIB "5.3.40") set(PIMCOMMON_LIB_VERSION_LIB "5.3.41") set(LIBKDEPIM_LIB_VERSION_LIB "5.3.40") set(LIBINCIDENCEEDITOR_LIB_VERSION_LIB "5.3.41") set(CALENDARSUPPORT_LIB_VERSION_LIB "5.3.41") set(EVENTVIEW_LIB_VERSION_LIB "5.3.40") set(LIBKSIEVE_LIB_VERSION_LIB "5.3.42") find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) set(WEBENGINE_TYPE "QtWebEngine") # Find KF5 package find_package(KF5KDELibs4Support ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Wallet ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5NewStuff ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5KCMUtils ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Archive ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5NotifyConfig ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Service ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DBusAddons ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Auth ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DocTools ${KF5_VERSION} REQUIRED) find_package(Phonon4Qt5 CONFIG REQUIRED) find_package(KF5DNSSD ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5TextEditor ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Sonnet ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5GlobalAccel ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Crash ${KF5_VERSION} REQUIRED) # Find KdepimLibs Package find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADI_CONTACT_VERSION} CONFIG REQUIRED) find_package(KF5IdentityManagement ${IDENTITYMANAGEMENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Ldap ${KLDAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailTransport ${KMAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADI_MIMELIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Holidays ${KHOLIDAYS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Tnef ${KTNEF_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IMAP ${KIMAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mbox ${KMBOX_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiCalendar ${AKONADICALENDAR_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Syndication ${SYNDICATION_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Gpgmepp ${GPGMEPP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5KontactInterface ${KONTACTINTERFACE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AlarmCalendar ${AKONADIKALARM_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5XmlRpcClient ${XMLRPCCLIENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Blog ${KBLOG_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiNotes ${AKONADINOTES_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Gravatar ${LIBGRAVATAR_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MailImporter ${LIBMAILIMPORTER_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MailCommon ${MAILCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5KaddressbookGrantlee ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5GrantleeTheme ${LIBGRANTLEETHEME_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5IncidenceEditor ${LIBINCIDENCEEDITOR_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageCore ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageComposer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageList ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5TemplateParser ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5CalendarSupport ${CALENDARSUPPORT_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5EventViews ${EVENTVIEW_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5FollowupReminder ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5SendLater ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5KdepimDBusInterfaces ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5LibKSieve ${LIBKSIEVE_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(MailTransportDBusService CONFIG REQUIRED) if (NOT APPLE) find_package(X11) endif() set(KDEPIM_HAVE_X11 ${X11_FOUND}) # Extra package find_package(KF5GAPI "5.2.80" CONFIG) include_directories(${kdepim_SOURCE_DIR} ${kdepim_BINARY_DIR}) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) find_package(KF5AkonadiSearch "5.3.40" CONFIG REQUIRED) set_package_properties(KF5AkonadiSearch PROPERTIES DESCRIPTION "The Akonadi Search libraries" URL "http://www.kde.org" TYPE REQUIRED PURPOSE "Provides search capabilities in KMail and Akonadi") if(KDEPIM_ENTERPRISE_BUILD) message(STATUS "Enterprise build is enabled.") endif() ############### Desktop vs. Mobile options ############## find_package(Boost 1.34.0) set_package_properties(Boost PROPERTIES DESCRIPTION "Boost C++ Libraries" URL "http://www.boost.org" TYPE REQUIRED PURPOSE "Boost is required for building most KDEPIM applications") add_subdirectory(kmail) add_subdirectory(grantleeeditor) add_subdirectory(korganizer) add_subdirectory(sieveeditor) add_subdirectory(storageservicemanager) add_subdirectory(akregator) add_subdirectory(importwizard) add_subdirectory(kaddressbook) add_subdirectory(mboximporter) add_subdirectory(knotes) add_subdirectory(ktnef) add_subdirectory(pimsettingexporter) add_subdirectory(kalarm) add_subdirectory(blogilo) add_subdirectory(kontact) add_subdirectory(akonadiconsole) add_subdirectory(console) add_subdirectory(accountwizard) # doc must be a subdir of kdepim or packagers will kill us add_subdirectory(doc) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES ) endif() diff --git a/akonadiconsole/CMakeLists.txt b/akonadiconsole/CMakeLists.txt index 8df88957bc..b0f2be8f6c 100644 --- a/akonadiconsole/CMakeLists.txt +++ b/akonadiconsole/CMakeLists.txt @@ -1,101 +1,101 @@ project(akonadiconsole) if(${CMAKE_SOURCE_DIR} STREQUAL ${akonadiconsole_SOURCE_DIR}) cmake_minimum_required(VERSION 3.1) set(KF5_VERSION "5.23.0") find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(ECMInstallIcons) include(ECMOptionalAddSubdirectory) include(ECMSetupVersion) include(ECMAddTests) include(ECMMarkNonGuiExecutable) include(GenerateExportHeader) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(FeatureSummary) include(CheckFunctionExists) include(ECMGeneratePriFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) # Do NOT add quote set(KDEPIM_DEV_VERSION pre) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_VERSION_NUMBER "5.3.40") set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(AKONADI_MIMELIB_VERSION "5.3.40") set(AKONADI_CONTACT_VERSION "5.3.40") set(CALENDARSUPPORT_LIB_VERSION_LIB "5.3.41") set(KPIMTEXTEDIT_LIB_VERSION "5.3.41") set(AKONADI_VERSION "5.3.40") set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}") set(KDEPIM_LIB_SOVERSION "5") set(QT_REQUIRED_VERSION "5.6.0") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets DBus Sql) set(LIBMAILIMPORTER_VERSION_LIB "5.3.40") set(MESSAGELIB_LIB_VERSION_LIB "5.3.44") - set(LIBKLEO_LIB_VERSION_LIB "5.3.40") + set(LIBKLEO_LIB_VERSION_LIB "5.3.42") set(LIBKDEPIM_LIB_VERSION_LIB "5.3.40") set(KCALENDARCORE_LIB_VERSION "5.3.40") set(KCONTACTS_LIB_VERSION "5.3.42") set(KMIME_LIB_VERSION "5.3.40") # Find KF5 package find_package(KF5Completion ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DBusAddons ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DocTools ${KF5_VERSION} REQUIRED) find_package(KF5I18n ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5ItemModels ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5KDELibs4Support ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5TextWidgets ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Crash ${KF5_VERSION} REQUIRED) # Find KdepimLibs Package find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADI_CONTACT_VERSION} CONFIG REQUIRED) find_package(KF5CalendarSupport ${CALENDARSUPPORT_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADI_MIMELIB_VERSION} CONFIG REQUIRED) find_package(KF5MailImporter ${LIBMAILIMPORTER_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION_LIB} CONFIG REQUIRED) include_directories(${akonadiconsole_SOURCE_DIR} ${akonadiconsole_BINARY_DIR}) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) endif() add_definitions(-DQT_USE_QSTRINGBUILDER) install( FILES akonadiconsole.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) add_subdirectory(src) if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) endif() diff --git a/akregator/CMakeLists.txt b/akregator/CMakeLists.txt index eebcf2dde5..dbd83dfea4 100644 --- a/akregator/CMakeLists.txt +++ b/akregator/CMakeLists.txt @@ -1,103 +1,103 @@ project(akregator) if(${CMAKE_SOURCE_DIR} STREQUAL ${akregator_SOURCE_DIR}) cmake_minimum_required(VERSION 3.1) set(KF5_VERSION "5.23.0") find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(ECMInstallIcons) include(ECMOptionalAddSubdirectory) include(ECMSetupVersion) include(ECMAddTests) include(ECMMarkNonGuiExecutable) include(GenerateExportHeader) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(FeatureSummary) include(CheckFunctionExists) include(ECMGeneratePriFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) # Do NOT add quote set(KDEPIM_DEV_VERSION pre) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_VERSION_NUMBER "5.3.40") set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}") set(KDEPIM_LIB_SOVERSION "5") set(QT_REQUIRED_VERSION "5.6.0") set(KONTACTINTERFACE_LIB_VERSION "5.3.40") set(KPIMTEXTEDIT_LIB_VERSION "5.3.41") set(LIBGRANTLEETHEME_LIB_VERSION_LIB "5.3.40") set(LIBKDEPIM_LIB_VERSION_LIB "5.3.40") - set(LIBKLEO_LIB_VERSION_LIB "5.3.40") + set(LIBKLEO_LIB_VERSION_LIB "5.3.42") set(MESSAGELIB_LIB_VERSION_LIB "5.3.44") set(PIMCOMMON_LIB_VERSION_LIB "5.3.41") set(SYNDICATION_LIB_VERSION "5.3.40") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test WebEngine WebEngineWidgets) find_package(Grantlee5 "5.1" CONFIG REQUIRED) # Find KF5 package find_package(KF5Crash ${KF5_VERSION} REQUIRED) find_package(KF5DocTools ${KF5_VERSION} REQUIRED) find_package(KF5KCMUtils ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5NotifyConfig ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Parts ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5TextEditor ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_VERSION} CONFIG REQUIRED) # Find KdepimLibs Package find_package(KF5AkonadiMime ${AKONADI_MIMELIB_VERSION} CONFIG REQUIRED) find_package(KF5GrantleeTheme ${LIBGRANTLEETHEME_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5KontactInterface ${KONTACTINTERFACE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Syndication ${SYNDICATION_LIB_VERSION} CONFIG REQUIRED) find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) set(WEBENGINE_TYPE "QtWebEngine") add_definitions(-DQT_NO_URL_CAST_FROM_STRING) endif() add_definitions(-DQT_USE_QSTRINGBUILDER) include_directories(${akregator_SOURCE_DIR} ${akregator_BINARY_DIR}) include(CheckTypeSize) check_type_size("long" SIZEOF_LONG) configure_file(config-akregator.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-akregator.h) add_definitions(-DTRANSLATION_DOMAIN=\"akregator\") add_definitions( -DQT_NO_CAST_FROM_ASCII ) add_definitions( -DQT_NO_CAST_TO_ASCII ) add_subdirectory(export) add_subdirectory(interfaces) add_subdirectory(plugins) add_subdirectory(configuration) add_subdirectory(src) add_subdirectory(kontactplugin) add_subdirectory(kconf_update) install( FILES akregator.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) endif() diff --git a/grantleeeditor/CMakeLists.txt b/grantleeeditor/CMakeLists.txt index 5f9b402867..64858c2313 100644 --- a/grantleeeditor/CMakeLists.txt +++ b/grantleeeditor/CMakeLists.txt @@ -1,90 +1,90 @@ project(grantleeditor) if(${CMAKE_SOURCE_DIR} STREQUAL ${grantleeditor_SOURCE_DIR}) cmake_minimum_required(VERSION 3.1) set(KF5_VERSION "5.23.0") find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(ECMInstallIcons) include(ECMOptionalAddSubdirectory) include(ECMSetupVersion) include(ECMAddTests) include(ECMMarkNonGuiExecutable) include(GenerateExportHeader) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(FeatureSummary) include(CheckFunctionExists) include(ECMGeneratePriFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) # Do NOT add quote set(KDEPIM_DEV_VERSION pre) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_VERSION_NUMBER "5.3.40") set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(MESSAGELIB_LIB_VERSION_LIB "5.3.44") set(AKONADI_MIMELIB_VERSION "5.3.40") set(KPIMTEXTEDIT_LIB_VERSION "5.3.41") set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}") set(KDEPIM_LIB_SOVERSION "5") set(KDEPIM_APPS_LIB_VERSION_LIB "5.3.40") set(LIBGRANTLEETHEME_LIB_VERSION_LIB "5.3.40") - set(LIBKLEO_LIB_VERSION_LIB "5.3.40") + set(LIBKLEO_LIB_VERSION_LIB "5.3.42") set(QT_REQUIRED_VERSION "5.6.0") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets WebEngine WebEngineWidgets) set(PIMCOMMON_LIB_VERSION_LIB "5.3.41") set(LIBKDEPIM_LIB_VERSION_LIB "5.3.40") # Find KF5 package find_package(KF5Crash ${KF5_VERSION} REQUIRED) find_package(KF5DBusAddons ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DocTools ${KF5_VERSION} REQUIRED) find_package(KF5XmlGui ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5TextEditor ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Wallet ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5NewStuff ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5GrantleeTheme ${LIBGRANTLEETHEME_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADI_MIMELIB_VERSION} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION_LIB} CONFIG REQUIRED) # Find KdepimLibs Package find_package(KF5KaddressbookGrantlee ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) endif() add_definitions(-DQT_USE_QSTRINGBUILDER) include_directories(${grantleeditor_SOURCE_DIR} ${grantleeditor_BINARY_DIR}) add_definitions( -DQT_NO_CAST_FROM_ASCII ) add_definitions( -DQT_NO_CAST_TO_ASCII ) configure_file(grantleeeditor-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/grantleeeditor-version.h @ONLY) add_subdirectory(headerthemeeditor) add_subdirectory(contactthemeeditor) add_subdirectory(grantleethemeeditor) add_subdirectory(contactprintthemeeditor) install( FILES grantleeditor.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) endif() diff --git a/kmail/CMakeLists.txt b/kmail/CMakeLists.txt index c39051f4e9..5ab3b146aa 100644 --- a/kmail/CMakeLists.txt +++ b/kmail/CMakeLists.txt @@ -1,158 +1,158 @@ project(kmail) include(CheckIncludeFiles) if(${CMAKE_SOURCE_DIR} STREQUAL ${kmail_SOURCE_DIR}) cmake_minimum_required(VERSION 3.1) if (POLICY CMP0063) cmake_policy(SET CMP0063 NEW) endif() set(KF5_VERSION "5.23.0") find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(ECMOptionalAddSubdirectory) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddTests) include(ECMMarkNonGuiExecutable) include(GenerateExportHeader) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(FeatureSummary) include(CheckFunctionExists) include(ECMGeneratePriFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) # Do NOT add quote set(KDEPIM_DEV_VERSION pre) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_VERSION_NUMBER "5.3.40") set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(AKONADI_MIMELIB_VERSION "5.3.40") set(AKONADI_CONTACT_VERSION "5.3.40") set(KCONTACTS_LIB_VERSION "5.3.42") set(KCALENDARCORE_LIB_VERSION "5.3.40") set(CALENDARUTILS_LIB_VERSION "5.3.40") set(IDENTITYMANAGEMENT_LIB_VERSION "5.3.41") set(KLDAP_LIB_VERSION "5.3.40") set(KMAILTRANSPORT_LIB_VERSION "5.3.40") set(GPGMEPP_LIB_VERSION "5.3.40") set(KONTACTINTERFACE_LIB_VERSION "5.3.40") set(KMIME_LIB_VERSION "5.3.40") set(KPIMTEXTEDIT_LIB_VERSION "5.3.41") set(AKONADI_VERSION "5.3.40") set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}") set(KDEPIM_LIB_SOVERSION "5") set(QT_REQUIRED_VERSION "5.6.0") option(KDEPIM_ENTERPRISE_BUILD "Enable features specific to the enterprise branch, which are normally disabled. Also, it disables many components not needed for Kontact such as the Kolab client." FALSE) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED DBus Network Test Widgets WebEngine WebEngineWidgets Xml) set(LIBGRAVATAR_VERSION_LIB "5.3.40") set(MAILCOMMON_LIB_VERSION_LIB "5.3.41") set(KDEPIM_APPS_LIB_VERSION_LIB "5.3.40") set(MESSAGELIB_LIB_VERSION_LIB "5.3.44") - set(LIBKLEO_LIB_VERSION_LIB "5.3.40") + set(LIBKLEO_LIB_VERSION_LIB "5.3.42") set(PIMCOMMON_LIB_VERSION_LIB "5.3.41") set(LIBKDEPIM_LIB_VERSION_LIB "5.3.40") set(LIBKSIEVE_LIB_VERSION_LIB "5.3.42") find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) set(WEBENGINE_TYPE "QtWebEngine") find_package(KF5AkonadiSearch "5.3.40" CONFIG REQUIRED) set_package_properties(KF5AkonadiSearch PROPERTIES DESCRIPTION "The Akonadi Search libraries" URL "http://www.kde.org" TYPE REQUIRED PURPOSE "Provides search capabilities in KMail and Akonadi") # Find KF5 package find_package(KF5Crash ${KF5_VERSION} REQUIRED) find_package(KF5Bookmarks ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Crash ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DBusAddons ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DocTools ${KF5_VERSION} REQUIRED) find_package(KF5GuiAddons ${KF5_VERSION} REQUIRED) find_package(KF5I18n ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5ItemViews ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5JobWidgets ${KF5_VERSION} REQUIRED) find_package(KF5KIO ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5KCMUtils ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Notifications ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5NotifyConfig ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Parts ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Service ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Sonnet ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5TextWidgets ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5WindowSystem ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_VERSION} CONFIG REQUIRED) # Find KdepimLibs Package find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADI_CONTACT_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADI_MIMELIB_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IdentityManagement ${IDENTITYMANAGEMENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Ldap ${KLDAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailTransport ${KMAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Gpgmepp ${GPGMEPP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5KontactInterface ${KONTACTINTERFACE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5FollowupReminder ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Gravatar ${LIBGRAVATAR_VERSION_LIB} CONFIG REQUIRED) find_package(KF5KdepimDBusInterfaces ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5LibKSieve ${LIBKSIEVE_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MailCommon ${MAILCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageCore ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageComposer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageList ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5SendLater ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5TemplateParser ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(MailTransportDBusService CONFIG REQUIRED) find_package(Boost 1.34.0) set_package_properties(Boost PROPERTIES DESCRIPTION "Boost C++ Libraries" URL "http://www.boost.org" TYPE REQUIRED PURPOSE "Boost is required for building most KDEPIM applications") add_definitions(-DQT_NO_URL_CAST_FROM_STRING) endif() add_definitions(-DQT_USE_QSTRINGBUILDER) configure_file(config-enterprise.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-enterprise.h ) include_directories(${kmail_SOURCE_DIR} ${kmail_BINARY_DIR}) configure_file(kmail-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kmail-version.h @ONLY) add_definitions( -DQT_NO_CAST_FROM_ASCII ) add_definitions( -DQT_NO_CAST_TO_ASCII ) add_subdirectory(src) add_subdirectory(agents) install( FILES kmail.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) endif() diff --git a/kmail/src/identity/identitydialog.cpp b/kmail/src/identity/identitydialog.cpp index 7e08f21f54..5563c2abce 100644 --- a/kmail/src/identity/identitydialog.cpp +++ b/kmail/src/identity/identitydialog.cpp @@ -1,1030 +1,1151 @@ /* identitydialog.cpp This file is part of KMail, the KDE mail client. Copyright (c) 2002 Marc Mutz Copyright (c) 2014-2016 Laurent Montel KMail is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. KMail 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 "identitydialog.h" #include "identityeditvcarddialog.h" #include "identityaddvcarddialog.h" #include "identityinvalidfolder.h" #include "identityfolderrequester.h" #include "MessageComposer/MessageComposerSettings" #include // other KMail headers: #include "xfaceconfigurator.h" #include #include "mailcommon/folderrequester.h" #ifndef KCM_KPIMIDENTITIES_STANDALONE #include "settings/kmailsettings.h" #include "kmkernel.h" #endif #include "mailcommon/mailkernel.h" #include "job/addressvalidationjob.h" #include "MessageComposer/Kleo_Util" #include #include "TemplateParser/TemplatesConfiguration" #include "templatesconfiguration_kfg.h" // other kdepim headers: #include #include #include "PimCommon/AutoCorrectionLanguage" #include #include // libkleopatra: -#include "Libkleo/KeyRequester" -#include "Libkleo/CryptoBackendFactory" +#include +#include +#include +#include +#include + +// gpgme++ +#include #include #include #include #include #include using MailTransport::TransportManager; // other KDE headers: #include #include #include #include #include "kmail_debug.h" #include #include #include #include #include #include // Qt headers: #include #include #include #include #include #include #include #include #include // other headers: #include #include #include #include #include #include #include #include using namespace KPIM; using namespace MailTransport; using namespace MailCommon; namespace KMail { +class KeySelectionCombo : public Kleo::KeySelectionCombo +{ + Q_OBJECT + +public: + enum KeyType { + SigningKey, + EncryptionKey + }; + + KeySelectionCombo(KeyType keyType, GpgME::Protocol protocol, QWidget *parent); + ~KeySelectionCombo(); + + void setIdentity(const QString &name, const QString &email); + + void init() Q_DECL_OVERRIDE; + +private Q_SLOTS: + void onCustomItemSelected(const QVariant &type); + +private: + QString mEmail; + QString mName; + KeyType mKeyType; + GpgME::Protocol mProtocol; +}; + + +class KeyGenerationJob : public Kleo::Job +{ + Q_OBJECT + +public: + KeyGenerationJob(const QString &name, const QString &email, KeySelectionCombo *parent); + ~KeyGenerationJob(); + + void slotCancel() Q_DECL_OVERRIDE; + void start(); + +private Q_SLOTS: + void keyGenerated(const GpgME::KeyGenerationResult &result); + +private: + QString mName; + QString mEmail; + Kleo::Job *mJob; +}; + + + +KeyGenerationJob::KeyGenerationJob(const QString &name, const QString &email, KeySelectionCombo *parent) + : Kleo::Job(parent) + , mName(name) + , mEmail(email) + , mJob(Q_NULLPTR) +{ +} + +KeyGenerationJob::~KeyGenerationJob() +{ +} + +void KeyGenerationJob::slotCancel() +{ + if (mJob) { + mJob->slotCancel(); + } +} + +void KeyGenerationJob::start() +{ + const QString args = QStringLiteral("\n" + "%ask-passphrase\n" + "key-type: RSA\n" + "key-length: 2048\n" + "key-usage: sign\n" + "subkey-type: RSA\n" + "subkey-length: 2048\n" + "subkey-usage: encrypt\n" + "name-email: %1\n" + "name-real: %2\n" + "").arg(mEmail, mName); + + auto job = Kleo::CryptoBackendFactory::instance()->openpgp()->keyGenerationJob(); + connect(job, &Kleo::KeyGenerationJob::result, + this, &KeyGenerationJob::keyGenerated); + job->start(args); + mJob = job; +} + +void KeyGenerationJob::keyGenerated(const GpgME::KeyGenerationResult &result) +{ + mJob = Q_NULLPTR; + if (result.error()) { + KMessageBox::error(qobject_cast(parent()), + i18n("Error while generating new key pair: %1", QString::fromUtf8(result.error().asString())), + i18n("Key Generation Error")); + Q_EMIT done(); + return; + } + + KeySelectionCombo *combo = qobject_cast(parent()); + combo->setDefaultKey(QLatin1String(result.fingerprint())); + connect(combo, &KeySelectionCombo::keyListingFinished, + this, &KeyGenerationJob::done); + combo->refreshKeys(); +} + +KeySelectionCombo::KeySelectionCombo(KeyType keyType, GpgME::Protocol protocol, QWidget *parent) + : Kleo::KeySelectionCombo(parent) + , mKeyType(keyType) + , mProtocol(protocol) +{ +} + +KeySelectionCombo::~KeySelectionCombo() +{ +} + +void KeySelectionCombo::setIdentity(const QString &name, const QString &email) +{ + mName = name; + mEmail = email; + setIdFilter(email); +} + +void KeySelectionCombo::init() +{ + Kleo::KeySelectionCombo::init(); + + boost::shared_ptr keyFilter(new Kleo::DefaultKeyFilter); + keyFilter->setIsOpenPGP(mProtocol == GpgME::OpenPGP ? Kleo::DefaultKeyFilter::Set : Kleo::DefaultKeyFilter::NotSet); + if (mKeyType == SigningKey) { + keyFilter->setCanSign(Kleo::DefaultKeyFilter::Set); + } else { + keyFilter->setCanEncrypt(Kleo::DefaultKeyFilter::Set); + } + keyFilter->setHasSecret(Kleo::DefaultKeyFilter::Set); + setKeyFilter(keyFilter); + + prependCustomItem(QIcon(), i18n("No key"), QStringLiteral("no-key")); + if (mProtocol == GpgME::OpenPGP) { + appendCustomItem(QIcon::fromTheme(QStringLiteral("password-generate")), + i18n("Generate a new key pair"), QStringLiteral("generate-new-key")); + } + + connect(this, &KeySelectionCombo::customItemSelected, + this, &KeySelectionCombo::onCustomItemSelected); +} + +void KeySelectionCombo::onCustomItemSelected(const QVariant &type) +{ + const QString typeStr = type.toString(); + if (type == QLatin1String("no-key")) { + return; + } else if (type == QLatin1String("generate-new-key")) { + auto job = new KeyGenerationJob(mName, mEmail, this); + new Kleo::ProgressDialog(job, i18n("Generating new key pair..."), parentWidget()); + setEnabled(false); + connect(job, &KeyGenerationJob::done, + this, [this]() { setEnabled(true); }); + job->start(); + } +} + + + IdentityDialog::IdentityDialog(QWidget *parent) : QDialog(parent) { setWindowTitle(i18n("Edit Identity")); QDialogButtonBox *buttonBox = Q_NULLPTR; QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help); connect(buttonBox->button(QDialogButtonBox::Help), &QPushButton::clicked, this, &IdentityDialog::slotHelp); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &IdentityDialog::slotAccepted); connect(buttonBox, &QDialogButtonBox::rejected, this, &IdentityDialog::reject); okButton->setDefault(true); // tmp. vars: QWidget *tab; QLabel *label; int row; QGridLayout *glay; QString msg; // // Tab Widget: General // row = -1; QWidget *page = new QWidget(this); mainLayout->addWidget(page); mainLayout->addWidget(buttonBox); QVBoxLayout *vlay = new QVBoxLayout(page); vlay->setMargin(0); mTabWidget = new QTabWidget(page); mTabWidget->setObjectName(QStringLiteral("config-identity-tab")); vlay->addWidget(mTabWidget); tab = new QWidget(mTabWidget); mTabWidget->addTab(tab, i18nc("@title:tab General identity settings.", "General")); glay = new QGridLayout(tab); glay->setRowStretch(3, 1); glay->setColumnStretch(1, 1); // "Name" line edit and label: ++row; mNameEdit = new KLineEdit(tab); glay->addWidget(mNameEdit, row, 1); label = new QLabel(i18n("&Your name:"), tab); label->setBuddy(mNameEdit); glay->addWidget(label, row, 0); msg = i18n("

Your name

" "

This field should contain your name as you would like " "it to appear in the email header that is sent out;

" "

if you leave this blank your real name will not " "appear, only the email address.

"); label->setWhatsThis(msg); mNameEdit->setWhatsThis(msg); // "Organization" line edit and label: ++row; mOrganizationEdit = new KLineEdit(tab); glay->addWidget(mOrganizationEdit, row, 1); label = new QLabel(i18n("Organi&zation:"), tab); label->setBuddy(mOrganizationEdit); glay->addWidget(label, row, 0); msg = i18n("

Organization

" "

This field should have the name of your organization " "if you would like it to be shown in the email header that " "is sent out.

" "

It is safe (and normal) to leave this blank.

"); label->setWhatsThis(msg); mOrganizationEdit->setWhatsThis(msg); // "Email Address" line edit and label: // (row 3: spacer) ++row; mEmailEdit = new KLineEdit(tab); glay->addWidget(mEmailEdit, row, 1); label = new QLabel(i18n("&Email address:"), tab); label->setBuddy(mEmailEdit); glay->addWidget(label, row, 0); msg = i18n("

Email address

" "

This field should have your full email address.

" "

This address is the primary one, used for all outgoing mail. " "If you have more than one address, either create a new identity, " "or add additional alias addresses in the field below.

" "

If you leave this blank, or get it wrong, people " "will have trouble replying to you.

"); label->setWhatsThis(msg); mEmailEdit->setWhatsThis(msg); KPIM::EmailValidator *emailValidator = new KPIM::EmailValidator(this); mEmailEdit->setValidator(emailValidator); // "Email Aliases" string text edit and label: ++row; mAliasEdit = new KEditListWidget(tab); KPIM::EmailValidator *emailValidator1 = new KPIM::EmailValidator(this); mAliasEdit->lineEdit()->setValidator(emailValidator1); glay->addWidget(mAliasEdit, row, 1); label = new QLabel(i18n("Email a&liases:"), tab); label->setBuddy(mAliasEdit); glay->addWidget(label, row, 0, Qt::AlignTop); msg = i18n("

Email aliases

" "

This field contains alias addresses that should also " "be considered as belonging to this identity (as opposed " "to representing a different identity).

" "

Example:

" "" "" "" "
Primary address:first.last@example.org
Aliases:first@example.org
last@example.org
" "

Type one alias address per line.

"); label->setToolTip(msg); mAliasEdit->setWhatsThis(msg); // // Tab Widget: Cryptography // row = -1; mCryptographyTab = tab = new QWidget(mTabWidget); mTabWidget->addTab(tab, i18n("Cryptography")); glay = new QGridLayout(tab); glay->setColumnStretch(1, 1); // "OpenPGP Signature Key" requester and label: ++row; - mPGPSigningKeyRequester = new Kleo::SigningKeyRequester(false, Kleo::SigningKeyRequester::OpenPGP, tab); - mPGPSigningKeyRequester->dialogButton()->setText(i18n("Chang&e...")); - mPGPSigningKeyRequester->setDialogCaption(i18n("Your OpenPGP Signature Key")); - msg = i18n("Select the OpenPGP key which should be used to " - "digitally sign your messages."); - mPGPSigningKeyRequester->setDialogMessage(msg); - + mPGPSigningKeyRequester = new KeySelectionCombo(KeySelectionCombo::SigningKey, GpgME::OpenPGP, tab); msg = i18n("

The OpenPGP key you choose here will be used " "to digitally sign messages. You can also use GnuPG keys.

" "

You can leave this blank, but KMail will not be able " "to digitally sign emails using OpenPGP; " "normal mail functions will not be affected.

" "

You can find out more about keys at http://www.gnupg.org

"); - label = new QLabel(i18n("OpenPGP signing key:"), tab); label->setBuddy(mPGPSigningKeyRequester); mPGPSigningKeyRequester->setWhatsThis(msg); label->setWhatsThis(msg); glay->addWidget(label, row, 0); glay->addWidget(mPGPSigningKeyRequester, row, 1); // "OpenPGP Encryption Key" requester and label: ++row; - mPGPEncryptionKeyRequester = new Kleo::EncryptionKeyRequester(false, Kleo::EncryptionKeyRequester::OpenPGP, tab); - mPGPEncryptionKeyRequester->dialogButton()->setText(i18n("Chang&e...")); - mPGPEncryptionKeyRequester->setDialogCaption(i18n("Your OpenPGP Encryption Key")); - msg = i18n("Select the OpenPGP key which should be used when encrypting " - "to yourself and for the \"Attach My Public Key\" " - "feature in the composer."); - mPGPEncryptionKeyRequester->setDialogMessage(msg); - + mPGPEncryptionKeyRequester = new KeySelectionCombo(KeySelectionCombo::EncryptionKey, GpgME::OpenPGP, tab); msg = i18n("

The OpenPGP key you choose here will be used " "to encrypt messages to yourself and for the \"Attach My Public Key\" " "feature in the composer. You can also use GnuPG keys.

" "

You can leave this blank, but KMail will not be able " "to encrypt copies of outgoing messages to you using OpenPGP; " "normal mail functions will not be affected.

" "

You can find out more about keys at http://www.gnupg.org

"); label = new QLabel(i18n("OpenPGP encryption key:"), tab); label->setBuddy(mPGPEncryptionKeyRequester); mPGPEncryptionKeyRequester->setWhatsThis(msg); label->setWhatsThis(msg); glay->addWidget(label, row, 0); glay->addWidget(mPGPEncryptionKeyRequester, row, 1); // "S/MIME Signature Key" requester and label: ++row; - mSMIMESigningKeyRequester = new Kleo::SigningKeyRequester(false, Kleo::SigningKeyRequester::SMIME, tab); - mSMIMESigningKeyRequester->dialogButton()->setText(i18n("Chang&e...")); - mSMIMESigningKeyRequester->setDialogCaption(i18n("Your S/MIME Signature Certificate")); - msg = i18n("Select the S/MIME certificate which should be used to " - "digitally sign your messages."); - mSMIMESigningKeyRequester->setDialogMessage(msg); - + mSMIMESigningKeyRequester = new KeySelectionCombo(KeySelectionCombo::SigningKey, GpgME::CMS, tab); msg = i18n("

The S/MIME (X.509) certificate you choose here will be used " "to digitally sign messages.

" "

You can leave this blank, but KMail will not be able " "to digitally sign emails using S/MIME; " "normal mail functions will not be affected.

"); label = new QLabel(i18n("S/MIME signing certificate:"), tab); label->setBuddy(mSMIMESigningKeyRequester); mSMIMESigningKeyRequester->setWhatsThis(msg); label->setWhatsThis(msg); glay->addWidget(label, row, 0); glay->addWidget(mSMIMESigningKeyRequester, row, 1); const Kleo::CryptoBackend::Protocol *smimeProtocol = Kleo::CryptoBackendFactory::instance()->smime(); label->setEnabled(smimeProtocol); mSMIMESigningKeyRequester->setEnabled(smimeProtocol); // "S/MIME Encryption Key" requester and label: ++row; - mSMIMEEncryptionKeyRequester = new Kleo::EncryptionKeyRequester(false, Kleo::EncryptionKeyRequester::SMIME, tab); - mSMIMEEncryptionKeyRequester->dialogButton()->setText(i18n("Chang&e...")); - mSMIMEEncryptionKeyRequester->setDialogCaption(i18n("Your S/MIME Encryption Certificate")); - msg = i18n("Select the S/MIME certificate which should be used when encrypting " - "to yourself and for the \"Attach My Certificate\" " - "feature in the composer."); - mSMIMEEncryptionKeyRequester->setDialogMessage(msg); - + mSMIMEEncryptionKeyRequester = new KeySelectionCombo(KeySelectionCombo::EncryptionKey, GpgME::CMS, tab); msg = i18n("

The S/MIME certificate you choose here will be used " "to encrypt messages to yourself and for the \"Attach My Certificate\" " "feature in the composer.

" "

You can leave this blank, but KMail will not be able " "to encrypt copies of outgoing messages to you using S/MIME; " "normal mail functions will not be affected.

"); label = new QLabel(i18n("S/MIME encryption certificate:"), tab); label->setBuddy(mSMIMEEncryptionKeyRequester); mSMIMEEncryptionKeyRequester->setWhatsThis(msg); label->setWhatsThis(msg); glay->addWidget(label, row, 0); glay->addWidget(mSMIMEEncryptionKeyRequester, row, 1); label->setEnabled(smimeProtocol); mSMIMEEncryptionKeyRequester->setEnabled(smimeProtocol); // "Preferred Crypto Message Format" combobox and label: ++row; mPreferredCryptoMessageFormat = new KComboBox(tab); mPreferredCryptoMessageFormat->setEditable(false); QStringList l; l << Kleo::cryptoMessageFormatToLabel(Kleo::AutoFormat) << Kleo::cryptoMessageFormatToLabel(Kleo::InlineOpenPGPFormat) << Kleo::cryptoMessageFormatToLabel(Kleo::OpenPGPMIMEFormat) << Kleo::cryptoMessageFormatToLabel(Kleo::SMIMEFormat) << Kleo::cryptoMessageFormatToLabel(Kleo::SMIMEOpaqueFormat); mPreferredCryptoMessageFormat->addItems(l); label = new QLabel(i18nc("preferred format of encrypted messages", "Preferred format:"), tab); label->setBuddy(mPreferredCryptoMessageFormat); glay->addWidget(label, row, 0); glay->addWidget(mPreferredCryptoMessageFormat, row, 1); ++row; mAutoSign = new QCheckBox(i18n("Automatically sign messages")); glay->addWidget(mAutoSign, row, 0); ++row; mAutoEncrypt = new QCheckBox(i18n("Automatically encrypt messages when possible")); glay->addWidget(mAutoEncrypt, row, 0); ++row; glay->setRowStretch(row, 1); // // Tab Widget: Advanced // row = -1; tab = new QWidget(mTabWidget); QVBoxLayout *advancedMainLayout = new QVBoxLayout(tab); mIdentityInvalidFolder = new IdentityInvalidFolder(tab); advancedMainLayout->addWidget(mIdentityInvalidFolder); mTabWidget->addTab(tab, i18nc("@title:tab Advanced identity settings.", "Advanced")); glay = new QGridLayout; advancedMainLayout->addLayout(glay); // the last (empty) row takes all the remaining space glay->setColumnStretch(1, 1); // "Reply-To Address" line edit and label: ++row; mReplyToEdit = new KPIM::AddresseeLineEdit(tab, true); mReplyToEdit->setClearButtonShown(true); mReplyToEdit->setObjectName(QStringLiteral("mReplyToEdit")); glay->addWidget(mReplyToEdit, row, 1); label = new QLabel(i18n("&Reply-To address:"), tab); label->setBuddy(mReplyToEdit); glay->addWidget(label, row, 0); msg = i18n("

Reply-To addresses

" "

This sets the Reply-to: header to contain a " "different email address to the normal From: " "address.

" "

This can be useful when you have a group of people " "working together in similar roles. For example, you " "might want any emails sent to have your email in the " "From: field, but any responses to go to " "a group address.

" "

If in doubt, leave this field blank.

"); label->setWhatsThis(msg); mReplyToEdit->setWhatsThis(msg); // "CC addresses" line edit and label: ++row; mCcEdit = new KPIM::AddresseeLineEdit(tab, true); mCcEdit->setClearButtonShown(true); mCcEdit->setObjectName(QStringLiteral("mCcEdit")); glay->addWidget(mCcEdit, row, 1); label = new QLabel(i18n("&CC addresses:"), tab); label->setBuddy(mCcEdit); glay->addWidget(label, row, 0); msg = i18n("

CC (Carbon Copy) addresses

" "

The addresses that you enter here will be added to each " "outgoing mail that is sent with this identity.

" "

This is commonly used to send a copy of each sent message to " "another account of yours.

" "

To specify more than one address, use commas to separate " "the list of CC recipients.

" "

If in doubt, leave this field blank.

"); label->setWhatsThis(msg); mCcEdit->setWhatsThis(msg); // "BCC addresses" line edit and label: ++row; mBccEdit = new KPIM::AddresseeLineEdit(tab, true); mBccEdit->setClearButtonShown(true); mBccEdit->setObjectName(QStringLiteral("mBccEdit")); glay->addWidget(mBccEdit, row, 1); label = new QLabel(i18n("&BCC addresses:"), tab); label->setBuddy(mBccEdit); glay->addWidget(label, row, 0); msg = i18n("

BCC (Blind Carbon Copy) addresses

" "

The addresses that you enter here will be added to each " "outgoing mail that is sent with this identity. They will not " "be visible to other recipients.

" "

This is commonly used to send a copy of each sent message to " "another account of yours.

" "

To specify more than one address, use commas to separate " "the list of BCC recipients.

" "

If in doubt, leave this field blank.

"); label->setWhatsThis(msg); mBccEdit->setWhatsThis(msg); // "Dictionary" combo box and label: ++row; mDictionaryCombo = new Sonnet::DictionaryComboBox(tab); glay->addWidget(mDictionaryCombo, row, 1); label = new QLabel(i18n("D&ictionary:"), tab); label->setBuddy(mDictionaryCombo); glay->addWidget(label, row, 0); // "Sent-mail Folder" combo box and label: ++row; mFccFolderRequester = new IdentityFolderRequester(tab); mFccFolderRequester->setShowOutbox(false); glay->addWidget(mFccFolderRequester, row, 1); mSentMailFolderCheck = new QCheckBox(i18n("Sent-mail &folder:"), tab); glay->addWidget(mSentMailFolderCheck, row, 0); connect(mSentMailFolderCheck, &QCheckBox::toggled, mFccFolderRequester, &MailCommon::FolderRequester::setEnabled); // "Drafts Folder" combo box and label: ++row; mDraftsFolderRequester = new IdentityFolderRequester(tab); mDraftsFolderRequester->setShowOutbox(false); glay->addWidget(mDraftsFolderRequester, row, 1); label = new QLabel(i18n("&Drafts folder:"), tab); label->setBuddy(mDraftsFolderRequester); glay->addWidget(label, row, 0); // "Templates Folder" combo box and label: ++row; mTemplatesFolderRequester = new IdentityFolderRequester(tab); mTemplatesFolderRequester->setShowOutbox(false); glay->addWidget(mTemplatesFolderRequester, row, 1); label = new QLabel(i18n("&Templates folder:"), tab); label->setBuddy(mTemplatesFolderRequester); glay->addWidget(label, row, 0); // "Special transport" combobox and label: ++row; mTransportCheck = new QCheckBox(i18n("Outgoing Account:"), tab); glay->addWidget(mTransportCheck, row, 0); mTransportCombo = new TransportComboBox(tab); mTransportCombo->setEnabled(false); // since !mTransportCheck->isChecked() glay->addWidget(mTransportCombo, row, 1); connect(mTransportCheck, &QCheckBox::toggled, mTransportCombo, &MailTransport::TransportComboBox::setEnabled); ++row; mAttachMyVCard = new QCheckBox(i18n("Attach my vCard to message"), tab); glay->addWidget(mAttachMyVCard, row, 0); mEditVCard = new QPushButton(i18n("Create..."), tab); connect(mEditVCard, &QPushButton::clicked, this, &IdentityDialog::slotEditVcard); glay->addWidget(mEditVCard, row, 1); ++row; mAutoCorrectionLanguage = new PimCommon::AutoCorrectionLanguage(tab); glay->addWidget(mAutoCorrectionLanguage, row, 1); label = new QLabel(i18n("Autocorrection language:"), tab); label->setBuddy(mAutoCorrectionLanguage); glay->addWidget(label, row, 0); // "default domain" input field: ++row; QHBoxLayout *hbox = new QHBoxLayout; mDefaultDomainEdit = new KLineEdit(tab); mDefaultDomainEdit->setClearButtonShown(true); hbox->addWidget(mDefaultDomainEdit); QToolButton *restoreDefaultDomainName = new QToolButton; restoreDefaultDomainName->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); restoreDefaultDomainName->setToolTip(i18n("Restore default domain name")); hbox->addWidget(restoreDefaultDomainName); connect(restoreDefaultDomainName, &QToolButton::clicked, this, &IdentityDialog::slotRefreshDefaultDomainName); glay->addLayout(hbox, row, 1); label = new QLabel(i18n("Defaul&t domain:"), tab); label->setBuddy(mDefaultDomainEdit); glay->addWidget(label, row, 0); // and now: add QWhatsThis: msg = i18n("

The default domain is used to complete email " "addresses that only consist of the user's name." "

"); label->setWhatsThis(msg); mDefaultDomainEdit->setWhatsThis(msg); ++row; glay->setRowStretch(row, 1); // the last row is a spacer // // Tab Widget: Templates // tab = new QWidget(mTabWidget); vlay = new QVBoxLayout(tab); QHBoxLayout *tlay = new QHBoxLayout(); vlay->addLayout(tlay); mCustom = new QCheckBox(i18n("&Use custom message templates for this identity"), tab); tlay->addWidget(mCustom, Qt::AlignLeft); mWidget = new TemplateParser::TemplatesConfiguration(tab, QStringLiteral("identity-templates")); mWidget->setEnabled(false); // Move the help label outside of the templates configuration widget, // so that the help can be read even if the widget is not enabled. tlay->addStretch(9); tlay->addWidget(mWidget->helpLabel(), Qt::AlignRight); vlay->addWidget(mWidget); QHBoxLayout *btns = new QHBoxLayout(); mCopyGlobal = new QPushButton(i18n("&Copy Global Templates"), tab); mCopyGlobal->setEnabled(false); btns->addWidget(mCopyGlobal); vlay->addLayout(btns); connect(mCustom, &QCheckBox::toggled, mWidget, &TemplateParser::TemplatesConfiguration::setEnabled); connect(mCustom, &QCheckBox::toggled, mCopyGlobal, &QPushButton::setEnabled); connect(mCopyGlobal, &QPushButton::clicked, this, &IdentityDialog::slotCopyGlobal); mTabWidget->addTab(tab, i18n("Templates")); // // Tab Widget: Signature // mSignatureConfigurator = new KIdentityManagement::SignatureConfigurator(mTabWidget); mTabWidget->addTab(mSignatureConfigurator, i18n("Signature")); // // Tab Widget: Picture // mXFaceConfigurator = new XFaceConfigurator(mTabWidget); mTabWidget->addTab(mXFaceConfigurator, i18n("Picture")); #ifndef KCM_KPIMIDENTITIES_STANDALONE resize(KMailSettings::self()->identityDialogSize()); #endif mNameEdit->setFocus(); connect(mTabWidget, &QTabWidget::currentChanged, this, &IdentityDialog::slotAboutToShow); } IdentityDialog::~IdentityDialog() { #ifndef KCM_KPIMIDENTITIES_STANDALONE KMailSettings::self()->setIdentityDialogSize(size()); #endif } void IdentityDialog::slotHelp() { PimCommon::Util::invokeHelp(QStringLiteral("kmail/configure-identity.html")); } void IdentityDialog::slotAboutToShow(int index) { QWidget *w = mTabWidget->widget(index); if (w == mCryptographyTab) { // set the configured email address as initial query of the key // requesters: + const QString name = mNameEdit->text().trimmed(); const QString email = mEmailEdit->text().trimmed(); - mPGPEncryptionKeyRequester->setInitialQuery(email); - mPGPSigningKeyRequester->setInitialQuery(email); - mSMIMEEncryptionKeyRequester->setInitialQuery(email); - mSMIMESigningKeyRequester->setInitialQuery(email); + + mPGPEncryptionKeyRequester->setIdentity(name, email); + mPGPSigningKeyRequester->setIdentity(name, email); + mSMIMEEncryptionKeyRequester->setIdentity(name, email); + mSMIMESigningKeyRequester->setIdentity(name, email); } } void IdentityDialog::slotCopyGlobal() { mWidget->loadFromGlobal(); } -namespace -{ -struct DoesntMatchEMailAddress { - explicit DoesntMatchEMailAddress(const QString &s) - : email(s.trimmed().toLower()) {} - bool operator()(const GpgME::Key &key) const; -private: - bool checkForEmail(const char *email) const; - static QString extractEmail(const char *email); - const QString email; -}; - -bool DoesntMatchEMailAddress::operator()(const GpgME::Key &key) const -{ - const std::vector uids = key.userIDs(); - std::vector::const_iterator end = uids.end(); - for (std::vector::const_iterator it = uids.begin(); it != end; ++it) - if (checkForEmail(it->email() ? it->email() : it->id())) { - return false; - } - return true; // note the negation! -} - -bool DoesntMatchEMailAddress::checkForEmail(const char *e) const -{ - const QString em = extractEmail(e); - return !em.isEmpty() && email.toLower() == em.toLower(); -} - -QString DoesntMatchEMailAddress::extractEmail(const char *e) -{ - if (!e || !*e) { - return QString(); - } - const QString em = QString::fromUtf8(e); - if (e[0] == '<') { - return em.mid(1, em.length() - 2); - } else { - return em; - } -} -} - void IdentityDialog::slotRefreshDefaultDomainName() { mDefaultDomainEdit->setText(QHostInfo::localHostName()); } void IdentityDialog::slotAccepted() { const QStringList aliases = mAliasEdit->items(); foreach (const QString &alias, aliases) { if (!KEmailAddress::isValidSimpleAddress(alias)) { const QString errorMsg(KEmailAddress::simpleEmailAddressErrorMsg()); KMessageBox::sorry(this, errorMsg, i18n("Invalid Email Alias \"%1\"", alias)); return; } } // Validate email addresses const QString email = mEmailEdit->text().trimmed(); if (!KEmailAddress::isValidSimpleAddress(email)) { const QString errorMsg(KEmailAddress::simpleEmailAddressErrorMsg()); KMessageBox::sorry(this, errorMsg, i18n("Invalid Email Address")); return; } // Check if the 'Reply to' and 'BCC' recipients are valid const QString recipients = mReplyToEdit->text().trimmed() + QLatin1String(", ") + mBccEdit->text().trimmed() + QLatin1String(", ") + mCcEdit->text().trimmed(); AddressValidationJob *job = new AddressValidationJob(recipients, this, this); //Use default Value job->setDefaultDomain(mDefaultDomainEdit->text()); job->setProperty("email", email); connect(job, &AddressValidationJob::result, this, &IdentityDialog::slotDelayedButtonClicked); job->start(); } +bool IdentityDialog::keyMatchesEmailAddress(const GpgME::Key &key, const QString &email_) +{ + if (key.isNull()) { + return true; + } + const QString email = email_.trimmed().toLower(); + const auto uids = key.userIDs(); + for (const auto &uid : uids) { + QString em = QString::fromUtf8(uid.email() ? uid.email() : uid.id()); + if (em.isEmpty()) { + continue; + } + if (em[0] == QLatin1Char('<')) { + em = em.mid(1, em.length() - 2); + } + if (em.toLower() == email) { + return true; + } + } + + return false; +} + void IdentityDialog::slotDelayedButtonClicked(KJob *job) { const AddressValidationJob *validationJob = qobject_cast(job); // Abort if one of the recipient addresses is invalid if (!validationJob->isValid()) { return; } const QString email = validationJob->property("email").toString(); - const std::vector &pgpSigningKeys = - mPGPSigningKeyRequester->keys(); - const std::vector &pgpEncryptionKeys = - mPGPEncryptionKeyRequester->keys(); - const std::vector &smimeSigningKeys = - mSMIMESigningKeyRequester->keys(); - const std::vector &smimeEncryptionKeys = - mSMIMEEncryptionKeyRequester->keys(); + const GpgME::Key &pgpSigningKey = mPGPSigningKeyRequester->currentKey(); + const GpgME::Key &pgpEncryptionKey = mPGPEncryptionKeyRequester->currentKey(); + const GpgME::Key &smimeSigningKey = mSMIMESigningKeyRequester->currentKey(); + const GpgME::Key &smimeEncryptionKey = mSMIMEEncryptionKeyRequester->currentKey(); QString msg; bool err = false; - if (std::find_if(pgpSigningKeys.begin(), pgpSigningKeys.end(), - DoesntMatchEMailAddress(email)) != pgpSigningKeys.end()) { + if (!keyMatchesEmailAddress(pgpSigningKey, email)) { msg = i18n("One of the configured OpenPGP signing keys does not contain " "any user ID with the configured email address for this " "identity (%1).\n" "This might result in warning messages on the receiving side " "when trying to verify signatures made with this configuration.", email); err = true; - } else if (std::find_if(pgpEncryptionKeys.begin(), pgpEncryptionKeys.end(), - DoesntMatchEMailAddress(email)) != pgpEncryptionKeys.end()) { + } else if (!keyMatchesEmailAddress(pgpEncryptionKey, email)) { msg = i18n("One of the configured OpenPGP encryption keys does not contain " "any user ID with the configured email address for this " "identity (%1).", email); err = true; - } else if (std::find_if(smimeSigningKeys.begin(), smimeSigningKeys.end(), - DoesntMatchEMailAddress(email)) != smimeSigningKeys.end()) { + } else if (!keyMatchesEmailAddress(smimeSigningKey, email)) { msg = i18n("One of the configured S/MIME signing certificates does not contain " "the configured email address for this " "identity (%1).\n" "This might result in warning messages on the receiving side " "when trying to verify signatures made with this configuration.", email); err = true; - } else if (std::find_if(smimeEncryptionKeys.begin(), smimeEncryptionKeys.end(), - DoesntMatchEMailAddress(email)) != smimeEncryptionKeys.end()) { + } else if (!keyMatchesEmailAddress(smimeEncryptionKey, email)) { msg = i18n("One of the configured S/MIME encryption certificates does not contain " "the configured email address for this " "identity (%1).", email); err = true; } if (err) { if (KMessageBox::warningContinueCancel(this, msg, i18n("Email Address Not Found in Key/Certificates"), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), QStringLiteral("warn_email_not_in_certificate")) != KMessageBox::Continue) { return; } } if (mSignatureConfigurator->isSignatureEnabled() && mSignatureConfigurator->signatureType() == Signature::FromFile) { QFileInfo file(mSignatureConfigurator->filePath()); if (!file.isReadable()) { KMessageBox::error(this, i18n("The signature file is not valid")); return; } } accept(); } bool IdentityDialog::checkFolderExists(const QString &folderID) { const Akonadi::Collection folder = CommonKernel->collectionFromId(folderID.toLongLong()); return folder.isValid(); } void IdentityDialog::setIdentity(KIdentityManagement::Identity &ident) { setWindowTitle(i18n("Edit Identity \"%1\"", ident.identityName())); // "General" tab: mNameEdit->setText(ident.fullName()); mOrganizationEdit->setText(ident.organization()); mEmailEdit->setText(ident.primaryEmailAddress()); mAliasEdit->insertStringList(ident.emailAliases()); // "Cryptography" tab: - mPGPSigningKeyRequester->setFingerprint(QLatin1String(ident.pgpSigningKey())); - mPGPEncryptionKeyRequester->setFingerprint(QLatin1String(ident.pgpEncryptionKey())); - mSMIMESigningKeyRequester->setFingerprint(QLatin1String(ident.smimeSigningKey())); - mSMIMEEncryptionKeyRequester->setFingerprint(QLatin1String(ident.smimeEncryptionKey())); + mPGPSigningKeyRequester->setDefaultKey(QLatin1String(ident.pgpSigningKey())); + mPGPEncryptionKeyRequester->setDefaultKey(QLatin1String(ident.pgpEncryptionKey())); + mSMIMESigningKeyRequester->setDefaultKey(QLatin1String(ident.smimeSigningKey())); + mSMIMEEncryptionKeyRequester->setDefaultKey(QLatin1String(ident.smimeEncryptionKey())); mPreferredCryptoMessageFormat->setCurrentIndex(format2cb( Kleo::stringToCryptoMessageFormat(ident.preferredCryptoMessageFormat()))); mAutoSign->setChecked(ident.pgpAutoSign()); mAutoEncrypt->setChecked(ident.pgpAutoEncrypt()); // "Advanced" tab: mReplyToEdit->setText(ident.replyToAddr()); mBccEdit->setText(ident.bcc()); mCcEdit->setText(ident.cc()); const int transportId = ident.transport().isEmpty() ? -1 : ident.transport().toInt(); const Transport *transport = TransportManager::self()->transportById(transportId, true); mTransportCheck->setChecked(transportId != -1); mTransportCombo->setEnabled(transportId != -1); if (transport) { mTransportCombo->setCurrentTransport(transport->id()); } mDictionaryCombo->setCurrentByDictionaryName(ident.dictionary()); mSentMailFolderCheck->setChecked(!ident.disabledFcc()); mFccFolderRequester->setEnabled(mSentMailFolderCheck->isChecked()); bool foundNoExistingFolder = false; if (ident.fcc().isEmpty() || !checkFolderExists(ident.fcc())) { foundNoExistingFolder = true; mFccFolderRequester->setIsInvalidFolder(); mFccFolderRequester->setCollection(CommonKernel->sentCollectionFolder()); } else { mFccFolderRequester->setCollection(Akonadi::Collection(ident.fcc().toLongLong())); } if (ident.drafts().isEmpty() || !checkFolderExists(ident.drafts())) { foundNoExistingFolder = true; mDraftsFolderRequester->setIsInvalidFolder(); mDraftsFolderRequester->setCollection(CommonKernel->draftsCollectionFolder()); } else { mDraftsFolderRequester->setCollection(Akonadi::Collection(ident.drafts().toLongLong())); } if (ident.templates().isEmpty() || !checkFolderExists(ident.templates())) { foundNoExistingFolder = true; mTemplatesFolderRequester->setIsInvalidFolder(); mTemplatesFolderRequester->setCollection(CommonKernel->templatesCollectionFolder()); } else { mTemplatesFolderRequester->setCollection(Akonadi::Collection(ident.templates().toLongLong())); } if (foundNoExistingFolder) { mIdentityInvalidFolder->setErrorMessage(i18n("Some custom folder for identity does not exist (anymore); therefore, default folders will be used.")); } mVcardFilename = ident.vCardFile(); mAutoCorrectionLanguage->setLanguage(ident.autocorrectionLanguage()); updateVcardButton(); if (mVcardFilename.isEmpty()) { mVcardFilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + ident.identityName() + QLatin1String(".vcf"); QFileInfo fileInfo(mVcardFilename); QDir().mkpath(fileInfo.absolutePath()); } else { //Convert path. const QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + ident.identityName() + QLatin1String(".vcf"); if (QFile(path).exists() && (mVcardFilename != path)) { mVcardFilename = path; } } mAttachMyVCard->setChecked(ident.attachVcard()); QString defaultDomainName = ident.defaultDomainName(); if (defaultDomainName.isEmpty()) { defaultDomainName = QHostInfo::localHostName(); } mDefaultDomainEdit->setText(defaultDomainName); // "Templates" tab: uint identity = ident.uoid(); QString iid = TemplateParser::TemplatesConfiguration::configIdString(identity); TemplateParser::Templates t(iid); mCustom->setChecked(t.useCustomTemplates()); mWidget->loadFromIdentity(identity); // "Signature" tab: mSignatureConfigurator->setImageLocation(ident); mSignatureConfigurator->setSignature(ident.signature()); mXFaceConfigurator->setXFace(ident.xface()); mXFaceConfigurator->setXFaceEnabled(ident.isXFaceEnabled()); } void IdentityDialog::updateIdentity(KIdentityManagement::Identity &ident) { // "General" tab: ident.setFullName(mNameEdit->text()); ident.setOrganization(mOrganizationEdit->text()); QString email = mEmailEdit->text(); ident.setPrimaryEmailAddress(email); ident.setEmailAliases(mAliasEdit->items()); // "Cryptography" tab: - ident.setPGPSigningKey(mPGPSigningKeyRequester->fingerprint().toLatin1()); - ident.setPGPEncryptionKey(mPGPEncryptionKeyRequester->fingerprint().toLatin1()); - ident.setSMIMESigningKey(mSMIMESigningKeyRequester->fingerprint().toLatin1()); - ident.setSMIMEEncryptionKey(mSMIMEEncryptionKeyRequester->fingerprint().toLatin1()); + ident.setPGPSigningKey(mPGPSigningKeyRequester->currentKey().primaryFingerprint()); + ident.setPGPEncryptionKey(mPGPEncryptionKeyRequester->currentKey().primaryFingerprint()); + ident.setSMIMESigningKey(mSMIMESigningKeyRequester->currentKey().primaryFingerprint()); + ident.setSMIMEEncryptionKey(mSMIMEEncryptionKeyRequester->currentKey().primaryFingerprint()); ident.setPreferredCryptoMessageFormat( QLatin1String(Kleo::cryptoMessageFormatToString(cb2format(mPreferredCryptoMessageFormat->currentIndex())))); ident.setPgpAutoSign(mAutoSign->isChecked()); ident.setPgpAutoEncrypt(mAutoEncrypt->isChecked()); // "Advanced" tab: ident.setReplyToAddr(mReplyToEdit->text()); ident.setBcc(mBccEdit->text()); ident.setCc(mCcEdit->text()); ident.setTransport(mTransportCheck->isChecked() ? QString::number(mTransportCombo->currentTransportId()) : QString()); ident.setDictionary(mDictionaryCombo->currentDictionaryName()); ident.setDisabledFcc(!mSentMailFolderCheck->isChecked()); Akonadi::Collection collection = mFccFolderRequester->collection(); if (collection.isValid()) { ident.setFcc(QString::number(collection.id())); Akonadi::EntityDisplayAttribute *attribute = collection.attribute(Akonadi::Collection::AddIfMissing); attribute->setIconName(QStringLiteral("mail-folder-sent")); new Akonadi::CollectionModifyJob(collection); } else { ident.setFcc(QString()); } collection = mDraftsFolderRequester->collection(); if (collection.isValid()) { ident.setDrafts(QString::number(collection.id())); Akonadi::EntityDisplayAttribute *attribute = collection.attribute(Akonadi::Collection::AddIfMissing); attribute->setIconName(QStringLiteral("document-properties")); new Akonadi::CollectionModifyJob(collection); } else { ident.setDrafts(QString()); } collection = mTemplatesFolderRequester->collection(); if (collection.isValid()) { ident.setTemplates(QString::number(collection.id())); Akonadi::EntityDisplayAttribute *attribute = collection.attribute(Akonadi::Collection::AddIfMissing); attribute->setIconName(QStringLiteral("document-new")); new Akonadi::CollectionModifyJob(collection); } else { ident.setTemplates(QString()); } ident.setVCardFile(mVcardFilename); ident.setAutocorrectionLanguage(mAutoCorrectionLanguage->language()); updateVcardButton(); ident.setAttachVcard(mAttachMyVCard->isChecked()); //Add default ? ident.setDefaultDomainName(mDefaultDomainEdit->text()); // "Templates" tab: uint identity = ident.uoid(); QString iid = TemplateParser::TemplatesConfiguration::configIdString(identity); TemplateParser::Templates t(iid); qCDebug(KMAIL_LOG) << "use custom templates for identity" << identity << ":" << mCustom->isChecked(); t.setUseCustomTemplates(mCustom->isChecked()); t.save(); mWidget->saveToIdentity(identity); // "Signature" tab: ident.setSignature(mSignatureConfigurator->signature()); ident.setXFace(mXFaceConfigurator->xface()); ident.setXFaceEnabled(mXFaceConfigurator->isXFaceEnabled()); } void IdentityDialog::slotEditVcard() { if (QFile(mVcardFilename).exists()) { editVcard(mVcardFilename); } else { if (!MailCommon::Kernel::self()->kernelIsRegistered()) { return; } KIdentityManagement::IdentityManager *manager = KernelIf->identityManager(); QPointer dlg = new IdentityAddVcardDialog(manager->shadowIdentities(), this); if (dlg->exec()) { IdentityAddVcardDialog::DuplicateMode mode = dlg->duplicateMode(); switch (mode) { case IdentityAddVcardDialog::Empty: { editVcard(mVcardFilename); break; } case IdentityAddVcardDialog::ExistingEntry: { KIdentityManagement::Identity ident = manager->modifyIdentityForName(dlg->duplicateVcardFromIdentity()); const QString filename = ident.vCardFile(); if (!filename.isEmpty()) { QFile::copy(filename, mVcardFilename); } editVcard(mVcardFilename); break; } case IdentityAddVcardDialog::FromExistingVCard: { const QString filename = dlg->existingVCard().path(); if (!filename.isEmpty()) { mVcardFilename = filename; } editVcard(mVcardFilename); break; } } } delete dlg; } } void IdentityDialog::editVcard(const QString &filename) { QPointer dlg = new IdentityEditVcardDialog(filename, this); connect(dlg.data(), &IdentityEditVcardDialog::vcardRemoved, this, &IdentityDialog::slotVCardRemoved); if (dlg->exec()) { mVcardFilename = dlg->saveVcard(); } updateVcardButton(); delete dlg; } void IdentityDialog::slotVCardRemoved() { mVcardFilename.clear(); } void IdentityDialog::updateVcardButton() { if (mVcardFilename.isEmpty() || !QFile(mVcardFilename).exists()) { mEditVCard->setText(i18n("Create...")); } else { mEditVCard->setText(i18n("Edit...")); } } } +#include "identitydialog.moc" diff --git a/kmail/src/identity/identitydialog.h b/kmail/src/identity/identitydialog.h index 653906cce9..f85c6c9994 100644 --- a/kmail/src/identity/identitydialog.h +++ b/kmail/src/identity/identitydialog.h @@ -1,164 +1,166 @@ /* identitydialog.h This file is part of KMail, the KDE mail client. Copyright (c) 2002 Marc Mutz KMail is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. KMail 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 __KMAIL_IDENTITYDIALOG_H__ #define __KMAIL_IDENTITYDIALOG_H__ #include class QCheckBox; class KEditListWidget; class KComboBox; class KJob; class KLineEdit; class QPushButton; class QTabWidget; -namespace Kleo +namespace GpgME { -class EncryptionKeyRequester; -class SigningKeyRequester; +class Key; } namespace KIdentityManagement { class Identity; class SignatureConfigurator; } namespace KMail { class XFaceConfigurator; } namespace MailCommon { class FolderRequester; } namespace Sonnet { class DictionaryComboBox; } namespace MailTransport { class TransportComboBox; } namespace TemplateParser { class TemplatesConfiguration; } namespace PimCommon { class AutoCorrectionLanguage; } namespace KMail { class IdentityFolderRequester; class IdentityInvalidFolder; +class KeySelectionCombo; + class IdentityDialog : public QDialog { Q_OBJECT public: explicit IdentityDialog(QWidget *parent = Q_NULLPTR); ~IdentityDialog(); void setIdentity(/*_not_ const*/ KIdentityManagement::Identity &ident); void updateIdentity(KIdentityManagement::Identity &ident); protected Q_SLOTS: void slotAboutToShow(int); // copy default templates to identity templates void slotCopyGlobal(); private Q_SLOTS: void slotAccepted(); void slotDelayedButtonClicked(KJob *); void slotEditVcard(); void slotRefreshDefaultDomainName(); void slotVCardRemoved(); void slotHelp(); private: + bool keyMatchesEmailAddress(const GpgME::Key &key, const QString &email); bool checkFolderExists(const QString &folder); bool validateAddresses(const QString &addresses); void updateVcardButton(); void editVcard(const QString &filename); private: // "general" tab: KLineEdit *mNameEdit; KLineEdit *mOrganizationEdit; KLineEdit *mEmailEdit; KEditListWidget *mAliasEdit; // "cryptography" tab: QWidget *mCryptographyTab; - Kleo::SigningKeyRequester *mPGPSigningKeyRequester; - Kleo::EncryptionKeyRequester *mPGPEncryptionKeyRequester; - Kleo::SigningKeyRequester *mSMIMESigningKeyRequester; - Kleo::EncryptionKeyRequester *mSMIMEEncryptionKeyRequester; + KeySelectionCombo *mPGPSigningKeyRequester; + KeySelectionCombo *mPGPEncryptionKeyRequester; + KeySelectionCombo *mSMIMESigningKeyRequester; + KeySelectionCombo *mSMIMEEncryptionKeyRequester; KComboBox *mPreferredCryptoMessageFormat; QCheckBox *mAutoSign; QCheckBox *mAutoEncrypt; // "advanced" tab: KLineEdit *mReplyToEdit; KLineEdit *mBccEdit; KLineEdit *mCcEdit; Sonnet::DictionaryComboBox *mDictionaryCombo; IdentityFolderRequester *mFccFolderRequester; QCheckBox *mSentMailFolderCheck; IdentityFolderRequester *mDraftsFolderRequester; IdentityFolderRequester *mTemplatesFolderRequester; QCheckBox *mTransportCheck; MailTransport::TransportComboBox *mTransportCombo; QCheckBox *mAttachMyVCard; QString mVcardFilename; QPushButton *mEditVCard; PimCommon::AutoCorrectionLanguage *mAutoCorrectionLanguage; KLineEdit *mDefaultDomainEdit; // "templates" tab: TemplateParser::TemplatesConfiguration *mWidget; QCheckBox *mCustom; QPushButton *mCopyGlobal; // "signature" tab: KIdentityManagement::SignatureConfigurator *mSignatureConfigurator; // "X-Face" tab: KMail::XFaceConfigurator *mXFaceConfigurator; QTabWidget *mTabWidget; IdentityInvalidFolder *mIdentityInvalidFolder; }; } // namespace KMail #endif // __KMAIL_IDENTITYDIALOG_H__