Commit c7e4cd81 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Use new helpers for writing/reading key groups to/from a file

GnuPG-bug-id: 5638
parent 928e7a25
Pipeline #97886 failed with stage
in 9 minutes and 30 seconds
......@@ -30,7 +30,7 @@ option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
# Standalone build. Find / include everything necessary.
set(KF5_MIN_VERSION "5.88.0")
set(KMIME_VERSION "5.19.40")
set(LIBKLEO_VERSION "5.19.41")
set(LIBKLEO_VERSION "5.19.42")
set(QT_REQUIRED_VERSION "5.15.2")
set(GPGME_REQUIRED_VERSION "1.13.1")
set(BOOST_REQUIRED_VERSION "1.58")
......
......@@ -17,7 +17,7 @@
#include <Libkleo/Algorithm>
#include <Libkleo/KeyGroup>
#include <Libkleo/KeyGroupConfig>
#include <Libkleo/KeyGroupImportExport>
#include <Libkleo/KeyHelpers>
#include <KConfigGroup>
......@@ -104,7 +104,7 @@ public:
void start();
void exportGroups();
bool exportGroups();
bool startExportJob(GpgME::Protocol protocol, const std::vector<Key> &keys);
void onExportJobResult(const QGpgME::Job *job, const GpgME::Error &err, const QByteArray &keyData);
......@@ -176,7 +176,10 @@ void ExportGroupsCommand::Private::start()
finished();
return;
}
exportGroups();
if (!exportGroups()) {
finished();
return;
}
if (!openpgpKeys.empty()) {
if (!startExportJob(GpgME::OpenPGP, openpgpKeys)) {
finished();
......@@ -190,10 +193,14 @@ void ExportGroupsCommand::Private::start()
}
}
void ExportGroupsCommand::Private::exportGroups()
bool ExportGroupsCommand::Private::exportGroups()
{
KeyGroupConfig config{filename};
config.writeGroups(groups);
const auto result = writeKeyGroups(filename, groups);
if (result != WriteKeyGroups::Success) {
error(xi18n("Writing groups to file <filename>%1</filename> failed.", filename),
i18nc("@title:window", "Export Failed"));
}
return result == WriteKeyGroups::Success;
}
bool ExportGroupsCommand::Private::startExportJob(GpgME::Protocol protocol, const std::vector<Key> &keys)
......
......@@ -23,7 +23,7 @@
#include <Libkleo/KeyList>
#include <Libkleo/KeyListSortFilterProxyModel>
#include <Libkleo/KeyCache>
#include <Libkleo/KeyGroupConfig>
#include <Libkleo/KeyGroupImportExport>
#include <Libkleo/Predicates>
#include <Libkleo/Formatting>
#include <Libkleo/Stl_Util>
......@@ -653,8 +653,7 @@ void ImportCertificatesCommand::Private::importGroups()
});
if (certificateImportSucceeded) {
qCDebug(KLEOPATRA_LOG) << __func__ << "Importing groups from file" << path;
const KeyGroupConfig config{path};
const auto groups = config.readGroups();
const auto groups = readKeyGroups(path);
std::transform(std::begin(groups), std::end(groups),
std::back_inserter(importedGroups),
[path](const auto &group) {
......
Markdown is supported
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