[Pkg-gnupg-commit] [gpgme] 78/412: Qt: Make Protocol class public API

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 22 21:26:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gpgme.

commit 56c4d9ea9520c95612e525b2fa1359db6fa88f4a
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue May 10 14:05:10 2016 +0200

    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.
---
 lang/qt/src/Makefile.am                         |   2 +
 lang/qt/src/{qgpgmebackend.h => protocol.h}     | 103 ++-----
 lang/qt/src/{qgpgmebackend.cpp => protocol_p.h} | 162 +----------
 lang/qt/src/qgpgmebackend.cpp                   | 346 +-----------------------
 lang/qt/src/qgpgmebackend.h                     |  76 +-----
 5 files changed, 47 insertions(+), 642 deletions(-)

diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am
index 30c24b9..7de3ef6 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/qgpgmebackend.h b/lang/qt/src/protocol.h
similarity index 77%
copy from lang/qt/src/qgpgmebackend.h
copy to lang/qt/src/protocol.h
index 3b03633..5162fe6 100644
--- a/lang/qt/src/qgpgmebackend.h
+++ b/lang/qt/src/protocol.h
@@ -1,5 +1,5 @@
 /*
-    qgpgmebackend.h
+    protocol.h
 
     This file is part of qgpgme, the Qt API binding for gpgme
     Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB
@@ -30,14 +30,15 @@
     you do not wish to do so, delete this exception statement from
     your version.
 */
-
-#ifndef __QGPGME_QGPGMEBACKEND_H__
-#define __QGPGME_QGPGMEBACKEND_H__
+#ifndef __QGPGME_PROTOCOL_H__
+#define __QGPGME_PROTOCOL_H__
 
 #include <QString>
+#include <QVariant>
 
-namespace QGpgME
-{
+#include "qgpgme_export.h"
+
+namespace QGpgME {
 class CryptoConfig;
 class KeyListJob;
 class ListAllKeysJob;
@@ -61,72 +62,8 @@ class ChangeOwnerTrustJob;
 class ChangePasswdJob;
 class AddUserIDJob;
 class SpecialJob;
-}
 
-class QString;
-class QVariant;
-template <typename T_Key, typename T_Value> class QMap;
-
-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
-{
-public:
-    QGpgMEBackend();
-    ~QGpgMEBackend();
-
-    QString name() const;
-    QString displayName() const;
-
-    CryptoConfig *config() const;
-
-    Protocol *openpgp() const;
-    Protocol *smime() const;
-    Protocol *protocol(const char *name) const;
-
-    static const char OpenPGP[];
-    static const char SMIME[];
-
-    bool checkForOpenPGP(QString *reason = Q_NULLPTR) const;
-    bool checkForSMIME(QString *reason = Q_NULLPTR) const;
-    bool checkForProtocol(const char *name, QString *reason) const;
-
-    bool supportsOpenPGP() const
-    {
-        return true;
-    }
-    bool supportsSMIME() const
-    {
-        return true;
-    }
-    bool supportsProtocol(const char *name) const;
-
-    const char *enumerateProtocols(int i) const;
-
-private:
-    mutable QGpgME::CryptoConfig *mCryptoConfig;
-    mutable Protocol *mOpenPGPProtocol;
-    mutable Protocol *mSMIMEProtocol;
-};
-
-class Protocol
+class QGPGME_EXPORT Protocol
 {
 public:
     virtual ~Protocol() {}
@@ -161,6 +98,26 @@ public:
     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 // __QGPGME_QGPGMEBACKEND_H__
+}
+#endif
diff --git a/lang/qt/src/qgpgmebackend.cpp b/lang/qt/src/protocol_p.h
similarity index 74%
copy from lang/qt/src/qgpgmebackend.cpp
copy to lang/qt/src/protocol_p.h
index 27cd178..d6c5625 100644
--- a/lang/qt/src/qgpgmebackend.cpp
+++ b/lang/qt/src/protocol_p.h
@@ -1,5 +1,5 @@
 /*
-    qgpgmebackend.cpp
+    protocol_p.h
 
     This file is part of qgpgme, the Qt API binding for gpgme
     Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB
@@ -30,9 +30,8 @@
     you do not wish to do so, delete this exception statement from
     your version.
 */
-
-#include "qgpgmebackend.h"
-
+#ifndef __QGPGME_PROTOCOL_P_H__
+#define __QGPGME_PROTOCOL_P_H__
 #include "qgpgmenewcryptoconfig.h"
 
 #include "qgpgmekeygenerationjob.h"
@@ -58,15 +57,6 @@
 #include "qgpgmechangepasswdjob.h"
 #include "qgpgmeadduseridjob.h"
 
-#include "error.h"
-#include "engineinfo.h"
-
-#include <QFile>
-#include <QString>
-
-const char QGpgME::QGpgMEBackend::OpenPGP[] = "OpenPGP";
-const char QGpgME::QGpgMEBackend::SMIME[] = "SMIME";
-
 namespace
 {
 
@@ -378,150 +368,4 @@ public:
 };
 
 }
-
-QGpgME::QGpgMEBackend::QGpgMEBackend()
-    : mCryptoConfig(0),
-      mOpenPGPProtocol(0),
-      mSMIMEProtocol(0)
-{
-    GpgME::initializeLibrary();
-}
-
-QGpgME::QGpgMEBackend::~QGpgMEBackend()
-{
-    delete mCryptoConfig; mCryptoConfig = 0;
-    delete mOpenPGPProtocol; mOpenPGPProtocol = 0;
-    delete mSMIMEProtocol; mSMIMEProtocol = 0;
-}
-
-QString QGpgME::QGpgMEBackend::name() const
-{
-    return QStringLiteral("gpgme");
-}
-
-QString QGpgME::QGpgMEBackend::displayName() const
-{
-    return QStringLiteral("GpgME");
-}
-
-QGpgME::CryptoConfig *QGpgME::QGpgMEBackend::config() const
-{
-    if (!mCryptoConfig) {
-        if (GpgME::hasFeature(GpgME::GpgConfEngineFeature, 0)) {
-            mCryptoConfig = new QGpgMENewCryptoConfig;
-        }
-    }
-    return mCryptoConfig;
-}
-
-static bool check(GpgME::Protocol proto, QString *reason)
-{
-    if (!GpgME::checkEngine(proto)) {
-        return true;
-    }
-    if (!reason) {
-        return false;
-    }
-    // error, check why:
-#if 0
-Port away from localised string or delete.
-    const GpgME::EngineInfo ei = GpgME::engineInfo(proto);
-    if (ei.isNull()) {
-        *reason = i18n("GPGME was compiled without support for %1.", proto == GpgME::CMS ? QLatin1String("S/MIME") : QLatin1String("OpenPGP"));
-    } else if (ei.fileName() && !ei.version()) {
-        *reason = i18n("Engine %1 is not installed properly.", QFile::decodeName(ei.fileName()));
-    } else if (ei.fileName() && ei.version() && ei.requiredVersion())
-        *reason = i18n("Engine %1 version %2 installed, "
-                       "but at least version %3 is required.",
-                       QFile::decodeName(ei.fileName()), QLatin1String(ei.version()), QLatin1String(ei.requiredVersion()));
-    else {
-        *reason = i18n("Unknown problem with engine for protocol %1.", proto == GpgME::CMS ? QLatin1String("S/MIME") : QLatin1String("OpenPGP"));
-    }
 #endif
-    return false;
-}
-
-bool QGpgME::QGpgMEBackend::checkForOpenPGP(QString *reason) const
-{
-    return check(GpgME::OpenPGP, reason);
-}
-
-bool QGpgME::QGpgMEBackend::checkForSMIME(QString *reason) const
-{
-    return check(GpgME::CMS, reason);
-}
-
-bool QGpgME::QGpgMEBackend::checkForProtocol(const char *name, QString *reason) const
-{
-    if (qstricmp(name, OpenPGP) == 0) {
-        return check(GpgME::OpenPGP, reason);
-    }
-    if (qstricmp(name, SMIME) == 0) {
-        return check(GpgME::CMS, reason);
-    }
-    if (reason) {
-        *reason = QStringLiteral("Unsupported protocol \"%1\"").arg(QLatin1String(name));
-    }
-    return false;
-}
-
-QGpgME::Protocol *QGpgME::QGpgMEBackend::openpgp() const
-{
-    if (!mOpenPGPProtocol)
-        if (checkForOpenPGP()) {
-            mOpenPGPProtocol = new ::Protocol(GpgME::OpenPGP);
-        }
-    return mOpenPGPProtocol;
-}
-
-QGpgME::Protocol *QGpgME::QGpgMEBackend::smime() const
-{
-    if (!mSMIMEProtocol)
-        if (checkForSMIME()) {
-            mSMIMEProtocol = new ::Protocol(GpgME::CMS);
-        }
-    return mSMIMEProtocol;
-}
-
-QGpgME::Protocol *QGpgME::QGpgMEBackend::protocol(const char *name) const
-{
-    if (qstricmp(name, OpenPGP) == 0) {
-        return openpgp();
-    }
-    if (qstricmp(name, SMIME) == 0) {
-        return smime();
-    }
-    return 0;
-}
-
-bool QGpgME::QGpgMEBackend::supportsProtocol(const char *name) const
-{
-    return qstricmp(name, OpenPGP) == 0 || qstricmp(name, SMIME) == 0;
-}
-
-const char *QGpgME::QGpgMEBackend::enumerateProtocols(int i) const
-{
-    switch (i) {
-    case 0: return OpenPGP;
-    case 1: return SMIME;
-    default: return 0;
-    }
-}
-
-static QGpgME::QGpgMEBackend *gpgmeBackend;
-
-QGpgME::Protocol *QGpgME::openpgp()
-{
-    if (!gpgmeBackend) {
-        gpgmeBackend = new QGpgME::QGpgMEBackend();
-    }
-    return gpgmeBackend->openpgp();
-}
-
-QGpgME::Protocol *QGpgME::smime()
-{
-    if (!gpgmeBackend) {
-        gpgmeBackend = new QGpgME::QGpgMEBackend();
-    }
-    return gpgmeBackend->smime();
-}
diff --git a/lang/qt/src/qgpgmebackend.cpp b/lang/qt/src/qgpgmebackend.cpp
index 27cd178..797e58a 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 3b03633..cca8b71 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__

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list