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-09-12 13:07:23 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             : 
      68             : /** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.
      69             :  *
      70             :  * Use the proctocol class to obtain an instance of a job. Jobs
      71             :  * provide async API for GnuPG that can be connected to signals / slots.
      72             :  *
      73             :  * A job is usually started with start() and emits a result signal.
      74             :  * The parameters of the result signal depend on the job but the last
      75             :  * two are always a QString for the auditlog and an GpgME::Error for
      76             :  * an eventual error.
      77             :  *
      78             :  * In case async API is used and the result signal is emited a
      79             :  * job schedules its own deletion.
      80             :  *
      81             :  * Most jobs also provide a synchronous call exec in which case
      82             :  * you have to explicitly delete the job if you don't need it anymore.
      83             :  *
      84             :  * \code
      85             :  * // Async example:
      86             :  * KeyListJob *job = openpgp()->keyListJob();
      87             :  * connect(job, &KeyListJob::result, job, [this, job](KeyListResult, std::vector<Key> keys, QString, Error)
      88             :  * {
      89             :  *    // keys and resuls can now be used.
      90             :  * });
      91             :  * \endcode
      92             :  *
      93             :  * \code
      94             :  * // Sync eaxmple:
      95             :  * KeyListJob *job = openpgp()->keyListJob(false, false, false);
      96             :  * std::vector<GpgME::Key> keys;
      97             :  * GpgME::KeyListResult result = job->exec(QStringList() <<
      98             :  *                                         QStringLiteral("alfa@example.net"),
      99             :  *                                         false, keys);
     100             :  * delete job;
     101             :  * \endcode
     102             :  */
     103           6 : class QGPGME_EXPORT Protocol
     104             : {
     105             : public:
     106           0 :     virtual ~Protocol() {}
     107             : 
     108             :     virtual QString name() const = 0;
     109             : 
     110             :     virtual QString displayName() const = 0;
     111             : 
     112             :     virtual KeyListJob           *keyListJob(bool remote = false, bool includeSigs = false, bool validate = false) const = 0;
     113             :     virtual ListAllKeysJob       *listAllKeysJob(bool includeSigs = false, bool validate = false) const = 0;
     114             :     virtual EncryptJob           *encryptJob(bool armor = false, bool textmode = false) const = 0;
     115             :     virtual DecryptJob           *decryptJob() const = 0;
     116             :     virtual SignJob              *signJob(bool armor = false, bool textMode = false) const = 0;
     117             :     virtual VerifyDetachedJob    *verifyDetachedJob(bool textmode = false) const = 0;
     118             :     virtual VerifyOpaqueJob      *verifyOpaqueJob(bool textmode = false) const = 0;
     119             :     virtual KeyGenerationJob     *keyGenerationJob() const = 0;
     120             :     virtual ImportJob            *importJob() const = 0;
     121             :     virtual ImportFromKeyserverJob *importFromKeyserverJob() const = 0;
     122             :     virtual ExportJob            *publicKeyExportJob(bool armor = false) const = 0;
     123             :     // @param charset the encoding of the passphrase in the exported file
     124             :     virtual ExportJob            *secretKeyExportJob(bool armor = false, const QString &charset = QString()) const = 0;
     125             :     virtual DownloadJob          *downloadJob(bool armor = false) const = 0;
     126             :     virtual DeleteJob            *deleteJob() const = 0;
     127             :     virtual SignEncryptJob       *signEncryptJob(bool armor = false, bool textMode = false) const = 0;
     128             :     virtual DecryptVerifyJob     *decryptVerifyJob(bool textmode = false) const = 0;
     129             :     virtual RefreshKeysJob       *refreshKeysJob() const = 0;
     130             :     virtual ChangeExpiryJob      *changeExpiryJob() const = 0;
     131             :     virtual SignKeyJob           *signKeyJob() const = 0;
     132             :     virtual ChangePasswdJob      *changePasswdJob() const = 0;
     133             :     virtual ChangeOwnerTrustJob  *changeOwnerTrustJob() const = 0;
     134             :     virtual AddUserIDJob         *addUserIDJob() const = 0;
     135             :     virtual SpecialJob           *specialJob(const char *type, const QMap<QString, QVariant> &args) const = 0;
     136             : 
     137             :     /** A key locate job.
     138             :      *
     139             :      * This tries to find a key in local
     140             :      * and remote sources, if the key was remote it is imported
     141             :      * by GnuPG. Same as KeyListJob but intended to be used
     142             :      * to locate keys automatically. This ends up calling --locate-keys.
     143             :      *
     144             :      * Only available for OpenPGP
     145             :      *
     146             :      * Results are validated. As if keyListJob was called
     147             :      * with both includeSigs and validate options.
     148             :      */
     149             :     virtual KeyListJob *locateKeysJob() const = 0;
     150             :     /** Find the best key to use for a mailbox. */
     151             :     virtual KeyForMailboxJob *keyForMailboxJob() const = 0;
     152             : 
     153             :     /** A Job for interacting with gnupg's wks tools. */
     154             :     virtual WKSPublishJob *wksPublishJob() const = 0;
     155             : };
     156             : 
     157             : /** Obtain a reference to the OpenPGP Protocol.
     158             :  *
     159             :  * The reference is to a static object.
     160             :  * @returns Refrence to the OpenPGP Protocol.
     161             :  */
     162             : QGPGME_EXPORT Protocol *openpgp();
     163             : 
     164             : /** Obtain a reference to the smime Protocol.
     165             :  *
     166             :  * The reference is to a static object.
     167             :  * @returns Refrence to the smime Protocol.
     168             :  */
     169             : QGPGME_EXPORT Protocol *smime();
     170             : 
     171             : /** Obtain a reference to a cryptoConfig object.
     172             :  *
     173             :  * The reference is to a static object.
     174             :  * @returns reference to cryptoConfig object.
     175             :  */
     176             : QGPGME_EXPORT CryptoConfig *cryptoConfig();
     177             : 
     178             : }
     179             : #endif

Generated by: LCOV version 1.11