Line data Source code
1 : /*
2 : tofuinfo.h - wraps gpgme tofu info
3 : Copyright (C) 2016 Intevation GmbH
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_TOFUINFO_H__
24 : #define __GPGMEPP_TOFUINFO_H__
25 :
26 : #include "gpgmepp_export.h"
27 :
28 : #include "gpgme.h"
29 :
30 : #include "global.h"
31 :
32 : #include <memory>
33 :
34 : namespace GpgME
35 : {
36 :
37 21 : class GPGMEPP_EXPORT TofuInfo
38 : {
39 : public:
40 : TofuInfo();
41 : explicit TofuInfo(gpgme_tofu_info_t info);
42 :
43 2 : const TofuInfo &operator=(TofuInfo other)
44 : {
45 2 : swap(other);
46 2 : return *this;
47 : }
48 :
49 2 : void swap(TofuInfo &other)
50 : {
51 : using std::swap;
52 2 : swap(this->d, other.d);
53 2 : }
54 :
55 : bool isNull() const;
56 :
57 : /* @enum Validity
58 : * @brief The TOFU Validity. */
59 : enum Validity {
60 : /*! Unknown (uninitialized).*/
61 : ValidityUnknown,
62 : /*! TOFU Conflict.*/
63 : Conflict,
64 : /*! Key without history.*/
65 : NoHistory,
66 : /*! Key with too little history.*/
67 : LittleHistory,
68 : /*! Key with enough history for basic trust.*/
69 : BasicHistory,
70 : /*! Key with a lot of history.*/
71 : LargeHistory,
72 : };
73 : Validity validity() const;
74 :
75 : /* @enum Policy
76 : * @brief The TOFU Validity. */
77 : enum Policy {
78 : /*! GPGME_TOFU_POLICY_NONE */
79 : PolicyNone,
80 : /*! GPGME_TOFU_POLICY_AUTO */
81 : PolicyAuto,
82 : /*! GPGME_TOFU_POLICY_GOOD */
83 : PolicyGood,
84 : /*! GPGME_TOFU_POLICY_UNKNOWN */
85 : PolicyUnknown,
86 : /*! GPGME_TOFU_POLICY_BAD */
87 : PolicyBad,
88 : /*! GPGME_TOFU_POLICY_ASK */
89 : PolicyAsk,
90 : };
91 : Policy policy() const;
92 :
93 : /* Number of signatures seen for this binding. Capped at USHRT_MAX. */
94 : unsigned short signCount() const;
95 :
96 : /* Number of encryption done to this binding. Capped at USHRT_MAX. */
97 : unsigned short encrCount() const;
98 :
99 : /** Number of seconds since epoch when the first message was verified */
100 : unsigned long signFirst() const;
101 :
102 : /** Number of seconds since epoch when the last message was verified */
103 : unsigned long signLast() const;
104 :
105 : /** Number of seconds since epoch when the first message was encrypted */
106 : unsigned long encrFirst() const;
107 :
108 : /** Number of seconds since epoch when the last message was encrypted */
109 : unsigned long encrLast() const;
110 :
111 : /* If non-NULL a human readable string summarizing the TOFU data. */
112 : const char *description() const;
113 :
114 : private:
115 : class Private;
116 : std::shared_ptr<Private> d;
117 : };
118 :
119 : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const TofuInfo &info);
120 :
121 : } // namespace GpgME
122 :
123 : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(TofuInfo)
124 : #endif // __GPGMEPP_TOFUINFO_H__
|