Line data Source code
1 : /*
2 : engineinfo.h
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 : #ifdef HAVE_CONFIG_H
24 : #include "config.h"
25 : #endif
26 :
27 : #include "engineinfo.h"
28 :
29 : #include <gpgme.h>
30 :
31 : class GpgME::EngineInfo::Private
32 : {
33 : public:
34 0 : Private(gpgme_engine_info_t engine = 0) : info(engine) {}
35 0 : ~Private()
36 0 : {
37 0 : info = 0;
38 0 : }
39 :
40 : gpgme_engine_info_t info;
41 : };
42 :
43 0 : GpgME::EngineInfo::EngineInfo() : d() {}
44 :
45 0 : GpgME::EngineInfo::EngineInfo(gpgme_engine_info_t engine)
46 0 : : d(new Private(engine))
47 : {
48 :
49 0 : }
50 :
51 0 : bool GpgME::EngineInfo::isNull() const
52 : {
53 0 : return !d || !d->info;
54 : }
55 :
56 0 : GpgME::Protocol GpgME::EngineInfo::protocol() const
57 : {
58 0 : if (isNull()) {
59 0 : return UnknownProtocol;
60 : }
61 0 : switch (d->info->protocol) {
62 0 : case GPGME_PROTOCOL_OpenPGP: return OpenPGP;
63 0 : case GPGME_PROTOCOL_CMS: return CMS;
64 : default:
65 0 : return UnknownProtocol;
66 : }
67 : }
68 :
69 0 : const char *GpgME::EngineInfo::fileName() const
70 : {
71 0 : return isNull() ? 0 : d->info->file_name;
72 : }
73 :
74 0 : const char *GpgME::EngineInfo::version() const
75 : {
76 0 : return isNull() ? 0 : d->info->version;
77 : }
78 :
79 0 : GpgME::EngineInfo::Version GpgME::EngineInfo::engineVersion() const
80 : {
81 0 : return Version(version());
82 : }
83 :
84 0 : const char *GpgME::EngineInfo::requiredVersion() const
85 : {
86 0 : return isNull() ? 0 : d->info->req_version;
87 : }
88 :
89 0 : const char *GpgME::EngineInfo::homeDirectory() const
90 : {
91 0 : return isNull() ? 0 : d->info->home_dir;
92 0 : }
|