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