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

Generated by: LCOV version 1.11