Line data Source code
1 : /*
2 : engineinfo.h
3 : Copyright (C) 2004 Klarälvdalens Datakonsult AB
4 : 2016 Bundesamt für Sicherheit in der Informationstechnik
5 : Software engineering by Intevation GmbH
6 :
7 : This file is part of GPGME++.
8 :
9 : GPGME++ is free software; you can redistribute it and/or
10 : modify it under the terms of the GNU Library General Public
11 : License as published by the Free Software Foundation; either
12 : version 2 of the License, or (at your option) any later version.
13 :
14 : GPGME++ is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU Library General Public License for more details.
18 :
19 : You should have received a copy of the GNU Library General Public License
20 : along with GPGME++; see the file COPYING.LIB. If not, write to the
21 : Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 : Boston, MA 02110-1301, USA.
23 : */
24 :
25 : #ifdef HAVE_CONFIG_H
26 : #include "config.h"
27 : #endif
28 :
29 : #include "engineinfo.h"
30 :
31 : #include <gpgme.h>
32 :
33 : class GpgME::EngineInfo::Private
34 : {
35 : public:
36 9 : Private(gpgme_engine_info_t engine = 0) : info(engine) {}
37 9 : ~Private()
38 9 : {
39 9 : info = 0;
40 9 : }
41 :
42 : gpgme_engine_info_t info;
43 : };
44 :
45 0 : GpgME::EngineInfo::EngineInfo() : d() {}
46 :
47 9 : GpgME::EngineInfo::EngineInfo(gpgme_engine_info_t engine)
48 9 : : d(new Private(engine))
49 : {
50 :
51 9 : }
52 :
53 9 : bool GpgME::EngineInfo::isNull() const
54 : {
55 9 : return !d || !d->info;
56 : }
57 :
58 0 : GpgME::Protocol GpgME::EngineInfo::protocol() const
59 : {
60 0 : if (isNull()) {
61 0 : return UnknownProtocol;
62 : }
63 0 : switch (d->info->protocol) {
64 0 : case GPGME_PROTOCOL_OpenPGP: return OpenPGP;
65 0 : case GPGME_PROTOCOL_CMS: return CMS;
66 : default:
67 0 : return UnknownProtocol;
68 : }
69 : }
70 :
71 0 : const char *GpgME::EngineInfo::fileName() const
72 : {
73 0 : return isNull() ? 0 : d->info->file_name;
74 : }
75 :
76 9 : const char *GpgME::EngineInfo::version() const
77 : {
78 9 : return isNull() ? 0 : d->info->version;
79 : }
80 :
81 9 : GpgME::EngineInfo::Version GpgME::EngineInfo::engineVersion() const
82 : {
83 9 : return Version(version());
84 : }
85 :
86 0 : const char *GpgME::EngineInfo::requiredVersion() const
87 : {
88 0 : return isNull() ? 0 : d->info->req_version;
89 : }
90 :
91 0 : const char *GpgME::EngineInfo::homeDirectory() const
92 : {
93 0 : return isNull() ? 0 : d->info->home_dir;
94 24 : }
|