Line data Source code
1 : /*
2 : importresult.h - wraps a gpgme import 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_IMPORTRESULT_H__
24 : #define __GPGMEPP_IMPORTRESULT_H__
25 :
26 : #include "gpgmefw.h"
27 : #include "result.h"
28 : #include "gpgmepp_export.h"
29 :
30 : #include <memory>
31 :
32 : #include <vector>
33 :
34 : namespace GpgME
35 : {
36 :
37 : class Error;
38 : class Import;
39 :
40 0 : class GPGMEPP_EXPORT ImportResult : public Result
41 : {
42 : public:
43 : ImportResult();
44 : ImportResult(gpgme_ctx_t ctx, int error);
45 : ImportResult(gpgme_ctx_t ctx, const Error &error);
46 : explicit ImportResult(const Error &error);
47 :
48 0 : const ImportResult &operator=(ImportResult other)
49 : {
50 0 : swap(other);
51 0 : return *this;
52 : }
53 :
54 0 : void swap(ImportResult &other)
55 : {
56 0 : Result::swap(other);
57 : using std::swap;
58 0 : swap(this->d, other.d);
59 0 : }
60 :
61 : bool isNull() const;
62 :
63 : int numConsidered() const;
64 : int numKeysWithoutUserID() const;
65 : int numImported() const;
66 : int numRSAImported() const;
67 : int numUnchanged() const;
68 :
69 : int newUserIDs() const;
70 : int newSubkeys() const;
71 : int newSignatures() const;
72 : int newRevocations() const;
73 :
74 : int numSecretKeysConsidered() const;
75 : int numSecretKeysImported() const;
76 : int numSecretKeysUnchanged() const;
77 :
78 : int notImported() const;
79 :
80 : Import import(unsigned int idx) const;
81 : std::vector<Import> imports() const;
82 :
83 : class Private;
84 : private:
85 : void init(gpgme_ctx_t ctx);
86 : std::shared_ptr<Private> d;
87 : };
88 :
89 0 : class GPGMEPP_EXPORT Import
90 : {
91 : friend class ::GpgME::ImportResult;
92 : Import(const std::shared_ptr<ImportResult::Private> &parent, unsigned int idx);
93 : public:
94 : Import();
95 :
96 : const Import &operator=(Import other)
97 : {
98 : swap(other);
99 : return *this;
100 : }
101 :
102 : void swap(Import &other)
103 : {
104 : using std::swap;
105 : swap(this->d, other.d);
106 : swap(this->idx, other.idx);
107 : }
108 :
109 : bool isNull() const;
110 :
111 : const char *fingerprint() const;
112 : Error error() const;
113 :
114 : enum Status {
115 : Unknown = 0x0,
116 : NewKey = 0x1,
117 : NewUserIDs = 0x2,
118 : NewSignatures = 0x4,
119 : NewSubkeys = 0x8,
120 : ContainedSecretKey = 0x10
121 : };
122 : Status status() const;
123 :
124 : private:
125 : std::shared_ptr<ImportResult::Private> d;
126 : unsigned int idx;
127 : };
128 :
129 : }
130 :
131 : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(ImportResult)
132 : GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Import)
133 :
134 : #endif // __GPGMEPP_IMPORTRESULT_H__
|