diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am index 3b12d6dc..199db9b9 100644 --- a/lang/qt/src/Makefile.am +++ b/lang/qt/src/Makefile.am @@ -35,7 +35,6 @@ qgpgme_sources = \ qgpgmeimportjob.cpp qgpgmekeygenerationjob.cpp qgpgmekeylistjob.cpp \ qgpgmelistallkeysjob.cpp qgpgmenewcryptoconfig.cpp \ qgpgmereceivekeysjob.cpp \ - qgpgmerefreshopenpgpkeysjob.cpp \ qgpgmerefreshsmimekeysjob.cpp \ qgpgmerevokekeyjob.cpp \ qgpgmesignencryptjob.cpp \ @@ -80,7 +79,6 @@ qgpgme_headers= \ signencryptjob.h \ verifyopaquejob.h \ refreshkeysjob.h \ - refreshopenpgpkeysjob.h \ cryptoconfig.h \ deletejob.h \ importfromkeyserverjob.h \ @@ -126,7 +124,6 @@ camelcase_headers= \ SignEncryptJob \ VerifyOpaqueJob \ RefreshKeysJob \ - RefreshOpenPGPKeysJob \ CryptoConfig \ DeleteJob \ ImportFromKeyserverJob \ @@ -165,7 +162,6 @@ private_qgpgme_headers = \ qgpgmekeylistjob.h \ qgpgmelistallkeysjob.h \ qgpgmereceivekeysjob.h \ - qgpgmerefreshopenpgpkeysjob.h \ qgpgmerefreshsmimekeysjob.h \ qgpgmerevokekeyjob.h \ qgpgmesignencryptjob.h \ @@ -220,7 +216,6 @@ qgpgme_moc_sources = \ qgpgmekeylistjob.moc \ qgpgmelistallkeysjob.moc \ qgpgmereceivekeysjob.moc \ - qgpgmerefreshopenpgpkeysjob.moc \ qgpgmerefreshsmimekeysjob.moc \ qgpgmerevokekeyjob.moc \ qgpgmesignencryptjob.moc \ @@ -234,7 +229,6 @@ qgpgme_moc_sources = \ qgpgmetofupolicyjob.moc \ receivekeysjob.moc \ refreshkeysjob.moc \ - refreshopenpgpkeysjob.moc \ revokekeyjob.moc \ signencryptjob.moc \ signjob.moc \ diff --git a/lang/qt/src/job.cpp b/lang/qt/src/job.cpp index 4a379f12..dba7556b 100644 --- a/lang/qt/src/job.cpp +++ b/lang/qt/src/job.cpp @@ -61,7 +61,6 @@ #include "downloadjob.h" #include "deletejob.h" #include "refreshkeysjob.h" -#include "refreshopenpgpkeysjob.h" #include "addexistingsubkeyjob.h" #include "adduseridjob.h" #include "specialjob.h" @@ -158,7 +157,6 @@ make_job_subclass(AbstractImportJob) make_job_subclass_ext(ImportJob, AbstractImportJob) make_job_subclass_ext(ImportFromKeyserverJob, AbstractImportJob) make_job_subclass_ext(ReceiveKeysJob, AbstractImportJob) -make_job_subclass_ext(RefreshOpenPGPKeysJob, AbstractImportJob) make_job_subclass(ExportJob) make_job_subclass(ChangeExpiryJob) make_job_subclass(ChangeOwnerTrustJob) @@ -202,7 +200,6 @@ make_job_subclass(RevokeKeyJob) #include "downloadjob.moc" #include "deletejob.moc" #include "refreshkeysjob.moc" -#include "refreshopenpgpkeysjob.moc" #include "addexistingsubkeyjob.moc" #include "adduseridjob.moc" #include "specialjob.moc" diff --git a/lang/qt/src/protocol.h b/lang/qt/src/protocol.h index f0772eef..7c24186c 100644 --- a/lang/qt/src/protocol.h +++ b/lang/qt/src/protocol.h @@ -59,7 +59,6 @@ class VerifyOpaqueJob; class SignEncryptJob; class DecryptVerifyJob; class RefreshKeysJob; -class RefreshOpenPGPKeysJob; class ChangeExpiryJob; class ChangeOwnerTrustJob; class ChangePasswdJob; @@ -140,7 +139,7 @@ public: /** * For S/MIME keys this job performs a full validation check of the keys * with updated CRLs. - * For OpenPGP keys, use refreshOpenPGPKeysJob. + * For OpenPGP keys, use receiveKeysJob. */ virtual RefreshKeysJob *refreshKeysJob() const = 0; virtual ChangeExpiryJob *changeExpiryJob() const = 0; @@ -183,13 +182,6 @@ public: virtual ReceiveKeysJob *receiveKeysJob() const = 0; virtual RevokeKeyJob *revokeKeyJob() const = 0; - - /** - * This job performs a refresh of OpenPGP keys via the external methods - * as defined by the \c auto-key-locate option and via an import from the - * configured keyserver. - */ - virtual RefreshOpenPGPKeysJob *refreshOpenPGPKeysJob() const = 0; }; /** Obtain a reference to the OpenPGP Protocol. diff --git a/lang/qt/src/protocol_p.h b/lang/qt/src/protocol_p.h index 36cb7199..0b022dda 100644 --- a/lang/qt/src/protocol_p.h +++ b/lang/qt/src/protocol_p.h @@ -42,7 +42,6 @@ #include "qgpgmelistallkeysjob.h" #include "qgpgmedecryptjob.h" #include "qgpgmedecryptverifyjob.h" -#include "qgpgmerefreshopenpgpkeysjob.h" #include "qgpgmerefreshsmimekeysjob.h" #include "qgpgmedeletejob.h" #include "qgpgmedownloadjob.h" @@ -291,19 +290,6 @@ public: return new QGpgME::QGpgMERefreshSMIMEKeysJob; } - QGpgME::RefreshOpenPGPKeysJob *refreshOpenPGPKeysJob() const Q_DECL_OVERRIDE - { - if (mProtocol != GpgME::OpenPGP) { - return nullptr; - } - - GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); - if (!context) { - return nullptr; - } - return new QGpgME::QGpgMERefreshOpenPGPKeysJob{context}; - } - QGpgME::DownloadJob *downloadJob(bool armor) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); diff --git a/lang/qt/src/qgpgmerefreshopenpgpkeysjob.cpp b/lang/qt/src/qgpgmerefreshopenpgpkeysjob.cpp deleted file mode 100644 index 721d3cfc..00000000 --- a/lang/qt/src/qgpgmerefreshopenpgpkeysjob.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - qgpgmerefreshopenpgpkeysjob.cpp - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - QGpgME 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. -*/ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "qgpgmerefreshopenpgpkeysjob.h" - -#include "qgpgmekeylistjob.h" -#include "qgpgmereceivekeysjob.h" -#include "util.h" - -#include -#include - -#include - -#include "qgpgme_debug.h" - -using namespace QGpgME; -using namespace GpgME; - -QStringList toEmailAddresses(const std::vector &keys) -{ - const auto numUserIDs = std::accumulate(std::begin(keys), std::end(keys), 0, [](auto num, const auto &key) { - return num + key.numUserIDs(); - }); - - QStringList emails; - emails.reserve(numUserIDs); - emails = std::accumulate(std::begin(keys), std::end(keys), emails, [](auto &emails, const auto &key) { - const auto userIDs = key.userIDs(); - emails = std::accumulate(std::begin(userIDs), std::end(userIDs), emails, [](auto &emails, const auto &userID) { - if (!userID.isRevoked() && !userID.addrSpec().empty()) { - emails.push_back(QString::fromStdString(userID.addrSpec())); - } - return emails; - }); - return emails; - }); - return emails; -} - -QGpgMERefreshOpenPGPKeysJob::QGpgMERefreshOpenPGPKeysJob(Context *context) - : mixin_type{context} -{ - lateInitialization(); -} - -QGpgMERefreshOpenPGPKeysJob::~QGpgMERefreshOpenPGPKeysJob() = default; - -static ImportResult locate_external_keys(Context *ctx, const std::vector &keys) -{ - Context::KeyListModeSaver saver{ctx}; - ctx->setKeyListMode(GpgME::LocateExternal); - - const auto emails = toEmailAddresses(keys); - std::vector dummy; - auto job = std::unique_ptr{new QGpgMEKeyListJob{ctx}}; - (void) job->exec(emails, false, dummy); - const auto result = ctx->importResult(); - job.release(); - - return result; -} - -static ImportResult receive_keys(Context *ctx, const std::vector &keys) -{ - const auto fprs = toFingerprints(keys); - - auto job = std::unique_ptr{new QGpgMEReceiveKeysJob{ctx}}; - const auto result = job->exec(fprs); - job.release(); - - return result; -} - -static QGpgMERefreshOpenPGPKeysJob::result_type refresh_keys(Context *ctx, const std::vector &keys) -{ - ImportResult result; - - result = locate_external_keys(ctx, keys); - if (!result.error()) { - const auto res2 = receive_keys(ctx, keys); - if (!res2.error()) { - result.mergeWith(res2); - } - } - - return std::make_tuple(result, QString{}, Error{}); -} - -GpgME::Error QGpgMERefreshOpenPGPKeysJob::start(const std::vector &keys) -{ - run([keys](Context *ctx) { return refresh_keys(ctx, keys); }); - return Error{}; -} - -#include "qgpgmerefreshopenpgpkeysjob.moc" diff --git a/lang/qt/src/qgpgmerefreshopenpgpkeysjob.h b/lang/qt/src/qgpgmerefreshopenpgpkeysjob.h deleted file mode 100644 index be322e41..00000000 --- a/lang/qt/src/qgpgmerefreshopenpgpkeysjob.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - qgpgmerefreshopenpgpkeysjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - QGpgME 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 __QGPGME_QGPGMEREFRESHOPENPGPKEYSJOB_H__ -#define __QGPGME_QGPGMEREFRESHOPENPGPKEYSJOB_H__ - -#include "refreshopenpgpkeysjob.h" -#include "threadedjobmixin.h" - -#ifdef BUILDING_QGPGME -# include "importresult.h" -#else -# include -#endif - -namespace QGpgME -{ - -class QGpgMERefreshOpenPGPKeysJob -#ifdef Q_MOC_RUN - : public RefreshOpenPGPKeysJob -#else - : public _detail::ThreadedJobMixin> -#endif -{ - Q_OBJECT -#ifdef Q_MOC_RUN -public Q_SLOTS: - void slotFinished(); -#endif -public: - explicit QGpgMERefreshOpenPGPKeysJob(GpgME::Context *context); - ~QGpgMERefreshOpenPGPKeysJob() override; - - GpgME::Error start(const std::vector &keys) override; -}; - -} - -#endif // __QGPGME_QGPGMEREFRESHOPENPGPKEYSJOB_H__ diff --git a/lang/qt/src/refreshopenpgpkeysjob.h b/lang/qt/src/refreshopenpgpkeysjob.h deleted file mode 100644 index 74233b61..00000000 --- a/lang/qt/src/refreshopenpgpkeysjob.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - refreshopenpgpkeysjob.h - - This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2022 g10 Code GmbH - Software engineering by Ingo Klöcker - - QGpgME is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - QGpgME 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 __KLEO_REFRESHOPENPGPKEYSJOB_H__ -#define __KLEO_REFRESHOPENPGPKEYSJOB_H__ - -#include "abstractimportjob.h" -#include "qgpgme_export.h" - -#include - -namespace GpgME -{ -class Error; -class Key; -} - -namespace QGpgME -{ - -class QGPGME_EXPORT RefreshOpenPGPKeysJob : public AbstractImportJob -{ - Q_OBJECT -protected: - explicit RefreshOpenPGPKeysJob(QObject *parent); -public: - ~RefreshOpenPGPKeysJob() override; - - /** - Starts a refresh of the \a keys. - */ - virtual GpgME::Error start(const std::vector &keys) = 0; -}; - -} - -#endif // __KLEO_REFRESHOPENPGPKEYSJOB_H__ diff --git a/lang/qt/tests/run-refreshkeysjob.cpp b/lang/qt/tests/run-refreshkeysjob.cpp index aa9a6d62..940c0c77 100644 --- a/lang/qt/tests/run-refreshkeysjob.cpp +++ b/lang/qt/tests/run-refreshkeysjob.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -120,16 +120,16 @@ int main(int argc, char **argv) std::cout << "Refreshing " << displayName(key.protocol()) << " key " << key.userID(0).id() << std::endl; if (key.protocol() == GpgME::OpenPGP) { - auto job = QGpgME::openpgp()->refreshOpenPGPKeysJob(); + auto job = QGpgME::openpgp()->receiveKeysJob(); if (!job) { std::cerr << "Error: Could not create job to refresh OpenPGP key" << std::endl; return 1; } - QObject::connect(job, &QGpgME::RefreshOpenPGPKeysJob::result, &app, [](const GpgME::ImportResult &result, const QString &, const GpgME::Error &) { + QObject::connect(job, &QGpgME::ReceiveKeysJob::result, &app, [](const GpgME::ImportResult &result, const QString &, const GpgME::Error &) { std::cout << "Result: " << result << std::endl; qApp->quit(); }); - const auto err = job->start({key}); + const auto err = job->start({QString::fromLatin1(key.primaryFingerprint())}); if (err) { std::cerr << "Error: " << err.asString() << std::endl; return 1;