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