summaryrefslogtreecommitdiffstats
path: root/certmanager/lib/backends/kpgp
diff options
context:
space:
mode:
Diffstat (limited to 'certmanager/lib/backends/kpgp')
-rw-r--r--certmanager/lib/backends/kpgp/Makefile.am12
-rw-r--r--certmanager/lib/backends/kpgp/gpg1backend.h52
-rw-r--r--certmanager/lib/backends/kpgp/kpgpbackendbase.cpp111
-rw-r--r--certmanager/lib/backends/kpgp/kpgpbackendbase.h73
-rw-r--r--certmanager/lib/backends/kpgp/kpgpkeylistjob.cpp303
-rw-r--r--certmanager/lib/backends/kpgp/kpgpkeylistjob.h79
-rw-r--r--certmanager/lib/backends/kpgp/kpgpwrapper.cpp173
-rw-r--r--certmanager/lib/backends/kpgp/kpgpwrapper.h97
-rw-r--r--certmanager/lib/backends/kpgp/pgp2backend.h52
-rw-r--r--certmanager/lib/backends/kpgp/pgp5backend.h52
-rw-r--r--certmanager/lib/backends/kpgp/pgp6backend.h52
11 files changed, 1056 insertions, 0 deletions
diff --git a/certmanager/lib/backends/kpgp/Makefile.am b/certmanager/lib/backends/kpgp/Makefile.am
new file mode 100644
index 000000000..ad350f22c
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES = -I$(top_srcdir)/libkdenetwork \
+ -I$(top_srcdir)/certmanager/lib \
+ -I$(top_srcdir)/libkpgp \
+ $(GPGME_CFLAGS) $(all_includes)
+
+noinst_LTLIBRARIES = libkleopatra_backend_kpgp.la
+
+libkleopatra_backend_kpgp_la_SOURCES = \
+ kpgpbackendbase.cpp kpgpwrapper.cpp \
+ kpgpkeylistjob.cpp
+
+METASOURCES = AUTO
diff --git a/certmanager/lib/backends/kpgp/gpg1backend.h b/certmanager/lib/backends/kpgp/gpg1backend.h
new file mode 100644
index 000000000..f9413accf
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/gpg1backend.h
@@ -0,0 +1,52 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+ gpg1backend.h
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Klarälvdalens Datakonsult AB
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+
+#ifndef __KLEO_GPG1BACKEND_H__
+#define __KLEO_GPG1BACKEND_H__
+
+#include "kpgpbackendbase.h"
+
+class QString;
+
+namespace Kleo {
+
+ class GPG1Backend : public KpgpBackendBase {
+ public:
+ QString name() const;
+ QString displayName() const;
+ };
+
+}
+
+
+#endif // __KLEO_GPG1BACKEND_H__
diff --git a/certmanager/lib/backends/kpgp/kpgpbackendbase.cpp b/certmanager/lib/backends/kpgp/kpgpbackendbase.cpp
new file mode 100644
index 000000000..2d4d17ab2
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/kpgpbackendbase.cpp
@@ -0,0 +1,111 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+ kpgpbackendbase.cpp
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Klarälvdalens Datakonsult AB
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "kpgpbackendbase.h"
+
+#include "pgp2backend.h"
+#include "pgp5backend.h"
+#include "pgp6backend.h"
+#include "gpg1backend.h"
+
+#include <klocale.h>
+
+#include <qstring.h>
+
+#include "kpgpwrapper.h"
+
+Kleo::KpgpBackendBase::KpgpBackendBase()
+ : Kleo::CryptoBackend(),
+ mOpenPGPProtocol( 0 )
+{
+}
+
+Kleo::KpgpBackendBase::~KpgpBackendBase()
+{
+ delete mOpenPGPProtocol; mOpenPGPProtocol = 0;
+}
+
+QString Kleo::GPG1Backend::name() const {
+ return GPG1_BACKEND_NAME;
+}
+
+QString Kleo::GPG1Backend::displayName() const {
+ return i18n("Kpgp/gpg");
+}
+
+QString Kleo::PGP2Backend::name() const {
+ return PGP2_BACKEND_NAME;
+}
+
+QString Kleo::PGP2Backend::displayName() const {
+ return i18n("Kpgp/pgp v2");
+}
+
+QString Kleo::PGP5Backend::name() const {
+ return PGP5_BACKEND_NAME;
+}
+
+QString Kleo::PGP5Backend::displayName() const {
+ return i18n("Kpgp/pgp v5");
+}
+
+QString Kleo::PGP6Backend::name() const {
+ return PGP6_BACKEND_NAME;
+}
+
+QString Kleo::PGP6Backend::displayName() const {
+ return i18n("Kpgp/pgp v6");
+}
+
+static const QString notSupported() {
+ return i18n("This backend does not support S/MIME");
+}
+
+bool Kleo::KpgpBackendBase::checkForOpenPGP( QString * /*reason*/ ) const {
+ return true;
+}
+
+bool Kleo::KpgpBackendBase::checkForSMIME( QString * reason ) const {
+ if ( reason ) *reason = notSupported();
+ return false;
+}
+
+Kleo::CryptoBackend::Protocol * Kleo::KpgpBackendBase::openpgp() const {
+ if ( !mOpenPGPProtocol )
+ if ( checkForOpenPGP() )
+ mOpenPGPProtocol = new KpgpWrapper( name() );
+ return mOpenPGPProtocol;
+}
diff --git a/certmanager/lib/backends/kpgp/kpgpbackendbase.h b/certmanager/lib/backends/kpgp/kpgpbackendbase.h
new file mode 100644
index 000000000..854e800c3
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/kpgpbackendbase.h
@@ -0,0 +1,73 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+ kpgpbackendbase.h
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Klarälvdalens Datakonsult AB
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+
+#ifndef __KLEO_KPGPBACKENDBASE_H__
+#define __KLEO_KPGPBACKENDBASE_H__
+
+#include "kleo/cryptobackend.h"
+
+#define GPG1_BACKEND_NAME "Kpgp/gpg1"
+#define PGP2_BACKEND_NAME "Kpgp/pgp2"
+#define PGP5_BACKEND_NAME "Kpgp/pgp5"
+#define PGP6_BACKEND_NAME "Kpgp/pgp6"
+
+namespace Kleo {
+ class CryptoConfig;
+}
+class QString;
+class KpgpWrapper;
+
+namespace Kleo {
+
+ class KpgpBackendBase : public Kleo::CryptoBackend {
+ public:
+ KpgpBackendBase();
+ ~KpgpBackendBase();
+
+ CryptoConfig * config() const { return 0; }
+ Protocol * openpgp() const;
+ Protocol * smime() const { return 0; }
+
+ bool supportsOpenPGP() const { return true; }
+ bool supportsSMIME() const { return false; }
+
+ bool checkForOpenPGP( QString * reason=0 ) const;
+ bool checkForSMIME( QString * reason=0 ) const;
+ private:
+ mutable KpgpWrapper * mOpenPGPProtocol;
+ };
+
+}
+
+
+#endif // __KLEO_KPGPBACKENDBASE_H__
diff --git a/certmanager/lib/backends/kpgp/kpgpkeylistjob.cpp b/certmanager/lib/backends/kpgp/kpgpkeylistjob.cpp
new file mode 100644
index 000000000..4c328adee
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/kpgpkeylistjob.cpp
@@ -0,0 +1,303 @@
+/*
+ kpgpkeylistjob.cpp
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Ingo Kloecker <kloecker@kde.org>
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "kpgpkeylistjob.h"
+
+#include <kpgpbase.h>
+#include <kpgpkey.h>
+
+#include <gpgmepp/key.h>
+#include <gpgmepp/keylistresult.h>
+
+#include <gpgme.h>
+
+#include <qtimer.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+Kleo::KpgpKeyListJob::KpgpKeyListJob( Kpgp::Base * pgpBase )
+ : KeyListJob( 0, "Kleo::KpgpKeyListJob" ),
+ mPgpBase( pgpBase )
+{
+}
+
+Kleo::KpgpKeyListJob::~KpgpKeyListJob() {
+}
+
+// the following function is a verbatim copy from gpgme/key.c
+static char *
+set_user_id_part (char *tail, const char *buf, size_t len)
+{
+ while (len && (buf[len - 1] == ' ' || buf[len - 1] == '\t'))
+ len--;
+ for (; len; len--)
+ *tail++ = *buf++;
+ *tail++ = 0;
+ return tail;
+}
+
+// the following function is a verbatim copy from gpgme/key.c
+static void
+parse_user_id (char *src, char **name, char **email,
+ char **comment, char *tail)
+{
+ const char *start = NULL;
+ int in_name = 0;
+ int in_email = 0;
+ int in_comment = 0;
+
+ while (*src)
+ {
+ if (in_email)
+ {
+ if (*src == '<')
+ /* Not legal but anyway. */
+ in_email++;
+ else if (*src == '>')
+ {
+ if (!--in_email && !*email)
+ {
+ *email = tail;
+ tail = set_user_id_part (tail, start, src - start);
+ }
+ }
+ }
+ else if (in_comment)
+ {
+ if (*src == '(')
+ in_comment++;
+ else if (*src == ')')
+ {
+ if (!--in_comment && !*comment)
+ {
+ *comment = tail;
+ tail = set_user_id_part (tail, start, src - start);
+ }
+ }
+ }
+ else if (*src == '<')
+ {
+ if (in_name)
+ {
+ if (!*name)
+ {
+ *name = tail;
+ tail = set_user_id_part (tail, start, src - start);
+ }
+ in_name = 0;
+ }
+ in_email = 1;
+ start = src + 1;
+ }
+ else if (*src == '(')
+ {
+ if (in_name)
+ {
+ if (!*name)
+ {
+ *name = tail;
+ tail = set_user_id_part (tail, start, src - start);
+ }
+ in_name = 0;
+ }
+ in_comment = 1;
+ start = src + 1;
+ }
+ else if (!in_name && *src != ' ' && *src != '\t')
+ {
+ in_name = 1;
+ start = src;
+ }
+ src++;
+ }
+
+ if (in_name)
+ {
+ if (!*name)
+ {
+ *name = tail;
+ tail = set_user_id_part (tail, start, src - start);
+ }
+ }
+
+ /* Let unused parts point to an EOS. */
+ tail--;
+ if (!*name)
+ *name = tail;
+ if (!*email)
+ *email = tail;
+ if (!*comment)
+ *comment = tail;
+}
+
+gpgme_user_id_t KpgpUserID2GPGMEUserID( const Kpgp::UserID * kUserId )
+{
+ // inspired by _gpgme_key_append_name
+
+ const QCString text = kUserId->text().utf8();
+ const int src_len = text.length();
+
+ gpgme_user_id_t uid;
+ /* Allocate enough memory for the _gpgme_user_id struct, for the actual user
+ id (the text) and for the parsed version. */
+ uid = (gpgme_user_id_t) malloc( sizeof( *uid ) + 2 * src_len + 3 );
+ memset( uid, 0, sizeof *uid );
+ uid->revoked = kUserId->revoked();
+ uid->invalid = kUserId->invalid();
+ uid->validity = (gpgme_validity_t) kUserId->validity();
+
+ uid->uid = ((char *) uid) + sizeof (*uid);
+ char *dst = uid->uid;
+ memcpy( dst, text.data(), src_len + 1 );
+
+ dst += src_len + 1;
+ parse_user_id( uid->uid, &uid->name, &uid->email,
+ &uid->comment, dst );
+
+ return uid;
+}
+
+gpgme_subkey_t KpgpSubkey2GPGMESubKey( const Kpgp::Subkey * kSubkey )
+{
+ gpgme_subkey_t subkey;
+
+ const QCString fpr = kSubkey->fingerprint();
+ const unsigned int fpr_len = fpr.length();
+ const QCString keyId = kSubkey->longKeyID();
+
+ subkey = (gpgme_subkey_t) calloc( 1, sizeof( *subkey ) + fpr_len + 1 );
+ subkey->revoked = kSubkey->revoked();
+ subkey->expired = kSubkey->expired();
+ subkey->disabled = kSubkey->disabled();
+ subkey->invalid = kSubkey->invalid();
+ subkey->can_encrypt = kSubkey->canEncrypt();
+ subkey->can_sign = kSubkey->canSign();
+ subkey->can_certify = kSubkey->canCertify();
+ subkey->secret = kSubkey->secret();
+ subkey->pubkey_algo = (gpgme_pubkey_algo_t) kSubkey->keyAlgorithm();
+ subkey->length = kSubkey->keyLength();
+ subkey->keyid = subkey->_keyid;
+ memcpy( subkey->_keyid, keyId.data(), keyId.length() + 1 );
+ subkey->fpr = ((char *) subkey) + sizeof( *subkey );
+ memcpy( subkey->fpr, fpr.data(), fpr_len + 1 );
+ subkey->timestamp = kSubkey->creationDate();
+ subkey->expires = kSubkey->expirationDate();
+
+ return subkey;
+}
+
+gpgme_key_t KpgpKey2gpgme_key( const Kpgp::Key * kKey )
+{
+ gpgme_key_t key;
+
+ key = (gpgme_key_t) calloc( 1, sizeof( *key ) );
+ key->revoked = kKey->revoked();
+ key->expired = kKey->expired();
+ key->disabled = kKey->disabled();
+ key->invalid = kKey->invalid();
+ key->can_encrypt = kKey->canEncrypt();
+ key->can_sign = kKey->canSign();
+ key->can_certify = kKey->canCertify();
+ key->secret = kKey->secret();
+ key->protocol = GPGME_PROTOCOL_OpenPGP;
+ key->owner_trust = GPGME_VALIDITY_UNKNOWN; // FIXME?
+
+ Kpgp::UserIDList kUserIDs = kKey->userIDs();
+ for ( Kpgp::UserIDListIterator it( kUserIDs ); it.current(); ++it ) {
+ gpgme_user_id_t uid = KpgpUserID2GPGMEUserID( *it );
+ if ( !key->uids )
+ key->uids = uid;
+ if ( key->_last_uid )
+ key->_last_uid->next = uid;
+ key->_last_uid = uid;
+ }
+
+ Kpgp::SubkeyList kSubkeys = kKey->subkeys();
+ for ( Kpgp::SubkeyListIterator it( kSubkeys ); it.current(); ++it ) {
+ gpgme_subkey_t subkey = KpgpSubkey2GPGMESubKey( *it );
+ if (!key->subkeys)
+ key->subkeys = subkey;
+ if (key->_last_subkey)
+ key->_last_subkey->next = subkey;
+ key->_last_subkey = subkey;
+ }
+
+ return key;
+}
+
+GpgME::Error Kleo::KpgpKeyListJob::start( const QStringList & patterns,
+ bool secretOnly ) {
+ mPatterns = patterns;
+ mSecretOnly = secretOnly;
+ QTimer::singleShot( 0, this, SLOT( slotDoIt() ) );
+ return GpgME::Error( 0 );
+}
+
+void Kleo::KpgpKeyListJob::slotDoIt() {
+ std::vector<GpgME::Key> keys;
+ GpgME::KeyListResult res = exec( mPatterns, mSecretOnly, keys );
+ for ( std::vector<GpgME::Key>::const_iterator it = keys.begin();
+ it != keys.end(); ++it )
+ emit nextKey( *it );
+ emit done();
+ emit result( res );
+ deleteLater();
+}
+
+GpgME::KeyListResult Kleo::KpgpKeyListJob::exec( const QStringList & patterns,
+ bool secretOnly,
+ std::vector<GpgME::Key> & keys ) {
+ Kpgp::KeyList kKeys;
+ if ( secretOnly )
+ kKeys = mPgpBase->secretKeys( patterns );
+ else
+ kKeys = mPgpBase->publicKeys( patterns );
+
+ keys.clear();
+ for ( Kpgp::KeyListIterator it( kKeys ); it.current(); ++it ) {
+ keys.push_back( GpgME::Key( KpgpKey2gpgme_key(*it), true ) );
+ }
+
+ _gpgme_op_keylist_result res;
+ res.truncated = 0; // key list is not truncated
+ res._unused = 0;
+
+ return GpgME::KeyListResult( GpgME::Error( 0 ), res );
+}
+
+#include "kpgpkeylistjob.moc"
diff --git a/certmanager/lib/backends/kpgp/kpgpkeylistjob.h b/certmanager/lib/backends/kpgp/kpgpkeylistjob.h
new file mode 100644
index 000000000..779680c2d
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/kpgpkeylistjob.h
@@ -0,0 +1,79 @@
+/* -*- mode: C++ -*-
+ kpgpkeylistjob.h
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Ingo Kloecker <kloecker@kde.org>
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifndef __KLEO_KPGPKEYLISTJOB_H__
+#define __KLEO_KPGPKEYLISTJOB_H__
+
+#include <kleo/keylistjob.h>
+
+#include <qstringlist.h>
+
+namespace GpgME {
+ class Error;
+ class Context;
+ class Key;
+}
+
+namespace Kpgp {
+ class Base;
+}
+
+namespace Kleo {
+
+ class KpgpKeyListJob : public KeyListJob {
+ Q_OBJECT
+ public:
+ KpgpKeyListJob( Kpgp::Base * pgpBase );
+ ~KpgpKeyListJob();
+
+ /*! \reimp from KeyListJob */
+ GpgME::Error start( const QStringList & patterns, bool secretOnly );
+
+ /*! \reimp from KeyListJob */
+ GpgME::KeyListResult exec( const QStringList & patterns, bool secretOnly,
+ std::vector<GpgME::Key> & keys );
+
+ /*! \reimp from Job */
+ void slotCancel() { /*FIXME*/ }
+
+ private slots:
+ void slotDoIt();
+
+ private:
+ Kpgp::Base * mPgpBase;
+ QStringList mPatterns;
+ bool mSecretOnly;
+ };
+
+}
+
+#endif // __KLEO_KPGPKEYLISTJOB_H__
diff --git a/certmanager/lib/backends/kpgp/kpgpwrapper.cpp b/certmanager/lib/backends/kpgp/kpgpwrapper.cpp
new file mode 100644
index 000000000..20d885dd5
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/kpgpwrapper.cpp
@@ -0,0 +1,173 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+ kpgpwrapper.cpp
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Ingo Kloecker <kloecker@kde.org>
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "kpgpwrapper.h"
+
+#include "kpgpbackendbase.h"
+
+#include <kpgpbase.h>
+
+#include <backends/kpgp/kpgpkeylistjob.h>
+//#include <backends/kpgp/kpgpencryptjob.h>
+//#include <backends/kpgp/kpgpdecryptjob.h>
+//#include <backends/kpgp/kpgpsignjob.h>
+//#include <backends/kpgp/kpgpverifydetachedjob.h>
+//#include <backends/kpgp/kpgpverifyopaquejob.h>
+//#include <backends/kpgp/kpgpkeygenerationjob.h>
+//#include <backends/kpgp/kpgpimportjob.h>
+//#include <backends/kpgp/kpgpexportjob.h>
+//#include <backends/kpgp/kpgpsecretkeyexportjob.h>
+//#include <backends/kpgp/kpgpdownloadjob.h>
+//#include <backends/kpgp/kpgpdeletejob.h>
+//#include <backends/kpgp/kpgpsignencryptjob.h>
+//#include <backends/kpgp/kpgpdecryptverifyjob.h>
+//#include <backends/kpgp/kpgpcryptoconfig.h>
+
+KpgpWrapper::KpgpWrapper( const QString & name )
+ : mName( name ),
+ mPgpBase( 0 )
+{
+
+}
+
+KpgpWrapper::~KpgpWrapper()
+{
+
+}
+
+QString KpgpWrapper::name() const
+{
+ return mName;
+}
+
+QString KpgpWrapper::displayName() const
+{
+ return mName;
+}
+
+Kleo::KeyListJob * KpgpWrapper::keyListJob( bool /*remote*/,
+ bool /*includeSigs*/,
+ bool /*validate*/ ) const
+{
+ return new Kleo::KpgpKeyListJob( pgpBase() );
+}
+
+Kleo::EncryptJob * KpgpWrapper::encryptJob( bool /*armor*/,
+ bool /*textmode*/ ) const
+{
+ return 0;
+}
+
+Kleo::DecryptJob * KpgpWrapper::decryptJob() const
+{
+ return 0;
+}
+
+Kleo::SignJob * KpgpWrapper::signJob( bool /*armor*/, bool /*textMode*/ ) const
+{
+ return 0;
+}
+
+Kleo::VerifyDetachedJob * KpgpWrapper::verifyDetachedJob( bool /*textmode*/ ) const
+{
+ return 0;
+}
+
+Kleo::VerifyOpaqueJob * KpgpWrapper::verifyOpaqueJob( bool /*textmode*/ ) const
+{
+ return 0;
+}
+
+Kleo::KeyGenerationJob * KpgpWrapper::keyGenerationJob() const
+{
+ return 0;
+}
+
+Kleo::ImportJob * KpgpWrapper::importJob() const
+{
+ return 0;
+}
+
+Kleo::ExportJob * KpgpWrapper::publicKeyExportJob( bool /*armor*/ ) const
+{
+ return 0;
+}
+
+Kleo::ExportJob * KpgpWrapper::secretKeyExportJob( bool /*armor*/ ) const
+{
+ return 0;
+}
+
+Kleo::DownloadJob * KpgpWrapper::downloadJob( bool /*armor*/ ) const
+{
+ return 0;
+}
+
+Kleo::DeleteJob * KpgpWrapper::deleteJob() const
+{
+ return 0;
+}
+
+Kleo::SignEncryptJob * KpgpWrapper::signEncryptJob( bool /*armor*/,
+ bool /*textMode*/ ) const
+{
+ return 0;
+}
+
+Kleo::DecryptVerifyJob * KpgpWrapper::decryptVerifyJob( bool /*textmode*/ ) const
+{
+ return 0;
+}
+
+Kleo::RefreshKeysJob * KpgpWrapper::refreshKeysJob() const
+{
+ return 0;
+}
+
+Kpgp::Base * KpgpWrapper::pgpBase() const
+{
+ if ( !mPgpBase ) {
+ if ( name() == GPG1_BACKEND_NAME )
+ mPgpBase = new Kpgp::BaseG();
+ else if ( name() == PGP2_BACKEND_NAME )
+ mPgpBase = new Kpgp::Base2();
+ else if ( name() == PGP5_BACKEND_NAME )
+ mPgpBase = new Kpgp::Base5();
+ else if ( name() == PGP6_BACKEND_NAME )
+ mPgpBase = new Kpgp::Base6();
+ }
+ return mPgpBase;
+}
diff --git a/certmanager/lib/backends/kpgp/kpgpwrapper.h b/certmanager/lib/backends/kpgp/kpgpwrapper.h
new file mode 100644
index 000000000..182661ec4
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/kpgpwrapper.h
@@ -0,0 +1,97 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+ kpgpwrapper.h
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Ingo Kloecker <kloecker@kde.org>
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+#ifndef __KLEO_KPGPWRAPPER_H__
+#define __KLEO_KPGPWRAPPER_H__
+
+#include <kleo/cryptobackend.h>
+
+#include <qstring.h>
+
+namespace Kleo {
+ class KeyListJob;
+ class EncryptJob;
+ class DecryptJob;
+ class SignJob;
+ class VerifyDetachedJob;
+ class VerifyOpaqueJob;
+ class KeyGenerationJob;
+ class ImportJob;
+ class ExportJob;
+ class DownloadJob;
+ class DeleteJob;
+ class SignEncryptJob;
+ class DecryptVerifyJob;
+ class CryptoConfig;
+ class RefreshKeysJob;
+}
+
+namespace Kpgp {
+ class Base;
+}
+
+class KpgpWrapper : public Kleo::CryptoBackend::Protocol {
+public:
+ KpgpWrapper( const QString & name );
+ ~KpgpWrapper();
+
+ QString name() const;
+
+ QString displayName() const;
+
+ Kleo::KeyListJob * keyListJob( bool remote=false, bool includeSigs=false,
+ bool validate=false ) const;
+ Kleo::EncryptJob * encryptJob( bool armor=false, bool textmode=false ) const;
+ Kleo::DecryptJob * decryptJob() const;
+ Kleo::SignJob * signJob( bool armor=false, bool textMode=false ) const;
+ Kleo::VerifyDetachedJob * verifyDetachedJob( bool textmode=false) const;
+ Kleo::VerifyOpaqueJob * verifyOpaqueJob( bool textmode=false ) const;
+ Kleo::KeyGenerationJob * keyGenerationJob() const;
+ Kleo::ImportJob * importJob() const;
+ Kleo::ExportJob * publicKeyExportJob( bool armor=false ) const;
+ Kleo::ExportJob * secretKeyExportJob( bool armor=false ) const;
+ Kleo::DownloadJob * downloadJob( bool armor=false ) const;
+ Kleo::DeleteJob * deleteJob() const;
+ Kleo::SignEncryptJob * signEncryptJob( bool armor=false,
+ bool textMode=false ) const;
+ Kleo::DecryptVerifyJob * decryptVerifyJob( bool textmode=false ) const;
+ Kleo::RefreshKeysJob * refreshKeysJob() const;
+
+private:
+ Kpgp::Base * pgpBase() const;
+
+private:
+ QString mName;
+ mutable Kpgp::Base * mPgpBase;
+};
+
+#endif // __KLEO_KPGPWRAPPER_H__
diff --git a/certmanager/lib/backends/kpgp/pgp2backend.h b/certmanager/lib/backends/kpgp/pgp2backend.h
new file mode 100644
index 000000000..fc053a20c
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/pgp2backend.h
@@ -0,0 +1,52 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+ pgp2backend.h
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Klarälvdalens Datakonsult AB
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+
+#ifndef __KLEO_PGP2BACKEND_H__
+#define __KLEO_PGP2BACKEND_H__
+
+#include "kpgpbackendbase.h"
+
+class QString;
+
+namespace Kleo {
+
+ class PGP2Backend : public KpgpBackendBase {
+ public:
+ QString name() const;
+ QString displayName() const;
+ };
+
+}
+
+
+#endif // __KLEO_PGP2BACKEND_H__
diff --git a/certmanager/lib/backends/kpgp/pgp5backend.h b/certmanager/lib/backends/kpgp/pgp5backend.h
new file mode 100644
index 000000000..bf323b6fb
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/pgp5backend.h
@@ -0,0 +1,52 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+ pgp5backend.h
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Klarälvdalens Datakonsult AB
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+
+#ifndef __KLEO_PGP5BACKEND_H__
+#define __KLEO_PGP5BACKEND_H__
+
+#include "kpgpbackendbase.h"
+
+class QString;
+
+namespace Kleo {
+
+ class PGP5Backend : public KpgpBackendBase {
+ public:
+ QString name() const;
+ QString displayName() const;
+ };
+
+}
+
+
+#endif // __KLEO_PGP5BACKEND_H__
diff --git a/certmanager/lib/backends/kpgp/pgp6backend.h b/certmanager/lib/backends/kpgp/pgp6backend.h
new file mode 100644
index 000000000..827cf239b
--- /dev/null
+++ b/certmanager/lib/backends/kpgp/pgp6backend.h
@@ -0,0 +1,52 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+ pgp6backend.h
+
+ This file is part of libkleopatra, the KDE keymanagement library
+ Copyright (c) 2004 Klarälvdalens Datakonsult AB
+
+ Libkleopatra is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ Libkleopatra is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+
+
+#ifndef __KLEO_PGP6BACKEND_H__
+#define __KLEO_PGP6BACKEND_H__
+
+#include "kpgpbackendbase.h"
+
+class QString;
+
+namespace Kleo {
+
+ class PGP6Backend : public KpgpBackendBase {
+ public:
+ QString name() const;
+ QString displayName() const;
+ };
+
+}
+
+
+#endif // __KLEO_PGP6BACKEND_H__