diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am index 3b0b9c3c..e20d239d 100644 --- a/lang/qt/src/Makefile.am +++ b/lang/qt/src/Makefile.am @@ -1,314 +1,314 @@ # Makefile.am for GPGMEPP. # Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik # Software engineering by Intevation GmbH # # This file is part of GPGMEPP. # # GPGME-CL 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. # # GPGME-CL 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 Lesser 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA lib_LTLIBRARIES = libqgpgme.la EXTRA_DIST = QGpgmeConfig.cmake.in.in QGpgmeConfigVersion.cmake.in \ qgpgme_debug.h qgpgme_version.h.in \ QGpgmeConfig.cmake.in.in qgpgme_sources = \ dataprovider.cpp \ debug.cpp \ job.cpp multideletejob.cpp qgpgmeadduseridjob.cpp \ qgpgmeaddexistingsubkeyjob.cpp \ qgpgmebackend.cpp qgpgmechangeexpiryjob.cpp qgpgmechangeownertrustjob.cpp \ qgpgmechangepasswdjob.cpp qgpgmedecryptjob.cpp \ qgpgmedecryptverifyjob.cpp qgpgmedeletejob.cpp qgpgmedownloadjob.cpp \ qgpgmeencryptjob.cpp qgpgmeexportjob.cpp qgpgmeimportfromkeyserverjob.cpp \ qgpgmeimportjob.cpp qgpgmekeygenerationjob.cpp qgpgmekeylistjob.cpp \ qgpgmelistallkeysjob.cpp qgpgmenewcryptoconfig.cpp \ qgpgmereceivekeysjob.cpp \ - qgpgmerefreshkeysjob.cpp \ + qgpgmerefreshsmimekeysjob.cpp \ qgpgmerevokekeyjob.cpp \ qgpgmesignencryptjob.cpp \ qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \ qgpgmeverifyopaquejob.cpp qgpgmewkdlookupjob.cpp threadedjobmixin.cpp \ qgpgmekeyformailboxjob.cpp qgpgme_debug.cpp \ qgpgmetofupolicyjob.cpp qgpgmequickjob.cpp \ defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp \ qgpgmegpgcardjob.cpp changeexpiryjob.cpp importjob.cpp \ dn.cpp cryptoconfig.cpp wkdlookupresult.cpp \ util.cpp # If you add one here make sure that you also add one in camelcase qgpgme_headers= \ abstractimportjob.h \ addexistingsubkeyjob.h \ adduseridjob.h \ changeexpiryjob.h \ changeownertrustjob.h \ changepasswdjob.h \ dataprovider.h \ debug.h \ decryptjob.h \ decryptverifyjob.h \ downloadjob.h \ encryptjob.h \ exportjob.h \ hierarchicalkeylistjob.h \ job.h \ keyformailboxjob.h \ multideletejob.h \ protocol.h \ qgpgme_export.h \ qgpgmenewcryptoconfig.h \ quickjob.h \ receivekeysjob.h \ revokekeyjob.h \ specialjob.h \ signjob.h \ signkeyjob.h \ signencryptjob.h \ verifyopaquejob.h \ refreshkeysjob.h \ cryptoconfig.h \ deletejob.h \ importfromkeyserverjob.h \ importjob.h \ keygenerationjob.h \ keylistjob.h \ listallkeysjob.h \ verifydetachedjob.h \ defaultkeygenerationjob.h \ tofupolicyjob.h \ wkdlookupjob.h \ wkdlookupresult.h \ wkspublishjob.h \ gpgcardjob.h \ dn.h camelcase_headers= \ AddExistingSubkeyJob \ AddUserIDJob \ AbstractImportJob \ ChangeExpiryJob \ ChangeOwnerTrustJob \ ChangePasswdJob \ DataProvider \ Debug \ DecryptJob \ DecryptVerifyJob \ DN \ DownloadJob \ EncryptJob \ ExportJob \ HierarchicalKeyKistJob \ Job \ MultiDeleteJob \ Protocol \ QGpgMENewCryptoConfig \ QuickJob \ ReceiveKeysJob \ RevokeKeyJob \ SpecialJob \ SignJob \ SignKeyJob \ SignEncryptJob \ VerifyOpaqueJob \ RefreshKeysJob \ CryptoConfig \ DeleteJob \ ImportFromKeyserverJob \ ImportJob \ KeyGenerationJob \ KeyListJob \ ListAllKeysJob \ VerifyDetachedJob \ KeyForMailboxJob \ DefaultKeyGenerationJob \ WKDLookupJob \ WKDLookupResult \ WKSPublishJob \ TofuPolicyJob \ GpgCardJob private_qgpgme_headers = \ qgpgme_export.h \ protocol_p.h \ job_p.h \ qgpgmeaddexistingsubkeyjob.h \ qgpgmeadduseridjob.h \ qgpgmebackend.h \ qgpgmechangeexpiryjob.h \ qgpgmechangeownertrustjob.h \ qgpgmechangepasswdjob.h \ qgpgmedecryptjob.h \ qgpgmedecryptverifyjob.h \ qgpgmedeletejob.h \ qgpgmedownloadjob.h \ qgpgmeencryptjob.h \ qgpgmeexportjob.h \ qgpgmeimportfromkeyserverjob.h \ qgpgmeimportjob.h \ qgpgmekeygenerationjob.h \ qgpgmekeylistjob.h \ qgpgmelistallkeysjob.h \ qgpgmereceivekeysjob.h \ - qgpgmerefreshkeysjob.h \ + qgpgmerefreshsmimekeysjob.h \ qgpgmerevokekeyjob.h \ qgpgmesignencryptjob.h \ qgpgmesignjob.h \ qgpgmesignkeyjob.h \ qgpgmeverifydetachedjob.h \ qgpgmeverifyopaquejob.h \ qgpgmewkdlookupjob.h \ qgpgmekeyformailboxjob.h \ qgpgmewkspublishjob.h \ qgpgmetofupolicyjob.h \ qgpgmegpgcardjob.h \ qgpgmequickjob.h \ threadedjobmixin.h \ util.h qgpgme_moc_sources = \ abstractimportjob.moc \ addexistingsubkeyjob.moc \ adduseridjob.moc \ changeexpiryjob.moc \ changeownertrustjob.moc \ changepasswdjob.moc \ decryptjob.moc \ decryptverifyjob.moc \ deletejob.moc \ downloadjob.moc \ encryptjob.moc \ exportjob.moc \ hierarchicalkeylistjob.moc \ importfromkeyserverjob.moc \ importjob.moc \ job.moc \ keygenerationjob.moc \ keylistjob.moc \ listallkeysjob.moc \ multideletejob.moc \ qgpgmeaddexistingsubkeyjob.moc \ qgpgmeadduseridjob.moc \ qgpgmechangeexpiryjob.moc \ qgpgmechangeownertrustjob.moc \ qgpgmechangepasswdjob.moc \ qgpgmedecryptjob.moc \ qgpgmedecryptverifyjob.moc \ qgpgmedeletejob.moc \ qgpgmedownloadjob.moc \ qgpgmeencryptjob.moc \ qgpgmeexportjob.moc \ qgpgmeimportfromkeyserverjob.moc \ qgpgmeimportjob.moc \ qgpgmekeygenerationjob.moc \ qgpgmekeylistjob.moc \ qgpgmelistallkeysjob.moc \ qgpgmereceivekeysjob.moc \ - qgpgmerefreshkeysjob.moc \ + qgpgmerefreshsmimekeysjob.moc \ qgpgmerevokekeyjob.moc \ qgpgmesignencryptjob.moc \ qgpgmesignjob.moc \ qgpgmesignkeyjob.moc \ qgpgmeverifydetachedjob.moc \ qgpgmeverifyopaquejob.moc \ qgpgmewkdlookupjob.moc \ qgpgmewkspublishjob.moc \ tofupolicyjob.moc \ qgpgmetofupolicyjob.moc \ receivekeysjob.moc \ refreshkeysjob.moc \ revokekeyjob.moc \ signencryptjob.moc \ signjob.moc \ signkeyjob.moc \ specialjob.moc \ verifydetachedjob.moc \ verifyopaquejob.moc \ wkdlookupjob.moc \ keyformailboxjob.moc \ wkspublishjob.moc \ qgpgmekeyformailboxjob.moc \ defaultkeygenerationjob.moc \ quickjob.moc \ qgpgmequickjob.moc \ gpgcardjob.moc \ qgpgmegpgcardjob.moc qgpgmeincludedir = $(includedir)/qgpgme qgpgmeinclude_HEADERS = $(qgpgme_headers) camelcaseincludedir = $(includedir)/QGpgME camelcaseinclude_HEADERS = $(camelcase_headers) nodist_qgpgmeinclude_HEADERS = qgpgme_version.h libqgpgme_la_SOURCES = $(qgpgme_sources) $(qgpgme_headers) $(private_qgpgme_headers) AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \ @GPGME_QT_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \ -DBUILDING_QGPGME -Wsuggest-override \ -Wzero-as-null-pointer-constant libqgpgme_la_LIBADD = ../../cpp/src/libgpgmepp.la ../../../src/libgpgme.la \ @LIBASSUAN_LIBS@ @GPG_ERROR_LIBS@ @GPGME_QT_LIBS@ libqgpgme_la_LDFLAGS = -no-undefined -version-info \ @LIBQGPGME_LT_CURRENT@:@LIBQGPGME_LT_REVISION@:@LIBQGPGME_LT_AGE@ if HAVE_MACOS_SYSTEM libsuffix=.dylib else libsuffix=.so endif if HAVE_W32_SYSTEM QGpgmeConfig.cmake: QGpgmeConfig-w32.cmake.in sed -e 's|[@]resolved_bindir@|$(bindir)|g' < "$<" | \ sed -e 's|[@]resolved_libdir@|$(libdir)|g' | \ sed -e 's|[@]resolved_includedir@|$(includedir)|g' > $@ else QGpgmeConfig.cmake: QGpgmeConfig.cmake.in sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" | \ sed -e 's|[@]libsuffix@|$(libsuffix)|g' | \ sed -e 's|[@]resolved_includedir@|$(includedir)|g' > $@ endif $(camelcase_headers): Makefile.am echo -n "#include \"qgpgme/" > "$@" echo -n "$@" | tr '[:upper:]' '[:lower:]' >> "$@" echo ".h\"" >> "$@" install-cmake-files: QGpgmeConfig.cmake QGpgmeConfigVersion.cmake -$(INSTALL) -d $(DESTDIR)$(libdir)/cmake/QGpgme $(INSTALL) -m 644 QGpgmeConfig.cmake \ $(DESTDIR)$(libdir)/cmake/QGpgme/QGpgmeConfig.cmake $(INSTALL) -m 644 QGpgmeConfigVersion.cmake \ $(DESTDIR)$(libdir)/cmake/QGpgme/QGpgmeConfigVersion.cmake uninstall-cmake-files: -rm $(DESTDIR)$(libdir)/cmake/QGpgme/QGpgmeConfigVersion.cmake -rm $(DESTDIR)$(libdir)/cmake/QGpgme/QGpgmeConfig.cmake -rmdir $(DESTDIR)$(libdir)/cmake/QGpgme/ install-data-local: install-cmake-files uninstall-local: uninstall-cmake-files BUILT_SOURCES = $(qgpgme_moc_sources) $(camelcase_headers) CLEANFILES = $(qgpgme_moc_sources) $(camelcase_headers) QGpgmeConfig.cmake \ qgpgme_version.h QGpgmeConfig.cmake.in \ QGpgmeConfigVersion.cmake nodist_libqgpgme_la_SOURCES = $(qgpgme_moc_sources) .h.moc: $(MOC) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ diff --git a/lang/qt/src/protocol_p.h b/lang/qt/src/protocol_p.h index 2ca1cf18..91c522f1 100644 --- a/lang/qt/src/protocol_p.h +++ b/lang/qt/src/protocol_p.h @@ -1,500 +1,500 @@ /* protocol_p.h This file is part of qgpgme, the Qt API binding for gpgme Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik Software engineering by Intevation GmbH Copyright (c) 2022 by 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_PROTOCOL_P_H__ #define __QGPGME_PROTOCOL_P_H__ #include "qgpgmenewcryptoconfig.h" #include "qgpgmekeygenerationjob.h" #include "qgpgmekeylistjob.h" #include "qgpgmelistallkeysjob.h" #include "qgpgmedecryptjob.h" #include "qgpgmedecryptverifyjob.h" -#include "qgpgmerefreshkeysjob.h" +#include "qgpgmerefreshsmimekeysjob.h" #include "qgpgmedeletejob.h" #include "qgpgmedownloadjob.h" #include "qgpgmesignencryptjob.h" #include "qgpgmeencryptjob.h" #include "qgpgmesignjob.h" #include "qgpgmesignkeyjob.h" #include "qgpgmeexportjob.h" #include "qgpgmeverifydetachedjob.h" #include "qgpgmeimportjob.h" #include "qgpgmeimportfromkeyserverjob.h" #include "qgpgmeverifyopaquejob.h" #include "qgpgmechangeexpiryjob.h" #include "qgpgmechangeownertrustjob.h" #include "qgpgmechangepasswdjob.h" #include "qgpgmeaddexistingsubkeyjob.h" #include "qgpgmeadduseridjob.h" #include "qgpgmekeyformailboxjob.h" #include "qgpgmewkdlookupjob.h" #include "qgpgmewkspublishjob.h" #include "qgpgmetofupolicyjob.h" #include "qgpgmequickjob.h" #include "qgpgmereceivekeysjob.h" #include "qgpgmerevokekeyjob.h" namespace { class Protocol : public QGpgME::Protocol { GpgME::Protocol mProtocol; public: explicit Protocol(GpgME::Protocol proto) : mProtocol(proto) {} QString name() const Q_DECL_OVERRIDE { switch (mProtocol) { case GpgME::OpenPGP: return QStringLiteral("OpenPGP"); case GpgME::CMS: return QStringLiteral("SMIME"); default: return QString(); } } QString displayName() const Q_DECL_OVERRIDE { // ah (2.4.16): Where is this used and isn't this inverted // with name switch (mProtocol) { case GpgME::OpenPGP: return QStringLiteral("gpg"); case GpgME::CMS: return QStringLiteral("gpgsm"); default: return QStringLiteral("unknown"); } } QGpgME::SpecialJob *specialJob(const char *, const QMap &) const Q_DECL_OVERRIDE { return nullptr; } QGpgME::KeyListJob *keyListJob(bool remote, bool includeSigs, bool validate) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } unsigned int mode = context->keyListMode(); if (remote) { mode |= GpgME::Extern; mode &= ~GpgME::Local; } else { mode |= GpgME::Local; mode &= ~GpgME::Extern; } if (includeSigs) { mode |= GpgME::Signatures; } if (validate) { mode |= GpgME::Validate; } context->setKeyListMode(mode); return new QGpgME::QGpgMEKeyListJob(context); } QGpgME::ListAllKeysJob *listAllKeysJob(bool includeSigs, bool validate) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } unsigned int mode = context->keyListMode(); mode |= GpgME::Local; mode &= ~GpgME::Extern; if (includeSigs) { mode |= GpgME::Signatures; } if (validate) { mode |= GpgME::Validate; /* Setting the context to offline mode disables CRL / OCSP checks in this Job. Otherwise we would try to fetch the CRL's for all CMS keys in the users keyring because GpgME::Validate includes remote resources by default in the validity check. This setting only has any effect if gpgsm >= 2.1.6 is used. */ context->setOffline(true); } context->setKeyListMode(mode); return new QGpgME::QGpgMEListAllKeysJob(context); } QGpgME::EncryptJob *encryptJob(bool armor, bool textmode) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setArmor(armor); context->setTextMode(textmode); return new QGpgME::QGpgMEEncryptJob(context); } QGpgME::DecryptJob *decryptJob() const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEDecryptJob(context); } QGpgME::SignJob *signJob(bool armor, bool textMode) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setArmor(armor); context->setTextMode(textMode); return new QGpgME::QGpgMESignJob(context); } QGpgME::VerifyDetachedJob *verifyDetachedJob(bool textMode) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setTextMode(textMode); return new QGpgME::QGpgMEVerifyDetachedJob(context); } QGpgME::VerifyOpaqueJob *verifyOpaqueJob(bool textMode) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setTextMode(textMode); return new QGpgME::QGpgMEVerifyOpaqueJob(context); } QGpgME::KeyGenerationJob *keyGenerationJob() const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEKeyGenerationJob(context); } QGpgME::ImportJob *importJob() const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEImportJob(context); } QGpgME::ImportFromKeyserverJob *importFromKeyserverJob() const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEImportFromKeyserverJob(context); } QGpgME::ReceiveKeysJob *receiveKeysJob() const override { if (mProtocol != GpgME::OpenPGP) { return nullptr; } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEReceiveKeysJob{context}; } QGpgME::ExportJob *publicKeyExportJob(bool armor) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setArmor(armor); return new QGpgME::QGpgMEExportJob(context); } QGpgME::ExportJob *secretKeyExportJob(bool armor, const QString &) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setArmor(armor); return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecret); } QGpgME::ExportJob *secretSubkeyExportJob(bool armor) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setArmor(armor); return new QGpgME::QGpgMEExportJob(context, GpgME::Context::ExportSecretSubkey); } QGpgME::RefreshKeysJob *refreshKeysJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too return nullptr; } // this operation is not supported by gpgme, so we have to call gpgsm ourselves: - return new QGpgME::QGpgMERefreshKeysJob(); + return new QGpgME::QGpgMERefreshSMIMEKeysJob(); } QGpgME::DownloadJob *downloadJob(bool armor) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setArmor(armor); // this is the hackish interface for downloading from keyserers currently: context->setKeyListMode(GpgME::Extern); return new QGpgME::QGpgMEDownloadJob(context); } QGpgME::DeleteJob *deleteJob() const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEDeleteJob(context); } QGpgME::SignEncryptJob *signEncryptJob(bool armor, bool textMode) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setArmor(armor); context->setTextMode(textMode); return new QGpgME::QGpgMESignEncryptJob(context); } QGpgME::DecryptVerifyJob *decryptVerifyJob(bool textMode) const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setTextMode(textMode); return new QGpgME::QGpgMEDecryptVerifyJob(context); } QGpgME::ChangeExpiryJob *changeExpiryJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; // only supported by gpg } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEChangeExpiryJob(context); } QGpgME::ChangePasswdJob *changePasswdJob() const Q_DECL_OVERRIDE { if (!GpgME::hasFeature(GpgME::PasswdFeature, 0)) { return nullptr; } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEChangePasswdJob(context); } QGpgME::SignKeyJob *signKeyJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; // only supported by gpg } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMESignKeyJob(context); } QGpgME::ChangeOwnerTrustJob *changeOwnerTrustJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; // only supported by gpg } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEChangeOwnerTrustJob(context); } QGpgME:: AddExistingSubkeyJob *addExistingSubkeyJob() const override { if (mProtocol != GpgME::OpenPGP) { return nullptr; // only supported by gpg } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEAddExistingSubkeyJob{context}; } QGpgME::AddUserIDJob *addUserIDJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; // only supported by gpg } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEAddUserIDJob(context); } QGpgME::KeyListJob *locateKeysJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } context->setKeyListMode(GpgME::Extern | GpgME::Local | GpgME::Signatures | GpgME::Validate); return new QGpgME::QGpgMEKeyListJob(context); } QGpgME::KeyForMailboxJob *keyForMailboxJob() const Q_DECL_OVERRIDE { GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEKeyForMailboxJob(context); } QGpgME::WKDLookupJob *wkdLookupJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; } auto context = GpgME::Context::createForEngine(GpgME::AssuanEngine); if (!context) { return nullptr; } return new QGpgME::QGpgMEWKDLookupJob(context.release()); } QGpgME::WKSPublishJob *wksPublishJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; } auto context = GpgME::Context::createForEngine(GpgME::SpawnEngine); if (!context) { return nullptr; } return new QGpgME::QGpgMEWKSPublishJob(context.release()); } QGpgME::TofuPolicyJob *tofuPolicyJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMETofuPolicyJob(context); } QGpgME::QuickJob *quickJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMEQuickJob(context); } QGpgME::RevokeKeyJob *revokeKeyJob() const Q_DECL_OVERRIDE { if (mProtocol != GpgME::OpenPGP) { return nullptr; } GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); if (!context) { return nullptr; } return new QGpgME::QGpgMERevokeKeyJob(context); } }; } #endif diff --git a/lang/qt/src/qgpgmerefreshkeysjob.cpp b/lang/qt/src/qgpgmerefreshsmimekeysjob.cpp similarity index 89% rename from lang/qt/src/qgpgmerefreshkeysjob.cpp rename to lang/qt/src/qgpgmerefreshsmimekeysjob.cpp index 5f78f2ae..e300454b 100644 --- a/lang/qt/src/qgpgmerefreshkeysjob.cpp +++ b/lang/qt/src/qgpgmerefreshsmimekeysjob.cpp @@ -1,230 +1,230 @@ /* - qgpgmerefreshkeysjob.cpp + qgpgmerefreshsmimekeysjob.cpp This file is part of qgpgme, the Qt API binding for gpgme Copyright (c) 2004 Klarävdalens Datakonsult AB Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik Software engineering by Intevation GmbH 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. */ #define MAX_CMD_LENGTH 32768 #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "qgpgmerefreshkeysjob.h" +#include "qgpgmerefreshsmimekeysjob.h" #include #include "qgpgme_debug.h" #include "context.h" #include #include #include #include -QGpgME::QGpgMERefreshKeysJob::QGpgMERefreshKeysJob() +QGpgME::QGpgMERefreshSMIMEKeysJob::QGpgMERefreshSMIMEKeysJob() : RefreshKeysJob(nullptr), mProcess(nullptr), mError(0) { } -QGpgME::QGpgMERefreshKeysJob::~QGpgMERefreshKeysJob() +QGpgME::QGpgMERefreshSMIMEKeysJob::~QGpgMERefreshSMIMEKeysJob() { } -GpgME::Error QGpgME::QGpgMERefreshKeysJob::start(const QStringList &patterns) +GpgME::Error QGpgME::QGpgMERefreshSMIMEKeysJob::start(const QStringList &patterns) { assert(mPatternsToDo.empty()); mPatternsToDo = patterns; if (mPatternsToDo.empty()) { mPatternsToDo.push_back(QStringLiteral(" ")); // empty list means all -> mae } // sure to fail the first // startAProcess() guard clause return startAProcess(); } #if MAX_CMD_LENGTH < 65 + 128 #error MAX_CMD_LENGTH is too low #endif -GpgME::Error QGpgME::QGpgMERefreshKeysJob::startAProcess() +GpgME::Error QGpgME::QGpgMERefreshSMIMEKeysJob::startAProcess() { if (mPatternsToDo.empty()) { return GpgME::Error(); } // create and start gpgsm process: mProcess = new QProcess(this); mProcess->setObjectName(QStringLiteral("gpgsm -k --with-validation --force-crl-refresh --enable-crl-checks")); // FIXME: obbtain the path to gpgsm from gpgme, so we use the same instance. mProcess->setProgram(QStringLiteral("gpgsm")); QStringList arguments; arguments << QStringLiteral("-k") << QStringLiteral("--with-validation") << QStringLiteral("--force-crl-refresh") << QStringLiteral("--enable-crl-checks"); unsigned int commandLineLength = MAX_CMD_LENGTH; commandLineLength -= strlen("gpgsm") + 1 + strlen("-k") + 1 + strlen("--with-validation") + 1 + strlen("--force-crl-refresh") + 1 + strlen("--enable-crl-checks") + 1; while (!mPatternsToDo.empty()) { const QByteArray pat = mPatternsToDo.front().toUtf8().trimmed(); const unsigned int patLength = pat.length(); if (patLength >= commandLineLength) { break; } mPatternsToDo.pop_front(); if (pat.isEmpty()) { continue; } arguments << QLatin1String(pat); commandLineLength -= patLength + 1; } mProcess->setArguments(arguments); connect(mProcess, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(slotProcessExited(int,QProcess::ExitStatus))); connect(mProcess, SIGNAL(readyReadStandardOutput()), SLOT(slotStdout())); connect(mProcess, &QProcess::readyReadStandardError, - this, &QGpgMERefreshKeysJob::slotStderr); + this, &QGpgMERefreshSMIMEKeysJob::slotStderr); mProcess->start(); if (!mProcess->waitForStarted()) { mError = GpgME::Error::fromCode(GPG_ERR_ENOENT, GPG_ERR_SOURCE_GPGSM); // what else? deleteLater(); return mError; } else { return GpgME::Error(); } } -void QGpgME::QGpgMERefreshKeysJob::slotCancel() +void QGpgME::QGpgMERefreshSMIMEKeysJob::slotCancel() { if (mProcess) { mProcess->kill(); } mProcess = nullptr; mError = GpgME::Error::fromCode(GPG_ERR_CANCELED, GPG_ERR_SOURCE_GPGSM); } -void QGpgME::QGpgMERefreshKeysJob::slotStatus(QProcess *proc, const QString &type, const QStringList &args) +void QGpgME::QGpgMERefreshSMIMEKeysJob::slotStatus(QProcess *proc, const QString &type, const QStringList &args) { if (proc != mProcess) { return; } QStringList::const_iterator it = args.begin(); bool ok = false; if (type == QLatin1String("ERROR")) { if (args.size() < 2) { qCDebug(QGPGME_LOG) << "not recognising ERROR with < 2 args!"; return; } const int source = (*++it).toInt(&ok); if (!ok) { qCDebug(QGPGME_LOG) << "expected number for first ERROR arg, got something else"; return; } ok = false; const int code = (*++it).toInt(&ok); if (!ok) { qCDebug(QGPGME_LOG) << "expected number for second ERROR arg, got something else"; return; } mError = GpgME::Error::fromCode(code, source); } else if (type == QLatin1String("PROGRESS")) { if (args.size() < 4) { qCDebug(QGPGME_LOG) << "not recognising PROGRESS with < 4 args!"; return; } const QString what = *++it; ok = false; (*++it).toInt(&ok); if (!ok) { qCDebug(QGPGME_LOG) << "expected number for \"type\", got something else"; return; } ok = false; const int cur = (*++it).toInt(&ok); if (!ok) { qCDebug(QGPGME_LOG) << "expected number for \"cur\", got something else"; return; } ok = false; const int total = (*++it).toInt(&ok); if (!ok) { qCDebug(QGPGME_LOG) << "expected number for \"total\", got something else"; return; } // TODO port Q_EMIT progress(QString(), cur, total); } } -void QGpgME::QGpgMERefreshKeysJob::slotStderr() +void QGpgME::QGpgMERefreshSMIMEKeysJob::slotStderr() { // implement? or not? } -void QGpgME::QGpgMERefreshKeysJob::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus) +void QGpgME::QGpgMERefreshSMIMEKeysJob::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus) { if (!mError && !mPatternsToDo.empty()) { if (const GpgME::Error err = startAProcess()) { mError = err; } else { return; } } Q_EMIT done(); if (!mError && (exitStatus != QProcess::NormalExit || exitCode != 0)) { mError = GpgME::Error::fromCode(GPG_ERR_GENERAL, GPG_ERR_SOURCE_GPGSM); } Q_EMIT result(mError); deleteLater(); } -#include "qgpgmerefreshkeysjob.moc" +#include "qgpgmerefreshsmimekeysjob.moc" diff --git a/lang/qt/src/qgpgmerefreshkeysjob.h b/lang/qt/src/qgpgmerefreshsmimekeysjob.h similarity index 88% rename from lang/qt/src/qgpgmerefreshkeysjob.h rename to lang/qt/src/qgpgmerefreshsmimekeysjob.h index 4dfd942f..8ed0b379 100644 --- a/lang/qt/src/qgpgmerefreshkeysjob.h +++ b/lang/qt/src/qgpgmerefreshsmimekeysjob.h @@ -1,80 +1,80 @@ /* - qgpgmerefreshkeysjob.h + qgpgmerefreshsmimekeysjob.h This file is part of qgpgme, the Qt API binding for gpgme Copyright (c) 2004 Klarälvdalens Datakonsult AB Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik Software engineering by Intevation GmbH 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_QGPGMEREFRESHKEYSJOB_H__ -#define __QGPGME_QGPGMEREFRESHKEYSJOB_H__ +#ifndef __QGPGME_QGPGMEREFRESHSMIMEKEYSJOB_H__ +#define __QGPGME_QGPGMEREFRESHSMIMEKEYSJOB_H__ #include "refreshkeysjob.h" #ifdef BUILDING_QGPGME # include "context.h" #else #include "gpgme++/context.h" #endif #include #include namespace QGpgME { -class QGpgMERefreshKeysJob : public RefreshKeysJob +class QGpgMERefreshSMIMEKeysJob : public RefreshKeysJob { Q_OBJECT public: - QGpgMERefreshKeysJob(); - ~QGpgMERefreshKeysJob(); + QGpgMERefreshSMIMEKeysJob(); + ~QGpgMERefreshSMIMEKeysJob(); /* from RefreshKeysJob */ GpgME::Error start(const QStringList &patterns) Q_DECL_OVERRIDE; private Q_SLOTS: /* from Job */ void slotCancel() Q_DECL_OVERRIDE; void slotStatus(QProcess *, const QString &, const QStringList &); void slotStderr(); void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus); private: GpgME::Error startAProcess(); private: QProcess *mProcess; GpgME::Error mError; QStringList mPatternsToDo; }; } -#endif // __QGPGME_QGPGMEREFRESHKEYSJOB_H__ +#endif // __QGPGME_QGPGMEREFRESHSMIMEKEYSJOB_H__