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