certmanager/lib

kpgpbackendbase.cpp
1 /*
2  kpgpbackendbase.cpp
3 
4  This file is part of libkleopatra, the KDE keymanagement library
5  Copyright (c) 2004 Klarälvdalens Datakonsult AB
6 
7  Libkleopatra is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of the
10  License, or (at your option) any later version.
11 
12  Libkleopatra 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 GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the TQt library by Trolltech AS, Norway (or with modified versions
24  of TQt that use the same license as TQt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  TQt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #ifdef HAVE_CONFIG_H
34 #include <config.h>
35 #endif
36 
37 #include "kpgpbackendbase.h"
38 
39 #include "pgp2backend.h"
40 #include "pgp5backend.h"
41 #include "pgp6backend.h"
42 #include "gpg1backend.h"
43 
44 #include <tdelocale.h>
45 
46 #include <tqstring.h>
47 
48 #include "kpgpwrapper.h"
49 
50 Kleo::KpgpBackendBase::KpgpBackendBase()
51  : Kleo::CryptoBackend(),
52  mOpenPGPProtocol( 0 )
53 {
54 }
55 
56 Kleo::KpgpBackendBase::~KpgpBackendBase()
57 {
58  delete mOpenPGPProtocol; mOpenPGPProtocol = 0;
59 }
60 
61 TQString Kleo::GPG1Backend::name() const {
62  return GPG1_BACKEND_NAME;
63 }
64 
65 TQString Kleo::GPG1Backend::displayName() const {
66  return i18n("Kpgp/gpg");
67 }
68 
69 TQString Kleo::PGP2Backend::name() const {
70  return PGP2_BACKEND_NAME;
71 }
72 
73 TQString Kleo::PGP2Backend::displayName() const {
74  return i18n("Kpgp/pgp v2");
75 }
76 
77 TQString Kleo::PGP5Backend::name() const {
78  return PGP5_BACKEND_NAME;
79 }
80 
81 TQString Kleo::PGP5Backend::displayName() const {
82  return i18n("Kpgp/pgp v5");
83 }
84 
85 TQString Kleo::PGP6Backend::name() const {
86  return PGP6_BACKEND_NAME;
87 }
88 
89 TQString Kleo::PGP6Backend::displayName() const {
90  return i18n("Kpgp/pgp v6");
91 }
92 
93 static const TQString notSupported() {
94  return i18n("This backend does not support S/MIME");
95 }
96 
97 bool Kleo::KpgpBackendBase::checkForOpenPGP( TQString * /*reason*/ ) const {
98  return true;
99 }
100 
101 bool Kleo::KpgpBackendBase::checkForSMIME( TQString * reason ) const {
102  if ( reason ) *reason = notSupported();
103  return false;
104 }
105 
106 Kleo::CryptoBackend::Protocol * Kleo::KpgpBackendBase::openpgp() const {
107  if ( !mOpenPGPProtocol )
108  if ( checkForOpenPGP() )
109  mOpenPGPProtocol = new KpgpWrapper( name() );
110  return mOpenPGPProtocol;
111 }