Page MenuHome GnuPG

No OneTemporary

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 150959441..36ccc4cdd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,644 +1,644 @@
# 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)
if(WIN32)
set(_kleopatra_extra_uiserver_SRCS uiserver/uiserver_win.cpp)
set(_kleopatra_extra_SRCS
pics/gpg4win.qrc
selftest/registrycheck.cpp selftest/registrycheck.h
utils/gnupg-registry.c
utils/userinfo_win.cpp
utils/winapi-helpers.cpp utils/winapi-helpers.h
utils/windowsprocessdevice.cpp utils/windowsprocessdevice.h
versioninfo.rc kleopatra.w32-manifest
)
else()
set(_kleopatra_extra_uiserver_SRCS uiserver/uiserver_unix.cpp)
set(_kleopatra_extra_SRCS)
endif()
set(_kleopatra_uiserver_SRCS
${_kleopatra_extra_uiserver_SRCS}
selftest/uiservercheck.cpp selftest/uiservercheck.h
uiserver/assuanserverconnection.cpp uiserver/assuanserverconnection.h
uiserver/createchecksumscommand.cpp uiserver/createchecksumscommand.h
uiserver/decryptverifycommandemailbase.cpp uiserver/decryptverifycommandemailbase.h
uiserver/decryptverifycommandfilesbase.cpp uiserver/decryptverifycommandfilesbase.h
uiserver/echocommand.cpp uiserver/echocommand.h
uiserver/encryptcommand.cpp uiserver/encryptcommand.h
uiserver/importfilescommand.cpp uiserver/importfilescommand.h
uiserver/prepencryptcommand.cpp uiserver/prepencryptcommand.h
uiserver/prepsigncommand.cpp uiserver/prepsigncommand.h
uiserver/selectcertificatecommand.cpp
uiserver/sessiondata.cpp uiserver/sessiondata.h
uiserver/signcommand.cpp uiserver/signcommand.h
uiserver/signencryptfilescommand.cpp
uiserver/uiserver.cpp
uiserver/verifychecksumscommand.cpp uiserver/verifychecksumscommand.h
)
set(_kleopatra_uiserver_extra_libs LibAssuan::LibAssuan LibGpgError::LibGpgError)
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()
if(KPim6IdentityManagementCore_FOUND AND KPim6MailTransport_FOUND AND KPim6AkonadiMime_FOUND)
set(_kleopatra_mail_libs
KPim6::IdentityManagementCore # Export OpenPGP keys using WKS
KPim6::MailTransport
KPim6::AkonadiMime
)
add_definitions(-DMAILAKONADI_ENABLED)
endif()
ki18n_wrap_ui(_kleopatra_uiserver_SRCS crypto/gui/signingcertificateselectionwidget.ui)
set(_kleopatra_SRCS
${_kleopatra_extra_SRCS}
accessibility/accessiblelink.cpp
accessibility/accessiblelink_p.h
accessibility/accessiblerichtextlabel.cpp
accessibility/accessiblerichtextlabel_p.h
accessibility/accessiblevaluelabel.cpp
accessibility/accessiblevaluelabel_p.h
accessibility/accessiblewidgetfactory.cpp
accessibility/accessiblewidgetfactory.h
commands/addadskcommand.cpp
commands/addadskcommand.h
commands/addsubkeycommand.cpp
commands/addsubkeycommand.h
commands/adduseridcommand.cpp
commands/adduseridcommand.h
commands/authenticatepivcardapplicationcommand.cpp
commands/authenticatepivcardapplicationcommand.h
commands/cardcommand.cpp
commands/cardcommand.h
commands/certificatetocardcommand.cpp
commands/certificatetocardcommand.h
commands/certificatetopivcardcommand.cpp
commands/certificatetopivcardcommand.h
commands/certifycertificatecommand.cpp
commands/certifycertificatecommand.h
commands/certifygroupcommand.cpp
commands/certifygroupcommand.h
commands/changeexpirycommand.cpp
commands/changeexpirycommand.h
commands/changeownertrustcommand.cpp
commands/changeownertrustcommand.h
commands/changepassphrasecommand.cpp
commands/changepassphrasecommand.h
commands/changepincommand.cpp
commands/changepincommand.h
commands/changeroottrustcommand.cpp
commands/changeroottrustcommand.h
commands/checksumcreatefilescommand.cpp
commands/checksumcreatefilescommand.h
commands/checksumverifyfilescommand.cpp
commands/checksumverifyfilescommand.h
commands/clearcrlcachecommand.cpp
commands/clearcrlcachecommand.h
commands/command.cpp
commands/command.h
commands/createcsrforcardkeycommand.cpp
commands/createcsrforcardkeycommand.h
commands/creategroupcommand.cpp
commands/creategroupcommand.h
commands/createopenpgpkeyfromcardkeyscommand.cpp
commands/createopenpgpkeyfromcardkeyscommand.h
commands/decryptverifyclipboardcommand.cpp
commands/decryptverifyclipboardcommand.h
commands/decryptverifyfilescommand.cpp
commands/decryptverifyfilescommand.h
commands/deletecertificatescommand.cpp
commands/deletecertificatescommand.h
commands/detailscommand.cpp
commands/detailscommand.h
commands/dumpcertificatecommand.cpp
commands/dumpcertificatecommand.h
commands/dumpcrlcachecommand.cpp
commands/dumpcrlcachecommand.h
commands/exportcertificatecommand.cpp
commands/exportcertificatecommand.h
commands/exportgroupscommand.cpp
commands/exportgroupscommand.h
commands/exportopenpgpcertstoservercommand.cpp
commands/exportopenpgpcertstoservercommand.h
commands/exportopenpgpcerttoprovidercommand.cpp
commands/exportopenpgpcerttoprovidercommand.h
commands/exportpaperkeycommand.cpp
commands/exportpaperkeycommand.h
commands/exportsecretkeycommand.cpp
commands/exportsecretkeycommand.h
commands/exportsecretsubkeycommand.cpp
commands/exportsecretsubkeycommand.h
commands/generateopenpgpcardkeysandcertificatecommand.cpp
commands/generateopenpgpcardkeysandcertificatecommand.h
commands/genrevokecommand.cpp
commands/genrevokecommand.h
commands/gnupgprocesscommand.cpp
commands/gnupgprocesscommand.h
commands/importcertificatefromclipboardcommand.cpp
commands/importcertificatefromclipboardcommand.h
commands/importcertificatefromdatacommand.cpp
commands/importcertificatefromdatacommand.h
commands/importcertificatefromfilecommand.cpp
commands/importcertificatefromfilecommand.h
commands/importcertificatefromkeyservercommand.cpp
commands/importcertificatefromkeyservercommand.h
commands/importcertificatefrompivcardcommand.cpp
commands/importcertificatefrompivcardcommand.h
commands/importcertificatescommand.cpp
commands/importcertificatescommand.h
commands/importcrlcommand.cpp
commands/importcrlcommand.h
commands/importpaperkeycommand.cpp
commands/importpaperkeycommand.h
commands/keytocardcommand.cpp
commands/keytocardcommand.h
commands/lookupcertificatescommand.cpp
commands/lookupcertificatescommand.h
commands/newcertificatesigningrequestcommand.cpp
commands/newcertificatesigningrequestcommand.h
commands/newopenpgpcertificatecommand.cpp
commands/newopenpgpcertificatecommand.h
commands/openpgpgeneratecardkeycommand.cpp
commands/openpgpgeneratecardkeycommand.h
commands/pivgeneratecardkeycommand.cpp
commands/pivgeneratecardkeycommand.h
commands/refreshcertificatescommand.cpp
commands/refreshcertificatescommand.h
commands/refreshopenpgpcertscommand.cpp
commands/refreshopenpgpcertscommand.h
commands/refreshx509certscommand.cpp
commands/refreshx509certscommand.h
commands/reloadkeyscommand.cpp
commands/reloadkeyscommand.h
commands/revokecertificationcommand.cpp
commands/revokecertificationcommand.h
commands/revokekeycommand.cpp
commands/revokekeycommand.h
commands/revokeuseridcommand.cpp
commands/revokeuseridcommand.h
commands/selftestcommand.cpp
commands/selftestcommand.h
commands/setinitialpincommand.cpp
commands/setinitialpincommand.h
commands/setpivcardapplicationadministrationkeycommand.cpp
commands/setpivcardapplicationadministrationkeycommand.h
commands/setprimaryuseridcommand.cpp
commands/setprimaryuseridcommand.h
commands/signencryptclipboardcommand.cpp
commands/signencryptclipboardcommand.h
commands/signencryptfilescommand.cpp
commands/signencryptfilescommand.h
commands/signencryptfoldercommand.cpp
commands/signencryptfoldercommand.h
+ commands/testuiservercommand.cpp
+ commands/testuiservercommand.h
commands/togglecertificateenabledcommand.cpp
commands/togglecertificateenabledcommand.h
commands/viewemailfilescommand.cpp
commands/viewemailfilescommand.h
conf/configuredialog.cpp
conf/configuredialog.h
conf/groupsconfigdialog.cpp
conf/groupsconfigdialog.h
conf/groupsconfigwidget.cpp
conf/groupsconfigwidget.h
crypto/autodecryptverifyfilescontroller.cpp
crypto/autodecryptverifyfilescontroller.h
crypto/certificateresolver.cpp
crypto/certificateresolver.h
crypto/checksumsutils_p.cpp
crypto/checksumsutils_p.h
crypto/controller.cpp
crypto/controller.h
crypto/createchecksumscontroller.cpp
crypto/createchecksumscontroller.h
crypto/decryptverifyemailcontroller.cpp
crypto/decryptverifyemailcontroller.h
crypto/decryptverifyfilescontroller.cpp
crypto/decryptverifyfilescontroller.h
crypto/decryptverifytask.cpp
crypto/decryptverifytask.h
crypto/encryptemailcontroller.cpp
crypto/encryptemailcontroller.h
crypto/encryptemailtask.cpp
crypto/encryptemailtask.h
crypto/gui/certificatelineedit.cpp
crypto/gui/certificatelineedit.h
crypto/gui/certificateselectionline.cpp
crypto/gui/certificateselectionline.h
crypto/gui/decryptverifyfilesdialog.cpp
crypto/gui/decryptverifyfilesdialog.h
crypto/gui/decryptverifyfileswizard.cpp
crypto/gui/decryptverifyfileswizard.h
crypto/gui/decryptverifyoperationwidget.cpp
crypto/gui/decryptverifyoperationwidget.h
crypto/gui/encryptemailwizard.cpp
crypto/gui/encryptemailwizard.h
crypto/gui/newresultpage.cpp
crypto/gui/newresultpage.h
crypto/gui/objectspage.cpp
crypto/gui/objectspage.h
crypto/gui/resolverecipientspage.cpp
crypto/gui/resolverecipientspage.h
crypto/gui/resultitemwidget.cpp
crypto/gui/resultitemwidget.h
crypto/gui/resultlistwidget.cpp
crypto/gui/resultlistwidget.h
crypto/gui/resultpage.cpp
crypto/gui/resultpage.h
crypto/gui/signemailwizard.cpp
crypto/gui/signemailwizard.h
crypto/gui/signencryptemailconflictdialog.cpp
crypto/gui/signencryptemailconflictdialog.h
crypto/gui/signencryptfilesdialog.cpp
crypto/gui/signencryptfilesdialog.h
crypto/gui/signencryptwidget.cpp
crypto/gui/signencryptwidget.h
crypto/gui/signencryptwizard.cpp
crypto/gui/signencryptwizard.h
crypto/gui/signerresolvepage.cpp
crypto/gui/signerresolvepage.h
crypto/gui/signingcertificateselectiondialog.cpp
crypto/gui/signingcertificateselectiondialog.h
crypto/gui/signingcertificateselectionwidget.cpp
crypto/gui/signingcertificateselectionwidget.h
crypto/gui/unknownrecipientwidget.cpp
crypto/gui/unknownrecipientwidget.h
crypto/gui/verifychecksumsdialog.cpp
crypto/gui/verifychecksumsdialog.h
crypto/gui/wizard.cpp
crypto/gui/wizard.h
crypto/gui/wizardpage.cpp
crypto/gui/wizardpage.h
crypto/newsignencryptemailcontroller.cpp
crypto/newsignencryptemailcontroller.h
crypto/recipient.cpp
crypto/recipient.h
crypto/sender.cpp
crypto/sender.h
crypto/signemailcontroller.cpp
crypto/signemailcontroller.h
crypto/signemailtask.cpp
crypto/signemailtask.h
crypto/signencryptfilescontroller.cpp
crypto/signencryptfilescontroller.h
crypto/signencrypttask.cpp
crypto/signencrypttask.h
crypto/task.cpp
crypto/task.h
crypto/taskcollection.cpp
crypto/taskcollection.h
crypto/verifychecksumscontroller.cpp
crypto/verifychecksumscontroller.h
dialogs/addsubkeydialog.cpp
dialogs/addsubkeydialog.h
dialogs/adduseriddialog.cpp
dialogs/adduseriddialog.h
dialogs/animatedexpander.cpp
dialogs/animatedexpander.h
dialogs/certificatedetailsdialog.cpp
dialogs/certificatedetailsdialog.h
dialogs/certificatedetailsinputwidget.cpp
dialogs/certificatedetailsinputwidget.h
dialogs/certificatedetailswidget.cpp
dialogs/certificatedetailswidget.h
dialogs/certificatedumpwidget.cpp
dialogs/certificatedumpwidget.h
dialogs/certificateselectiondialog.cpp
dialogs/certificateselectiondialog.h
dialogs/certifycertificatedialog.cpp
dialogs/certifycertificatedialog.h
dialogs/certifywidget.cpp
dialogs/certifywidget.h
dialogs/createcsrforcardkeydialog.cpp
dialogs/createcsrforcardkeydialog.h
dialogs/copytosmartcarddialog.cpp
dialogs/copytosmartcarddialog.h
dialogs/debugdialog.cpp
dialogs/debugdialog.h
dialogs/deletecertificatesdialog.cpp
dialogs/deletecertificatesdialog.h
dialogs/editgroupdialog.cpp
dialogs/editgroupdialog.h
dialogs/expirydialog.cpp
dialogs/expirydialog.h
dialogs/exportdialog.cpp
dialogs/exportdialog.h
dialogs/gencardkeydialog.cpp
dialogs/gencardkeydialog.h
dialogs/groupdetailsdialog.cpp
dialogs/groupdetailsdialog.h
dialogs/lookupcertificatesdialog.cpp
dialogs/lookupcertificatesdialog.h
dialogs/pivcardapplicationadministrationkeyinputdialog.cpp
dialogs/pivcardapplicationadministrationkeyinputdialog.h
dialogs/revokekeydialog.cpp
dialogs/revokekeydialog.h
dialogs/revokerswidget.cpp
dialogs/revokerswidget.h
dialogs/selftestdialog.cpp
dialogs/selftestdialog.h
dialogs/setinitialpindialog.cpp
dialogs/setinitialpindialog.h
dialogs/signencryptclipboarddialog.cpp
dialogs/signencryptclipboarddialog.h
dialogs/smartcardwindow.cpp
dialogs/smartcardwindow.h
dialogs/subkeyswidget.cpp
dialogs/subkeyswidget.h
dialogs/trustchainwidget.cpp
dialogs/trustchainwidget.h
dialogs/updatenotification.cpp
dialogs/updatenotification.h
dialogs/useridswidget.cpp
dialogs/useridswidget.h
dialogs/weboftrustwidget.cpp
dialogs/weboftrustwidget.h
interfaces/anchorprovider.h
interfaces/focusfirstchild.h
newcertificatewizard/advancedsettingsdialog.cpp
newcertificatewizard/advancedsettingsdialog_p.h
newcertificatewizard/enterdetailspage.cpp
newcertificatewizard/enterdetailspage_p.h
newcertificatewizard/keycreationpage.cpp
newcertificatewizard/keycreationpage_p.h
newcertificatewizard/listwidget.cpp
newcertificatewizard/listwidget.h
newcertificatewizard/newcertificatewizard.cpp
newcertificatewizard/newcertificatewizard.h
newcertificatewizard/resultpage.cpp
newcertificatewizard/resultpage_p.h
newcertificatewizard/wizardpage.cpp
newcertificatewizard/wizardpage_p.h
selftest/compliancecheck.cpp
selftest/compliancecheck.h
selftest/enginecheck.cpp
selftest/enginecheck.h
selftest/gpgagentcheck.cpp
selftest/gpgagentcheck.h
selftest/gpgconfcheck.cpp
selftest/gpgconfcheck.h
selftest/libkleopatrarccheck.cpp
selftest/libkleopatrarccheck.h
selftest/selftest.cpp
selftest/selftest.h
smartcard/algorithminfo.h
smartcard/card.cpp
smartcard/card.h
smartcard/deviceinfowatcher.cpp
smartcard/deviceinfowatcher.h
smartcard/keypairinfo.cpp
smartcard/keypairinfo.h
smartcard/netkeycard.cpp
smartcard/netkeycard.h
smartcard/openpgpcard.cpp
smartcard/openpgpcard.h
smartcard/p15card.cpp
smartcard/p15card.h
smartcard/pivcard.cpp
smartcard/pivcard.h
smartcard/readerstatus.cpp
smartcard/readerstatus.h
smartcard/utils.cpp
smartcard/utils.h
utils/accessibility.cpp
utils/accessibility.h
utils/action_data.cpp
utils/action_data.h
utils/applicationstate.cpp
utils/applicationstate.h
utils/archivedefinition.cpp
utils/archivedefinition.h
utils/certificatepair.h
utils/clipboardmenu.cpp
utils/clipboardmenu.h
utils/debug-helpers.cpp
utils/debug-helpers.h
utils/dragqueen.cpp
utils/dragqueen.h
utils/email.cpp
utils/email.h
utils/emptypassphraseprovider.cpp
utils/emptypassphraseprovider.h
utils/filedialog.cpp
utils/filedialog.h
utils/fileutils.cpp
utils/fileutils.h
utils/gui-helper.cpp
utils/gui-helper.h
utils/headerview.cpp
utils/headerview.h
utils/input.cpp
utils/input.h
utils/iodevicelogger.cpp
utils/iodevicelogger.h
utils/kdpipeiodevice.cpp
utils/kdpipeiodevice.h
utils/keyexportdraghandler.cpp
utils/keyexportdraghandler.h
utils/kuniqueservice.cpp
utils/kuniqueservice.h
utils/log.cpp
utils/log.h
utils/memory-helpers.h
utils/migration.cpp
utils/migration.h
utils/output.cpp
utils/output.h
utils/overwritedialog.cpp
utils/overwritedialog.h
utils/path-helper.cpp
utils/path-helper.h
utils/statusmessage.cpp
utils/statusmessage.h
utils/systemtrayicon.cpp
utils/systemtrayicon.h
utils/tags.cpp
utils/tags.h
utils/types.cpp
utils/types.h
utils/userinfo.cpp
utils/userinfo.h
utils/writecertassuantransaction.cpp
utils/writecertassuantransaction.h
utils/wsastarter.cpp
utils/wsastarter.h
view/anchorcache.cpp
view/anchorcache_p.h
view/cardkeysview.cpp
view/cardkeysview.h
view/htmllabel.cpp
view/htmllabel.h
view/infofield.cpp
view/infofield.h
view/keycacheoverlay.cpp
view/keycacheoverlay.h
view/keylistcontroller.cpp
view/keylistcontroller.h
view/keytreeview.cpp
view/keytreeview.h
view/netkeywidget.cpp
view/netkeywidget.h
view/overlaywidget.cpp
view/overlaywidget.h
view/p15cardwidget.cpp
view/p15cardwidget.h
view/padwidget.cpp
view/padwidget.h
view/pgpcardwidget.cpp
view/pgpcardwidget.h
view/pivcardwidget.cpp
view/pivcardwidget.h
view/progressoverlay.cpp
view/progressoverlay.h
view/searchbar.cpp
view/searchbar.h
view/smartcardactions.cpp
view/smartcardactions.h
view/smartcardswidget.cpp
view/smartcardswidget.h
view/smartcardwidget.cpp
view/smartcardwidget.h
view/tabwidget.cpp
view/tabwidget.h
view/textoverlay.cpp
view/textoverlay.h
view/urllabel.cpp
view/urllabel.h
view/waitwidget.cpp
view/waitwidget.h
view/welcomewidget.cpp
view/welcomewidget.h
aboutdata.cpp
aboutdata.h
kleopatra.qrc
kleopatraapplication.cpp
kleopatraapplication.h
main.cpp
mainwindow.cpp
mainwindow.h
systrayicon.cpp
systrayicon.h
kleopatra_options.h
)
if(WIN32)
configure_file (versioninfo.rc.in versioninfo.rc)
configure_file (kleopatra.w32-manifest.in kleopatra.w32-manifest)
set(_kleopatra_SRCS
${CMAKE_CURRENT_BINARY_DIR}/kleopatra.w32-manifest
${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc
conf/kmessageboxdontaskagainstorage.cpp
conf/kmessageboxdontaskagainstorage.h
${_kleopatra_SRCS}
)
endif()
set (_kleopatra_SRCS conf/kleopageconfigdialog.cpp conf/kleopageconfigdialog.h ${_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/setinitialpindialog.ui
newcertificatewizard/listwidget.ui
)
kconfig_add_kcfg_files(_kleopatra_SRCS
kcfg/emailoperationspreferences.kcfgc
kcfg/fileoperationspreferences.kcfgc
kcfg/settings.kcfgc
kcfg/smimevalidationpreferences.kcfgc
kcfg/tooltippreferences.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
KPim6::Libkleo
KPim6::Mime
KPim6::MimeTreeParserWidgets
KF6::Codecs
KF6::CoreAddons
KF6::Crash
KF6::I18n
KF6::IconThemes
KF6::ItemModels
KF6::KIOCore
KF6::KIOWidgets
KF6::WindowSystem
KF6::XmlGui
Qt::Network
Qt::PrintSupport # Printing secret keys
- kleopatraclientcore
${_kleopatra_extra_libs}
${_kleopatra_mail_libs}
${_kleopatra_uiserver_extra_libs}
${_kleopatra_dbusaddons_libs}
${_kleopatra_platform_libs}
)
target_link_libraries(kleopatra_bin QGpgmeQt6)
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(FILES data/kleopatra-mime.xml DESTINATION ${KDE_INSTALL_MIMEDIR})
install(
PROGRAMS data/kleopatra_signencryptfiles.desktop
data/kleopatra_signencryptfolders.desktop
data/kleopatra_decryptverifyfiles.desktop
data/kleopatra_decryptverifyfolders.desktop
DESTINATION ${KDE_INSTALL_DATADIR}/kio/servicemenus
)
install(FILES kleopatradebugcommandsrc DESTINATION ${KDE_INSTALL_CONFDIR})
diff --git a/src/commands/testuiservercommand.cpp b/src/commands/testuiservercommand.cpp
new file mode 100644
index 000000000..36cad91dc
--- /dev/null
+++ b/src/commands/testuiservercommand.cpp
@@ -0,0 +1,318 @@
+/* -*- mode: c++; c-basic-offset:4 -*-
+ command.cpp
+
+ This file is part of KleopatraClient, the Kleopatra interface library
+ SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
+
+ SPDX-License-Identifier: LGPL-2.0-or-later
+*/
+
+#include <config-kleopatra.h>
+
+#include "testuiservercommand.h"
+
+#include <KLocalizedString>
+#include <QDir>
+#include <QFile>
+#include <QMutexLocker>
+#include <QProcess>
+#include <QThread>
+
+#include <assuan.h>
+#include <gpg-error.h>
+#include <gpgme++/error.h>
+
+#include <memory>
+#include <string>
+
+using namespace Kleo::Commands;
+
+class TestUiServerCommand::Private : public QThread
+{
+ Q_OBJECT
+private:
+ friend class ::TestUiServerCommand;
+ TestUiServerCommand *const q;
+
+public:
+ explicit Private(TestUiServerCommand *qq)
+ : QThread()
+ , q(qq)
+ , mutex()
+ , inputs()
+ , outputs()
+ {
+ }
+ ~Private() override
+ {
+ }
+
+private:
+ void init();
+
+private:
+ void run() override;
+
+private:
+ QRecursiveMutex mutex;
+ struct Inputs {
+ Inputs()
+ {
+ }
+ std::map<std::string, QByteArray> inquireData;
+ QByteArray command;
+ } inputs;
+ struct Outputs {
+ Outputs()
+ : serverPid(0)
+ {
+ }
+ QString errorString;
+ QByteArray data;
+ qint64 serverPid;
+ QString serverLocation;
+ } outputs;
+};
+
+TestUiServerCommand::TestUiServerCommand(QObject *p)
+ : QObject(p)
+ , d(new Private(this))
+{
+ d->init();
+}
+
+TestUiServerCommand::~TestUiServerCommand()
+{
+ delete d;
+ d = nullptr;
+}
+
+void TestUiServerCommand::Private::init()
+{
+ connect(this, &QThread::started, q, &TestUiServerCommand::started);
+ connect(this, &QThread::finished, q, &TestUiServerCommand::finished);
+}
+
+bool TestUiServerCommand::error() const
+{
+ const QMutexLocker locker(&d->mutex);
+ return !d->outputs.errorString.isEmpty();
+}
+
+QString TestUiServerCommand::errorString() const
+{
+ const QMutexLocker locker(&d->mutex);
+ return d->outputs.errorString;
+}
+
+qint64 TestUiServerCommand::serverPid() const
+{
+ const QMutexLocker locker(&d->mutex);
+ return d->outputs.serverPid;
+}
+
+void TestUiServerCommand::start()
+{
+ d->start();
+}
+
+static void my_assuan_release(assuan_context_t ctx)
+{
+ if (ctx) {
+ assuan_release(ctx);
+ }
+}
+
+using AssuanContextBase = std::shared_ptr<std::remove_pointer<assuan_context_t>::type>;
+namespace
+{
+struct AssuanClientContext : AssuanContextBase {
+ AssuanClientContext()
+ : AssuanContextBase()
+ {
+ }
+ explicit AssuanClientContext(assuan_context_t ctx)
+ : AssuanContextBase(ctx, &my_assuan_release)
+ {
+ }
+ void reset(assuan_context_t ctx = nullptr)
+ {
+ AssuanContextBase::reset(ctx, &my_assuan_release);
+ }
+};
+}
+
+static gpg_error_t my_assuan_transact(const AssuanClientContext &ctx,
+ const char *command,
+ gpg_error_t (*data_cb)(void *, const void *, size_t) = nullptr,
+ void *data_cb_arg = nullptr,
+ gpg_error_t (*inquire_cb)(void *, const char *) = nullptr,
+ void *inquire_cb_arg = nullptr,
+ gpg_error_t (*status_cb)(void *, const char *) = nullptr,
+ void *status_cb_arg = nullptr)
+{
+ return assuan_transact(ctx.get(), command, data_cb, data_cb_arg, inquire_cb, inquire_cb_arg, status_cb, status_cb_arg);
+}
+
+static QString to_error_string(int err)
+{
+ char buffer[1024];
+ gpg_strerror_r(static_cast<gpg_error_t>(err), buffer, sizeof buffer);
+ buffer[sizeof buffer - 1] = '\0';
+ return QString::fromLocal8Bit(buffer);
+}
+
+static QString gnupg_home_directory()
+{
+ static const char *hDir = GpgME::dirInfo("homedir");
+ return QFile::decodeName(hDir);
+}
+
+static QString get_default_socket_name()
+{
+ const QString socketPath{QString::fromUtf8(GpgME::dirInfo("uiserver-socket"))};
+ if (!socketPath.isEmpty()) {
+ // Note: The socket directory exists after GpgME::dirInfo() has been called.
+ return socketPath;
+ }
+ const QString homeDir = gnupg_home_directory();
+ if (homeDir.isEmpty()) {
+ return QString();
+ }
+ return QDir(homeDir).absoluteFilePath(QStringLiteral("S.uiserver"));
+}
+
+static QString uiserver_executable()
+{
+ return QStringLiteral("kleopatra");
+}
+
+static QString start_uiserver()
+{
+ // Warning: Don't assume that the program needs to be in PATH. On Windows, it will also be found next to the calling process.
+ if (!QProcess::startDetached(uiserver_executable(), QStringList() << QStringLiteral("--daemon"))) {
+ return i18n("Failed to start uiserver %1", uiserver_executable());
+ } else {
+ return QString();
+ }
+}
+
+static gpg_error_t getinfo_pid_cb(void *opaque, const void *buffer, size_t length)
+{
+ qint64 &pid = *static_cast<qint64 *>(opaque);
+ pid = QByteArray(static_cast<const char *>(buffer), length).toLongLong();
+ return 0;
+}
+
+static gpg_error_t command_data_cb(void *opaque, const void *buffer, size_t length)
+{
+ QByteArray &ba = *static_cast<QByteArray *>(opaque);
+ ba.append(QByteArray(static_cast<const char *>(buffer), length));
+ return 0;
+}
+
+namespace
+{
+struct inquire_data {
+ const std::map<std::string, QByteArray> *map;
+ const AssuanClientContext *ctx;
+};
+}
+
+static gpg_error_t command_inquire_cb(void *opaque, const char *what)
+{
+ if (!opaque) {
+ return 0;
+ }
+ const inquire_data &id = *static_cast<const inquire_data *>(opaque);
+ const auto it = id.map->find(what);
+ if (it != id.map->end()) {
+ const QByteArray &v = it->second;
+ assuan_send_data(id.ctx->get(), v.data(), v.size());
+ }
+ return 0;
+}
+
+void TestUiServerCommand::Private::run()
+{
+ // Take a snapshot of the input data, and clear the output data:
+ Inputs in;
+ Outputs out;
+ {
+ const QMutexLocker locker(&mutex);
+ in = inputs;
+ outputs = out;
+ }
+
+ AssuanClientContext ctx;
+ gpg_error_t err = 0;
+
+ inquire_data id = {&in.inquireData, &ctx};
+
+ const QString socketName = get_default_socket_name();
+ if (socketName.isEmpty()) {
+ out.errorString = i18n("Invalid socket name!");
+ goto leave;
+ }
+
+ {
+ assuan_context_t naked_ctx = nullptr;
+ err = assuan_new(&naked_ctx);
+ if (err) {
+ out.errorString = i18n("Could not allocate resources to connect to Kleopatra UI server at %1: %2", socketName, to_error_string(err));
+ goto leave;
+ }
+
+ ctx.reset(naked_ctx);
+ }
+
+ err = assuan_socket_connect(ctx.get(), socketName.toUtf8().constData(), -1, 0);
+ if (err) {
+ qDebug("UI server not running, starting it");
+
+ const QString errorString = start_uiserver();
+ if (!errorString.isEmpty()) {
+ out.errorString = errorString;
+ goto leave;
+ }
+
+ // give it a bit of time to start up and try a couple of times
+ for (int i = 0; err && i < 20; ++i) {
+ msleep(500);
+ err = assuan_socket_connect(ctx.get(), socketName.toUtf8().constData(), -1, 0);
+ }
+ }
+
+ if (err) {
+ out.errorString = i18n("Could not connect to Kleopatra UI server at %1: %2", socketName, to_error_string(err));
+ goto leave;
+ }
+
+ out.serverPid = -1;
+ err = my_assuan_transact(ctx, "GETINFO pid", &getinfo_pid_cb, &out.serverPid);
+ if (err || out.serverPid <= 0) {
+ out.errorString = i18n("Could not get the process-id of the Kleopatra UI server at %1: %2", socketName, to_error_string(err));
+ goto leave;
+ }
+
+ if (in.command.isEmpty()) {
+ goto leave;
+ }
+
+ err = my_assuan_transact(ctx, in.command.constData(), &command_data_cb, &out.data, &command_inquire_cb, &id);
+ if (err) {
+ if (GpgME::Error{err}.isCanceled()) {
+ } else {
+ out.errorString = i18n("Command (%1) failed: %2", QString::fromLatin1(in.command.constData()), to_error_string(err));
+ }
+ goto leave;
+ }
+
+leave:
+ const QMutexLocker locker(&mutex);
+ // copy outputs to where Command can see them:
+ outputs = out;
+}
+
+#include "moc_testuiservercommand.cpp"
+#include "testuiservercommand.moc"
diff --git a/src/commands/testuiservercommand.h b/src/commands/testuiservercommand.h
new file mode 100644
index 000000000..c2afc76cc
--- /dev/null
+++ b/src/commands/testuiservercommand.h
@@ -0,0 +1,45 @@
+/* -*- mode: c++; c-basic-offset:4 -*-
+ core/command.h
+
+ This file is part of KleopatraClient, the Kleopatra interface library
+ SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
+
+ SPDX-License-Identifier: LGPL-2.0-or-later
+*/
+
+#pragma once
+
+#include <QObject>
+
+class QString;
+
+namespace Kleo
+{
+namespace Commands
+{
+
+class TestUiServerCommand : public QObject
+{
+ Q_OBJECT
+public:
+ explicit TestUiServerCommand(QObject *parent = nullptr);
+ ~TestUiServerCommand() override;
+
+ bool error() const;
+ QString errorString() const;
+ qint64 serverPid() const;
+
+public Q_SLOTS:
+ void start();
+
+Q_SIGNALS:
+ void started();
+ void finished();
+
+protected:
+ class Private;
+ Private *d;
+};
+
+}
+}
diff --git a/src/libkleopatraclient/CMakeLists.txt b/src/libkleopatraclient/CMakeLists.txt
deleted file mode 100644
index b4bf7e3b8..000000000
--- a/src/libkleopatraclient/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-FileCopyrightText: none
-# SPDX-License-Identifier: BSD-3-Clause
-set(libkleopatraclient_version "1.3.0")
-set(libkleopatraclient_soversion "1")
-
-add_subdirectory(core)
diff --git a/src/libkleopatraclient/core/CMakeLists.txt b/src/libkleopatraclient/core/CMakeLists.txt
deleted file mode 100644
index 362fbd7b1..000000000
--- a/src/libkleopatraclient/core/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# SPDX-FileCopyrightText: none
-# SPDX-License-Identifier: BSD-3-Clause
-
-if(WIN32)
- set(_kleopatraclientcore_extra_SRCS ../../utils/gnupg-registry.c)
-else()
- set(_kleopatraclientcore_extra_SRCS)
-endif()
-
-ecm_qt_declare_logging_category(_kleopatraclientcore_common_SRCS HEADER libkleopatraclientcore_debug.h IDENTIFIER LIBKLEOPATRACLIENTCORE_LOG CATEGORY_NAME org.kde.pim.libkleopatraclientcore
- DESCRIPTION "kleopatra client core (kleopatra)"
- OLD_CATEGORY_NAMES log_libkleopatraclientcore
- EXPORT KLEOPATRA
- )
-
-
-add_library(kleopatraclientcore
- ${_kleopatraclientcore_extra_SRCS}
- command.cpp
- libkleopatraclientcore_debug.cpp
- command.h
- libkleopatraclientcore_debug.h
- ${_kleopatraclientcore_common_SRCS}
-)
-generate_export_header(kleopatraclientcore BASE_NAME kleopatraclientcore)
-
-set_target_properties(kleopatraclientcore PROPERTIES
- VERSION ${libkleopatraclient_version}
- SOVERSION ${libkleopatraclient_soversion}
-)
-if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
- set_target_properties(kleopatraclientcore PROPERTIES UNITY_BUILD ON)
-endif()
-
-target_link_libraries(kleopatraclientcore LibAssuan::LibAssuan LibGpgError::LibGpgError Qt::Widgets KF6::I18n Gpgmepp)
-
-install(TARGETS kleopatraclientcore ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
diff --git a/src/libkleopatraclient/core/command.cpp b/src/libkleopatraclient/core/command.cpp
deleted file mode 100644
index 79e5795e8..000000000
--- a/src/libkleopatraclient/core/command.cpp
+++ /dev/null
@@ -1,675 +0,0 @@
-/* -*- mode: c++; c-basic-offset:4 -*-
- command.cpp
-
- This file is part of KleopatraClient, the Kleopatra interface library
- SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
-
- SPDX-License-Identifier: LGPL-2.0-or-later
-*/
-
-#include <config-kleopatra.h>
-
-#include "command.h"
-#include "command_p.h"
-
-#include <QtSystemDetection> // Q_OS_WIN
-
-#ifdef Q_OS_WIN // HACK: AllowSetForegroundWindow needs _WIN32_WINDOWS >= 0x0490 set
-#ifndef _WIN32_WINDOWS
-#define _WIN32_WINDOWS 0x0500
-#endif
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0500 // good enough for Vista too
-#endif
-#include <utils/gnupg-registry.h>
-#include <windows.h>
-#endif
-
-#include "libkleopatraclientcore_debug.h"
-#include <KLocalizedString>
-#include <QDir>
-#include <QFile>
-#include <QMutexLocker>
-#include <QProcess>
-
-#include <assuan.h>
-#include <gpg-error.h>
-#include <gpgme++/error.h>
-
-#include <algorithm>
-#include <memory>
-#include <sstream>
-#include <string>
-#include <type_traits>
-
-using namespace KleopatraClientCopy;
-
-// copied from kleopatra/utils/hex.cpp
-static std::string hexencode(const std::string &in)
-{
- std::string result;
- result.reserve(3 * in.size());
-
- static const char hex[] = "0123456789ABCDEF";
-
- for (std::string::const_iterator it = in.begin(), end = in.end(); it != end; ++it)
- switch (const unsigned char ch = *it) {
- default:
- if ((ch >= '!' && ch <= '~') || ch > 0xA0) {
- result += ch;
- break;
- }
- [[fallthrough]];
- // else fall through
- case ' ':
- result += '+';
- break;
- case '"':
- case '#':
- case '$':
- case '%':
- case '\'':
- case '+':
- case '=':
- result += '%';
- result += hex[(ch & 0xF0) >> 4];
- result += hex[(ch & 0x0F)];
- break;
- }
-
- return result;
-}
-
-#ifdef UNUSED
-static std::string hexencode(const char *in)
-{
- if (!in) {
- return std::string();
- }
- return hexencode(std::string(in));
-}
-#endif
-
-// changed from returning QByteArray to returning std::string
-static std::string hexencode(const QByteArray &in)
-{
- if (in.isNull()) {
- return std::string();
- }
- return hexencode(std::string(in.data(), in.size()));
-}
-// end copied from kleopatra/utils/hex.cpp
-
-Command::Command(QObject *p)
- : QObject(p)
- , d(new Private(this))
-{
- d->init();
-}
-
-Command::Command(Private *pp, QObject *p)
- : QObject(p)
- , d(pp)
-{
- d->init();
-}
-
-Command::~Command()
-{
- delete d;
- d = nullptr;
-}
-
-void Command::Private::init()
-{
- connect(this, &QThread::started, q, &Command::started);
- connect(this, &QThread::finished, q, &Command::finished);
-}
-
-void Command::setParentWId(WId wid)
-{
- const QMutexLocker locker(&d->mutex);
- d->inputs.parentWId = wid;
-}
-
-WId Command::parentWId() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->inputs.parentWId;
-}
-
-void Command::setServerLocation(const QString &location)
-{
- const QMutexLocker locker(&d->mutex);
- d->outputs.serverLocation = location;
-}
-
-QString Command::serverLocation() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->outputs.serverLocation;
-}
-
-bool Command::waitForFinished()
-{
- return d->wait();
-}
-
-bool Command::waitForFinished(unsigned long ms)
-{
- return d->wait(ms);
-}
-
-bool Command::error() const
-{
- const QMutexLocker locker(&d->mutex);
- return !d->outputs.errorString.isEmpty();
-}
-
-bool Command::wasCanceled() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->outputs.canceled;
-}
-
-QString Command::errorString() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->outputs.errorString;
-}
-
-qint64 Command::serverPid() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->outputs.serverPid;
-}
-
-void Command::start()
-{
- d->start();
-}
-
-void Command::cancel()
-{
- qCDebug(LIBKLEOPATRACLIENTCORE_LOG) << "Sorry, not implemented: KleopatraClient::Command::Cancel";
-}
-
-void Command::setOptionValue(const char *name, const QVariant &value, bool critical)
-{
- if (!name || !*name) {
- return;
- }
- const Private::Option opt = {value, true, critical};
- const QMutexLocker locker(&d->mutex);
- d->inputs.options[name] = opt;
-}
-
-QVariant Command::optionValue(const char *name) const
-{
- if (!name || !*name) {
- return QVariant();
- }
- const QMutexLocker locker(&d->mutex);
-
- const auto it = d->inputs.options.find(name);
- if (it == d->inputs.options.end()) {
- return QVariant();
- } else {
- return it->second.value;
- }
-}
-
-void Command::setOption(const char *name, bool critical)
-{
- if (!name || !*name) {
- return;
- }
- const QMutexLocker locker(&d->mutex);
-
- if (isOptionSet(name)) {
- unsetOption(name);
- }
-
- const Private::Option opt = {QVariant(), false, critical};
-
- d->inputs.options[name] = opt;
-}
-
-void Command::unsetOption(const char *name)
-{
- if (!name || !*name) {
- return;
- }
- const QMutexLocker locker(&d->mutex);
- d->inputs.options.erase(name);
-}
-
-bool Command::isOptionSet(const char *name) const
-{
- if (!name || !*name) {
- return false;
- }
- const QMutexLocker locker(&d->mutex);
- return d->inputs.options.count(name);
-}
-
-bool Command::isOptionCritical(const char *name) const
-{
- if (!name || !*name) {
- return false;
- }
- const QMutexLocker locker(&d->mutex);
- const auto it = d->inputs.options.find(name);
- return it != d->inputs.options.end() && it->second.isCritical;
-}
-
-void Command::setFilePaths(const QStringList &filePaths)
-{
- const QMutexLocker locker(&d->mutex);
- d->inputs.filePaths = filePaths;
-}
-
-QStringList Command::filePaths() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->inputs.filePaths;
-}
-
-void Command::setRecipients(const QStringList &recipients, bool informative)
-{
- const QMutexLocker locker(&d->mutex);
- d->inputs.recipients = recipients;
- d->inputs.areRecipientsInformative = informative;
-}
-
-QStringList Command::recipients() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->inputs.recipients;
-}
-
-bool Command::areRecipientsInformative() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->inputs.areRecipientsInformative;
-}
-
-void Command::setSenders(const QStringList &senders, bool informative)
-{
- const QMutexLocker locker(&d->mutex);
- d->inputs.senders = senders;
- d->inputs.areSendersInformative = informative;
-}
-
-QStringList Command::senders() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->inputs.senders;
-}
-
-bool Command::areSendersInformative() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->inputs.areSendersInformative;
-}
-
-void Command::setInquireData(const char *what, const QByteArray &data)
-{
- const QMutexLocker locker(&d->mutex);
- d->inputs.inquireData[what] = data;
-}
-
-void Command::unsetInquireData(const char *what)
-{
- const QMutexLocker locker(&d->mutex);
- d->inputs.inquireData.erase(what);
-}
-
-QByteArray Command::inquireData(const char *what) const
-{
- const QMutexLocker locker(&d->mutex);
- const auto it = d->inputs.inquireData.find(what);
- if (it == d->inputs.inquireData.end()) {
- return QByteArray();
- } else {
- return it->second;
- }
-}
-
-bool Command::isInquireDataSet(const char *what) const
-{
- const QMutexLocker locker(&d->mutex);
- const auto it = d->inputs.inquireData.find(what);
- return it != d->inputs.inquireData.end();
-}
-
-QByteArray Command::receivedData() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->outputs.data;
-}
-
-void Command::setCommand(const char *command)
-{
- const QMutexLocker locker(&d->mutex);
- d->inputs.command = command;
-}
-
-QByteArray Command::command() const
-{
- const QMutexLocker locker(&d->mutex);
- return d->inputs.command;
-}
-
-//
-// here comes the ugly part
-//
-
-static void my_assuan_release(assuan_context_t ctx)
-{
- if (ctx) {
- assuan_release(ctx);
- }
-}
-
-using AssuanContextBase = std::shared_ptr<std::remove_pointer<assuan_context_t>::type>;
-namespace
-{
-struct AssuanClientContext : AssuanContextBase {
- AssuanClientContext()
- : AssuanContextBase()
- {
- }
- explicit AssuanClientContext(assuan_context_t ctx)
- : AssuanContextBase(ctx, &my_assuan_release)
- {
- }
- void reset(assuan_context_t ctx = nullptr)
- {
- AssuanContextBase::reset(ctx, &my_assuan_release);
- }
-};
-}
-
-static gpg_error_t my_assuan_transact(const AssuanClientContext &ctx,
- const char *command,
- gpg_error_t (*data_cb)(void *, const void *, size_t) = nullptr,
- void *data_cb_arg = nullptr,
- gpg_error_t (*inquire_cb)(void *, const char *) = nullptr,
- void *inquire_cb_arg = nullptr,
- gpg_error_t (*status_cb)(void *, const char *) = nullptr,
- void *status_cb_arg = nullptr)
-{
- return assuan_transact(ctx.get(), command, data_cb, data_cb_arg, inquire_cb, inquire_cb_arg, status_cb, status_cb_arg);
-}
-
-static QString to_error_string(int err)
-{
- char buffer[1024];
- gpg_strerror_r(static_cast<gpg_error_t>(err), buffer, sizeof buffer);
- buffer[sizeof buffer - 1] = '\0';
- return QString::fromLocal8Bit(buffer);
-}
-
-static QString gnupg_home_directory()
-{
- static const char *hDir = GpgME::dirInfo("homedir");
- return QFile::decodeName(hDir);
-}
-
-static QString get_default_socket_name()
-{
- const QString socketPath{QString::fromUtf8(GpgME::dirInfo("uiserver-socket"))};
- if (!socketPath.isEmpty()) {
- // Note: The socket directory exists after GpgME::dirInfo() has been called.
- return socketPath;
- }
- const QString homeDir = gnupg_home_directory();
- if (homeDir.isEmpty()) {
- return QString();
- }
- return QDir(homeDir).absoluteFilePath(QStringLiteral("S.uiserver"));
-}
-
-static QString default_socket_name()
-{
- static QString name = get_default_socket_name();
- return name;
-}
-
-static QString uiserver_executable()
-{
- return QStringLiteral("kleopatra");
-}
-
-static QString start_uiserver()
-{
- // Warning: Don't assume that the program needs to be in PATH. On Windows, it will also be found next to the calling process.
- if (!QProcess::startDetached(uiserver_executable(), QStringList() << QStringLiteral("--daemon"))) {
- return i18n("Failed to start uiserver %1", uiserver_executable());
- } else {
- return QString();
- }
-}
-
-static gpg_error_t getinfo_pid_cb(void *opaque, const void *buffer, size_t length)
-{
- qint64 &pid = *static_cast<qint64 *>(opaque);
- pid = QByteArray(static_cast<const char *>(buffer), length).toLongLong();
- return 0;
-}
-
-static gpg_error_t command_data_cb(void *opaque, const void *buffer, size_t length)
-{
- QByteArray &ba = *static_cast<QByteArray *>(opaque);
- ba.append(QByteArray(static_cast<const char *>(buffer), length));
- return 0;
-}
-
-namespace
-{
-struct inquire_data {
- const std::map<std::string, QByteArray> *map;
- const AssuanClientContext *ctx;
-};
-}
-
-static gpg_error_t command_inquire_cb(void *opaque, const char *what)
-{
- if (!opaque) {
- return 0;
- }
- const inquire_data &id = *static_cast<const inquire_data *>(opaque);
- const auto it = id.map->find(what);
- if (it != id.map->end()) {
- const QByteArray &v = it->second;
- assuan_send_data(id.ctx->get(), v.data(), v.size());
- }
- return 0;
-}
-
-static inline std::ostream &operator<<(std::ostream &s, const QByteArray &ba)
-{
- return s << std::string(ba.data(), ba.size());
-}
-
-static gpg_error_t send_option(const AssuanClientContext &ctx, const char *name, const QVariant &value)
-{
- std::stringstream ss;
- ss << "OPTION " << name;
- if (value.isValid()) {
- ss << '=' << value.toString().toUtf8();
- }
- return my_assuan_transact(ctx, ss.str().c_str());
-}
-
-static gpg_error_t send_file(const AssuanClientContext &ctx, const QString &file)
-{
- std::stringstream ss;
- ss << "FILE " << hexencode(QFile::encodeName(file));
- return my_assuan_transact(ctx, ss.str().c_str());
-}
-
-static gpg_error_t send_recipient(const AssuanClientContext &ctx, const QString &recipient, bool info)
-{
- std::stringstream ss;
- ss << "RECIPIENT ";
- if (info) {
- ss << "--info ";
- }
- ss << "--" << hexencode(recipient.toUtf8());
- return my_assuan_transact(ctx, ss.str().c_str());
-}
-
-static gpg_error_t send_sender(const AssuanClientContext &ctx, const QString &sender, bool info)
-{
- std::stringstream ss;
- ss << "SENDER ";
- if (info) {
- ss << "--info ";
- }
- ss << "--" << hexencode(sender.toUtf8());
- return my_assuan_transact(ctx, ss.str().c_str());
-}
-
-void Command::Private::run()
-{
- // Take a snapshot of the input data, and clear the output data:
- Inputs in;
- Outputs out;
- {
- const QMutexLocker locker(&mutex);
- in = inputs;
- outputs = out;
- }
-
- out.canceled = false;
-
- if (out.serverLocation.isEmpty()) {
- out.serverLocation = default_socket_name();
- }
-
- AssuanClientContext ctx;
- gpg_error_t err = 0;
-
- inquire_data id = {&in.inquireData, &ctx};
-
- const QString socketName = out.serverLocation;
- if (socketName.isEmpty()) {
- out.errorString = i18n("Invalid socket name!");
- goto leave;
- }
-
- {
- assuan_context_t naked_ctx = nullptr;
- err = assuan_new(&naked_ctx);
- if (err) {
- out.errorString = i18n("Could not allocate resources to connect to Kleopatra UI server at %1: %2", socketName, to_error_string(err));
- goto leave;
- }
-
- ctx.reset(naked_ctx);
- }
-
- err = assuan_socket_connect(ctx.get(), socketName.toUtf8().constData(), -1, 0);
- if (err) {
- qDebug("UI server not running, starting it");
-
- const QString errorString = start_uiserver();
- if (!errorString.isEmpty()) {
- out.errorString = errorString;
- goto leave;
- }
-
- // give it a bit of time to start up and try a couple of times
- for (int i = 0; err && i < 20; ++i) {
- msleep(500);
- err = assuan_socket_connect(ctx.get(), socketName.toUtf8().constData(), -1, 0);
- }
- }
-
- if (err) {
- out.errorString = i18n("Could not connect to Kleopatra UI server at %1: %2", socketName, to_error_string(err));
- goto leave;
- }
-
- out.serverPid = -1;
- err = my_assuan_transact(ctx, "GETINFO pid", &getinfo_pid_cb, &out.serverPid);
- if (err || out.serverPid <= 0) {
- out.errorString = i18n("Could not get the process-id of the Kleopatra UI server at %1: %2", socketName, to_error_string(err));
- goto leave;
- }
-
- qCDebug(LIBKLEOPATRACLIENTCORE_LOG) << "Server PID =" << out.serverPid;
-
-#if defined(Q_OS_WIN)
- if (!AllowSetForegroundWindow((pid_t)out.serverPid)) {
- qCDebug(LIBKLEOPATRACLIENTCORE_LOG) << "AllowSetForegroundWindow(" << out.serverPid << ") failed: " << GetLastError();
- }
-#endif
-
- if (in.command.isEmpty()) {
- goto leave;
- }
-
- if (in.parentWId) {
- err = send_option(ctx, "window-id", QString::number(in.parentWId, 16));
- if (err) {
- qDebug("sending option window-id failed - ignoring");
- }
- }
-
- for (auto it = in.options.begin(), end = in.options.end(); it != end; ++it)
- if ((err = send_option(ctx, it->first.c_str(), it->second.hasValue ? it->second.value.toString() : QVariant()))) {
- if (it->second.isCritical) {
- out.errorString = i18n("Failed to send critical option %1: %2", QString::fromLatin1(it->first.c_str()), to_error_string(err));
- goto leave;
- } else {
- qCDebug(LIBKLEOPATRACLIENTCORE_LOG) << "Failed to send non-critical option" << it->first.c_str() << ":" << to_error_string(err);
- }
- }
-
- for (const QString &filePath : std::as_const(in.filePaths)) {
- if ((err = send_file(ctx, filePath))) {
- out.errorString = i18n("Failed to send file path %1: %2", filePath, to_error_string(err));
- goto leave;
- }
- }
-
- for (const QString &sender : std::as_const(in.senders)) {
- if ((err = send_sender(ctx, sender, in.areSendersInformative))) {
- out.errorString = i18n("Failed to send sender %1: %2", sender, to_error_string(err));
- goto leave;
- }
- }
-
- for (const QString &recipient : std::as_const(in.recipients)) {
- if ((err = send_recipient(ctx, recipient, in.areRecipientsInformative))) {
- out.errorString = i18n("Failed to send recipient %1: %2", recipient, to_error_string(err));
- goto leave;
- }
- }
-
-#if 0
- setup I / O;
-#endif
-
- err = my_assuan_transact(ctx, in.command.constData(), &command_data_cb, &out.data, &command_inquire_cb, &id);
- if (err) {
- if (GpgME::Error{err}.isCanceled()) {
- out.canceled = true;
- } else {
- out.errorString = i18n("Command (%1) failed: %2", QString::fromLatin1(in.command.constData()), to_error_string(err));
- }
- goto leave;
- }
-
-leave:
- const QMutexLocker locker(&mutex);
- // copy outputs to where Command can see them:
- outputs = out;
-}
-
-#include "moc_command_p.cpp"
-
-#include "moc_command.cpp"
diff --git a/src/libkleopatraclient/core/command.h b/src/libkleopatraclient/core/command.h
deleted file mode 100644
index b97888aa2..000000000
--- a/src/libkleopatraclient/core/command.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- mode: c++; c-basic-offset:4 -*-
- core/command.h
-
- This file is part of KleopatraClient, the Kleopatra interface library
- SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
-
- SPDX-License-Identifier: LGPL-2.0-or-later
-*/
-
-#pragma once
-
-#include "kleopatraclientcore_export.h"
-
-#include <QObject>
-#include <QWidget> // only for WId, doesn't prevent linking against QtCore-only
-
-class QString;
-class QByteArray;
-class QVariant;
-
-namespace KleopatraClientCopy
-{
-
-class KLEOPATRACLIENTCORE_EXPORT Command : public QObject
-{
- Q_OBJECT
-public:
- explicit Command(QObject *parent = nullptr);
- ~Command() override;
-
- void setParentWId(WId wid);
- WId parentWId() const;
-
- void setServerLocation(const QString &location);
- QString serverLocation() const;
-
- bool waitForFinished();
- bool waitForFinished(unsigned long ms);
-
- bool error() const;
- bool wasCanceled() const;
- QString errorString() const;
-
- qint64 serverPid() const;
-
-public Q_SLOTS:
- void start();
- void cancel();
-
-Q_SIGNALS:
- void started();
- void finished();
-
-protected:
- void setOptionValue(const char *name, const QVariant &value, bool critical = true);
- void setOption(const char *name, bool critical = true);
- void unsetOption(const char *name);
-
- QVariant optionValue(const char *name) const;
- bool isOptionSet(const char *name) const;
- bool isOptionCritical(const char *name) const;
-
- void setFilePaths(const QStringList &filePaths);
- QStringList filePaths() const;
-
- void setRecipients(const QStringList &recipients, bool informative);
- QStringList recipients() const;
- bool areRecipientsInformative() const;
-
- void setSenders(const QStringList &senders, bool informative);
- QStringList senders() const;
- bool areSendersInformative() const;
-
- void setInquireData(const char *what, const QByteArray &data);
- void unsetInquireData(const char *what);
- QByteArray inquireData(const char *what) const;
- bool isInquireDataSet(const char *what) const;
-
- QByteArray receivedData() const;
-
- void setCommand(const char *command);
- QByteArray command() const;
-
-protected:
- class Private;
- Private *d;
- Command(Private *p, QObject *parent);
-};
-
-}
diff --git a/src/libkleopatraclient/core/command_p.h b/src/libkleopatraclient/core/command_p.h
deleted file mode 100644
index 6f2b459f9..000000000
--- a/src/libkleopatraclient/core/command_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- mode: c++; c-basic-offset:4 -*-
- command_p.h
-
- This file is part of KleopatraClient, the Kleopatra interface library
- SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
-
- SPDX-License-Identifier: LGPL-2.0-or-later
-*/
-#pragma once
-
-#include "command.h"
-
-#include <QRecursiveMutex>
-#include <QThread>
-
-#include <QByteArray>
-#include <QString>
-#include <QStringList>
-#include <QVariant>
-
-#include <map>
-#include <string>
-
-class KleopatraClientCopy::Command::Private : public QThread
-{
- Q_OBJECT
-private:
- friend class ::KleopatraClientCopy::Command;
- Command *const q;
-
-public:
- explicit Private(Command *qq)
- : QThread()
- , q(qq)
- , mutex()
- , inputs()
- , outputs()
- {
- }
- ~Private() override
- {
- }
-
-private:
- void init();
-
-private:
- void run() override;
-
-private:
- QRecursiveMutex mutex;
- struct Option {
- QVariant value;
- bool hasValue : 1;
- bool isCritical : 1;
- };
- struct Inputs {
- Inputs()
- : parentWId(0)
- , areRecipientsInformative(false)
- , areSendersInformative(false)
- {
- }
- std::map<std::string, Option> options;
- QStringList filePaths;
- QStringList recipients, senders;
- std::map<std::string, QByteArray> inquireData;
- WId parentWId;
- QByteArray command;
- bool areRecipientsInformative : 1;
- bool areSendersInformative : 1;
- } inputs;
- struct Outputs {
- Outputs()
- : canceled(false)
- , serverPid(0)
- {
- }
- QString errorString;
- bool canceled : 1;
- QByteArray data;
- qint64 serverPid;
- QString serverLocation;
- } outputs;
-};
diff --git a/src/selftest/uiservercheck.cpp b/src/selftest/uiservercheck.cpp
index dcc1d0249..533cddaa1 100644
--- a/src/selftest/uiservercheck.cpp
+++ b/src/selftest/uiservercheck.cpp
@@ -1,71 +1,70 @@
/* -*- mode: c++; c-basic-offset:4 -*-
selftest/uiservercheck.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 <config-kleopatra.h>
#include "uiservercheck.h"
+#include "commands/testuiservercommand.h"
#include "implementation_p.h"
-#include <libkleopatraclient/core/command.h>
-
#include <QCoreApplication>
#include <QEventLoop>
#include <KLocalizedString>
using namespace Kleo;
using namespace Kleo::_detail;
namespace
{
class UiServerCheck : public SelfTestImplementation
{
public:
explicit UiServerCheck()
: SelfTestImplementation(i18nc("@title", "UiServer Connectivity"))
{
runTest();
}
void runTest()
{
- KleopatraClientCopy::Command command;
+ Commands::TestUiServerCommand command;
{
QEventLoop loop;
loop.connect(&command, SIGNAL(finished()), SLOT(quit()));
QMetaObject::invokeMethod(&command, "start", Qt::QueuedConnection);
loop.exec();
}
if (command.error()) {
m_passed = false;
m_error = i18n("not reachable");
m_explanation = xi18nc("@info", "Could not connect to UiServer: <message>%1</message>", command.errorString().toHtmlEscaped());
m_proposedFix = xi18nc("@info",
"<para>Check that your firewall is not set to block local connections "
"(allow connections to <resource>localhost</resource> or <resource>127.0.0.1</resource>).</para>");
} else if (command.serverPid() != QCoreApplication::applicationPid()) {
m_passed = false;
m_error = i18n("multiple instances");
m_explanation = xi18nc("@info", "It seems another <application>Kleopatra</application> is running (with process-id %1)", command.serverPid());
m_proposedFix = xi18nc("@info", "Quit any other running instances of <application>Kleopatra</application>.");
} else {
m_passed = true;
}
}
};
}
std::shared_ptr<SelfTest> Kleo::makeUiServerConnectivitySelfTest()
{
return std::shared_ptr<SelfTest>(new UiServerCheck);
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Feb 7, 7:37 AM (21 h, 41 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
12/d0/e44be237c8424d551662649c6fcd

Event Timeline