LCOV - code coverage report
Current view: top level - lang/cpp/src - tofuinfo.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 7 100.0 %
Date: 2018-11-15 08:49:49 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*
       2             :   tofuinfo.h - wraps gpgme tofu info
       3             :   Copyright (C) 2016 by Bundesamt für Sicherheit in der Informationstechnik
       4             :   Software engineering by Intevation GmbH
       5             : 
       6             :   This file is part of GPGME++.
       7             : 
       8             :   GPGME++ is free software; you can redistribute it and/or
       9             :   modify it under the terms of the GNU Library General Public
      10             :   License as published by the Free Software Foundation; either
      11             :   version 2 of the License, or (at your option) any later version.
      12             : 
      13             :   GPGME++ 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
      16             :   GNU Library General Public License for more details.
      17             : 
      18             :   You should have received a copy of the GNU Library General Public License
      19             :   along with GPGME++; see the file COPYING.LIB.  If not, write to the
      20             :   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      21             :   Boston, MA 02110-1301, USA.
      22             : */
      23             : 
      24             : #ifndef __GPGMEPP_TOFUINFO_H__
      25             : #define __GPGMEPP_TOFUINFO_H__
      26             : 
      27             : #include "gpgmepp_export.h"
      28             : 
      29             : #include "global.h"
      30             : 
      31             : #include <memory>
      32             : 
      33             : namespace GpgME
      34             : {
      35             : 
      36          26 : class GPGMEPP_EXPORT TofuInfo
      37             : {
      38             : public:
      39             :     TofuInfo();
      40             :     explicit TofuInfo(gpgme_tofu_info_t info);
      41             : 
      42           3 :     const TofuInfo &operator=(TofuInfo other)
      43             :     {
      44           3 :         swap(other);
      45           3 :         return *this;
      46             :     }
      47             : 
      48           3 :     void swap(TofuInfo &other)
      49             :     {
      50             :         using std::swap;
      51           3 :         swap(this->d, other.d);
      52           3 :     }
      53             : 
      54             :     bool isNull() const;
      55             : 
      56             :     /* @enum Validity
      57             :      * @brief The TOFU Validity. */
      58             :     enum Validity : unsigned int {
      59             :         /*! Unknown (uninitialized).*/
      60             :         ValidityUnknown,
      61             :         /*! TOFU Conflict.*/
      62             :         Conflict,
      63             :         /*! Key without history.*/
      64             :         NoHistory,
      65             :         /*! Key with too little history.*/
      66             :         LittleHistory,
      67             :         /*! Key with enough history for basic trust.*/
      68             :         BasicHistory,
      69             :         /*! Key with a lot of history.*/
      70             :         LargeHistory,
      71             :     };
      72             :     Validity validity() const;
      73             : 
      74             :     /* @enum Policy
      75             :      * @brief The TOFU Validity. */
      76             :     enum Policy : unsigned int {
      77             :         /*! GPGME_TOFU_POLICY_NONE */
      78             :         PolicyNone,
      79             :         /*! GPGME_TOFU_POLICY_AUTO */
      80             :         PolicyAuto,
      81             :         /*! GPGME_TOFU_POLICY_GOOD */
      82             :         PolicyGood,
      83             :         /*! GPGME_TOFU_POLICY_UNKNOWN */
      84             :         PolicyUnknown,
      85             :         /*! GPGME_TOFU_POLICY_BAD */
      86             :         PolicyBad,
      87             :         /*! GPGME_TOFU_POLICY_ASK */
      88             :         PolicyAsk,
      89             :     };
      90             :     Policy policy() const;
      91             : 
      92             :     /* Number of signatures seen for this binding.  Capped at USHRT_MAX.  */
      93             :     unsigned short signCount() const;
      94             : 
      95             :     /* Number of encryption done to this binding.  Capped at USHRT_MAX.  */
      96             :     unsigned short encrCount() const;
      97             : 
      98             :     /** Number of seconds since epoch when the first message was verified */
      99             :     unsigned long signFirst() const;
     100             : 
     101             :     /** Number of seconds since epoch when the last message was verified */
     102             :     unsigned long signLast() const;
     103             : 
     104             :     /** Number of seconds since epoch when the first message was encrypted */
     105             :     unsigned long encrFirst() const;
     106             : 
     107             :     /** Number of seconds since epoch when the last message was encrypted */
     108             :     unsigned long encrLast() const;
     109             : 
     110             :     /* If non-NULL a human readable string summarizing the TOFU data. */
     111             :     const char *description() const;
     112             : 
     113             : private:
     114             :     class Private;
     115             :     std::shared_ptr<Private> d;
     116             : };
     117             : 
     118             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const TofuInfo &info);
     119             : 
     120             : } // namespace GpgME
     121             : 
     122             : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(TofuInfo)
     123             : #endif // __GPGMEPP_TOFUINFO_H__

Generated by: LCOV version 1.13