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