Line data Source code
1 : /*
2 : signingresult.h - wraps a gpgme sign 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_SIGNINGRESULT_H__
24 : #define __GPGMEPP_SIGNINGRESULT_H__
25 :
26 : #include "global.h"
27 : #include "result.h"
28 :
29 : #include <time.h>
30 :
31 : #include <memory>
32 :
33 : #include <vector>
34 : #include <iosfwd>
35 :
36 : namespace GpgME
37 : {
38 :
39 : class Error;
40 : class CreatedSignature;
41 : class InvalidSigningKey;
42 :
43 54 : class GPGMEPP_EXPORT SigningResult : public Result
44 : {
45 : public:
46 : SigningResult();
47 : SigningResult(gpgme_ctx_t ctx, int error);
48 : SigningResult(gpgme_ctx_t ctx, const Error &error);
49 : explicit SigningResult(const Error &err);
50 :
51 6 : const SigningResult &operator=(SigningResult other)
52 : {
53 6 : swap(other);
54 6 : return *this;
55 : }
56 :
57 6 : void swap(SigningResult &other)
58 : {
59 6 : Result::swap(other);
60 : using std::swap;
61 6 : swap(this->d, other.d);
62 6 : }
63 :
64 : bool isNull() const;
65 :
66 : CreatedSignature createdSignature(unsigned int index) const;
67 : std::vector<CreatedSignature> createdSignatures() const;
68 :
69 : InvalidSigningKey invalidSigningKey(unsigned int index) const;
70 : std::vector<InvalidSigningKey> invalidSigningKeys() const;
71 :
72 : class Private;
73 : private:
74 : void init(gpgme_ctx_t ctx);
75 : std::shared_ptr<Private> d;
76 : };
77 :
78 : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const SigningResult &result);
79 :
80 0 : class GPGMEPP_EXPORT InvalidSigningKey
81 : {
82 : friend class ::GpgME::SigningResult;
83 : InvalidSigningKey(const std::shared_ptr<SigningResult::Private> &parent, unsigned int index);
84 : public:
85 : InvalidSigningKey();
86 :
87 : const InvalidSigningKey &operator=(InvalidSigningKey other)
88 : {
89 : swap(other);
90 : return *this;
91 : }
92 :
93 : void swap(InvalidSigningKey &other)
94 : {
95 : using std::swap;
96 : swap(this->d, other.d);
97 : swap(this->idx, other.idx);
98 : }
99 :
100 : bool isNull() const;
101 :
102 : const char *fingerprint() const;
103 : Error reason() const;
104 :
105 : private:
106 : std::shared_ptr<SigningResult::Private> d;
107 : unsigned int idx;
108 : };
109 :
110 : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const InvalidSigningKey &key);
111 :
112 0 : class GPGMEPP_EXPORT CreatedSignature
113 : {
114 : friend class ::GpgME::SigningResult;
115 : CreatedSignature(const std::shared_ptr<SigningResult::Private> &parent, unsigned int index);
116 : public:
117 :
118 : CreatedSignature();
119 :
120 : const CreatedSignature &operator=(CreatedSignature other)
121 : {
122 : swap(other);
123 : return *this;
124 : }
125 :
126 : void swap(CreatedSignature &other)
127 : {
128 : using std::swap;
129 : swap(this->d, other.d);
130 : swap(this->idx, other.idx);
131 : }
132 :
133 : bool isNull() const;
134 :
135 : const char *fingerprint() const;
136 :
137 : time_t creationTime() const;
138 :
139 : SignatureMode mode() const;
140 :
141 : unsigned int publicKeyAlgorithm() const;
142 : const char *publicKeyAlgorithmAsString() const;
143 :
144 : unsigned int hashAlgorithm() const;
145 : const char *hashAlgorithmAsString() const;
146 :
147 : unsigned int signatureClass() const;
148 :
149 : private:
150 : std::shared_ptr<SigningResult::Private> d;
151 : unsigned int idx;
152 : };
153 :
154 : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const CreatedSignature &sig);
155 :
156 : }
157 :
158 : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(SigningResult)
159 : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(InvalidSigningKey)
160 : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(CreatedSignature)
161 :
162 : #endif // __GPGMEPP_SIGNINGRESULT_H__
|