LCOV - code coverage report
Current view: top level - lang/cpp/src - verificationresult.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 16 16 100.0 %
Date: 2016-12-01 18:45:36 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /*
       2             :   verificationresult.h - wraps a gpgme verify result
       3             :   Copyright (C) 2004 Klarälvdalens Datakonsult AB
       4             : 
       5             :   This file is part of GPGME++.
       6             : 
       7             :   GPGME++ is free software; you can redistribute it and/or
       8             :   modify it under the terms of the GNU Library General Public
       9             :   License as published by the Free Software Foundation; either
      10             :   version 2 of the License, or (at your option) any later version.
      11             : 
      12             :   GPGME++ is distributed in the hope that it will be useful,
      13             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :   GNU Library General Public License for more details.
      16             : 
      17             :   You should have received a copy of the GNU Library General Public License
      18             :   along with GPGME++; see the file COPYING.LIB.  If not, write to the
      19             :   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      20             :   Boston, MA 02110-1301, USA.
      21             : */
      22             : 
      23             : #ifndef __GPGMEPP_VERIFICATIONRESULT_H__
      24             : #define __GPGMEPP_VERIFICATIONRESULT_H__
      25             : 
      26             : #include "gpgmefw.h"
      27             : #include "result.h"
      28             : #include "gpgmepp_export.h"
      29             : 
      30             : #include <time.h>
      31             : 
      32             : #include <memory>
      33             : 
      34             : #include <vector>
      35             : #include <iosfwd>
      36             : 
      37             : namespace GpgME
      38             : {
      39             : 
      40             : class Error;
      41             : class Signature;
      42             : class Notation;
      43             : class Key;
      44             : 
      45          90 : class GPGMEPP_EXPORT VerificationResult : public Result
      46             : {
      47             : public:
      48             :     VerificationResult();
      49             :     VerificationResult(gpgme_ctx_t ctx, int error);
      50             :     VerificationResult(gpgme_ctx_t ctx, const Error &error);
      51             :     explicit VerificationResult(const Error &err);
      52             : 
      53          12 :     const VerificationResult &operator=(VerificationResult other)
      54             :     {
      55          12 :         swap(other);
      56          12 :         return *this;
      57             :     }
      58             : 
      59          12 :     void swap(VerificationResult &other)
      60             :     {
      61          12 :         Result::swap(other);
      62             :         using std::swap;
      63          12 :         swap(this->d, other.d);
      64          12 :     }
      65             : 
      66             :     bool isNull() const;
      67             : 
      68             :     const char *fileName() const;
      69             : 
      70             :     unsigned int numSignatures() const;
      71             :     Signature signature(unsigned int index) const;
      72             :     std::vector<Signature> signatures() const;
      73             : 
      74             :     class Private;
      75             : private:
      76             :     void init(gpgme_ctx_t ctx);
      77             :     std::shared_ptr<Private> d;
      78             : };
      79             : 
      80             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const VerificationResult &result);
      81             : 
      82          50 : class GPGMEPP_EXPORT Signature
      83             : {
      84             :     friend class ::GpgME::VerificationResult;
      85             :     Signature(const std::shared_ptr<VerificationResult::Private> &parent, unsigned int index);
      86             : public:
      87             :     typedef GPGMEPP_DEPRECATED GpgME::Notation Notation;
      88             : 
      89             :     Signature();
      90             : 
      91           2 :     const Signature &operator=(Signature other)
      92             :     {
      93           2 :         swap(other);
      94           2 :         return *this;
      95             :     }
      96             : 
      97           2 :     void swap(Signature &other)
      98             :     {
      99             :         using std::swap;
     100           2 :         swap(this->d, other.d);
     101           2 :         swap(this->idx, other.idx);
     102           2 :     }
     103             : 
     104             :     bool isNull() const;
     105             : 
     106             :     enum Summary {
     107             :         None       = 0x000,
     108             :         Valid      = 0x001,
     109             :         Green      = 0x002,
     110             :         Red        = 0x004,
     111             :         KeyRevoked = 0x008,
     112             :         KeyExpired = 0x010,
     113             :         SigExpired = 0x020,
     114             :         KeyMissing = 0x040,
     115             :         CrlMissing = 0x080,
     116             :         CrlTooOld  = 0x100,
     117             :         BadPolicy  = 0x200,
     118             :         SysError   = 0x400,
     119             :         TofuConflict= 0x800
     120             :     };
     121             :     Summary summary() const;
     122             : 
     123             :     const char *fingerprint() const;
     124             : 
     125             :     Error status() const;
     126             : 
     127             :     time_t creationTime() const;
     128             :     time_t expirationTime() const;
     129             :     bool neverExpires() const;
     130             : 
     131             :     GPGMEPP_DEPRECATED bool wrongKeyUsage() const
     132             :     {
     133             :         return isWrongKeyUsage();
     134             :     }
     135             :     bool isWrongKeyUsage() const;
     136             :     bool isVerifiedUsingChainModel() const;
     137             : 
     138             :     enum PKAStatus {
     139             :         UnknownPKAStatus, PKAVerificationFailed, PKAVerificationSucceeded
     140             :     };
     141             :     PKAStatus pkaStatus() const;
     142             :     const char *pkaAddress() const;
     143             : 
     144             :     enum Validity {
     145             :         Unknown, Undefined, Never, Marginal, Full, Ultimate
     146             :     };
     147             :     Validity validity() const;
     148             :     char validityAsString() const;
     149             :     Error nonValidityReason() const;
     150             : 
     151             :     unsigned int publicKeyAlgorithm() const;
     152             :     const char *publicKeyAlgorithmAsString() const;
     153             : 
     154             :     unsigned int hashAlgorithm() const;
     155             :     const char *hashAlgorithmAsString() const;
     156             : 
     157             :     const char *policyURL() const;
     158             :     GpgME::Notation notation(unsigned int index) const;
     159             :     std::vector<GpgME::Notation> notations() const;
     160             : 
     161             :     /** Returns the key object associated with this signature.
     162             :      * May be incomplete but will have at least the fingerprint
     163             :      * set or the associated TOFU Information if applicable. */
     164             :     GpgME::Key key() const;
     165             : 
     166             :     /* Search / Update the key of this signature.
     167             :      *
     168             :      * Same as above but if search is set to true this will
     169             :      * either update the key provided by the engine or search
     170             :      * the key in the engine. The key is cached.
     171             :      *
     172             :      * As this involves an engine call it might take some time
     173             :      * to finish so it should be avoided to do this in a UI
     174             :      * thread. The result will be cached and no engine call
     175             :      * will be done if update is set to false and a key is
     176             :      * already cached.
     177             :      *
     178             :      * If no key was provided by the engine this will look
     179             :      * up the key so this call might block while the engine
     180             :      * is called to obtain the key.
     181             :      *
     182             :      * If both search and update are false this is the same
     183             :      * as calling key()
     184             :      */
     185             :     GpgME::Key key(bool search, bool update) const;
     186             : 
     187             : private:
     188             :     std::shared_ptr<VerificationResult::Private> d;
     189             :     unsigned int idx;
     190             : };
     191             : 
     192             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Signature &sig);
     193             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Signature::PKAStatus pkaStatus);
     194             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Signature::Summary summary);
     195             : 
     196             : }
     197             : 
     198             : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(VerificationResult)
     199             : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Signature)
     200             : 
     201             : #endif // __GPGMEPP_VERIFICATIONRESULT_H__

Generated by: LCOV version 1.11