1 | /* |
2 | decryptionresult.h - wraps a gpgme keygen 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_DECRYPTIONRESULT_H__ |
24 | #define __GPGMEPP_DECRYPTIONRESULT_H__ |
25 | |
26 | #include <gpgme++/gpgmefw.h> |
27 | #include <gpgme++/result.h> |
28 | #include <gpgme++/gpgme++_export.h> |
29 | |
30 | #include <boost/shared_ptr.hpp> |
31 | |
32 | #include <vector> |
33 | #include <algorithm> |
34 | #include <iosfwd> |
35 | |
36 | namespace GpgME { |
37 | |
38 | class Error; |
39 | |
40 | class GPGMEPP_EXPORT DecryptionResult : public Result { |
41 | public: |
42 | DecryptionResult(); |
43 | DecryptionResult( gpgme_ctx_t ctx, int error ); |
44 | DecryptionResult( gpgme_ctx_t ctx, const Error & err ); |
45 | explicit DecryptionResult( const Error & err ); |
46 | |
47 | const DecryptionResult & operator=( DecryptionResult other ) { |
48 | swap( other ); |
49 | return *this; |
50 | } |
51 | |
52 | void swap( DecryptionResult & other ) { |
53 | Result::swap( other ); |
54 | using std::swap; |
55 | swap( this->d, other.d ); |
56 | } |
57 | |
58 | bool isNull() const; |
59 | |
60 | GPGMEPP_DEPRECATED const char * unsupportedAlgortihm() const { |
61 | return unsupportedAlgorithm(); |
62 | } |
63 | const char * unsupportedAlgorithm() const; |
64 | |
65 | GPGMEPP_DEPRECATED bool wrongKeyUsage() const { |
66 | return isWrongKeyUsage(); |
67 | } |
68 | bool isWrongKeyUsage() const; |
69 | |
70 | const char * fileName() const; |
71 | |
72 | class Recipient; |
73 | |
74 | unsigned int numRecipients() const; |
75 | Recipient recipient( unsigned int idx ) const; |
76 | std::vector<Recipient> recipients() const; |
77 | |
78 | private: |
79 | class Private; |
80 | void init( gpgme_ctx_t ctx ); |
81 | boost::shared_ptr<Private> d; |
82 | }; |
83 | |
84 | GPGMEPP_EXPORT std::ostream & operator<<( std::ostream & os, const DecryptionResult & result ); |
85 | |
86 | class GPGMEPP_EXPORT DecryptionResult::Recipient { |
87 | public: |
88 | Recipient(); |
89 | explicit Recipient( gpgme_recipient_t reci ); |
90 | |
91 | const Recipient & operator=( Recipient other ) { |
92 | swap( other ); |
93 | return *this; |
94 | } |
95 | |
96 | void swap( Recipient & other ) { |
97 | using std::swap; |
98 | swap( this->d, other.d ); |
99 | } |
100 | |
101 | bool isNull() const; |
102 | |
103 | const char * keyID() const; |
104 | const char * shortKeyID() const; |
105 | |
106 | unsigned int publicKeyAlgorithm() const; |
107 | const char * publicKeyAlgorithmAsString() const; |
108 | |
109 | Error status() const; |
110 | |
111 | private: |
112 | class Private; |
113 | boost::shared_ptr<Private> d; |
114 | }; |
115 | |
116 | GPGMEPP_EXPORT std::ostream & operator<<( std::ostream & os, const DecryptionResult::Recipient & reci ); |
117 | |
118 | } |
119 | |
120 | GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION( DecryptionResult ) |
121 | |
122 | #endif // __GPGMEPP_DECRYPTIONRESULT_H__ |
123 | |