LCOV - code coverage report
Current view: top level - lang/qt/src - protocol.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 2 50.0 %
Date: 2018-11-14 16:53:58 Functions: 1 3 33.3 %

          Line data    Source code
       1             : /*
       2             :     protocol.h
       3             : 
       4             :     This file is part of qgpgme, the Qt API binding for gpgme
       5             :     Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB
       6             :     Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
       7             :     Software engineering by Intevation GmbH
       8             : 
       9             :     QGpgME is free software; you can redistribute it and/or
      10             :     modify it under the terms of the GNU General Public License as
      11             :     published by the Free Software Foundation; either version 2 of the
      12             :     License, or (at your option) any later version.
      13             : 
      14             :     QGpgME is distributed in the hope that it will be useful,
      15             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17             :     General Public License for more details.
      18             : 
      19             :     You should have received a copy of the GNU General Public License
      20             :     along with this program; if not, write to the Free Software
      21             :     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
      22             : 
      23             :     In addition, as a special exception, the copyright holders give
      24             :     permission to link the code of this program with any edition of
      25             :     the Qt library by Trolltech AS, Norway (or with modified versions
      26             :     of Qt that use the same license as Qt), and distribute linked
      27             :     combinations including the two.  You must obey the GNU General
      28             :     Public License in all respects for all of the code used other than
      29             :     Qt.  If you modify this file, you may extend this exception to
      30             :     your version of the file, but you are not obligated to do so.  If
      31             :     you do not wish to do so, delete this exception statement from
      32             :     your version.
      33             : */
      34             : #ifndef __QGPGME_PROTOCOL_H__
      35             : #define __QGPGME_PROTOCOL_H__
      36             : 
      37             : #include <QString>
      38             : #include <QVariant>
      39             : 
      40             : #include "qgpgme_export.h"
      41             : 
      42             : namespace QGpgME {
      43             : class CryptoConfig;
      44             : class KeyListJob;
      45             : class ListAllKeysJob;
      46             : class KeyGenerationJob;
      47             : class ImportJob;
      48             : class ImportFromKeyserverJob;
      49             : class ExportJob;
      50             : class DownloadJob;
      51             : class DeleteJob;
      52             : class EncryptJob;
      53             : class DecryptJob;
      54             : class SignJob;
      55             : class SignKeyJob;
      56             : class VerifyDetachedJob;
      57             : class VerifyOpaqueJob;
      58             : class SignEncryptJob;
      59             : class DecryptVerifyJob;
      60             : class RefreshKeysJob;
      61             : class ChangeExpiryJob;
      62             : class ChangeOwnerTrustJob;
      63             : class ChangePasswdJob;
      64             : class AddUserIDJob;
      65             : class SpecialJob;
      66             : class KeyForMailboxJob;
      67             : class WKSPublishJob;
      68             : class TofuPolicyJob;
      69             : class QuickJob;
      70             : 
      71             : /** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.
      72             :  *
      73             :  * Use the proctocol class to obtain an instance of a job. Jobs
      74             :  * provide async API for GnuPG that can be connected to signals / slots.
      75             :  *
      76             :  * A job is usually started with start() and emits a result signal.
      77             :  * The parameters of the result signal depend on the job but the last
      78             :  * two are always a QString for the auditlog and an GpgME::Error for
      79             :  * an eventual error.
      80             :  *
      81             :  * In case async API is used and the result signal is emitted a
      82             :  * job schedules its own deletion.
      83             :  *
      84             :  * Most jobs also provide a synchronous call exec in which case
      85             :  * you have to explicitly delete the job if you don't need it anymore.
      86             :  *
      87             :  * \code
      88             :  * // Async example:
      89             :  * KeyListJob *job = openpgp()->keyListJob();
      90             :  * connect(job, &KeyListJob::result, job, [this, job](KeyListResult, std::vector<Key> keys, QString, Error)
      91             :  * {
      92             :  *    // keys and resuls can now be used.
      93             :  * });
      94             :  * \endcode
      95             :  *
      96             :  * \code
      97             :  * // Sync eaxmple:
      98             :  * KeyListJob *job = openpgp()->keyListJob(false, false, false);
      99             :  * std::vector<GpgME::Key> keys;
     100             :  * GpgME::KeyListResult result = job->exec(QStringList() <<
     101             :  *                                         QStringLiteral("alfa@example.net"),
     102             :  *                                         false, keys);
     103             :  * delete job;
     104             :  * \endcode
     105             :  */
     106           7 : class QGPGME_EXPORT Protocol
     107             : {
     108             : public:
     109           0 :     virtual ~Protocol() {}
     110             : 
     111             :     virtual QString name() const = 0;
     112             : 
     113             :     virtual QString displayName() const = 0;
     114             : 
     115             :     virtual KeyListJob           *keyListJob(bool remote = false, bool includeSigs = false, bool validate = false) const = 0;
     116             :     virtual ListAllKeysJob       *listAllKeysJob(bool includeSigs = false, bool validate = false) const = 0;
     117             :     virtual EncryptJob           *encryptJob(bool armor = false, bool textmode = false) const = 0;
     118             :     virtual DecryptJob           *decryptJob() const = 0;
     119             :     virtual SignJob              *signJob(bool armor = false, bool textMode = false) const = 0;
     120             :     virtual VerifyDetachedJob    *verifyDetachedJob(bool textmode = false) const = 0;
     121             :     virtual VerifyOpaqueJob      *verifyOpaqueJob(bool textmode = false) const = 0;
     122             :     virtual KeyGenerationJob     *keyGenerationJob() const = 0;
     123             :     virtual ImportJob            *importJob() const = 0;
     124             :     virtual ImportFromKeyserverJob *importFromKeyserverJob() const = 0;
     125             :     virtual ExportJob            *publicKeyExportJob(bool armor = false) const = 0;
     126             :     // @param charset the encoding of the passphrase in the exported file
     127             :     virtual ExportJob            *secretKeyExportJob(bool armor = false, const QString &charset = QString()) const = 0;
     128             :     virtual DownloadJob          *downloadJob(bool armor = false) const = 0;
     129             :     virtual DeleteJob            *deleteJob() const = 0;
     130             :     virtual SignEncryptJob       *signEncryptJob(bool armor = false, bool textMode = false) const = 0;
     131             :     virtual DecryptVerifyJob     *decryptVerifyJob(bool textmode = false) const = 0;
     132             :     virtual RefreshKeysJob       *refreshKeysJob() const = 0;
     133             :     virtual ChangeExpiryJob      *changeExpiryJob() const = 0;
     134             :     virtual SignKeyJob           *signKeyJob() const = 0;
     135             :     virtual ChangePasswdJob      *changePasswdJob() const = 0;
     136             :     virtual ChangeOwnerTrustJob  *changeOwnerTrustJob() const = 0;
     137             :     virtual AddUserIDJob         *addUserIDJob() const = 0;
     138             :     virtual SpecialJob           *specialJob(const char *type, const QMap<QString, QVariant> &args) const = 0;
     139             : 
     140             :     /** A key locate job.
     141             :      *
     142             :      * This tries to find a key in local
     143             :      * and remote sources, if the key was remote it is imported
     144             :      * by GnuPG. Same as KeyListJob but intended to be used
     145             :      * to locate keys automatically. This ends up calling --locate-keys.
     146             :      *
     147             :      * Only available for OpenPGP
     148             :      *
     149             :      * Results are validated. As if keyListJob was called
     150             :      * with both includeSigs and validate options.
     151             :      */
     152             :     virtual KeyListJob *locateKeysJob() const = 0;
     153             :     /** Find the best key to use for a mailbox. */
     154             :     virtual KeyForMailboxJob *keyForMailboxJob() const = 0;
     155             : 
     156             :     /** A Job for interacting with gnupg's wks tools. */
     157             :     virtual WKSPublishJob *wksPublishJob() const = 0;
     158             : 
     159             :     /** A Job to set tofu policy */
     160             :     virtual TofuPolicyJob *tofuPolicyJob() const = 0;
     161             : 
     162             :     /** A Job for the quick commands */
     163             :     virtual QuickJob *quickJob() const = 0;
     164             : };
     165             : 
     166             : /** Obtain a reference to the OpenPGP Protocol.
     167             :  *
     168             :  * The reference is to a static object.
     169             :  * @returns Reference to the OpenPGP Protocol.
     170             :  */
     171             : QGPGME_EXPORT Protocol *openpgp();
     172             : 
     173             : /** Obtain a reference to the smime Protocol.
     174             :  *
     175             :  * The reference is to a static object.
     176             :  * @returns Reference to the smime Protocol.
     177             :  */
     178             : QGPGME_EXPORT Protocol *smime();
     179             : 
     180             : /** Obtain a reference to a cryptoConfig object.
     181             :  *
     182             :  * The reference is to a static object.
     183             :  * @returns reference to cryptoConfig object.
     184             :  */
     185             : QGPGME_EXPORT CryptoConfig *cryptoConfig();
     186             : 
     187             : }
     188             : #endif

Generated by: LCOV version 1.13