1 | /* |
2 | encryptionresult.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_ENCRYPTIONRESULT_H__ |
24 | #define __GPGMEPP_ENCRYPTIONRESULT_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 <iosfwd> |
34 | |
35 | namespace GpgME { |
36 | |
37 | class Error; |
38 | class InvalidRecipient; |
39 | |
40 | class GPGMEPP_EXPORT EncryptionResult : public Result { |
41 | public: |
42 | EncryptionResult(); |
43 | EncryptionResult( gpgme_ctx_t ctx, int error ); |
44 | EncryptionResult( gpgme_ctx_t ctx, const Error & error ); |
45 | EncryptionResult( const Error & err ); |
46 | |
47 | const EncryptionResult & operator=( EncryptionResult other ) { |
48 | swap( other ); |
49 | return *this; |
50 | } |
51 | |
52 | void swap( EncryptionResult & other ) { |
53 | Result::swap( other ); |
54 | using std::swap; |
55 | swap( this->d, other.d ); |
56 | } |
57 | |
58 | bool isNull() const; |
59 | |
60 | unsigned int numInvalidRecipients() const; |
61 | |
62 | InvalidRecipient invalidEncryptionKey( unsigned int index ) const; |
63 | std::vector<InvalidRecipient> invalidEncryptionKeys() const; |
64 | |
65 | class Private; |
66 | private: |
67 | void init( gpgme_ctx_t ctx ); |
68 | boost::shared_ptr<Private> d; |
69 | }; |
70 | |
71 | GPGMEPP_EXPORT std::ostream & operator<<( std::ostream & os, const EncryptionResult & result ); |
72 | |
73 | class GPGMEPP_EXPORT InvalidRecipient { |
74 | friend class ::GpgME::EncryptionResult; |
75 | InvalidRecipient( const boost::shared_ptr<EncryptionResult::Private> & parent, unsigned int index ); |
76 | public: |
77 | InvalidRecipient(); |
78 | |
79 | const InvalidRecipient & operator=( InvalidRecipient other ) { |
80 | swap( other ); |
81 | return *this; |
82 | } |
83 | |
84 | void swap( InvalidRecipient & other ) { |
85 | using std::swap; |
86 | swap( this->d, other.d ); |
87 | } |
88 | |
89 | bool isNull() const; |
90 | |
91 | const char * fingerprint() const; |
92 | Error reason() const; |
93 | |
94 | private: |
95 | boost::shared_ptr<EncryptionResult::Private> d; |
96 | unsigned int idx; |
97 | }; |
98 | |
99 | GPGMEPP_EXPORT std::ostream & operator<<( std::ostream & os, const InvalidRecipient & recipient ); |
100 | |
101 | } |
102 | |
103 | GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION( EncryptionResult ) |
104 | GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION( InvalidRecipient ) |
105 | |
106 | #endif // __GPGMEPP_ENCRYPTIONRESULT_H__ |
107 | |