Commit 288f5590 authored by Felix Tiede's avatar Felix Tiede Committed by Ingo Klöcker
Browse files

Drop feature when Akonadi is unavailable.

See !16 (comment 427798)

Assuming a user either has KMail (then with Akonadi) or is likely to use
an entirely different GUI tool for key management, no option to create a
publish request at all is provided in case Akonadi is not found.
parent 3b7a986b
......@@ -120,9 +120,9 @@ endif()
# Kdepimlibs packages
find_package(KF5Libkleo ${LIBKLEO_VERSION} CONFIG REQUIRED)
find_package(KF5Mime ${KMIME_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5IdentityManagement ${KIDENTITYMANAGEMENT_VERSION} CONFIG REQUIRED)
find_package(KF5MailTransport ${KMAILTRANSPORT_VERSION} CONFIG REQUIRED)
find_package(KF5MailTransportAkonadi ${KMAILTRANSPORT_VERSION} CONFIG REQUIRED)
find_package(KF5IdentityManagement ${KIDENTITYMANAGEMENT_VERSION} CONFIG)
find_package(KF5MailTransport ${KMAILTRANSPORT_VERSION} CONFIG)
find_package(KF5MailTransportAkonadi ${KMAILTRANSPORT_VERSION} CONFIG)
find_package(Qt${QT_MAJOR_VERSION} ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport)
......
......@@ -67,6 +67,15 @@ else()
add_definitions(-DGPGMEPP_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_USER_1)
endif()
if(KF5IdentityManagement_FOUND AND KF5MailTransport_FOUND AND KF5MailTransportAkonadi_FOUND)
set(_kleopatra_mail_libs
KF5::IdentityManagement # Export OpenPGP keys using WKS
KF5::MailTransport
KF5::MailTransportAkonadi
)
add_definitions(-DMAILAKONADI_ENABLED)
endif()
ki18n_wrap_ui(_kleopatra_uiserver_SRCS crypto/gui/signingcertificateselectionwidget.ui)
set(_kleopatra_SRCS
......@@ -376,9 +385,7 @@ target_link_libraries(kleopatra_bin
KF5::CoreAddons
KF5::ItemModels
KF5::Crash
KF5::IdentityManagement # Export OpenPGP keys using WKS
KF5::MailTransport
KF5::MailTransportAkonadi
${_kleopatra_mail_libs}
Qt${QT_MAJOR_VERSION}::Network
Qt${QT_MAJOR_VERSION}::PrintSupport # Printing secret keys
${_kleopatra_uiserver_extra_libs}
......
......@@ -13,25 +13,29 @@
#include "exportopenpgpcerttoprovidercommand.h"
#include "command_p.h"
#include <gpgme++/key.h>
#include <QGpgME/Protocol>
#include <QGpgME/WKSPublishJob>
#include <kidentitymanagement/identity.h>
#include <kidentitymanagement/identitymanager.h>
#ifdef MAILAKONADI_ENABLED
#include <KIdentityManagement/Identity>
#include <KIdentityManagement/IdentityManager>
#include <MailTransport/TransportManager>
#include <MailTransportAkonadi/MessageQueueJob>
#endif // MAILAKONADI_ENABLED
#include <KLocalizedString>
#include <KMessageBox>
#include <QGpgME/Protocol>
#include <QGpgME/WKSPublishJob>
#include <QString>
#include <gpgme++/key.h>
using namespace Kleo;
using namespace Kleo::Commands;
using namespace GpgME;
using namespace QGpgME;
#ifdef MAILAKONADI_ENABLED
static const QString identityTransportForAddress(const QString &senderAddress) {
static const KIdentityManagement::IdentityManager *idManager = new KIdentityManagement::IdentityManager{true};
......@@ -42,6 +46,7 @@ static const QString identityTransportForAddress(const QString &senderAddress) {
return identity.transport();
}
}
#endif // MAILAKONADI_ENABLED
ExportOpenPGPCertToProviderCommand::ExportOpenPGPCertToProviderCommand(QAbstractItemView *v, KeyListController *c)
: Command{v, c}
......@@ -59,6 +64,8 @@ ExportOpenPGPCertToProviderCommand::~ExportOpenPGPCertToProviderCommand() = defa
void ExportOpenPGPCertToProviderCommand::doStart()
{
const QString sender = senderAddress();
#ifdef MAILAKONADI_ENABLED
const QString transportName = identityTransportForAddress(sender);
if (transportName.isEmpty()) {
......@@ -70,6 +77,8 @@ void ExportOpenPGPCertToProviderCommand::doStart()
d->canceled();
return;
}
#endif // MAILAKONADI_ENABLED
if (KMessageBox::warningContinueCancel(d->parentWidgetOrView(),
xi18nc("@info",
"<para>Not every mail provider supports WKS, so any key being "
......@@ -111,6 +120,7 @@ void ExportOpenPGPCertToProviderCommand::wksJobResult(const GpgME::Error &error,
return;
}
#ifdef MAILAKONADI_ENABLED
MailTransport::Transport *transport = MailTransport::TransportManager::self()->transportByName(
identityTransportForAddress(senderAddress()));
......@@ -143,6 +153,9 @@ void ExportOpenPGPCertToProviderCommand::wksJobResult(const GpgME::Error &error,
});
job->start();
#else // MAILAKONADI_ENABLED
Q_UNUSED(returnedData);
#endif // MAILAKONADI_ENABLED
}
QString ExportOpenPGPCertToProviderCommand::senderAddress() const
......
......@@ -24,7 +24,9 @@
#include "commands/changepassphrasecommand.h"
#include "commands/changeexpirycommand.h"
#include "commands/certifycertificatecommand.h"
#ifdef MAILAKONADI_ENABLED
#include "commands/exportopenpgpcerttoprovidercommand.h"
#endif // MAILAKONADI_ENABLED
#include "commands/refreshcertificatecommand.h"
#include "commands/revokecertificationcommand.h"
#include "commands/revokeuseridcommand.h"
......@@ -747,6 +749,7 @@ void CertificateDetailsWidget::Private::userIDTableContextMenuRequested(const QP
cmd->start();
});
}
#ifdef MAILAKONADI_ENABLED
if (key.hasSecret() && key.protocol() == GpgME::OpenPGP) {
menu->addAction(QIcon::fromTheme(QStringLiteral("view-certificate-export-provider")),
i18n("Publish at mail provider ..."),
......@@ -758,6 +761,7 @@ void CertificateDetailsWidget::Private::userIDTableContextMenuRequested(const QP
cmd->start();
});
}
#endif // MAILAKONADI_ENABLED
connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
menu->popup(ui.userIDTable->viewport()->mapToGlobal(p));
}
......
......@@ -22,7 +22,9 @@
#include "kleopatra_debug.h"
#include "commands/exportcertificatecommand.h"
#include "commands/exportopenpgpcertstoservercommand.h"
#ifdef MAILAKONADI_ENABLED
#include "commands/exportopenpgpcerttoprovidercommand.h"
#endif // MAILAKONADI_ENABLED
#ifdef QGPGME_SUPPORTS_SECRET_KEY_EXPORT
# include "commands/exportsecretkeycommand.h"
#else
......@@ -370,10 +372,12 @@ void KeyListController::createActions(KActionCollection *coll)
"file_export_certificates_to_server", i18n("Publish on Server..."), i18n("Publish the selected certificate (public key) on a public keyserver"),
"view-certificate-export-server", nullptr, nullptr, QStringLiteral("Ctrl+Shift+E"), false, true
},
#ifdef MAILAKONADI_ENABLED
{
"file_export_certificate_to_provider", i18n("Publish at Mailprovider..."), i18n("Publish the selected certificate (public key) at mail provider's Web Key Directory if offered"),
"view-certificate-export-provider", nullptr, nullptr, QString(), false, true
},
#endif // MAILAKONADI_ENABLED
{
"file_export_secret_keys", i18n("Backup Secret Keys..."), QString(),
"view-certificate-export-secret", nullptr, nullptr, QString(), false, true
......@@ -526,7 +530,9 @@ void KeyListController::createActions(KActionCollection *coll)
registerActionForCommand<ExportSecretKeyCommand>(coll->action(QStringLiteral("file_export_secret_keys")));
registerActionForCommand<ExportPaperKeyCommand>(coll->action(QStringLiteral("file_export_paper_key")));
registerActionForCommand<ExportOpenPGPCertsToServerCommand>(coll->action(QStringLiteral("file_export_certificates_to_server")));
#ifdef MAILAKONADI_ENABLED
registerActionForCommand<ExportOpenPGPCertToProviderCommand>(coll->action(QStringLiteral("file_export_certificate_to_provider")));
#endif // MAILAKONADI_ENABLED
//---
registerActionForCommand<DecryptVerifyFilesCommand>(coll->action(QStringLiteral("file_decrypt_verify_files")));
registerActionForCommand<SignEncryptFilesCommand>(coll->action(QStringLiteral("file_sign_encrypt_files")));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment