diff options
Diffstat (limited to 'lang/qt/src')
| -rw-r--r-- | lang/qt/src/Makefile.am | 8 | ||||
| -rw-r--r-- | lang/qt/src/job.cpp | 3 | ||||
| -rw-r--r-- | lang/qt/src/protocol.h | 4 | ||||
| -rw-r--r-- | lang/qt/src/protocol_p.h | 13 | ||||
| -rw-r--r-- | lang/qt/src/qgpgmetofupolicyjob.cpp | 65 | ||||
| -rw-r--r-- | lang/qt/src/qgpgmetofupolicyjob.h | 65 | ||||
| -rw-r--r-- | lang/qt/src/tofupolicyjob.h | 80 | 
7 files changed, 237 insertions, 1 deletions
| diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am index f63b2958..c15da182 100644 --- a/lang/qt/src/Makefile.am +++ b/lang/qt/src/Makefile.am @@ -34,6 +34,7 @@ qgpgme_sources = \      qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \      qgpgmeverifyopaquejob.cpp threadedjobmixin.cpp \      qgpgmekeyformailboxjob.cpp gpgme_backend_debug.cpp \ +    qgpgmetofupolicyjob.cpp \      defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp  # If you add one here make sure that you also add one in camelcase @@ -69,6 +70,7 @@ qgpgme_headers= \      listallkeysjob.h \      verifydetachedjob.h \      defaultkeygenerationjob.h \ +    tofupolicyjob.h \      wkspublishjob.h  camelcase_headers= \ @@ -102,7 +104,8 @@ camelcase_headers= \      VerifyDetachedJob \      KeyForMailboxJob \      DefaultKeyGenerationJob \ -    WKSPublishJob +    WKSPublishJob \ +    TofuPolicyJob  private_qgpgme_headers = \      qgpgme_export.h \ @@ -133,6 +136,7 @@ private_qgpgme_headers = \      qgpgmeverifyopaquejob.h \      qgpgmekeyformailboxjob.h \      qgpgmewkspublishjob.h \ +    qgpgmetofupolicyjob.h \      specialjob.h \      threadedjobmixin.h @@ -179,6 +183,8 @@ qgpgme_moc_sources = \      qgpgmeverifydetachedjob.moc \      qgpgmeverifyopaquejob.moc \      qgpgmewkspublishjob.moc \ +    tofupolicyjob.moc \ +    qgpgmetofupolicyjob.moc \      refreshkeysjob.moc \      signencryptjob.moc \      signjob.moc \ diff --git a/lang/qt/src/job.cpp b/lang/qt/src/job.cpp index 6b355a09..8936ea5f 100644 --- a/lang/qt/src/job.cpp +++ b/lang/qt/src/job.cpp @@ -57,6 +57,7 @@  #include "specialjob.h"  #include "keyformailboxjob.h"  #include "wkspublishjob.h" +#include "tofupolicyjob.h"  #include <QCoreApplication>  #include <QDebug> @@ -124,6 +125,7 @@ make_job_subclass(AddUserIDJob)  make_job_subclass(SpecialJob)  make_job_subclass(KeyForMailboxJob)  make_job_subclass(WKSPublishJob) +make_job_subclass(TofuPolicyJob)  #undef make_job_subclass @@ -154,3 +156,4 @@ make_job_subclass(WKSPublishJob)  #include "specialjob.moc"  #include "keyformailboxjob.moc"  #include "wkspublishjob.moc" +#include "tofupolicyjob.moc" diff --git a/lang/qt/src/protocol.h b/lang/qt/src/protocol.h index b2dee1de..40ddcb53 100644 --- a/lang/qt/src/protocol.h +++ b/lang/qt/src/protocol.h @@ -64,6 +64,7 @@ class AddUserIDJob;  class SpecialJob;  class KeyForMailboxJob;  class WKSPublishJob; +class TofuPolicyJob;  /** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.   * @@ -152,6 +153,9 @@ public:      /** A Job for interacting with gnupg's wks tools. */      virtual WKSPublishJob *wksPublishJob() const = 0; + +    /** A Job to set tofu policy */ +    virtual TofuPolicyJob *tofuPolicyJob() 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 2ce41824..7f66fa49 100644 --- a/lang/qt/src/protocol_p.h +++ b/lang/qt/src/protocol_p.h @@ -58,6 +58,7 @@  #include "qgpgmeadduseridjob.h"  #include "qgpgmekeyformailboxjob.h"  #include "qgpgmewkspublishjob.h" +#include "qgpgmetofupolicyjob.h"  namespace  { @@ -400,6 +401,18 @@ public:          }          return new QGpgME::QGpgMEWKSPublishJob(context.release());      } + +    QGpgME::TofuPolicyJob *tofuPolicyJob() const Q_DECL_OVERRIDE +    { +        if (mProtocol != GpgME::OpenPGP) { +            return Q_NULLPTR; +        } +        GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol); +        if (!context) { +            return Q_NULLPTR; +        } +        return new QGpgME::QGpgMETofuPolicyJob(context); +    }  };  } diff --git a/lang/qt/src/qgpgmetofupolicyjob.cpp b/lang/qt/src/qgpgmetofupolicyjob.cpp new file mode 100644 index 00000000..a24c946f --- /dev/null +++ b/lang/qt/src/qgpgmetofupolicyjob.cpp @@ -0,0 +1,65 @@ +/* qgpgmetofupolicyjob.cpp + +    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. +*/ + +#include "qgpgmetofupolicyjob.h" + +#include "context.h" +#include "key.h" +#include "tofuinfo.h" + + +using namespace QGpgME; +using namespace GpgME; + +QGpgMETofuPolicyJob::QGpgMETofuPolicyJob(Context *context) +    : mixin_type(context) +{ +    lateInitialization(); +} + +QGpgMETofuPolicyJob::~QGpgMETofuPolicyJob() {} + +static QGpgMETofuPolicyJob::result_type policy_worker(Context *ctx, const Key &key, TofuInfo::Policy policy) +{ +    return std::make_tuple (ctx->setTofuPolicy(key, policy), +                            QString(), Error()); +} + +void QGpgMETofuPolicyJob::start(const Key &key, TofuInfo::Policy policy) +{ +    run(std::bind(&policy_worker, std::placeholders::_1, key, policy)); +} + +Error QGpgMETofuPolicyJob::exec(const Key &key, TofuInfo::Policy policy) +{ +    return std::get<0>(policy_worker(context(), key, policy)); +} + +#include "qgpgmetofupolicyjob.moc" diff --git a/lang/qt/src/qgpgmetofupolicyjob.h b/lang/qt/src/qgpgmetofupolicyjob.h new file mode 100644 index 00000000..e7272e70 --- /dev/null +++ b/lang/qt/src/qgpgmetofupolicyjob.h @@ -0,0 +1,65 @@ +/* qgpgmetofupolicyjob.h + +    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_QGPGMETOFUPOLICYJOB_H +#define QGPGME_QGPGMETOFUPOLICYJOB_H + +#include "tofupolicyjob.h" + +#include "threadedjobmixin.h" +namespace GpgME +{ +    class Key; +} // namespace GpgME + +namespace QGpgME { + +class QGpgMETofuPolicyJob +#ifdef Q_MOC_RUN +    : public TofuPolicyJob +#else +    : public _detail::ThreadedJobMixin<TofuPolicyJob, std::tuple<GpgME::Error, QString, GpgME::Error> > +#endif +{ +    Q_OBJECT +#ifdef Q_MOC_RUN +public Q_SLOTS: +    void slotFinished(); +#endif +public: +    explicit QGpgMETofuPolicyJob(GpgME::Context *context); +    ~QGpgMETofuPolicyJob(); + +    void start(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) Q_DECL_OVERRIDE; +    GpgME::Error exec(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) Q_DECL_OVERRIDE; +}; + +} + +#endif diff --git a/lang/qt/src/tofupolicyjob.h b/lang/qt/src/tofupolicyjob.h new file mode 100644 index 00000000..3079f911 --- /dev/null +++ b/lang/qt/src/tofupolicyjob.h @@ -0,0 +1,80 @@ +/* tofupolicyjob.h + +    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_TOFUPOLICYJOB_H +#define QGPGME_TOFUPOLICYJOB_H + +#include "job.h" + +#include "qgpgme_export.h" + +#ifdef BUILDING_QGPGME +# include "tofuinfo.h" +#else +# include <gpgme++/tofuinfo.h> +#endif + +namespace GpgME +{ +    class Key; +} // namespace GpgME + +namespace QGpgME { + +/** + * Set the TOFU Policy for a key + */ +class QGPGME_EXPORT TofuPolicyJob: public Job +{ +    Q_OBJECT +protected: +    explicit TofuPolicyJob(QObject *parent); +public: +    ~TofuPolicyJob(); + + +    /* Set the policy to \a policy see the gpgme manual for +     * policy explanations. */ +    virtual void start(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) = 0; + +    virtual GpgME::Error exec(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) = 0; + +Q_SIGNALS: +    /* Result of the operation +     * +     * As usual auditLogAsHtml and auditLogError can be ignored. +     **/ +    void result(const GpgME::Error &error, +                const QString &auditLogAsHtml = QString(), +                const GpgME::Error &auditLogError = GpgME::Error()); +}; + +} + +#endif | 
