aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2016-05-10 12:05:10 +0000
committerAndre Heinecke <[email protected]>2016-05-10 12:05:10 +0000
commit56c4d9ea9520c95612e525b2fa1359db6fa88f4a (patch)
tree0bde1452d35628ecbf96ada35bfec71c0ad99865
parentQt: Make doxygen quieter (diff)
downloadgpgme-56c4d9ea9520c95612e525b2fa1359db6fa88f4a.tar.gz
gpgme-56c4d9ea9520c95612e525b2fa1359db6fa88f4a.zip
Qt: Make Protocol class public API
* lang/qt/src/Makefile.am (qgpgme_headers): Add protocol.h (private_qgpgme_headers): Add protocol_p.h * lang/qt/src/protocol.h: New. From QGpgMEBackend. * lang/qt/src/protocol_p.h: New. From QGpgMEBackend. * lang/qt/src/qgpgmebackend.h, lang/qt/src/qgpgmebackend.cpp (Protocol): Removed. -- The backend class does not make much sense anymore as we only have the GpgME backend obviously. It's purpose was for Libkleo's Backend abstraction.
-rw-r--r--lang/qt/src/Makefile.am2
-rw-r--r--lang/qt/src/protocol.h123
-rw-r--r--lang/qt/src/protocol_p.h371
-rw-r--r--lang/qt/src/qgpgmebackend.cpp346
-rw-r--r--lang/qt/src/qgpgmebackend.h76
5 files changed, 508 insertions, 410 deletions
diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am
index 30c24b94..7de3ef63 100644
--- a/lang/qt/src/Makefile.am
+++ b/lang/qt/src/Makefile.am
@@ -49,6 +49,7 @@ qgpgme_headers= \
hierarchicalkeylistjob.h \
job.h \
multideletejob.h \
+ protocol.h \
qgpgme_export.h \
qgpgmenewcryptoconfig.h \
signjob.h \
@@ -67,6 +68,7 @@ qgpgme_headers= \
private_qgpgme_headers = \
qgpgme_export.h \
abstractimportjob.h \
+ protocol_p.h \
qgpgmeadduseridjob.h \
qgpgmebackend.h \
qgpgmechangeexpiryjob.h \
diff --git a/lang/qt/src/protocol.h b/lang/qt/src/protocol.h
new file mode 100644
index 00000000..5162fe6a
--- /dev/null
+++ b/lang/qt/src/protocol.h
@@ -0,0 +1,123 @@
+/*
+ protocol.h
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB
+ Copyright (c) 2016 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_PROTOCOL_H__
+#define __QGPGME_PROTOCOL_H__
+
+#include <QString>
+#include <QVariant>
+
+#include "qgpgme_export.h"
+
+namespace QGpgME {
+class CryptoConfig;
+class KeyListJob;
+class ListAllKeysJob;
+class KeyGenerationJob;
+class ImportJob;
+class ImportFromKeyserverJob;
+class ExportJob;
+class DownloadJob;
+class DeleteJob;
+class EncryptJob;
+class DecryptJob;
+class SignJob;
+class SignKeyJob;
+class VerifyDetachedJob;
+class VerifyOpaqueJob;
+class SignEncryptJob;
+class DecryptVerifyJob;
+class RefreshKeysJob;
+class ChangeExpiryJob;
+class ChangeOwnerTrustJob;
+class ChangePasswdJob;
+class AddUserIDJob;
+class SpecialJob;
+
+class QGPGME_EXPORT Protocol
+{
+public:
+ virtual ~Protocol() {}
+
+ virtual QString name() const = 0;
+
+ virtual QString displayName() const = 0;
+
+ virtual KeyListJob *keyListJob(bool remote = false, bool includeSigs = false, bool validate = false) const = 0;
+ virtual ListAllKeysJob *listAllKeysJob(bool includeSigs = false, bool validate = false) const = 0;
+ virtual EncryptJob *encryptJob(bool armor = false, bool textmode = false) const = 0;
+ virtual DecryptJob *decryptJob() const = 0;
+ virtual SignJob *signJob(bool armor = false, bool textMode = false) const = 0;
+ virtual VerifyDetachedJob *verifyDetachedJob(bool textmode = false) const = 0;
+ virtual VerifyOpaqueJob *verifyOpaqueJob(bool textmode = false) const = 0;
+ virtual KeyGenerationJob *keyGenerationJob() const = 0;
+ virtual ImportJob *importJob() const = 0;
+ virtual ImportFromKeyserverJob *importFromKeyserverJob() const = 0;
+ virtual ExportJob *publicKeyExportJob(bool armor = false) const = 0;
+ // @param charset the encoding of the passphrase in the exported file
+ virtual ExportJob *secretKeyExportJob(bool armor = false, const QString &charset = QString()) const = 0;
+ virtual DownloadJob *downloadJob(bool armor = false) const = 0;
+ virtual DeleteJob *deleteJob() const = 0;
+ virtual SignEncryptJob *signEncryptJob(bool armor = false, bool textMode = false) const = 0;
+ virtual DecryptVerifyJob *decryptVerifyJob(bool textmode = false) const = 0;
+ virtual RefreshKeysJob *refreshKeysJob() const = 0;
+ virtual ChangeExpiryJob *changeExpiryJob() const = 0;
+ virtual SignKeyJob *signKeyJob() const = 0;
+ virtual ChangePasswdJob *changePasswdJob() const = 0;
+ virtual ChangeOwnerTrustJob *changeOwnerTrustJob() const = 0;
+ virtual AddUserIDJob *addUserIDJob() const = 0;
+ virtual SpecialJob *specialJob(const char *type, const QMap<QString, QVariant> &args) const = 0;
+};
+
+/** Obtain a reference to the OpenPGP Protocol.
+ *
+ * The reference is to a static object.
+ * @returns Refrence to the OpenPGP Protocol.
+ */
+QGPGME_EXPORT Protocol *openpgp();
+
+/** Obtain a reference to the smime Protocol.
+ *
+ * The reference is to a static object.
+ * @returns Refrence to the smime Protocol.
+ */
+QGPGME_EXPORT Protocol *smime();
+
+/** Obtain a reference to a cryptoConfig object.
+ *
+ * The reference is to a static object.
+ * @returns reference to cryptoConfig object.
+ */
+QGPGME_EXPORT CryptoConfig *cryptoConfig();
+
+}
+#endif
diff --git a/lang/qt/src/protocol_p.h b/lang/qt/src/protocol_p.h
new file mode 100644
index 00000000..d6c5625a
--- /dev/null
+++ b/lang/qt/src/protocol_p.h
@@ -0,0 +1,371 @@
+/*
+ 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 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_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 "qgpgmedeletejob.h"
+#include "qgpgmesecretkeyexportjob.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 "qgpgmeadduseridjob.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<QString, QVariant> &) const Q_DECL_OVERRIDE
+ {
+ return 0;
+ }
+
+ QGpgME::KeyListJob *keyListJob(bool remote, bool includeSigs, bool validate) const Q_DECL_OVERRIDE
+ {
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+
+ 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 0;
+ }
+
+ 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 0;
+ }
+
+ 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 0;
+ }
+ 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 0;
+ }
+
+ 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 0;
+ }
+
+ 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 0;
+ }
+
+ 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 0;
+ }
+ return new QGpgME::QGpgMEKeyGenerationJob(context);
+ }
+
+ QGpgME::ImportJob *importJob() const Q_DECL_OVERRIDE
+ {
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+ return new QGpgME::QGpgMEImportJob(context);
+ }
+
+ QGpgME::ImportFromKeyserverJob *importFromKeyserverJob() const Q_DECL_OVERRIDE
+ {
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+ return new QGpgME::QGpgMEImportFromKeyserverJob(context);
+ }
+
+ QGpgME::ExportJob *publicKeyExportJob(bool armor) const Q_DECL_OVERRIDE
+ {
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+
+ context->setArmor(armor);
+ return new QGpgME::QGpgMEExportJob(context);
+ }
+
+ QGpgME::ExportJob *secretKeyExportJob(bool armor, const QString &charset) const Q_DECL_OVERRIDE
+ {
+ if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too
+ return 0;
+ }
+
+ // this operation is not supported by gpgme, so we have to call gpgsm ourselves:
+ return new QGpgME::QGpgMESecretKeyExportJob(armor, charset);
+ }
+
+ QGpgME::RefreshKeysJob *refreshKeysJob() const Q_DECL_OVERRIDE
+ {
+ if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too
+ return 0;
+ }
+
+ // this operation is not supported by gpgme, so we have to call gpgsm ourselves:
+ return new QGpgME::QGpgMERefreshKeysJob();
+ }
+
+ QGpgME::DownloadJob *downloadJob(bool armor) const Q_DECL_OVERRIDE
+ {
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+
+ 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 0;
+ }
+ 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 0;
+ }
+
+ 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 0;
+ }
+
+ context->setTextMode(textMode);
+ return new QGpgME::QGpgMEDecryptVerifyJob(context);
+ }
+
+ QGpgME::ChangeExpiryJob *changeExpiryJob() const Q_DECL_OVERRIDE
+ {
+ if (mProtocol != GpgME::OpenPGP) {
+ return 0; // only supported by gpg
+ }
+
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+ return new QGpgME::QGpgMEChangeExpiryJob(context);
+ }
+
+ QGpgME::ChangePasswdJob *changePasswdJob() const Q_DECL_OVERRIDE
+ {
+ if (!GpgME::hasFeature(GpgME::PasswdFeature, 0)) {
+ return 0;
+ }
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+ return new QGpgME::QGpgMEChangePasswdJob(context);
+ }
+
+ QGpgME::SignKeyJob *signKeyJob() const Q_DECL_OVERRIDE
+ {
+ if (mProtocol != GpgME::OpenPGP) {
+ return 0; // only supported by gpg
+ }
+
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+ return new QGpgME::QGpgMESignKeyJob(context);
+ }
+
+ QGpgME::ChangeOwnerTrustJob *changeOwnerTrustJob() const Q_DECL_OVERRIDE
+ {
+ if (mProtocol != GpgME::OpenPGP) {
+ return 0; // only supported by gpg
+ }
+
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+ return new QGpgME::QGpgMEChangeOwnerTrustJob(context);
+ }
+
+ QGpgME::AddUserIDJob *addUserIDJob() const Q_DECL_OVERRIDE
+ {
+ if (mProtocol != GpgME::OpenPGP) {
+ return 0; // only supported by gpg
+ }
+
+ GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+ if (!context) {
+ return 0;
+ }
+ return new QGpgME::QGpgMEAddUserIDJob(context);
+ }
+
+};
+
+}
+#endif
diff --git a/lang/qt/src/qgpgmebackend.cpp b/lang/qt/src/qgpgmebackend.cpp
index 27cd178c..797e58a6 100644
--- a/lang/qt/src/qgpgmebackend.cpp
+++ b/lang/qt/src/qgpgmebackend.cpp
@@ -33,351 +33,18 @@
#include "qgpgmebackend.h"
-#include "qgpgmenewcryptoconfig.h"
-
-#include "qgpgmekeygenerationjob.h"
-#include "qgpgmekeylistjob.h"
-#include "qgpgmelistallkeysjob.h"
-#include "qgpgmedecryptjob.h"
-#include "qgpgmedecryptverifyjob.h"
-#include "qgpgmerefreshkeysjob.h"
-#include "qgpgmedeletejob.h"
-#include "qgpgmesecretkeyexportjob.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 "qgpgmeadduseridjob.h"
#include "error.h"
#include "engineinfo.h"
+#include "protocol_p.h"
+
#include <QFile>
#include <QString>
const char QGpgME::QGpgMEBackend::OpenPGP[] = "OpenPGP";
const char QGpgME::QGpgMEBackend::SMIME[] = "SMIME";
-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<QString, QVariant> &) const Q_DECL_OVERRIDE
- {
- return 0;
- }
-
- QGpgME::KeyListJob *keyListJob(bool remote, bool includeSigs, bool validate) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- 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 0;
- }
-
- 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 0;
- }
-
- 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 0;
- }
- 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 0;
- }
-
- 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 0;
- }
-
- 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 0;
- }
-
- 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 0;
- }
- return new QGpgME::QGpgMEKeyGenerationJob(context);
- }
-
- QGpgME::ImportJob *importJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new QGpgME::QGpgMEImportJob(context);
- }
-
- QGpgME::ImportFromKeyserverJob *importFromKeyserverJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new QGpgME::QGpgMEImportFromKeyserverJob(context);
- }
-
- QGpgME::ExportJob *publicKeyExportJob(bool armor) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setArmor(armor);
- return new QGpgME::QGpgMEExportJob(context);
- }
-
- QGpgME::ExportJob *secretKeyExportJob(bool armor, const QString &charset) const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too
- return 0;
- }
-
- // this operation is not supported by gpgme, so we have to call gpgsm ourselves:
- return new QGpgME::QGpgMESecretKeyExportJob(armor, charset);
- }
-
- QGpgME::RefreshKeysJob *refreshKeysJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too
- return 0;
- }
-
- // this operation is not supported by gpgme, so we have to call gpgsm ourselves:
- return new QGpgME::QGpgMERefreshKeysJob();
- }
-
- QGpgME::DownloadJob *downloadJob(bool armor) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- 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 0;
- }
- 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 0;
- }
-
- 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 0;
- }
-
- context->setTextMode(textMode);
- return new QGpgME::QGpgMEDecryptVerifyJob(context);
- }
-
- QGpgME::ChangeExpiryJob *changeExpiryJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::OpenPGP) {
- return 0; // only supported by gpg
- }
-
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new QGpgME::QGpgMEChangeExpiryJob(context);
- }
-
- QGpgME::ChangePasswdJob *changePasswdJob() const Q_DECL_OVERRIDE
- {
- if (!GpgME::hasFeature(GpgME::PasswdFeature, 0)) {
- return 0;
- }
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new QGpgME::QGpgMEChangePasswdJob(context);
- }
-
- QGpgME::SignKeyJob *signKeyJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::OpenPGP) {
- return 0; // only supported by gpg
- }
-
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new QGpgME::QGpgMESignKeyJob(context);
- }
-
- QGpgME::ChangeOwnerTrustJob *changeOwnerTrustJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::OpenPGP) {
- return 0; // only supported by gpg
- }
-
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new QGpgME::QGpgMEChangeOwnerTrustJob(context);
- }
-
- QGpgME::AddUserIDJob *addUserIDJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::OpenPGP) {
- return 0; // only supported by gpg
- }
-
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new QGpgME::QGpgMEAddUserIDJob(context);
- }
-
-};
-
-}
QGpgME::QGpgMEBackend::QGpgMEBackend()
: mCryptoConfig(0),
@@ -510,6 +177,15 @@ const char *QGpgME::QGpgMEBackend::enumerateProtocols(int i) const
static QGpgME::QGpgMEBackend *gpgmeBackend;
+QGpgME::CryptoConfig *QGpgME::cryptoConfig()
+{
+ if (!gpgmeBackend) {
+ gpgmeBackend = new QGpgME::QGpgMEBackend();
+ }
+ return gpgmeBackend->config();
+
+}
+
QGpgME::Protocol *QGpgME::openpgp()
{
if (!gpgmeBackend) {
diff --git a/lang/qt/src/qgpgmebackend.h b/lang/qt/src/qgpgmebackend.h
index 3b036334..cca8b711 100644
--- a/lang/qt/src/qgpgmebackend.h
+++ b/lang/qt/src/qgpgmebackend.h
@@ -36,35 +36,9 @@
#include <QString>
-namespace QGpgME
-{
-class CryptoConfig;
-class KeyListJob;
-class ListAllKeysJob;
-class KeyGenerationJob;
-class ImportJob;
-class ImportFromKeyserverJob;
-class ExportJob;
-class DownloadJob;
-class DeleteJob;
-class EncryptJob;
-class DecryptJob;
-class SignJob;
-class SignKeyJob;
-class VerifyDetachedJob;
-class VerifyOpaqueJob;
-class SignEncryptJob;
-class DecryptVerifyJob;
-class RefreshKeysJob;
-class ChangeExpiryJob;
-class ChangeOwnerTrustJob;
-class ChangePasswdJob;
-class AddUserIDJob;
-class SpecialJob;
-}
+#include "protocol.h"
class QString;
-class QVariant;
template <typename T_Key, typename T_Value> class QMap;
namespace QGpgME
@@ -72,19 +46,6 @@ namespace QGpgME
class CryptoConfig;
class Protocol;
-/** Obtain a reference to the OpenPGP Protocol.
- *
- * The reference is to a static object.
- * @returns Refrence to the OpenPGP Protocol.
- */
-Protocol *openpgp();
-
-/** Obtain a reference to the smime Protocol.
- *
- * The reference is to a static object.
- * @returns Refrence to the smime Protocol.
- */
-Protocol *smime();
class QGpgMEBackend
{
@@ -126,41 +87,6 @@ private:
mutable Protocol *mSMIMEProtocol;
};
-class Protocol
-{
-public:
- virtual ~Protocol() {}
-
- virtual QString name() const = 0;
-
- virtual QString displayName() const = 0;
-
- virtual KeyListJob *keyListJob(bool remote = false, bool includeSigs = false, bool validate = false) const = 0;
- virtual ListAllKeysJob *listAllKeysJob(bool includeSigs = false, bool validate = false) const = 0;
- virtual EncryptJob *encryptJob(bool armor = false, bool textmode = false) const = 0;
- virtual DecryptJob *decryptJob() const = 0;
- virtual SignJob *signJob(bool armor = false, bool textMode = false) const = 0;
- virtual VerifyDetachedJob *verifyDetachedJob(bool textmode = false) const = 0;
- virtual VerifyOpaqueJob *verifyOpaqueJob(bool textmode = false) const = 0;
- virtual KeyGenerationJob *keyGenerationJob() const = 0;
- virtual ImportJob *importJob() const = 0;
- virtual ImportFromKeyserverJob *importFromKeyserverJob() const = 0;
- virtual ExportJob *publicKeyExportJob(bool armor = false) const = 0;
- // @param charset the encoding of the passphrase in the exported file
- virtual ExportJob *secretKeyExportJob(bool armor = false, const QString &charset = QString()) const = 0;
- virtual DownloadJob *downloadJob(bool armor = false) const = 0;
- virtual DeleteJob *deleteJob() const = 0;
- virtual SignEncryptJob *signEncryptJob(bool armor = false, bool textMode = false) const = 0;
- virtual DecryptVerifyJob *decryptVerifyJob(bool textmode = false) const = 0;
- virtual RefreshKeysJob *refreshKeysJob() const = 0;
- virtual ChangeExpiryJob *changeExpiryJob() const = 0;
- virtual SignKeyJob *signKeyJob() const = 0;
- virtual ChangePasswdJob *changePasswdJob() const = 0;
- virtual ChangeOwnerTrustJob *changeOwnerTrustJob() const = 0;
- virtual AddUserIDJob *addUserIDJob() const = 0;
- virtual SpecialJob *specialJob(const char *type, const QMap<QString, QVariant> &args) const = 0;
-};
-
}
#endif // __QGPGME_QGPGMEBACKEND_H__