summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-04-12 09:16:15 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-10-12 17:26:10 (GMT)
commit6ac7ef85362ee76c3a4926fd4d93f6cde487e6f9 (patch)
treed8d49b3916cb93c8cb86c368d899c60772b417cc
parentfc7fe0206a9ff89e5715af8a847b7d10154722eb (diff)
API Break: Remove backends from libkleo
Libkleo is now a GUI and Utility Library for QGpgME. This depends on the branch gpgmepp in gpgme proper where most of the backend code has been moved into.
-rw-r--r--CMakeLists.txt5
-rw-r--r--src/CMakeLists.txt113
-rw-r--r--src/backends/CMakeLists.txt2
-rw-r--r--src/backends/chiasmus/CMakeLists.txt6
-rw-r--r--src/backends/chiasmus/chiasmusbackend.cpp764
-rw-r--r--src/backends/chiasmus/chiasmusbackend.h100
-rw-r--r--src/backends/chiasmus/chiasmusjob.cpp243
-rw-r--r--src/backends/chiasmus/chiasmusjob.h136
-rw-r--r--src/backends/chiasmus/chiasmuslibrary.cpp133
-rw-r--r--src/backends/chiasmus/chiasmuslibrary.h68
-rw-r--r--src/backends/chiasmus/config-chiasmus.h.cmake2
-rw-r--r--src/backends/chiasmus/config_data.c92
-rw-r--r--src/backends/chiasmus/config_data.h69
-rw-r--r--src/backends/chiasmus/obtainkeysjob.cpp132
-rw-r--r--src/backends/chiasmus/obtainkeysjob.h104
-rw-r--r--src/backends/chiasmus/symcryptrunprocessbase.cpp106
-rw-r--r--src/backends/chiasmus/symcryptrunprocessbase.h83
-rw-r--r--src/backends/qgpgme/gnupgprocessbase.cpp64
-rw-r--r--src/backends/qgpgme/gnupgprocessbase.h90
-rw-r--r--src/backends/qgpgme/qgpgmeadduseridjob.cpp82
-rw-r--r--src/backends/qgpgme/qgpgmeadduseridjob.h64
-rw-r--r--src/backends/qgpgme/qgpgmebackend.cpp528
-rw-r--r--src/backends/qgpgme/qgpgmebackend.h86
-rw-r--r--src/backends/qgpgme/qgpgmechangeexpiryjob.cpp81
-rw-r--r--src/backends/qgpgme/qgpgmechangeexpiryjob.h65
-rw-r--r--src/backends/qgpgme/qgpgmechangeownertrustjob.cpp77
-rw-r--r--src/backends/qgpgme/qgpgmechangeownertrustjob.h64
-rw-r--r--src/backends/qgpgme/qgpgmechangepasswdjob.cpp78
-rw-r--r--src/backends/qgpgme/qgpgmechangepasswdjob.h65
-rw-r--r--src/backends/qgpgme/qgpgmecryptoconfig.cpp952
-rw-r--r--src/backends/qgpgme/qgpgmecryptoconfig.h244
-rw-r--r--src/backends/qgpgme/qgpgmedecryptjob.cpp127
-rw-r--r--src/backends/qgpgme/qgpgmedecryptjob.h79
-rw-r--r--src/backends/qgpgme/qgpgmedecryptverifyjob.cpp135
-rw-r--r--src/backends/qgpgme/qgpgmedecryptverifyjob.h80
-rw-r--r--src/backends/qgpgme/qgpgmedeletejob.cpp65
-rw-r--r--src/backends/qgpgme/qgpgmedeletejob.h70
-rw-r--r--src/backends/qgpgme/qgpgmedownloadjob.cpp102
-rw-r--r--src/backends/qgpgme/qgpgmedownloadjob.h68
-rw-r--r--src/backends/qgpgme/qgpgmeencryptjob.cpp171
-rw-r--r--src/backends/qgpgme/qgpgmeencryptjob.h103
-rw-r--r--src/backends/qgpgme/qgpgmeexportjob.cpp76
-rw-r--r--src/backends/qgpgme/qgpgmeexportjob.h65
-rw-r--r--src/backends/qgpgme/qgpgmeimportfromkeyserverjob.cpp82
-rw-r--r--src/backends/qgpgme/qgpgmeimportfromkeyserverjob.h76
-rw-r--r--src/backends/qgpgme/qgpgmeimportjob.cpp85
-rw-r--r--src/backends/qgpgme/qgpgmeimportjob.h76
-rw-r--r--src/backends/qgpgme/qgpgmekeygenerationjob.cpp71
-rw-r--r--src/backends/qgpgme/qgpgmekeygenerationjob.h67
-rw-r--r--src/backends/qgpgme/qgpgmekeylistjob.cpp169
-rw-r--r--src/backends/qgpgme/qgpgmekeylistjob.h81
-rw-r--r--src/backends/qgpgme/qgpgmelistallkeysjob.cpp171
-rw-r--r--src/backends/qgpgme/qgpgmelistallkeysjob.h80
-rw-r--r--src/backends/qgpgme/qgpgmenewcryptoconfig.cpp738
-rw-r--r--src/backends/qgpgme/qgpgmenewcryptoconfig.h187
-rw-r--r--src/backends/qgpgme/qgpgmeprogresstokenmapper.cpp127
-rw-r--r--src/backends/qgpgme/qgpgmeprogresstokenmapper.h49
-rw-r--r--src/backends/qgpgme/qgpgmerefreshkeysjob.cpp226
-rw-r--r--src/backends/qgpgme/qgpgmerefreshkeysjob.h79
-rw-r--r--src/backends/qgpgme/qgpgmesecretkeyexportjob.cpp204
-rw-r--r--src/backends/qgpgme/qgpgmesecretkeyexportjob.h82
-rw-r--r--src/backends/qgpgme/qgpgmesignencryptjob.cpp170
-rw-r--r--src/backends/qgpgme/qgpgmesignencryptjob.h111
-rw-r--r--src/backends/qgpgme/qgpgmesignjob.cpp163
-rw-r--r--src/backends/qgpgme/qgpgmesignjob.h95
-rw-r--r--src/backends/qgpgme/qgpgmesignkeyjob.cpp127
-rw-r--r--src/backends/qgpgme/qgpgmesignkeyjob.h89
-rw-r--r--src/backends/qgpgme/qgpgmeverifydetachedjob.cpp119
-rw-r--r--src/backends/qgpgme/qgpgmeverifydetachedjob.h80
-rw-r--r--src/backends/qgpgme/qgpgmeverifyopaquejob.cpp126
-rw-r--r--src/backends/qgpgme/qgpgmeverifyopaquejob.h79
-rw-r--r--src/backends/qgpgme/threadedjobmixin.cpp111
-rw-r--r--src/backends/qgpgme/threadedjobmixin.h276
-rw-r--r--src/kleo/abstractimportjob.h61
-rw-r--r--src/kleo/adduseridjob.h83
-rw-r--r--src/kleo/changeexpiryjob.h83
-rw-r--r--src/kleo/changeownertrustjob.h76
-rw-r--r--src/kleo/changepasswdjob.h81
-rw-r--r--src/kleo/checksumdefinition.cpp28
-rw-r--r--src/kleo/cryptobackend.cpp57
-rw-r--r--src/kleo/cryptobackend.h157
-rw-r--r--src/kleo/cryptobackendfactory.cpp314
-rw-r--r--src/kleo/cryptobackendfactory.h117
-rw-r--r--src/kleo/cryptoconfig.h400
-rw-r--r--src/kleo/decryptjob.h99
-rw-r--r--src/kleo/decryptverifyjob.h104
-rw-r--r--src/kleo/deletejob.h81
-rw-r--r--src/kleo/downloadjob.h105
-rw-r--r--src/kleo/encryptjob.h133
-rw-r--r--src/kleo/exportjob.h85
-rw-r--r--src/kleo/hierarchicalkeylistjob.cpp167
-rw-r--r--src/kleo/hierarchicalkeylistjob.h120
-rw-r--r--src/kleo/importfromkeyserverjob.h82
-rw-r--r--src/kleo/importjob.h81
-rw-r--r--src/kleo/job.cpp161
-rw-r--r--src/kleo/job.h89
-rw-r--r--src/kleo/keyfiltermanager.cpp13
-rw-r--r--src/kleo/keygenerationjob.h85
-rw-r--r--src/kleo/keylistjob.h100
-rw-r--r--src/kleo/listallkeysjob.h98
-rw-r--r--src/kleo/multideletejob.cpp114
-rw-r--r--src/kleo/multideletejob.h106
-rw-r--r--src/kleo/refreshkeysjob.h92
-rw-r--r--src/kleo/signencryptjob.h147
-rw-r--r--src/kleo/signjob.h117
-rw-r--r--src/kleo/signkeyjob.h116
-rw-r--r--src/kleo/specialjob.h89
-rw-r--r--src/kleo/verifydetachedjob.h97
-rw-r--r--src/kleo/verifyopaquejob.h100
-rw-r--r--src/tests/CMakeLists.txt1
-rw-r--r--src/tests/test_cryptoconfig.cpp86
-rw-r--r--src/tests/test_gnupgprocessbase.cpp163
-rw-r--r--src/tests/test_jobs.cpp12
-rw-r--r--src/tests/test_keygen.cpp14
-rw-r--r--src/tests/test_keylister.cpp6
-rw-r--r--src/ui/cryptoconfigdialog.cpp2
-rw-r--r--src/ui/cryptoconfigdialog.h9
-rw-r--r--src/ui/cryptoconfigmodule.cpp62
-rw-r--r--src/ui/cryptoconfigmodule.h14
-rw-r--r--src/ui/cryptoconfigmodule_p.h37
-rw-r--r--src/ui/keyapprovaldialog.cpp2
-rw-r--r--src/ui/keyrequester.cpp10
-rw-r--r--src/ui/keyrequester.h7
-rw-r--r--src/ui/keyselectiondialog.cpp19
-rw-r--r--src/ui/keyselectiondialog.h8
-rw-r--r--src/ui/messagebox.cpp5
-rw-r--r--src/ui/messagebox.h40
-rw-r--r--src/ui/progressdialog.cpp10
-rw-r--r--src/ui/progressdialog.h6
129 files changed, 211 insertions, 14375 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 69ccdba..e00d010 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,6 @@ include(ECMAddTests)
set(PIM_VERSION "5.3.45")
set(LIBKLEO_LIB_VERSION ${PIM_VERSION})
set(QT_REQUIRED_VERSION "5.6.0")
-set(GPGMEPP_LIB_VERSION "5.3.40")
set(KDEPIMTEXTEDIT_VERSION "5.3.40")
set(PIMCOMMON_LIB_VERSION "5.3.40")
@@ -35,9 +34,11 @@ find_package(KF5WindowSystem ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5CoreAddons ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5Codecs ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5ItemModels ${KF5_VERSION} CONFIG REQUIRED)
-find_package(KF5Gpgmepp ${GPGMEPP_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5PimTextEdit ${KDEPIMTEXTEDIT_VERSION} CONFIG)
+find_package(Gpgmepp 1.7.0)
+set_package_properties(Gpgmepp PROPERTIES DESCRIPTION "GpgME++ Library" URL "http://www.gnupg.org" TYPE REQUIRED PURPOSE "GpgME++ is required for OpenPGP support")
+
find_package(Boost 1.34.0)
set_package_properties(Boost PROPERTIES DESCRIPTION "Boost C++ Libraries" URL "http://www.boost.org" TYPE REQUIRED PURPOSE "Boost is required for building most KDEPIM applications")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c7ed1f3..8a1bed4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,67 +15,16 @@ string(REPLACE "-pedantic" "" FOO "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${FOO}")
add_subdirectory( pics )
-add_subdirectory( backends )
if (BUILD_TESTING)
add_subdirectory( tests )
endif()
########### next target ###############
-set(libkleo_backend_qgpgme_SRCS
- backends/qgpgme/gnupgprocessbase.cpp
- backends/qgpgme/qgpgmeprogresstokenmapper.cpp
- backends/qgpgme/qgpgmebackend.cpp
- backends/qgpgme/threadedjobmixin.cpp
- backends/qgpgme/qgpgmekeylistjob.cpp
- backends/qgpgme/qgpgmelistallkeysjob.cpp
- backends/qgpgme/qgpgmekeygenerationjob.cpp
- backends/qgpgme/qgpgmeimportjob.cpp
- backends/qgpgme/qgpgmeimportfromkeyserverjob.cpp
- backends/qgpgme/qgpgmeexportjob.cpp
- backends/qgpgme/qgpgmesecretkeyexportjob.cpp
- backends/qgpgme/qgpgmechangeexpiryjob.cpp
- backends/qgpgme/qgpgmechangeownertrustjob.cpp
- backends/qgpgme/qgpgmechangepasswdjob.cpp
- backends/qgpgme/qgpgmedownloadjob.cpp
- backends/qgpgme/qgpgmedeletejob.cpp
- backends/qgpgme/qgpgmeencryptjob.cpp
- backends/qgpgme/qgpgmedecryptjob.cpp
- backends/qgpgme/qgpgmesignjob.cpp
- backends/qgpgme/qgpgmesignkeyjob.cpp
- backends/qgpgme/qgpgmeadduseridjob.cpp
- backends/qgpgme/qgpgmeverifydetachedjob.cpp
- backends/qgpgme/qgpgmeverifyopaquejob.cpp
- backends/qgpgme/qgpgmesignencryptjob.cpp
- backends/qgpgme/qgpgmedecryptverifyjob.cpp
- backends/qgpgme/qgpgmecryptoconfig.cpp
- backends/qgpgme/qgpgmenewcryptoconfig.cpp
- backends/qgpgme/qgpgmerefreshkeysjob.cpp
- backends/qgpgme/qgpgmekeyformailboxjob.cpp
- )
-ecm_qt_declare_logging_category(libkleo_backend_qgpgme_SRCS HEADER gpgme_backend_debug.h IDENTIFIER GPGPME_BACKEND_LOG CATEGORY_NAME org.kde.pim.gpgme_backend)
-
-set(libkleo_backend_chiasmus_SRCS
- backends/chiasmus/config_data.c
- backends/chiasmus/obtainkeysjob.cpp
- backends/chiasmus/symcryptrunprocessbase.cpp
- backends/chiasmus/chiasmusjob.cpp
- backends/chiasmus/chiasmuslibrary.cpp
- backends/chiasmus/chiasmusbackend.cpp
- )
-
-
set(libkleo_core_SRCS
kleo/checksumdefinition.cpp
- kleo/cryptobackend.cpp
- kleo/cryptobackendfactory.cpp
kleo/enum.cpp
kleo/exception.cpp
kleo/dn.cpp
- kleo/job.cpp
- kleo/multideletejob.cpp
- kleo/hierarchicalkeylistjob.cpp
- kleo/defaultkeyfilter.cpp
- kleo/defaultkeygenerationjob.cpp
kleo/kconfigbasedkeyfilter.cpp
kleo/keyfiltermanager.cpp
models/keycache.cpp
@@ -117,25 +66,16 @@ ki18n_wrap_ui(libkleo_ui_common_SRCS
ui/directoryserviceswidget.ui
)
-set(kleo_LIB_SRCS ${libkleo_core_SRCS} ${libkleo_backend_chiasmus_SRCS}
- ${libkleo_ui_SRCS}
- ${libkleo_ui_common_SRCS}
- ${libkleo_backend_qgpgme_SRCS})
+set(kleo_LIB_SRCS ${libkleo_core_SRCS} ${libkleo_ui_SRCS}
+ ${libkleo_ui_common_SRCS})
-set(kleo_LIB_LIBS PUBLIC KF5::QGpgme PRIVATE Qt5::Widgets
- KF5::I18n
- KF5::Completion
- KF5::ConfigCore
- KF5::CoreAddons
- KF5::WindowSystem
- KF5::WidgetsAddons
- KF5::Codecs
- KF5::ItemModels)
-if (WIN32)
- set(kleo_LIB_LIBS ${kleo_LIB_LIBS} PUBLIC KF5::Gpgmepp)
-else()
- set(kleo_LIB_LIBS ${kleo_LIB_LIBS} PUBLIC KF5::Gpgmepp-pthread)
-endif()
+set(kleo_LIB_LIBS PUBLIC QGpgme Gpgmepp PRIVATE Qt5::Widgets
+ KF5::I18n
+ KF5::Completion
+ KF5::ConfigCore
+ KF5::CoreAddons
+ KF5::WindowSystem
+ KF5::WidgetsAddons)
if (KF5PimTextEdit_FOUND)
add_definitions(-DHAVE_PIMTEXTEDIT)
@@ -169,44 +109,15 @@ target_include_directories(KF5Libkleo INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTA
ecm_generate_headers(libkleo_CamelCase_HEADERS
HEADER_NAMES
- AbstractImportJob
- AddUserIDJob
- ChangeExpiryJob
- ChangeOwnerTrustJob
- ChangePasswdJob
- ChecksumDefinition
- CryptoBackend
- CryptoBackendFactory
- CryptoConfig
- DecryptJob
- DecryptVerifyJob
- DefaultKeyFilter
- DefaultKeyGenerationJob
- DeleteJob
- Dn
- EncryptJob
Enum
+ Stl_Util
+ Dn
Exception
- ExportJob
- ImportFromKeyserverJob
- ImportJob
- Job
KeyFilter
+ ChecksumDefinition
KeyFilterManager
- KeyForMailboxJob
- KeyGenerationJob
- KeyListJob
- ListAllKeysJob
- MultiDeleteJob
OidMap
Predicates
- SignEncryptJob
- SignJob
- SignKeyJob
- SpecialJob
- Stl_Util
- VerifyDetachedJob
- VerifyOpaqueJob
REQUIRED_HEADERS libkleo_HEADERS
PREFIX Libkleo
RELATIVE kleo
diff --git a/src/backends/CMakeLists.txt b/src/backends/CMakeLists.txt
deleted file mode 100644
index 689e478..0000000
--- a/src/backends/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_subdirectory( chiasmus )
-
diff --git a/src/backends/chiasmus/CMakeLists.txt b/src/backends/chiasmus/CMakeLists.txt
deleted file mode 100644
index aeb0b9b..0000000
--- a/src/backends/chiasmus/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-
-if(NOT MSVC)
- set(HAVE_C99_INITIALIZERS 1)
-endif()
-
-configure_file (config-chiasmus.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-chiasmus.h )
diff --git a/src/backends/chiasmus/chiasmusbackend.cpp b/src/backends/chiasmus/chiasmusbackend.cpp
deleted file mode 100644
index 3b993fa..0000000
--- a/src/backends/chiasmus/chiasmusbackend.cpp
+++ /dev/null
@@ -1,764 +0,0 @@
-/*
- chiasmusbackend.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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.
-*/
-
-#include "chiasmusbackend.h"
-
-#include "config_data.h"
-#include "obtainkeysjob.h"
-#include "chiasmusjob.h"
-
-#include "libkleo/cryptoconfig.h"
-
-#include <KLocalizedString>
-#include <kconfig.h>
-#include <kshell.h>
-#include <QDebug>
-#include <kconfiggroup.h>
-
-#include <QStringList>
-#include <QVariant>
-#include <QFileInfo>
-
-#include <QList>
-#include <QUrl>
-
-#include <map>
-#include <memory>
-#include <vector>
-
-#include <cassert>
-
-namespace
-{
-
-//
-// The usual QVariant template helpers:
-//
-
-// to<> is a demarshaller. It's a class b/c you can't partially
-// specialize function templates yet. However, to<> can be used as if
-// it was a function: QString s = to<QString>( myVariant );
-template <typename T> class to {};
-
-#define MAKE_TO( type, func ) \
- template <> \
- class to< type > { \
- type m; \
- public: \
- to( const QVariant & v ) : m( v.func() ) {} \
- operator type() const { return m; } \
- }
-
-MAKE_TO(int, toInt);
-MAKE_TO(unsigned int, toUInt);
-
-template <>
-class to<QUrl>
-{
- QUrl m;
-public:
- to(const QVariant &v)
- {
- m.setPath(v.toString());
- }
- operator QUrl() const
- {
- return m;
- }
-};
-
-template <typename T>
-class to< QList<T> >
-{
- QList<T> m;
-public:
- to(const QVariant &v)
- {
- const QList<QVariant> vl = v.toList();
- for (QList<QVariant>::const_iterator it = vl.begin(), end = vl.end(); it != end; ++it) {
- m.push_back(to<T>(*it));
- }
- }
- operator QList<T> () const
- {
- return m;
- }
-};
-
-template <typename T>
-class to< std::vector<T> >
-{
- std::vector<T> m;
-public:
- to(const QVariant &v)
- {
- const QList<QVariant> vl = v.toList();
- m.reserve(m.size() + vl.size());
- for (QList<QVariant>::const_iterator it = vl.begin(), end = vl.end(); it != end; ++it) {
- m.push_back(to<T>(*it));
- }
- }
- operator std::vector<T> () const
- {
- return m;
- }
-};
-
-// from<> is the demarshaller. See to<> for why this is a class...
-
-template <typename T>
-struct from_helper : public QVariant {
- from_helper(const T &t) : QVariant(t) {}
-};
-
-template <typename T>
-QVariant from(const T &t)
-{
- return from_helper<T>(t);
-}
-
-// some special types:
-template <> struct from_helper<bool> : public QVariant {
- from_helper(bool b) : QVariant(b) {}
-};
-template <> struct from_helper<QUrl> : public QVariant {
- from_helper(const QUrl &url) : QVariant(url.path()) {}
-};
-template <typename T> struct from_helper< QList<T> > : public QVariant {
- from_helper(const QList<T> &l)
- {
- QList<QVariant> result;
- for (typename QList<T>::const_iterator it = l.begin(), end = l.end(); it != end; ++it) {
- result.push_back(from(*it));
- }
- QVariant::operator=(result);
- }
-};
-template <typename T> struct from_helper< std::vector<T> > : public QVariant {
- from_helper(const std::vector<T> &l)
- {
- QList<QVariant> result;
- for (typename std::vector<T>::const_iterator it = l.begin(), end = l.end(); it != end; ++it) {
- result.push_back(from(*it));
- }
- QVariant::operator=(result);
- }
-};
-
-class ChiasmusConfigEntry : public Kleo::CryptoConfigEntry
-{
- unsigned int mIdx;
- QVariant mValue;
- bool mDirty;
-public:
- ChiasmusConfigEntry(unsigned int i)
- : Kleo::CryptoConfigEntry(),
- mIdx(i), mValue(defaultValue()), mDirty(false)
- {
- assert(i < kleo_chiasmus_config_entries_dim);
- }
- QString name() const Q_DECL_OVERRIDE
- {
- return QLatin1String(kleo_chiasmus_config_entries[mIdx].name);
- }
- QString description() const Q_DECL_OVERRIDE
- {
- return i18n(kleo_chiasmus_config_entries[mIdx].description);
- }
- QString path() const Q_DECL_OVERRIDE
- {
- return name();
- }
- bool isOptional() const Q_DECL_OVERRIDE
- {
- return kleo_chiasmus_config_entries[mIdx].is_optional;
- }
- bool isReadOnly() const Q_DECL_OVERRIDE
- {
- return false;
- }
- bool isList() const Q_DECL_OVERRIDE
- {
- return kleo_chiasmus_config_entries[mIdx].is_list;
- }
- bool isRuntime() const Q_DECL_OVERRIDE
- {
- return kleo_chiasmus_config_entries[mIdx].is_runtime;
- }
- Level level() const Q_DECL_OVERRIDE
- {
- return static_cast<Level>(kleo_chiasmus_config_entries[mIdx].level);
- }
- ArgType argType() const Q_DECL_OVERRIDE
- {
- return static_cast<ArgType>(kleo_chiasmus_config_entries[mIdx].type);
- }
- bool isSet() const Q_DECL_OVERRIDE
- {
- return mValue != defaultValue();
- }
- bool boolValue() const Q_DECL_OVERRIDE
- {
- return mValue.toBool();
- }
- QString stringValue() const Q_DECL_OVERRIDE
- {
- return mValue.toString();
- }
- int intValue() const Q_DECL_OVERRIDE
- {
- return mValue.toInt();
- }
- unsigned int uintValue() const Q_DECL_OVERRIDE
- {
- return mValue.toUInt();
- }
- QUrl urlValue() const Q_DECL_OVERRIDE
- {
- Q_ASSERT(argType() == ArgType_Path || argType() == ArgType_DirPath);
- return QUrl::fromLocalFile(mValue.toString());
- }
- unsigned int numberOfTimesSet() const Q_DECL_OVERRIDE
- {
- return 0;
- }
- std::vector<int> intValueList() const Q_DECL_OVERRIDE
- {
- return to< std::vector<int> >(mValue);
- }
- std::vector<unsigned int> uintValueList() const Q_DECL_OVERRIDE
- {
- return to< std::vector<unsigned int> >(mValue);
- }
- QList<QUrl> urlValueList() const Q_DECL_OVERRIDE
- {
- return to< QList<QUrl> >(mValue);
- }
- void resetToDefault() Q_DECL_OVERRIDE {
- mValue = defaultValue();
- mDirty = false;
- }
- void setBoolValue(bool value) Q_DECL_OVERRIDE {
- setValue(QVariant(value));
- }
- void setStringValue(const QString &value) Q_DECL_OVERRIDE {
- setValue(value);
- }
- void setIntValue(int value) Q_DECL_OVERRIDE {
- setValue(value);
- }
- void setUIntValue(unsigned int value) Q_DECL_OVERRIDE {
- setValue(value);
- }
- void setURLValue(const QUrl &value) Q_DECL_OVERRIDE {
- if (argType() != ArgType_Path)
- {
- setValue(value.url());
- } else {
- setValue(value.path());
- }
- }
- void setNumberOfTimesSet(unsigned int) Q_DECL_OVERRIDE {}
- void setIntValueList(const std::vector<int> &l) Q_DECL_OVERRIDE {
- setValue(from(l));
- }
- void setUIntValueList(const std::vector<unsigned int> &l) Q_DECL_OVERRIDE {
- setValue(from(l));
- }
- void setURLValueList(const QList<QUrl> &l) Q_DECL_OVERRIDE {
- setValue(from(l));
- }
- bool isDirty() const Q_DECL_OVERRIDE
- {
- return mDirty;
- }
-
- QVariant value() const
- {
- return mValue;
- }
-
- void sync(KConfigGroup config)
- {
- if (!mDirty) {
- return;
- }
- mDirty = false;
- config.writeEntry(kleo_chiasmus_config_entries[mIdx].name, mValue);
- }
- void read(const KConfigGroup &config)
- {
- mDirty = false;
- mValue = config.readEntry(kleo_chiasmus_config_entries[mIdx].name, defaultValue());
- }
-private:
- QVariant defaultValue() const;
- void setValue(const QVariant &value)
- {
- mValue = value;
- mDirty = true;
- }
-};
-
-QVariant ChiasmusConfigEntry::defaultValue() const
-{
- const kleo_chiasmus_config_data &data = kleo_chiasmus_config_entries[mIdx];
- switch (data.type) {
- default:
- return QVariant();
- case ArgType_None:
- if (isList()) {
- return QList<QVariant>() << QVariant(data.defaults.boolean.value);
- } else {
- return QVariant(data.defaults.boolean.value);
- }
- case ArgType_String:
- if (isList()) {
- return QStringList(QString::fromLatin1(data.defaults.string));
- } else {
- return QString::fromLatin1(data.defaults.string);
- }
- case ArgType_Int:
- if (isList()) {
- return QList<QVariant>() << data.defaults.integer;
- } else {
- return data.defaults.integer;
- }
- case ArgType_UInt:
- if (isList()) {
- return QList<QVariant>() << data.defaults.unsigned_integer;
- } else {
- return data.defaults.unsigned_integer;
- }
- case ArgType_Path:
- case ArgType_DirPath:
- if (isList()) {
- return QList<QVariant>() << QString::fromLatin1(data.defaults.path);
- } else {
- return QString::fromLatin1(data.defaults.path);
- }
- case ArgType_LDAPURL:
- if (isList()) {
- return QList<QVariant>() << QString::fromLatin1(data.defaults.url);
- } else {
- return QString::fromLatin1(data.defaults.url);
- }
- }
-}
-
-class ChiasmusGeneralGroup : public Kleo::CryptoConfigGroup
-{
- mutable std::map<QString, ChiasmusConfigEntry *> mCache;
- mutable KConfig *mConfigObject;
-public:
- ChiasmusGeneralGroup() : Kleo::CryptoConfigGroup(), mConfigObject(0) {}
- ~ChiasmusGeneralGroup()
- {
- clear();
- delete mConfigObject;
- }
- QString name() const Q_DECL_OVERRIDE
- {
- return QStringLiteral("General");
- }
- QString iconName() const Q_DECL_OVERRIDE
- {
- return QStringLiteral("chiasmus_chi");
- }
- QString path() const Q_DECL_OVERRIDE
- {
- return QString();
- }
- QString description() const Q_DECL_OVERRIDE
- {
- return i18n("General");
- }
- Kleo::CryptoConfigEntry::Level level() const Q_DECL_OVERRIDE
- {
- return Kleo::CryptoConfigEntry::Level_Basic;
- }
- QStringList entryList() const Q_DECL_OVERRIDE
- {
- QStringList result;
- for (unsigned int i = 0; i < kleo_chiasmus_config_entries_dim; ++i) {
- result.push_back(QLatin1String(kleo_chiasmus_config_entries[i].name));
- }
- return result;
- }
- Kleo::CryptoConfigEntry *entry(const QString &name) const Q_DECL_OVERRIDE
- {
- if (ChiasmusConfigEntry *entry = mCache[name]) {
- return entry;
- }
- const KConfigGroup group(configObject(), "Chiasmus");
- for (unsigned int i = 0; i < kleo_chiasmus_config_entries_dim; ++i)
- if (name == QLatin1String(kleo_chiasmus_config_entries[i].name)) {
- ChiasmusConfigEntry *entry = new ChiasmusConfigEntry(i);
- entry->read(group);
- return mCache[name] = entry;
- }
- return 0;
- }
-
- void sync()
- {
- KConfigGroup group(configObject(), "Chiasmus");
- for (std::map<QString, ChiasmusConfigEntry *>::const_iterator it = mCache.begin(), end = mCache.end(); it != end; ++it) {
- it->second->sync(group);
- }
- group.sync();
- clear();
- }
-private:
- KConfig *configObject() const
- {
- if (!mConfigObject)
- // this is unsafe. We're a lib, used by concurrent apps.
- {
- mConfigObject = new KConfig(QStringLiteral("chiasmusbackendrc"));
- }
- return mConfigObject;
- }
- void clear()
- {
- for (std::map<QString, ChiasmusConfigEntry *>::const_iterator it = mCache.begin(), end = mCache.end(); it != end; ++it) {
- delete it->second;
- }
- mCache.clear();
- }
-};
-
-class ChiasmusComponent : public Kleo::CryptoConfigComponent
-{
- mutable ChiasmusGeneralGroup *mGeneralGroup;
-public:
- ChiasmusComponent() : Kleo::CryptoConfigComponent(), mGeneralGroup(0) {}
- ~ChiasmusComponent()
- {
- delete mGeneralGroup;
- }
-
- void sync()
- {
- if (mGeneralGroup) {
- mGeneralGroup->sync();
- }
- }
-
- QString name() const Q_DECL_OVERRIDE
- {
- return QStringLiteral("Chiasmus");
- }
- QString iconName() const Q_DECL_OVERRIDE
- {
- return QStringLiteral("chiasmus_chi");
- }
- QString description() const Q_DECL_OVERRIDE
- {
- return i18n("Chiasmus");
- }
- QStringList groupList() const Q_DECL_OVERRIDE
- {
- return QStringList() << QStringLiteral("General");
- }
- Kleo::CryptoConfigGroup *group(const QString &name) const Q_DECL_OVERRIDE
- {
- if (name != QLatin1String("General")) {
- return 0;
- }
- if (!mGeneralGroup) {
- mGeneralGroup = new ChiasmusGeneralGroup();
- }
- return mGeneralGroup;
- }
-};
-
-}
-
-class Kleo::ChiasmusBackend::CryptoConfig : public Kleo::CryptoConfig
-{
- mutable ChiasmusComponent *mComponent;
-public:
- CryptoConfig() : Kleo::CryptoConfig(), mComponent(0) {}
- ~CryptoConfig()
- {
- delete mComponent;
- }
-
- QStringList componentList() const Q_DECL_OVERRIDE
- {
- return QStringList() << QStringLiteral("Chiasmus");
- }
- ChiasmusComponent *component(const QString &name) const Q_DECL_OVERRIDE
- {
- if (name != QLatin1String("Chiasmus")) {
- return 0;
- }
- if (!mComponent) {
- mComponent = new ChiasmusComponent();
- }
- return mComponent;
- }
- void sync(bool) Q_DECL_OVERRIDE {
- if (mComponent)
- {
- mComponent->sync();
- }
- }
- void clear() Q_DECL_OVERRIDE {
- delete mComponent;
- mComponent = 0;
- }
-};
-
-class Kleo::ChiasmusBackend::Protocol : public Kleo::CryptoBackend::Protocol
-{
- Kleo::CryptoConfig *mCryptoConfig;
-public:
- Protocol(Kleo::CryptoConfig *config)
- : Kleo::CryptoBackend::Protocol(), mCryptoConfig(config)
- {
- assert(config);
- }
- ~Protocol() {}
-
- QString name() const Q_DECL_OVERRIDE
- {
- return QStringLiteral("Chiasmus");
- }
- QString displayName() const Q_DECL_OVERRIDE
- {
- return i18n("Chiasmus command line tool");
- }
- KeyListJob *keyListJob(bool, bool, bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- ListAllKeysJob *listAllKeysJob(bool, bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- EncryptJob *encryptJob(bool, bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- DecryptJob *decryptJob() const Q_DECL_OVERRIDE
- {
- return 0;
- }
- SignJob *signJob(bool, bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- VerifyDetachedJob *verifyDetachedJob(bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- VerifyOpaqueJob *verifyOpaqueJob(bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- KeyGenerationJob *keyGenerationJob() const Q_DECL_OVERRIDE
- {
- return 0;
- }
- ImportFromKeyserverJob *importFromKeyserverJob() const Q_DECL_OVERRIDE
- {
- return 0;
- }
- ImportJob *importJob() const Q_DECL_OVERRIDE
- {
- return 0;
- }
- ExportJob *publicKeyExportJob(bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- ExportJob *secretKeyExportJob(bool, const QString &) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- DownloadJob *downloadJob(bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- DeleteJob *deleteJob() const Q_DECL_OVERRIDE
- {
- return 0;
- }
- SignEncryptJob *signEncryptJob(bool, bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- DecryptVerifyJob *decryptVerifyJob(bool) const Q_DECL_OVERRIDE
- {
- return 0;
- }
- RefreshKeysJob *refreshKeysJob() const Q_DECL_OVERRIDE
- {
- return 0;
- }
-
- SpecialJob *specialJob(const char *type, const QMap<QString, QVariant> &args) const Q_DECL_OVERRIDE
- {
- if (qstricmp(type, "x-obtain-keys") == 0 && args.size() == 0) {
- return new ObtainKeysJob();
- }
- if (qstricmp(type, "x-encrypt") == 0 && args.size() == 0) {
- return new ChiasmusJob(ChiasmusJob::Encrypt);
- }
- if (qstricmp(type, "x-decrypt") == 0 && args.size() == 0) {
- return new ChiasmusJob(ChiasmusJob::Decrypt);
- }
- qDebug() << "ChiasmusBackend::Protocol: tried to instantiate unknown job type \""
- << type << "\"";
-
- return 0;
- }
-
- Kleo::KeyListJob *locateKeysJob() const Q_DECL_OVERRIDE
- {
- return 0;
- }
-
- Kleo::KeyForMailboxJob *keyForMailboxJob() const Q_DECL_OVERRIDE
- {
- return 0;
- }
-};
-
-Kleo::ChiasmusBackend *Kleo::ChiasmusBackend::self = 0;
-
-Kleo::ChiasmusBackend::ChiasmusBackend()
- : Kleo::CryptoBackend(),
- mCryptoConfig(0),
- mProtocol(0)
-{
- self = this;
-}
-
-Kleo::ChiasmusBackend::~ChiasmusBackend()
-{
- self = 0;
- delete mCryptoConfig;
- delete mProtocol;
-}
-
-QString Kleo::ChiasmusBackend::name() const
-{
- return QStringLiteral("Chiasmus");
-}
-
-QString Kleo::ChiasmusBackend::displayName() const
-{
- return i18n("Chiasmus");
-}
-
-Kleo::CryptoConfig *Kleo::ChiasmusBackend::config() const
-{
- if (!mCryptoConfig) {
- mCryptoConfig = new CryptoConfig();
- }
- return mCryptoConfig;
-}
-
-Kleo::CryptoBackend::Protocol *Kleo::ChiasmusBackend::protocol(const char *name) const
-{
- if (qstricmp(name, "Chiasmus") != 0) {
- return 0;
- }
- if (!mProtocol)
- if (checkForChiasmus()) {
- mProtocol = new Protocol(config());
- }
- return mProtocol;
-}
-
-bool Kleo::ChiasmusBackend::checkForOpenPGP(QString *reason) const
-{
- if (reason) {
- *reason = i18n("Unsupported protocol \"%1\"", QStringLiteral("OpenPGP"));
- }
- return false;
-}
-
-bool Kleo::ChiasmusBackend::checkForSMIME(QString *reason) const
-{
- if (reason) {
- *reason = i18n("Unsupported protocol \"%1\"", QStringLiteral("SMIME"));
- }
- return false;
-}
-
-bool Kleo::ChiasmusBackend::checkForChiasmus(QString *reason) const
-{
-
- // kills the protocol instance when we return false:
- std::unique_ptr<Protocol> tmp(mProtocol);
- mProtocol = 0;
-
- const CryptoConfigEntry *path = config()->entry(QStringLiteral("Chiasmus"), QStringLiteral("General"), QStringLiteral("path"));
- assert(path); assert(path->argType() == CryptoConfigEntry::ArgType_Path);
- const QString chiasmus = path->urlValue().path();
- const QFileInfo fi(KShell::tildeExpand(chiasmus));
- if (!fi.isExecutable()) {
- if (reason) {
- *reason = i18n("File \"%1\" does not exist or is not executable.", chiasmus);
- }
- return false;
- }
-
- // FIXME: more checks?
- mProtocol = tmp.release();
- return true;
-}
-
-bool Kleo::ChiasmusBackend::checkForProtocol(const char *name, QString *reason) const
-{
- if (qstricmp(name, "Chiasmus") == 0) {
- return checkForChiasmus(reason);
- }
- if (reason) {
- *reason = i18n("Unsupported protocol \"%1\"", QLatin1String(name));
- }
- return 0;
-}
-
-bool Kleo::ChiasmusBackend::supportsProtocol(const char *name) const
-{
- return qstricmp(name, "Chiasmus") == 0;
-}
-
-const char *Kleo::ChiasmusBackend::enumerateProtocols(int i) const
-{
- return i == 0 ? "Chiasmus" : 0;
-}
diff --git a/src/backends/chiasmus/chiasmusbackend.h b/src/backends/chiasmus/chiasmusbackend.h
deleted file mode 100644
index 90a4701..0000000
--- a/src/backends/chiasmus/chiasmusbackend.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- chiasmusbackend.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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_CHIASMUSBACKEND_H__
-#define __KLEO_CHIASMUSBACKEND_H__
-
-#include "libkleo/cryptobackend.h"
-
-namespace Kleo
-{
-class CryptoConfig;
-}
-class QString;
-
-namespace Kleo
-{
-
-class ChiasmusBackend : public Kleo::CryptoBackend
-{
-public:
- ChiasmusBackend();
- ~ChiasmusBackend();
-
- static const ChiasmusBackend *instance()
- {
- return self;
- }
-
- QString name() const Q_DECL_OVERRIDE;
- QString displayName() const Q_DECL_OVERRIDE;
-
- Kleo::CryptoConfig *config() const Q_DECL_OVERRIDE;
-
- Kleo::CryptoBackend::Protocol *openpgp() const Q_DECL_OVERRIDE
- {
- return 0;
- }
- Kleo::CryptoBackend::Protocol *smime() const Q_DECL_OVERRIDE
- {
- return 0;
- }
- Kleo::CryptoBackend::Protocol *protocol(const char *name) const Q_DECL_OVERRIDE;
-
- bool checkForOpenPGP(QString *reason = Q_NULLPTR) const Q_DECL_OVERRIDE;
- bool checkForSMIME(QString *reason = Q_NULLPTR) const Q_DECL_OVERRIDE;
- bool checkForChiasmus(QString *reason = Q_NULLPTR) const;
- bool checkForProtocol(const char *name, QString *reason = Q_NULLPTR) const Q_DECL_OVERRIDE;
-
- bool supportsOpenPGP() const Q_DECL_OVERRIDE
- {
- return false;
- }
- bool supportsSMIME() const Q_DECL_OVERRIDE
- {
- return false;
- }
- bool supportsProtocol(const char *name) const Q_DECL_OVERRIDE;
-
- const char *enumerateProtocols(int i) const Q_DECL_OVERRIDE;
-
-private:
- class CryptoConfig;
- class Protocol;
- mutable CryptoConfig *mCryptoConfig;
- mutable Protocol *mProtocol;
- static ChiasmusBackend *self;
-};
-
-}
-
-#endif // __KLEO_CHIASMUSBACKEND_H__
diff --git a/src/backends/chiasmus/chiasmusjob.cpp b/src/backends/chiasmus/chiasmusjob.cpp
deleted file mode 100644
index 3928e5d..0000000
--- a/src/backends/chiasmus/chiasmusjob.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- chiasmusjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 Klar�vdalens 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.
-*/
-
-#include "chiasmusjob.h"
-#include "chiasmusbackend.h"
-#include "symcryptrunprocessbase.h"
-
-#include "libkleo/cryptoconfig.h"
-
-#include <gpgme++/error.h>
-
-#include <kshell.h>
-#include <KLocalizedString>
-#include <QDebug>
-#include <kmessagebox.h>
-
-#include <QTimer>
-#include <QVariant>
-
-#include <memory>
-
-#include <cassert>
-
-using namespace GpgME;
-
-Kleo::ChiasmusJob::ChiasmusJob(Mode mode)
- : Kleo::SpecialJob(0),
- mSymCryptRun(0),
- mError(0),
- mCanceled(false),
- mTimeout(false),
- mMode(mode)
-{
-
-}
-
-Kleo::ChiasmusJob::~ChiasmusJob() {}
-
-GpgME::Error Kleo::ChiasmusJob::setup()
-{
- if (!checkPreconditions()) {
- return mError = Error::fromCode(GPG_ERR_INV_VALUE);
- }
-
- const Kleo::CryptoConfigEntry *class_
- = ChiasmusBackend::instance()->config()->entry(QStringLiteral("Chiasmus"), QStringLiteral("General"), QStringLiteral("symcryptrun-class"));
- const Kleo::CryptoConfigEntry *chiasmus
- = ChiasmusBackend::instance()->config()->entry(QStringLiteral("Chiasmus"), QStringLiteral("General"), QStringLiteral("path"));
- const Kleo::CryptoConfigEntry *timeoutEntry
- = ChiasmusBackend::instance()->config()->entry(QStringLiteral("Chiasmus"), QStringLiteral("General"), QStringLiteral("timeout"));
- if (!class_ || !chiasmus || !timeoutEntry) {
- return mError = Error::fromCode(GPG_ERR_INTERNAL);
- }
-
- mSymCryptRun = new SymCryptRunProcessBase(class_->stringValue(),
- KShell::tildeExpand(chiasmus->urlValue().path()),
- mKey, mOptions,
- mMode == Encrypt
- ? SymCryptRunProcessBase::Encrypt
- : SymCryptRunProcessBase::Decrypt,
- this);
- mSymCryptRun->setObjectName(QStringLiteral("symcryptrun"));
- QTimer::singleShot(timeoutEntry->uintValue() * 1000, this,
- &ChiasmusJob::slotTimeout);
- return GpgME::Error();
-}
-
-namespace
-{
-struct LaterDeleter {
- QObject *_this;
- LaterDeleter(QObject *o) : _this(o) {}
- ~LaterDeleter()
- {
- if (_this) {
- _this->deleteLater();
- }
- }
- void disable()
- {
- _this = 0;
- }
-};
-}
-
-GpgME::Error Kleo::ChiasmusJob::start()
-{
-
- LaterDeleter d(this);
-
- if (const GpgME::Error err = setup()) {
- return mError = err;
- }
-
- connect(mSymCryptRun, SIGNAL(finished(int,QProcess::ExitStatus)),
- this, SLOT(finished()));
-
- if (!mSymCryptRun->launch(mInput)) {
- return mError = Error::fromCode(GPG_ERR_ENOENT); // what else?
- }
-
- d.disable();
- return mError = GpgME::Error();
-}
-
-GpgME::Error Kleo::ChiasmusJob::finished()
-{
- if (!mSymCryptRun) {
- mError = Error::fromCode(GPG_ERR_INTERNAL);
- } else if (mCanceled) {
- mError = Error::fromCode(GPG_ERR_CANCELED);
- } else if (mTimeout) {
- mError = Error::fromCode(GPG_ERR_TIMEOUT);
- } else if (mSymCryptRun->exitStatus() != QProcess::NormalExit) {
- mError = Error::fromCode(GPG_ERR_GENERAL);
- } else
- switch (mSymCryptRun->exitCode()) {
- case 0: // success
- mOutput = mSymCryptRun->output();
- mError = GpgME::Error();
- break;
- default:
- case 1: // Some error occurred
- mStderr = mSymCryptRun->stdErr();
- mError = Error::fromCode(GPG_ERR_GENERAL);
- break;
- case 2: // No valid passphrase was provided
- mError = Error::fromCode(GPG_ERR_INV_PASSPHRASE);
- break;
- case 3: // Canceled
- mError = Error::fromCode(GPG_ERR_CANCELED);
- break;
- }
-
- const Kleo::CryptoConfigEntry *showOutput
- = ChiasmusBackend::instance()->config()->entry(QStringLiteral("Chiasmus"), QStringLiteral("General"), QStringLiteral("show-output"));
- if (showOutput && showOutput->boolValue()) {
- showChiasmusOutput();
- }
-
- Q_EMIT done();
- Q_EMIT SpecialJob::result(mError, QVariant(mOutput));
- return mError;
-}
-
-void Kleo::ChiasmusJob::showChiasmusOutput()
-{
- qDebug();
- if (mStderr.isEmpty()) {
- return;
- }
- KMessageBox::information(0 /*how to get a parent widget?*/,
- mStderr,
- i18n("Output from chiasmus"));
-}
-
-GpgME::Error Kleo::ChiasmusJob::exec()
-{
- if (const GpgME::Error err = setup()) {
- return mError = err;
- }
-
- if (!mSymCryptRun->launch(mInput, true)) {
- delete mSymCryptRun; mSymCryptRun = 0;
- return mError = Error::fromCode(GPG_ERR_ENOENT); // what else?
- }
-
- const GpgME::Error err = finished();
- delete mSymCryptRun; mSymCryptRun = 0;
- return err;
-}
-
-bool Kleo::ChiasmusJob::checkPreconditions() const
-{
- return !mKey.isEmpty();
-}
-
-void Kleo::ChiasmusJob::slotCancel()
-{
- if (mSymCryptRun) {
- mSymCryptRun->kill();
- }
- mCanceled = true;
-}
-
-void Kleo::ChiasmusJob::slotTimeout()
-{
- if (!mSymCryptRun) {
- return;
- }
- mSymCryptRun->kill();
- mTimeout = true;
-}
-
-void Kleo::ChiasmusJob::showErrorDialog(QWidget *parent, const QString &caption) const
-{
- if (!mError) {
- return;
- }
- if (mError.isCanceled()) {
- return;
- }
- const QString reason = QString::fromLocal8Bit(mError.asString());
- const QString msg = (mMode == Encrypt
- ? i18n("Encryption failed: %1", reason)
- : i18n("Decryption failed: %1", reason));
- if (!mStderr.isEmpty()) {
- const QString details = i18n("The following was received on stderr:\n%1", mStderr);
- KMessageBox::detailedError(parent, msg, details, caption);
- } else {
- KMessageBox::error(parent, msg, caption);
- }
-}
-
diff --git a/src/backends/chiasmus/chiasmusjob.h b/src/backends/chiasmus/chiasmusjob.h
deleted file mode 100644
index a5d5c52..0000000
--- a/src/backends/chiasmus/chiasmusjob.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- chiasmusjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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_CHIASMUSJOB_H__
-#define __KLEO_CHIASMUSJOB_H__
-
-#include "libkleo/specialjob.h"
-
-#include <gpgme++/context.h>
-
-namespace Kleo
-{
-
-class SymCryptRunProcessBase;
-
-/**
- @short SpecialJob for Chiasmus operations
-*/
-class ChiasmusJob : public Kleo::SpecialJob
-{
- Q_OBJECT
- Q_ENUMS(Mode)
- Q_PROPERTY(Mode mode READ mode)
- Q_PROPERTY(QString key READ key WRITE setKey)
- Q_PROPERTY(QString options READ options WRITE setOptions)
- Q_PROPERTY(QByteArray input READ input WRITE setInput)
- Q_PROPERTY(QByteArray result READ result)
-public:
- enum Mode {
- Encrypt, Decrypt
- };
- explicit ChiasmusJob(Mode op);
- ~ChiasmusJob();
-
- /*!\reimp SpecialJob */
- GpgME::Error start() Q_DECL_OVERRIDE;
- /*!\reimp SpecialJob */
- GpgME::Error exec() Q_DECL_OVERRIDE;
-
- /*!\reimp Kleo::Job */
- void showErrorDialog(QWidget *, const QString &) const Q_DECL_OVERRIDE;
-
- Mode mode() const
- {
- return mMode;
- }
-
- QString key() const
- {
- return mKey;
- }
- void setKey(const QString &key)
- {
- mKey = key;
- }
-
- QString options() const
- {
- return mOptions;
- }
- void setOptions(const QString &options)
- {
- mOptions = options;
- }
-
- QByteArray input() const
- {
- return mInput;
- }
- void setInput(const QByteArray &input)
- {
- mInput = input;
- }
-
- //using SpecialJob::result;
- QByteArray result() const
- {
- return mOutput;
- }
-
-public Q_SLOTS:
- void slotCancel() Q_DECL_OVERRIDE;
-
-private Q_SLOTS:
- GpgME::Error finished();
- void slotTimeout();
-
-private:
- bool checkPreconditions() const;
- GpgME::Error setup();
- void showChiasmusOutput();
-
-private:
- SymCryptRunProcessBase *mSymCryptRun;
- QString mKey;
- QString mOptions;
- QByteArray mInput, mOutput;
- GpgME::Error mError;
- QString mStderr;
- bool mCanceled;
- bool mTimeout;
- const Mode mMode;
-};
-
-}
-
-#endif // __KLEO_CHIASMUSJOB_H__
diff --git a/src/backends/chiasmus/chiasmuslibrary.cpp b/src/backends/chiasmus/chiasmuslibrary.cpp
deleted file mode 100644
index d025317..0000000
--- a/src/backends/chiasmus/chiasmuslibrary.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- chiasmuslibrary.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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.
-*/
-
-#include "chiasmuslibrary.h"
-
-#include "chiasmusbackend.h"
-
-#include "libkleo/cryptoconfig.h"
-
-#include <QDebug>
-#include <KLocalizedString>
-
-#include <QByteArray>
-#include <QLibrary>
-
-#include <vector>
-#include <algorithm>
-
-#include <cassert>
-#include <cstdlib>
-#include <cstring>
-
-Kleo::ChiasmusLibrary *Kleo::ChiasmusLibrary::self = 0;
-
-Kleo::ChiasmusLibrary::ChiasmusLibrary() : mXiaLibrary(0)
-{
- self = this;
-}
-
-Kleo::ChiasmusLibrary::~ChiasmusLibrary()
-{
- //delete mXiaLibrary; // hmm, how to get rid of it, then?
-}
-
-Kleo::ChiasmusLibrary::main_func Kleo::ChiasmusLibrary::chiasmus(QString *reason) const
-{
- assert(ChiasmusBackend::instance());
- assert(ChiasmusBackend::instance()->config());
- const CryptoConfigEntry *lib = ChiasmusBackend::instance()->config()->entry(QStringLiteral("Chiasmus"), QStringLiteral("General"), QStringLiteral("lib"));
- assert(lib);
- const QString libfile = lib->urlValue().path();
- if (!mXiaLibrary) {
- mXiaLibrary = new QLibrary(libfile);
- }
- if (mXiaLibrary->fileName().isEmpty() || !mXiaLibrary->isLoaded()) {
- if (reason)
- *reason = i18n("Failed to load %1: %2",
- libfile, mXiaLibrary->errorString());
- qDebug() << "ChiasmusLibrary: loading \"" << libfile
- << "\" failed:" << mXiaLibrary->errorString();
- delete mXiaLibrary;
- mXiaLibrary = 0;
- return 0;
- }
- QFunctionPointer symbol = mXiaLibrary->resolve("Chiasmus");
- if (!symbol) {
- if (reason)
- *reason = i18n("Failed to load %1: %2",
- libfile, i18n("Library does not contain the symbol \"Chiasmus\"."));
- qDebug() << "ChiasmusLibrary: loading \"" << libfile
- << "\" failed: " << "Library does not contain the symbol \"Chiasmus\".";
- delete mXiaLibrary;
- mXiaLibrary = 0;
- return 0;
- }
-
- assert(symbol);
- return (main_func)symbol;
-}
-
-namespace
-{
-class ArgvProvider
-{
- char **mArgv;
- int mArgc;
-public:
- ArgvProvider(const QVector<QByteArray> &args)
- {
- mArgv = new char *[args.size()];
- for (int i = 0; i < args.size(); ++i) {
- mArgv[i] = strdup(args[i].data());
- }
- }
- ~ArgvProvider()
- {
- std::for_each(mArgv, mArgv + mArgc, std::free);
- delete[] mArgv;
- }
- char **argv() const
- {
- return mArgv;
- }
-};
-}
-
-int Kleo::ChiasmusLibrary::perform(const QVector<QByteArray> &args) const
-{
- if (main_func func = chiasmus()) {
- return func(args.size(), ArgvProvider(args).argv());
- } else {
- return -1;
- }
-}
diff --git a/src/backends/chiasmus/chiasmuslibrary.h b/src/backends/chiasmus/chiasmuslibrary.h
deleted file mode 100644
index fc8c7c8..0000000
--- a/src/backends/chiasmus/chiasmuslibrary.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- chiasmuslibrary.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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_CHIASMUSLIBRARY_H__
-#define __KLEO_CHIASMUSLIBRARY_H__
-
-#include <qvector.h>
-#include <qbytearray.h>
-
-class QLibrary;
-
-namespace Kleo
-{
-
-/**
- @short small helper class to load xia.o through xia.so and make
- the functionality available.
-*/
-class ChiasmusLibrary
-{
- ChiasmusLibrary();
- ~ChiasmusLibrary();
-public:
- static const ChiasmusLibrary *instance();
- static void deleteInstance();
-
- int perform(const QVector<QByteArray> &args) const;
-private:
- typedef int (*main_func)(int, char **);
- main_func chiasmus(QString *reason = Q_NULLPTR) const;
-
-private:
- static ChiasmusLibrary *self;
- mutable QLibrary *mXiaLibrary;
-};
-
-}
-
-#endif // __KLEO_CHIASMUSLIBRARY_H__
diff --git a/src/backends/chiasmus/config-chiasmus.h.cmake b/src/backends/chiasmus/config-chiasmus.h.cmake
deleted file mode 100644
index 18297a2..0000000
--- a/src/backends/chiasmus/config-chiasmus.h.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Define to 1 if your C compiler support C99 designated initializers */
-#cmakedefine HAVE_C99_INITIALIZERS 1
diff --git a/src/backends/chiasmus/config_data.c b/src/backends/chiasmus/config_data.c
deleted file mode 100644
index 13d36ba..0000000
--- a/src/backends/chiasmus/config_data.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- config_data.c
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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.
-*/
-
-/* include "config-chiasmus.h" */
-#include "config_data.h"
-
-#include "kleo/cryptoconfig.h" /* for the enum values */
-
-/*
- This data structure uses C99 designated initializers. This is why
- it's in a .c file, and not in a .cpp file. If your compiler doesn't
- like this, just don't compile Chiasmus support, or live without the
- wrapper option :) Sorry.
-*/
-
-#ifdef PATH
-# undef PATH
-#endif
-#ifdef HAVE_C99_INITIALIZERS
-# define PATH .path =
-#else
-# define PATH
-#endif
-
-#define I18N_NOOP(x) (x)
-
-const struct kleo_chiasmus_config_data kleo_chiasmus_config_entries[] = {
- {
- "path", I18N_NOOP("Path to Chiasmus executable"),
- Level_Basic, ArgType_Path,
- { PATH "/usr/local/bin/chiasmus" }, /* in the absence of C99, we assume path is first in the union here */
- 0, 0, 1
- },
- {
- "keydir", I18N_NOOP("Key directory"),
- Level_Basic, ArgType_DirPath,
- { PATH "~/.chiasmus/keys" },
- 0, 0, 1 /* FIXME: should be a list */
- },
-#ifdef HAVE_C99_INITIALIZERS
- {
- "show-output", I18N_NOOP("Show output from chiasmus operations"),
- Level_Expert, ArgType_None,
- { .boolean = { .value = 0, .numTimesSet = 0 } },
- 0, 0, 1
- },
- {
- "symcryptrun-class", I18N_NOOP("SymCryptRun class to use"),
- Level_Expert, ArgType_String,
- { .string = "confucius" },
- 0, 0, 1
- },
- {
- "timeout", I18N_NOOP("Timeout in seconds for Chiasmus operations"),
- Level_Advanced, ArgType_UInt,
- { .unsigned_integer = 60 },
- 0, 0, 1
- },
-#endif /* HAVE_C99_INITIALIZERS */
-};
-const unsigned int kleo_chiasmus_config_entries_dim
- = sizeof kleo_chiasmus_config_entries / sizeof * kleo_chiasmus_config_entries;
-
diff --git a/src/backends/chiasmus/config_data.h b/src/backends/chiasmus/config_data.h
deleted file mode 100644
index c5576df..0000000
--- a/src/backends/chiasmus/config_data.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- config_data.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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__CHIASMUS_CONFIG_DATA_H__
-#define __KLEO__CHIASMUS_CONFIG_DATA_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct kleo_chiasmus_config_data {
- const char *name;
- const char *description;
- int level;
- int type;
- union {
- const char *path; /* must be first, see config_data.c */
- const char *string;
- const char *url;
- struct {
- unsigned int value : 1;
- unsigned int numTimesSet : 31;
- } boolean;
- int integer;
- unsigned int unsigned_integer;
- } defaults;
- unsigned int is_optional : 1;
- unsigned int is_list : 1;
- unsigned int is_runtime : 1;
-};
-
-extern const struct kleo_chiasmus_config_data kleo_chiasmus_config_entries[];
-extern const unsigned int kleo_chiasmus_config_entries_dim;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __KLEO__CHIASMUS_CONFIG_DATA_H__ */
-
diff --git a/src/backends/chiasmus/obtainkeysjob.cpp b/src/backends/chiasmus/obtainkeysjob.cpp
deleted file mode 100644
index aa468bc..0000000
--- a/src/backends/chiasmus/obtainkeysjob.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- obtainkeysjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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.
-*/
-
-#include "obtainkeysjob.h"
-
-#include "chiasmusbackend.h"
-
-#include "libkleo/cryptoconfig.h"
-
-#include <KLocalizedString>
-#include <kmessagebox.h>
-#include <kshell.h>
-
-#include <QDir>
-#include <QStringList>
-#include <QVariant>
-#include <QTimer>
-#include <QFileInfo>
-
-#include <gpg-error.h>
-
-#include <cassert>
-
-Kleo::ObtainKeysJob::ObtainKeysJob(QObject *p)
- : SpecialJob(p),
- mIndex(0),
- mCanceled(false)
-{
- assert(ChiasmusBackend::instance());
- assert(ChiasmusBackend::instance()->config());
- const CryptoConfigEntry *keypaths =
- ChiasmusBackend::instance()->config()->entry(QStringLiteral("Chiasmus"), QStringLiteral("General"), QStringLiteral("keydir"));
- assert(keypaths);
- mKeyPaths = QStringList(keypaths->urlValue().path());
-}
-
-Kleo::ObtainKeysJob::~ObtainKeysJob() {}
-
-GpgME::Error Kleo::ObtainKeysJob::start()
-{
- QTimer::singleShot(0, this, SLOT(slotPerform()));
- return mError = GpgME::Error();
-}
-
-GpgME::Error Kleo::ObtainKeysJob::exec()
-{
- slotPerform(false);
- return mError;
-}
-
-void Kleo::ObtainKeysJob::slotCancel()
-{
- mCanceled = true;
-}
-
-void Kleo::ObtainKeysJob::slotPerform()
-{
- slotPerform(true);
-}
-
-void Kleo::ObtainKeysJob::slotPerform(bool async)
-{
- if (mCanceled && !mError) {
- mError = GpgME::Error::fromCode(GPG_ERR_CANCELED);
- }
- if (int(mIndex) >= mKeyPaths.size() || mError) {
- Q_EMIT done();
- Q_EMIT SpecialJob::result(mError, QVariant(mResult));
- return;
- }
-
- Q_EMIT progress(i18n("Scanning directory %1...", mKeyPaths[mIndex]),
- mIndex, mKeyPaths.size());
-
- const QDir dir(KShell::tildeExpand(mKeyPaths[mIndex]));
-
- const QFileInfoList xisFiles = dir.entryInfoList(QStringList() << QStringLiteral("*.xis;*.XIS"), QDir::Files);
- for (QFileInfoList::const_iterator it = xisFiles.begin(), end = xisFiles.end(); it != end; ++it)
- if ((*it).isReadable()) {
- mResult.push_back((*it).absoluteFilePath());
- }
-
- ++mIndex;
-
- if (async) {
- QTimer::singleShot(0, this, SLOT(slotPerform()));
- } else {
- slotPerform(false);
- }
-}
-
-void Kleo::ObtainKeysJob::showErrorDialog(QWidget *parent, const QString &caption) const
-{
- if (!mError) {
- return;
- }
- if (mError.isCanceled()) {
- return;
- }
- const QString msg = QString::fromLocal8Bit(mError.asString());
- KMessageBox::error(parent, msg, caption);
-}
-
diff --git a/src/backends/chiasmus/obtainkeysjob.h b/src/backends/chiasmus/obtainkeysjob.h
deleted file mode 100644
index 6a5a538..0000000
--- a/src/backends/chiasmus/obtainkeysjob.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- obtainkeysjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 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_OBTAINKEYSJOB_H__
-#define __KLEO_OBTAINKEYSJOB_H__
-
-#include "libkleo/specialjob.h"
-
-#include <QStringList>
-
-#include <gpgme++/context.h>
-
-namespace Kleo
-{
-
-/**
- @short SpecialJob for listing Chiasmus key files.
-
- In the Chiasmus system, keys are mapped 1:1 to
- files. Furthermore, we have to definition of the format of those
- keys, so we cannot display more than the filename anyway. Due to
- all of these limitations, we don't use KeyListJob here, but roll
- our own interface.
-
- The name of the function is x-obtain-keys. It takes no parameters.
-
- To use, create an ObtainKeysJob instance like this:
- <code>
- Kleo::SpecialJob * job =
- protocol->specialJob("x-obtain-keys", QMap<QString,QVariant>());
- </code>
-
- The resulting QVariant will contain a QStringList containing the
- absolute filenames of the keys found in the configured key files.
-*/
-class ObtainKeysJob : public Kleo::SpecialJob
-{
- Q_OBJECT
- Q_PROPERTY(QStringList result READ result)
-public:
- explicit ObtainKeysJob(QObject *parent = Q_NULLPTR);
- ~ObtainKeysJob();
-
- /*!\reimp SpecialJob */
- GpgME::Error start() Q_DECL_OVERRIDE;
- /*!\reimp SpecialJob */
- GpgME::Error exec() Q_DECL_OVERRIDE;
-
- /*!\reimp Kleo::Job */
- void showErrorDialog(QWidget *, const QString &) const Q_DECL_OVERRIDE;
-
- //using SpecialJob::result;
- QStringList result() const
- {
- return mResult;
- }
-
-public Q_SLOTS:
- void slotCancel() Q_DECL_OVERRIDE;
-
-private Q_SLOTS:
- void slotPerform();
- void slotPerform(bool async);
-
-private:
- GpgME::Error mError;
- QStringList mKeyPaths;
- unsigned int mIndex;
- QStringList mResult;
- bool mCanceled;
-};
-
-}
-
-#endif // __KLEO_OBTAINKEYSJOB_H__
diff --git a/src/backends/chiasmus/symcryptrunprocessbase.cpp b/src/backends/chiasmus/symcryptrunprocessbase.cpp
deleted file mode 100644
index 52b47f8..0000000
--- a/src/backends/chiasmus/symcryptrunprocessbase.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- symcryptrunbackend.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 Klar�vdalens 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.
-*/
-
-#include "symcryptrunprocessbase.h"
-
-#include <QTemporaryFile>
-#include <kshell.h>
-
-#include <QStringList>
-
-#include <cstring>
-
-Kleo::SymCryptRunProcessBase::SymCryptRunProcessBase(const QString &class_, const QString &program,
- const QString &keyFile, const QString &options,
- Operation mode,
- QObject *parent)
- : KProcess(parent),
- mOperation(mode), mOptions(options)
-{
- *this << QStringLiteral("symcryptrun")
- << QStringLiteral("--class") << class_
- << QStringLiteral("--program") << program
- << QStringLiteral("--keyfile") << keyFile
- << (mode == Encrypt ? QStringLiteral("--encrypt") : QStringLiteral("--decrypt"));
-}
-
-Kleo::SymCryptRunProcessBase::~SymCryptRunProcessBase() {}
-
-bool Kleo::SymCryptRunProcessBase::launch(const QByteArray &input, bool block)
-{
- connect(this, &SymCryptRunProcessBase::readyReadStandardOutput, this, &SymCryptRunProcessBase::slotReadyReadStandardOutput);
- connect(this, &SymCryptRunProcessBase::readyReadStandardError, this, &SymCryptRunProcessBase::slotReadyReadStandardError);
- if (block) {
- QTemporaryFile tempfile;
- if (tempfile.open()) {
- tempfile.write(input);
- } else {
- return false;
- }
- tempfile.flush();
- *this << QStringLiteral("--input") << tempfile.fileName();
- addOptions();
- if (KProcess::execute() == -2) {
- return false;
- }
- } else {
- addOptions();
- KProcess::start();
- const bool ok = waitForStarted();
- if (!ok) {
- return ok;
- }
- mInput = input;
- write(mInput);
- closeWriteChannel();
- }
- return true;
-}
-
-void Kleo::SymCryptRunProcessBase::addOptions()
-{
- if (!mOptions.isEmpty()) {
- const QStringList args = KShell::splitArgs(mOptions);
- *this << QStringLiteral("--") << args;
- }
-}
-
-void Kleo::SymCryptRunProcessBase::slotReadyReadStandardOutput()
-{
- mOutput += readAllStandardOutput();
-}
-
-void Kleo::SymCryptRunProcessBase::slotReadyReadStandardError()
-{
- mStderr += QLatin1String(readAllStandardError());
-}
-
diff --git a/src/backends/chiasmus/symcryptrunprocessbase.h b/src/backends/chiasmus/symcryptrunprocessbase.h
deleted file mode 100644
index 240359d..0000000
--- a/src/backends/chiasmus/symcryptrunprocessbase.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- symcryptrunbackend.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005 Klar�vdalens 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_BACKEND_CHIASMUS__SYMCRYPTRUNPROCESSBASE_H__
-#define __KLEO_BACKEND_CHIASMUS__SYMCRYPTRUNPROCESSBASE_H__
-
-#include <kprocess.h>
-
-class QString;
-
-namespace Kleo
-{
-
-class SymCryptRunProcessBase : public KProcess
-{
- Q_OBJECT
-public:
- enum Operation {
- Encrypt, Decrypt
- };
- SymCryptRunProcessBase(const QString &class_, const QString &program,
- const QString &keyFile, const QString &options,
- Operation op,
- QObject *parent = Q_NULLPTR);
- virtual ~SymCryptRunProcessBase();
-
- bool launch(const QByteArray &input, bool block = true);
-
- const QByteArray &output() const
- {
- return mOutput;
- }
- const QString &stdErr() const
- {
- return mStderr;
- }
-
-private Q_SLOTS:
- void slotReadyReadStandardError();
- void slotReadyReadStandardOutput();
-
-private:
- void addOptions();
-
- QByteArray mInput;
- QByteArray mOutput;
- QString mStderr;
- const Operation mOperation;
- QString mOptions;
-};
-
-}
-
-#endif // __KLEO_BACKEND_CHIASMUS__SYMCRYPTRUNPROCESSBASE_H__
diff --git a/src/backends/qgpgme/gnupgprocessbase.cpp b/src/backends/qgpgme/gnupgprocessbase.cpp
deleted file mode 100644
index 5a6af20..0000000
--- a/src/backends/qgpgme/gnupgprocessbase.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- gnupgprocessbase.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004 Klar�vdalens 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.
-*/
-
-#include "gnupgprocessbase.h"
-
-#include <QDebug>
-#include "gpgme_backend_debug.h"
-
-#include <QSocketNotifier>
-#include <QStringList>
-#include <QByteArray>
-#include <QList>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <assert.h>
-#include <stdio.h>
-
-Kleo::GnuPGProcessBase::GnuPGProcessBase(QObject *parent)
- : KProcess(parent)
-{
- //d = new Private();
-}
-
-Kleo::GnuPGProcessBase::~GnuPGProcessBase()
-{
- //delete d; d = 0;
-}
-
-void Kleo::GnuPGProcessBase::setUseStatusFD(bool /*use*/)
-{
- //assert( d );
- //d->useStatusFD = use;
-}
-
diff --git a/src/backends/qgpgme/gnupgprocessbase.h b/src/backends/qgpgme/gnupgprocessbase.h
deleted file mode 100644
index f001a4d..0000000
--- a/src/backends/qgpgme/gnupgprocessbase.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- gnupgprocessbase.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004 Klar�vdalens 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_GNUPGPROCESSBASE_H__
-#define __KLEO_GNUPGPROCESSBASE_H__
-
-#include "kleo_export.h"
-#include <kprocess.h>
-
-namespace Kleo
-{
-
-/**
- * @short a base class for GPG and GPGSM processes.
- *
- * This K3Process subclass implements the status-fd handling common
- * to GPG and GPGSM.
- *
- * @author Marc Mutz <mutz@kde.org>
- */
-class KLEO_EXPORT GnuPGProcessBase : public KProcess
-{
- Q_OBJECT
-public:
- explicit GnuPGProcessBase(QObject *parent = Q_NULLPTR);
- ~GnuPGProcessBase();
-
- void setUseStatusFD(bool use);
-
- /*! reimplementation */
- //bool start( RunMode runmode, Communication comm );
-
- //bool closeStatus();
-
-Q_SIGNALS:
- void status(Kleo::GnuPGProcessBase *proc, const QString &type, const QStringList &args);
-
-protected:
- /*! reimplementation */
- //int setupCommunication( Communication comm );
- /*! reimplementation */
- //int commSetupDoneP();
- /*! reimplementation */
- //int commSetupDoneC();
-
- //int childStatus( int fd );
-
-private Q_SLOTS:
- //void slotChildStatus( int fd );
-
-private:
- //void parseStatusOutput();
-
-private:
- class Private;
- Private *d;
-};
-
-}
-
-#endif // __KLEO_GNUPGPROCESSBASE_H__
diff --git a/src/backends/qgpgme/qgpgmeadduseridjob.cpp b/src/backends/qgpgme/qgpgmeadduseridjob.cpp
deleted file mode 100644
index 5bf445d..0000000
--- a/src/backends/qgpgme/qgpgmeadduseridjob.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- qgpgmeadduseridjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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.
-*/
-
-#include "qgpgmeadduseridjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/gpgadduserideditinteractor.h>
-#include <gpgme++/key.h>
-
-#include <cassert>
-#include <memory>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEAddUserIDJob::QGpgMEAddUserIDJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEAddUserIDJob::~QGpgMEAddUserIDJob() {}
-
-static QGpgMEAddUserIDJob::result_type add_user_id(Context *ctx, const Key &key, const QString &name, const QString &email, const QString &comment)
-{
-
- std::auto_ptr<GpgAddUserIDEditInteractor> gau(new GpgAddUserIDEditInteractor);
-
- gau->setNameUtf8(name.toUtf8().constData());
- gau->setEmailUtf8(email.toUtf8().constData());
- gau->setCommentUtf8(comment.toUtf8().constData());
-
- std::auto_ptr<EditInteractor> ei(gau);
-
- QGpgME::QByteArrayDataProvider dp;
- Data data(&dp);
- assert(!data.isNull());
- const Error err = ctx->edit(key, ei, data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, log, ae);
-}
-
-Error QGpgMEAddUserIDJob::start(const Key &key, const QString &name, const QString &email, const QString &comment)
-{
- run(bind(&add_user_id, _1, key, name, email, comment));
- return Error();
-}
-
diff --git a/src/backends/qgpgme/qgpgmeadduseridjob.h b/src/backends/qgpgme/qgpgmeadduseridjob.h
deleted file mode 100644
index 981c0ae..0000000
--- a/src/backends/qgpgme/qgpgmeadduseridjob.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- qgpgmeadduseridjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_QGPGMEADDUSERIDJOB_H__
-#define __KLEO_QGPGMEADDUSERIDJOB_H__
-
-#include "libkleo/adduseridjob.h"
-
-#include "threadedjobmixin.h"
-
-namespace Kleo
-{
-
-class QGpgMEAddUserIDJob
-#ifdef Q_MOC_RUN
- : public AddUserIDJob
-#else
- : public _detail::ThreadedJobMixin<AddUserIDJob>
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-private Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEAddUserIDJob(GpgME::Context *context);
- ~QGpgMEAddUserIDJob();
-
- /*! \reimp from AddUserIDJob */
- GpgME::Error start(const GpgME::Key &key, const QString &name, const QString &email, const QString &comment) Q_DECL_OVERRIDE;
-};
-}
-
-#endif // __KLEO_QGPGMEADDUSERIDJOB_H__
diff --git a/src/backends/qgpgme/qgpgmebackend.cpp b/src/backends/qgpgme/qgpgmebackend.cpp
deleted file mode 100644
index e620f2c..0000000
--- a/src/backends/qgpgme/qgpgmebackend.cpp
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- qgpgmebackend.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2005 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.
-*/
-
-#include "qgpgmebackend.h"
-
-#include "qgpgmecryptoconfig.h"
-#include "qgpgmenewcryptoconfig.h"
-
-#include "qgpgmekeygenerationjob.h"
-#include "qgpgmekeylistjob.h"
-#include "qgpgmelistallkeysjob.h"
-#include "qgpgmedecryptjob.h"
-#include "qgpgmedecryptverifyjob.h"
-#include "qgpgmerefreshkeysjob.h"
-#include "qgpgmedeletejob.h"
-#include "qgpgmesecretkeyexportjob.h"
-#include "qgpgmedownloadjob.h"
-#include "qgpgmesignencryptjob.h"
-#include "qgpgmeencryptjob.h"
-#include "qgpgmesignjob.h"
-#include "qgpgmesignkeyjob.h"
-#include "qgpgmeexportjob.h"
-#include "qgpgmeverifydetachedjob.h"
-#include "qgpgmeimportjob.h"
-#include "qgpgmeimportfromkeyserverjob.h"
-#include "qgpgmeverifyopaquejob.h"
-#include "qgpgmechangeexpiryjob.h"
-#include "qgpgmechangeownertrustjob.h"
-#include "qgpgmechangepasswdjob.h"
-#include "qgpgmeadduseridjob.h"
-#include "qgpgmekeyformailboxjob.h"
-
-#include <gpgme++/error.h>
-#include <gpgme++/engineinfo.h>
-
-#include <KLocalizedString>
-
-#include <QFile>
-#include <QString>
-
-namespace
-{
-
-class Protocol : public Kleo::CryptoBackend::Protocol
-{
- GpgME::Protocol mProtocol;
-public:
- explicit Protocol(GpgME::Protocol proto) : mProtocol(proto) {}
-
- QString name() const Q_DECL_OVERRIDE
- {
- switch (mProtocol) {
- case GpgME::OpenPGP: return QStringLiteral("OpenPGP");
- case GpgME::CMS: return QStringLiteral("SMIME");
- default: return QString();
- }
- }
-
- QString displayName() const Q_DECL_OVERRIDE
- {
- switch (mProtocol) {
- case GpgME::OpenPGP: return QStringLiteral("gpg");
- case GpgME::CMS: return QStringLiteral("gpgsm");
- default: return i18n("unknown");
- }
- }
-
- Kleo::SpecialJob *specialJob(const char *, const QMap<QString, QVariant> &) const Q_DECL_OVERRIDE
- {
- return 0;
- }
-
- Kleo::KeyListJob *keyListJob(bool remote, bool includeSigs, bool validate) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- unsigned int mode = context->keyListMode();
- if (remote) {
- mode |= GpgME::Extern;
- mode &= ~GpgME::Local;
- } else {
- mode |= GpgME::Local;
- mode &= ~GpgME::Extern;
- }
- if (includeSigs) {
- mode |= GpgME::Signatures;
- }
- if (validate) {
- mode |= GpgME::Validate;
- }
- context->setKeyListMode(mode);
- return new Kleo::QGpgMEKeyListJob(context);
- }
-
- Kleo::ListAllKeysJob *listAllKeysJob(bool includeSigs, bool validate) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- unsigned int mode = context->keyListMode();
- mode |= GpgME::Local;
- mode &= ~GpgME::Extern;
- if (includeSigs) {
- mode |= GpgME::Signatures;
- }
- if (validate) {
- mode |= GpgME::Validate;
- /* Setting the context to offline mode disables CRL / OCSP checks in
- this Job. Otherwise we would try to fetch the CRL's for all CMS
- keys in the users keyring because GpgME::Validate includes remote
- resources by default in the validity check.
- This setting only has any effect if gpgsm >= 2.1.6 is used.
- */
- context->setOffline(true);
- }
- context->setKeyListMode(mode);
- return new Kleo::QGpgMEListAllKeysJob(context);
- }
-
- Kleo::EncryptJob *encryptJob(bool armor, bool textmode) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setArmor(armor);
- context->setTextMode(textmode);
- return new Kleo::QGpgMEEncryptJob(context);
- }
-
- Kleo::DecryptJob *decryptJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEDecryptJob(context);
- }
-
- Kleo::SignJob *signJob(bool armor, bool textMode) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setArmor(armor);
- context->setTextMode(textMode);
- return new Kleo::QGpgMESignJob(context);
- }
-
- Kleo::VerifyDetachedJob *verifyDetachedJob(bool textMode) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setTextMode(textMode);
- return new Kleo::QGpgMEVerifyDetachedJob(context);
- }
-
- Kleo::VerifyOpaqueJob *verifyOpaqueJob(bool textMode) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setTextMode(textMode);
- return new Kleo::QGpgMEVerifyOpaqueJob(context);
- }
-
- Kleo::KeyGenerationJob *keyGenerationJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEKeyGenerationJob(context);
- }
-
- Kleo::ImportJob *importJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEImportJob(context);
- }
-
- Kleo::ImportFromKeyserverJob *importFromKeyserverJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEImportFromKeyserverJob(context);
- }
-
- Kleo::ExportJob *publicKeyExportJob(bool armor) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setArmor(armor);
- return new Kleo::QGpgMEExportJob(context);
- }
-
- Kleo::ExportJob *secretKeyExportJob(bool armor, const QString &charset) const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too
- return 0;
- }
-
- // this operation is not supported by gpgme, so we have to call gpgsm ourselves:
- return new Kleo::QGpgMESecretKeyExportJob(armor, charset);
- }
-
- Kleo::RefreshKeysJob *refreshKeysJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::CMS) { // fixme: add support for gpg, too
- return 0;
- }
-
- // this operation is not supported by gpgme, so we have to call gpgsm ourselves:
- return new Kleo::QGpgMERefreshKeysJob();
- }
-
- Kleo::DownloadJob *downloadJob(bool armor) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setArmor(armor);
- // this is the hackish interface for downloading from keyserers currently:
- context->setKeyListMode(GpgME::Extern);
- return new Kleo::QGpgMEDownloadJob(context);
- }
-
- Kleo::DeleteJob *deleteJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEDeleteJob(context);
- }
-
- Kleo::SignEncryptJob *signEncryptJob(bool armor, bool textMode) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setArmor(armor);
- context->setTextMode(textMode);
- return new Kleo::QGpgMESignEncryptJob(context);
- }
-
- Kleo::DecryptVerifyJob *decryptVerifyJob(bool textMode) const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
-
- context->setTextMode(textMode);
- return new Kleo::QGpgMEDecryptVerifyJob(context);
- }
-
- Kleo::ChangeExpiryJob *changeExpiryJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::OpenPGP) {
- return 0; // only supported by gpg
- }
-
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEChangeExpiryJob(context);
- }
-
- Kleo::ChangePasswdJob *changePasswdJob() const Q_DECL_OVERRIDE
- {
- if (!GpgME::hasFeature(GpgME::PasswdFeature, 0)) {
- return 0;
- }
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEChangePasswdJob(context);
- }
-
- Kleo::SignKeyJob *signKeyJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::OpenPGP) {
- return 0; // only supported by gpg
- }
-
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMESignKeyJob(context);
- }
-
- Kleo::ChangeOwnerTrustJob *changeOwnerTrustJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::OpenPGP) {
- return 0; // only supported by gpg
- }
-
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEChangeOwnerTrustJob(context);
- }
-
- Kleo::AddUserIDJob *addUserIDJob() const Q_DECL_OVERRIDE
- {
- if (mProtocol != GpgME::OpenPGP) {
- return 0; // only supported by gpg
- }
-
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return 0;
- }
- return new Kleo::QGpgMEAddUserIDJob(context);
- }
-
- Kleo::KeyListJob *locateKeysJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return Q_NULLPTR;
- }
- context->setKeyListMode(GpgME::Extern | GpgME::Local | GpgME::Signatures | GpgME::Validate);
- return new Kleo::QGpgMEKeyListJob(context);
- }
-
- Kleo::KeyForMailboxJob *keyForMailboxJob() const Q_DECL_OVERRIDE
- {
- GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
- if (!context) {
- return Q_NULLPTR;
- }
- return new Kleo::QGpgMEKeyForMailboxJob(context);
- }
-};
-
-}
-
-Kleo::QGpgMEBackend::QGpgMEBackend()
- : Kleo::CryptoBackend(),
- mCryptoConfig(0),
- mOpenPGPProtocol(0),
- mSMIMEProtocol(0)
-{
- GpgME::initializeLibrary();
-}
-
-Kleo::QGpgMEBackend::~QGpgMEBackend()
-{
- delete mCryptoConfig; mCryptoConfig = 0;
- delete mOpenPGPProtocol; mOpenPGPProtocol = 0;
- delete mSMIMEProtocol; mSMIMEProtocol = 0;
-}
-
-QString Kleo::QGpgMEBackend::name() const
-{
- return QStringLiteral("gpgme");
-}
-
-QString Kleo::QGpgMEBackend::displayName() const
-{
- return i18n("GpgME");
-}
-
-Kleo::CryptoConfig *Kleo::QGpgMEBackend::config() const
-{
- if (!mCryptoConfig) {
-#ifdef _WIN32_WCE // for now...
- if (GpgME::hasFeature(GpgME::GpgConfEngineFeature, 0)) {
- mCryptoConfig = new QGpgMENewCryptoConfig;
- } else
-#endif
- if (!QGpgMECryptoConfig::gpgConfPath().isEmpty()) {
- mCryptoConfig = new QGpgMECryptoConfig();
- }
- }
- return mCryptoConfig;
-}
-
-static bool check(GpgME::Protocol proto, QString *reason)
-{
- if (!GpgME::checkEngine(proto)) {
- return true;
- }
- if (!reason) {
- return false;
- }
- // error, check why:
- const GpgME::EngineInfo ei = GpgME::engineInfo(proto);
- if (ei.isNull()) {
- *reason = i18n("GPGME was compiled without support for %1.", proto == GpgME::CMS ? QLatin1String("S/MIME") : QLatin1String("OpenPGP"));
- } else if (ei.fileName() && !ei.version()) {
- *reason = i18n("Engine %1 is not installed properly.", QFile::decodeName(ei.fileName()));
- } else if (ei.fileName() && ei.version() && ei.requiredVersion())
- *reason = i18n("Engine %1 version %2 installed, "
- "but at least version %3 is required.",
- QFile::decodeName(ei.fileName()), QLatin1String(ei.version()), QLatin1String(ei.requiredVersion()));
- else {
- *reason = i18n("Unknown problem with engine for protocol %1.", proto == GpgME::CMS ? QLatin1String("S/MIME") : QLatin1String("OpenPGP"));
- }
- return false;
-}
-
-bool Kleo::QGpgMEBackend::checkForOpenPGP(QString *reason) const
-{
- return check(GpgME::OpenPGP, reason);
-}
-
-bool Kleo::QGpgMEBackend::checkForSMIME(QString *reason) const
-{
- return check(GpgME::CMS, reason);
-}
-
-bool Kleo::QGpgMEBackend::checkForProtocol(const char *name, QString *reason) const
-{
- if (qstricmp(name, OpenPGP) == 0) {
- return check(GpgME::OpenPGP, reason);
- }
- if (qstricmp(name, SMIME) == 0) {
- return check(GpgME::CMS, reason);
- }
- if (reason) {
- *reason = i18n("Unsupported protocol \"%1\"", QLatin1String(name));
- }
- return false;
-}
-
-Kleo::CryptoBackend::Protocol *Kleo::QGpgMEBackend::openpgp() const
-{
- if (!mOpenPGPProtocol)
- if (checkForOpenPGP()) {
- mOpenPGPProtocol = new ::Protocol(GpgME::OpenPGP);
- }
- return mOpenPGPProtocol;
-}
-
-Kleo::CryptoBackend::Protocol *Kleo::QGpgMEBackend::smime() const
-{
- if (!mSMIMEProtocol)
- if (checkForSMIME()) {
- mSMIMEProtocol = new ::Protocol(GpgME::CMS);
- }
- return mSMIMEProtocol;
-}
-
-Kleo::CryptoBackend::Protocol *Kleo::QGpgMEBackend::protocol(const char *name) const
-{
- if (qstricmp(name, OpenPGP) == 0) {
- return openpgp();
- }
- if (qstricmp(name, SMIME) == 0) {
- return smime();
- }
- return 0;
-}
-
-bool Kleo::QGpgMEBackend::supportsProtocol(const char *name) const
-{
- return qstricmp(name, OpenPGP) == 0 || qstricmp(name, SMIME) == 0;
-}
-
-const char *Kleo::QGpgMEBackend::enumerateProtocols(int i) const
-{
- switch (i) {
- case 0: return OpenPGP;
- case 1: return SMIME;
- default: return 0;
- }
-}
diff --git a/src/backends/qgpgme/qgpgmebackend.h b/src/backends/qgpgme/qgpgmebackend.h
deleted file mode 100644
index 9f92a8b..0000000
--- a/src/backends/qgpgme/qgpgmebackend.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- qgpgmebackend.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2005 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_QGPGMEBACKEND_H__
-#define __KLEO_QGPGMEBACKEND_H__
-
-#include "libkleo/cryptobackend.h"
-
-namespace Kleo
-{
-class CryptoConfig;
-}
-class QString;
-
-namespace Kleo
-{
-
-class QGpgMEBackend : public Kleo::CryptoBackend
-{
-public:
- QGpgMEBackend();
- ~QGpgMEBackend();
-
- QString name() const Q_DECL_OVERRIDE;
- QString displayName() const Q_DECL_OVERRIDE;
-
- CryptoConfig *config() const Q_DECL_OVERRIDE;
-
- Protocol *openpgp() const Q_DECL_OVERRIDE;
- Protocol *smime() const Q_DECL_OVERRIDE;
- Protocol *protocol(const char *name) const Q_DECL_OVERRIDE;
-
- bool checkForOpenPGP(QString *reason = Q_NULLPTR) const Q_DECL_OVERRIDE;
- bool checkForSMIME(QString *reason = Q_NULLPTR) const Q_DECL_OVERRIDE;
- bool checkForProtocol(const char *name, QString *reason) const Q_DECL_OVERRIDE;
-
- bool supportsOpenPGP() const Q_DECL_OVERRIDE
- {
- return true;
- }
- bool supportsSMIME() const Q_DECL_OVERRIDE
- {
- return true;
- }
- bool supportsProtocol(const char *name) const Q_DECL_OVERRIDE;
-
- const char *enumerateProtocols(int i) const Q_DECL_OVERRIDE;
-
-private:
- mutable Kleo::CryptoConfig *mCryptoConfig;
- mutable Protocol *mOpenPGPProtocol;
- mutable Protocol *mSMIMEProtocol;
-};
-
-}
-
-#endif // __KLEO_QGPGMEBACKEND_H__
diff --git a/src/backends/qgpgme/qgpgmechangeexpiryjob.cpp b/src/backends/qgpgme/qgpgmechangeexpiryjob.cpp
deleted file mode 100644
index 57aa602..0000000
--- a/src/backends/qgpgme/qgpgmechangeexpiryjob.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- qgpgmechangeexpiryjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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.
-*/
-
-#include "qgpgmechangeexpiryjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/gpgsetexpirytimeeditinteractor.h>
-#include <gpgme++/key.h>
-
-#include <QDateTime>
-
-#include <cassert>
-#include <memory>
-#include <string>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEChangeExpiryJob::QGpgMEChangeExpiryJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEChangeExpiryJob::~QGpgMEChangeExpiryJob() {}
-
-static QGpgMEChangeExpiryJob::result_type change_expiry(Context *ctx, const Key &key, const QDateTime &expiry)
-{
- std::auto_ptr<EditInteractor>
- ei(expiry.isValid()
- ? new GpgSetExpiryTimeEditInteractor(expiry.date().toString(Qt::ISODate).toStdString())
- : new GpgSetExpiryTimeEditInteractor());
-
- QGpgME::QByteArrayDataProvider dp;
- Data data(&dp);
- assert(!data.isNull());
- const Error err = ctx->edit(key, ei, data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, log, ae);
-}
-
-Error QGpgMEChangeExpiryJob::start(const Key &key, const QDateTime &expiry)
-{
- run(bind(&change_expiry, _1, key, expiry));
- return Error();
-}
-
diff --git a/src/backends/qgpgme/qgpgmechangeexpiryjob.h b/src/backends/qgpgme/qgpgmechangeexpiryjob.h
deleted file mode 100644
index 9de5936..0000000
--- a/src/backends/qgpgme/qgpgmechangeexpiryjob.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- qgpgmechangeexpiryjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_QGPGMECHANGEEXPIRYJOB_H__
-#define __KLEO_QGPGMECHANGEEXPIRYJOB_H__
-
-#include "libkleo/changeexpiryjob.h"
-
-#include "threadedjobmixin.h"
-
-namespace Kleo
-{
-
-class QGpgMEChangeExpiryJob
-#ifdef Q_MOC_RUN
- : public ChangeExpiryJob
-#else
- : public _detail::ThreadedJobMixin<ChangeExpiryJob>
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-private Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEChangeExpiryJob(GpgME::Context *context);
- ~QGpgMEChangeExpiryJob();
-
- /*! \reimp from ChangeExpiryJob */
- GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry) Q_DECL_OVERRIDE;
-};
-
-}
-
-#endif // __KLEO_QGPGMECHANGEEXPIRYJOB_H__
diff --git a/src/backends/qgpgme/qgpgmechangeownertrustjob.cpp b/src/backends/qgpgme/qgpgmechangeownertrustjob.cpp
deleted file mode 100644
index 23dc9cf..0000000
--- a/src/backends/qgpgme/qgpgmechangeownertrustjob.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- qgpgmechangeownertrustjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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.
-*/
-
-#include "qgpgmechangeownertrustjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/gpgsetownertrusteditinteractor.h>
-#include <gpgme++/key.h>
-
-#include <cassert>
-#include <memory>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEChangeOwnerTrustJob::QGpgMEChangeOwnerTrustJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEChangeOwnerTrustJob::~QGpgMEChangeOwnerTrustJob() {}
-
-static QGpgMEChangeOwnerTrustJob::result_type change_ownertrust(Context *ctx, const Key &key, Key::OwnerTrust trust)
-{
- std::auto_ptr<EditInteractor>
- ei(new GpgSetOwnerTrustEditInteractor(trust));
-
- QGpgME::QByteArrayDataProvider dp;
- Data data(&dp);
- assert(!data.isNull());
-
- const Error err = ctx->edit(key, ei, data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, log, ae);
-}
-
-Error QGpgMEChangeOwnerTrustJob::start(const Key &key, Key::OwnerTrust trust)
-{
- run(bind(&change_ownertrust, _1, key, trust));
- return Error();
-}
-
diff --git a/src/backends/qgpgme/qgpgmechangeownertrustjob.h b/src/backends/qgpgme/qgpgmechangeownertrustjob.h
deleted file mode 100644
index 5da5ae7..0000000
--- a/src/backends/qgpgme/qgpgmechangeownertrustjob.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- qgpgmechangeexpiryjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_QGPGMECHANGEOWNERTRUSTJOB_H__
-#define __KLEO_QGPGMECHANGEOWNERTRUSTJOB_H__
-
-#include "libkleo/changeownertrustjob.h"
-
-#include "threadedjobmixin.h"
-
-namespace Kleo
-{
-
-class QGpgMEChangeOwnerTrustJob
-#ifdef Q_MOC_RUN
- : public ChangeOwnerTrustJob
-#else
- : public _detail::ThreadedJobMixin<ChangeOwnerTrustJob>
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-private Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEChangeOwnerTrustJob(GpgME::Context *context);
- ~QGpgMEChangeOwnerTrustJob();
-
- /*! \reimp from ChangeOwnerTrustJob */
- GpgME::Error start(const GpgME::Key &key, GpgME::Key::OwnerTrust trust) Q_DECL_OVERRIDE;
-};
-}
-
-#endif // __KLEO_QGPGMECHANGEOWNERTRUSTJOB_H__
diff --git a/src/backends/qgpgme/qgpgmechangepasswdjob.cpp b/src/backends/qgpgme/qgpgmechangepasswdjob.cpp
deleted file mode 100644
index 7244183..0000000
--- a/src/backends/qgpgme/qgpgmechangepasswdjob.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- qgpgmechangepasswdjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2010 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.
-*/
-
-#include "qgpgmechangepasswdjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/key.h>
-
-#include <cassert>
-#include <memory>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEChangePasswdJob::QGpgMEChangePasswdJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEChangePasswdJob::~QGpgMEChangePasswdJob() {}
-
-static QGpgMEChangePasswdJob::result_type change_passwd(Context *ctx, const Key &key)
-{
-#if 0 // in case we want to fall back to edit interactor for gpg...
- std::auto_ptr<EditInteractor> ei(new GpgChangePasswdEditInteractor);
-
- QGpgME::QByteArrayDataProvider dp;
- Data data(&dp);
- assert(!data.isNull());
- const Error err = ctx->edit(key, ei, data);
-#else
- const Error err = ctx->passwd(key);
-#endif
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, log, ae);
-}
-
-Error QGpgMEChangePasswdJob::start(const Key &key)
-{
- run(bind(&change_passwd, _1, key));
- return Error();
-}
-
diff --git a/src/backends/qgpgme/qgpgmechangepasswdjob.h b/src/backends/qgpgme/qgpgmechangepasswdjob.h
deleted file mode 100644
index 89780ab..0000000
--- a/src/backends/qgpgme/qgpgmechangepasswdjob.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- qgpgmechangepasswdjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2010 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_QGPGMECHANGEPASSWDJOB_H__
-#define __KLEO_QGPGMECHANGEPASSWDJOB_H__
-
-#include "libkleo/changepasswdjob.h"
-
-#include "threadedjobmixin.h"
-
-namespace Kleo
-{
-
-class QGpgMEChangePasswdJob
-#ifdef Q_MOC_RUN
- : public ChangePasswdJob
-#else
- : public _detail::ThreadedJobMixin<ChangePasswdJob>
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-private Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEChangePasswdJob(GpgME::Context *context);
- ~QGpgMEChangePasswdJob();
-
- /*! \reimp from ChangePasswdJob */
- GpgME::Error start(const GpgME::Key &key) Q_DECL_OVERRIDE;
-};
-
-}
-
-#endif // __KLEO_QGPGMECHANGEPASSWDJOB_H__
diff --git a/src/backends/qgpgme/qgpgmecryptoconfig.cpp b/src/backends/qgpgme/qgpgmecryptoconfig.cpp
deleted file mode 100644
index ed6f40f..0000000
--- a/src/backends/qgpgme/qgpgmecryptoconfig.cpp
+++ /dev/null
@@ -1,952 +0,0 @@
-/*
- qgpgmecryptoconfig.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.
-*/
-
-#include "qgpgmecryptoconfig.h"
-
-#include <QList>
-#include <QByteArray>
-#include <kprocess.h>
-#include <errno.h>
-#include <kmessagebox.h>
-#include <KLocalizedString>
-#include <kshell.h>
-#include "gpgme_backend_debug.h"
-
-#include <gpgme++/engineinfo.h>
-#include <gpgme++/global.h>
-
-#include <cassert>
-#include <QTemporaryFile>
-#include <QFile>
-#include <cstdlib>
-#include <iterator>
-#include <QStandardPaths>
-
-// Just for the Q_ASSERT in the dtor. Not thread-safe, but who would
-// have 2 threads talking to gpgconf anyway? :)
-static bool s_duringClear = false;
-
-static const int GPGCONF_FLAG_GROUP = 1;
-static const int GPGCONF_FLAG_OPTIONAL = 2;
-static const int GPGCONF_FLAG_LIST = 4;
-static const int GPGCONF_FLAG_RUNTIME = 8;
-static const int GPGCONF_FLAG_DEFAULT = 16; // fixed default value available
-//static const int GPGCONF_FLAG_DEFAULT_DESC = 32; // runtime default value available
-//static const int GPGCONF_FLAG_NOARG_DESC = 64; // option with optional arg; special meaning if no arg set
-static const int GPGCONF_FLAG_NO_CHANGE = 128; // readonly
-// Change size of mFlags bitfield if adding new values here
-
-QString QGpgMECryptoConfig::gpgConfPath()
-{
- const GpgME::EngineInfo info = GpgME::engineInfo(GpgME::GpgConfEngine);
- return info.fileName() ? QFile::decodeName(info.fileName()) : QStandardPaths::findExecutable(QStringLiteral("gpgconf"));
-}
-
-QGpgMECryptoConfig::QGpgMECryptoConfig()
- : mParsed(false)
-{
-}
-
-QGpgMECryptoConfig::~QGpgMECryptoConfig()
-{
- clear();
-}
-
-void QGpgMECryptoConfig::runGpgConf(bool showErrors)
-{
- // Run gpgconf --list-components to make the list of components
- KProcess process;
-
- process << gpgConfPath();
- process << QStringLiteral("--list-components");
-
- connect(&process, &KProcess::readyReadStandardOutput, this, &QGpgMECryptoConfig::slotCollectStdOut);
-
- // run the process:
- int rc = 0;
- process.setOutputChannelMode(KProcess::OnlyStdoutChannel);
- process.start();
- if (!process.waitForFinished()) {
- rc = -2;
- } else if (process.exitStatus() == QProcess::NormalExit) {
- rc = process.exitCode();
- } else {
- rc = -1;
- }
-
- // handle errors, if any (and if requested)
- if (showErrors && rc != 0) {
- QString reason;
- if (rc == -1) {
- reason = i18n("program terminated unexpectedly");
- } else if (rc == -2) {
- reason = i18n("program not found or cannot be started");
- } else {
- reason = QString::fromLocal8Bit(strerror(rc)); // XXX errno as an exit code?
- }
- QString wmsg = i18n("<qt>Failed to execute gpgconf:<p>%1</p></qt>", reason);
- qCWarning(GPGPME_BACKEND_LOG) << wmsg; // to see it from test_cryptoconfig.cpp
- KMessageBox::error(0, wmsg);
- }
- mParsed = true;
-}
-
-void QGpgMECryptoConfig::slotCollectStdOut()
-{
- assert(qobject_cast<KProcess *>(QObject::sender()));
- KProcess *const proc = static_cast<KProcess *>(QObject::sender());
- while (proc->canReadLine()) {
- QString line = QString::fromUtf8(proc->readLine());
- if (line.endsWith(QLatin1Char('\n'))) {
- line.chop(1);
- }
- if (line.endsWith(QLatin1Char('\r'))) {
- line.chop(1);
- }
- //qCDebug(GPGPME_BACKEND_LOG) <<"GOT LINE:" << line;
- // Format: NAME:DESCRIPTION
- const QStringList lst = line.split(QLatin1Char(':'));
- if (lst.count() >= 2) {
- const std::pair<QString, QGpgMECryptoConfigComponent *> pair(lst[0], new QGpgMECryptoConfigComponent(this, lst[0], lst[1]));
- mComponentsNaturalOrder.push_back(pair);
- mComponentsByName[pair.first] = pair.second;
- } else {
- qCWarning(GPGPME_BACKEND_LOG) << "Parse error on gpgconf --list-components output:" << line;
- }
- }
-}
-
-namespace
-{
-struct Select1St {
- template <typename U, typename V>
- const U &operator()(const std::pair<U, V> &p) const
- {
- return p.first;
- }
- template <typename U, typename V>
- const U &operator()(const QPair<U, V> &p) const
- {
- return p.first;
- }
-};
-}
-
-QStringList QGpgMECryptoConfig::componentList() const
-{
- if (!mParsed) {
- const_cast<QGpgMECryptoConfig *>(this)->runGpgConf(true);
- }
- QStringList result;
- std::transform(mComponentsNaturalOrder.begin(), mComponentsNaturalOrder.end(),
- std::back_inserter(result), Select1St());
- return result;
-}
-
-Kleo::CryptoConfigComponent *QGpgMECryptoConfig::component(const QString &name) const
-{
- if (!mParsed) {
- const_cast<QGpgMECryptoConfig *>(this)->runGpgConf(false);
- }
- return mComponentsByName.value(name);
-}
-
-void QGpgMECryptoConfig::sync(bool runtime)
-{
- Q_FOREACH (QGpgMECryptoConfigComponent *it, mComponentsByName) {
- it->sync(runtime);
- }
-}
-
-void QGpgMECryptoConfig::clear()
-{
- s_duringClear = true;
- mComponentsNaturalOrder.clear();
- qDeleteAll(mComponentsByName);
- mComponentsByName.clear();
- s_duringClear = false;
- mParsed = false; // next call to componentList/component will need to run gpgconf again
-}
-
-////
-
-QGpgMECryptoConfigComponent::QGpgMECryptoConfigComponent(QGpgMECryptoConfig *, const QString &name, const QString &description)
- : mName(name), mDescription(description)
-{
- runGpgConf();
-}
-
-QGpgMECryptoConfigComponent::~QGpgMECryptoConfigComponent()
-{
- mGroupsNaturalOrder.clear();
- qDeleteAll(mGroupsByName);
- mGroupsByName.clear();
-}
-
-void QGpgMECryptoConfigComponent::runGpgConf()
-{
- const QString gpgconf = QGpgMECryptoConfig::gpgConfPath();
- if (gpgconf.isEmpty()) {
- qCWarning(GPGPME_BACKEND_LOG) << "Can't get path to gpgconf executable...";
- return;
- }
-
- // Run gpgconf --list-options <component>, and create all groups and entries for that component
- KProcess proc;
- proc << gpgconf;
- proc << QStringLiteral("--list-options");
- proc << mName;
-
- //qCDebug(GPGPME_BACKEND_LOG) <<"Running gpgconf --list-options" << mName;
-
- connect(&proc, &KProcess::readyReadStandardOutput, this, &QGpgMECryptoConfigComponent::slotCollectStdOut);
- mCurrentGroup = 0;
-
- // run the process:
- int rc = 0;
- proc.setOutputChannelMode(KProcess::OnlyStdoutChannel);
- proc.start();
- if (!proc.waitForFinished()) {
- rc = -2;
- } else if (proc.exitStatus() == QProcess::NormalExit) {
- rc = proc.exitCode();
- } else {
- rc = -1;
- }
-
- if (rc != 0) { // can happen when using the wrong version of gpg...
- qCWarning(GPGPME_BACKEND_LOG) << "Running 'gpgconf --list-options" << mName << "' failed." << strerror(rc) << ", but try that command to see the real output";
- } else {
- if (mCurrentGroup && !mCurrentGroup->mEntriesNaturalOrder.empty()) { // only add non-empty groups
- mGroupsByName.insert(mCurrentGroupName, mCurrentGroup);
- mGroupsNaturalOrder.push_back(std::make_pair(mCurrentGroupName, mCurrentGroup));
- }
- }
-}
-
-void QGpgMECryptoConfigComponent::slotCollectStdOut()
-{
- assert(qobject_cast<KProcess *>(QObject::sender()));
- KProcess *const proc = static_cast<KProcess *>(QObject::sender());
- while (proc->canReadLine()) {
- QString line = QString::fromUtf8(proc->readLine());
- if (line.endsWith(QLatin1Char('\n'))) {
- line.chop(1);
- }
- if (line.endsWith(QLatin1Char('\r'))) {
- line.chop(1);
- }
- //qCDebug(GPGPME_BACKEND_LOG) <<"GOT LINE:" << line;
- // Format: NAME:FLAGS:LEVEL:DESCRIPTION:TYPE:ALT-TYPE:ARGNAME:DEFAULT:ARGDEF:VALUE
- const QStringList lst = line.split(QLatin1Char(':'));
- if (lst.count() >= 10) {
- const int flags = lst[1].toInt();
- const int level = lst[2].toInt();
- if (level > 2) { // invisible or internal -> skip it;
- continue;
- }
- if (flags & GPGCONF_FLAG_GROUP) {
- if (mCurrentGroup && !mCurrentGroup->mEntriesNaturalOrder.empty()) { // only add non-empty groups
- mGroupsByName.insert(mCurrentGroupName, mCurrentGroup);
- mGroupsNaturalOrder.push_back(std::make_pair(mCurrentGroupName, mCurrentGroup));
- }
- //else
- // qCDebug(GPGPME_BACKEND_LOG) <<"Discarding empty group" << mCurrentGroupName;
- mCurrentGroup = new QGpgMECryptoConfigGroup(this, lst[0], lst[3], level);
- mCurrentGroupName = lst[0];
- } else {
- // normal entry
- if (!mCurrentGroup) { // first toplevel entry -> create toplevel group
- mCurrentGroup = new QGpgMECryptoConfigGroup(this, QStringLiteral("<nogroup>"), QString(), 0);
- mCurrentGroupName = QStringLiteral("<nogroup>");
- }
- const QString &name = lst[0];
- QGpgMECryptoConfigEntry *value = new QGpgMECryptoConfigEntry(mCurrentGroup, lst);
- mCurrentGroup->mEntriesByName.insert(name, value);
- mCurrentGroup->mEntriesNaturalOrder.push_back(std::make_pair(name, value));
- }
- } else {
- // This happens on lines like
- // dirmngr[31465]: error opening `/home/dfaure/.gnupg/dirmngr_ldapservers.conf': No such file or directory
- // so let's not bother the user with it.
- //qCWarning(GPGPME_BACKEND_LOG) <<"Parse error on gpgconf --list-options output:" << line;
- }
- }
-}
-
-QStringList QGpgMECryptoConfigComponent::groupList() const
-{
- QStringList result;
- std::transform(mGroupsNaturalOrder.begin(), mGroupsNaturalOrder.end(),
- std::back_inserter(result), Select1St());
- return result;
-}
-
-Kleo::CryptoConfigGroup *QGpgMECryptoConfigComponent::group(const QString &name) const
-{
- return mGroupsByName.value(name);
-}
-
-void QGpgMECryptoConfigComponent::sync(bool runtime)
-{
- QTemporaryFile tmpFile;
- tmpFile.open();
-
- QList<QGpgMECryptoConfigEntry *> dirtyEntries;
-
- // Collect all dirty entries
- const QList<QString> keylist = mGroupsByName.uniqueKeys();
- Q_FOREACH (const QString &key, keylist) {
- const QHash<QString, QGpgMECryptoConfigEntry *> entry = mGroupsByName[key]->mEntriesByName;
- const QList<QString> keylistentry = entry.uniqueKeys();
- Q_FOREACH (const QString &keyentry, keylistentry) {
- if (entry[keyentry]->isDirty()) {
- // OK, we can set it.currentKey() to it.current()->outputString()
- QString line = keyentry;
- if (entry[keyentry]->isSet()) { // set option
- line += QLatin1String(":0:");
- line += entry[keyentry]->outputString();
- } else { // unset option
- line += QLatin1String(":16:");
- }
-#ifdef Q_OS_WIN
- line += QLatin1Char('\r');
-#endif
- line += QLatin1Char('\n');
- const QByteArray line8bit = line.toUtf8(); // encode with utf8, and K3ProcIO uses utf8 when reading.
- tmpFile.write(line8bit);
- dirtyEntries.append(entry[keyentry]);
-
- }
- }
- }
-
- tmpFile.flush();
- if (dirtyEntries.isEmpty()) {
- return;
- }
-
- // Call gpgconf --change-options <component>
- const QString gpgconf = QGpgMECryptoConfig::gpgConfPath();
- QString commandLine = gpgconf.isEmpty()
- ? QStringLiteral("gpgconf")
- : KShell::quoteArg(gpgconf);
- if (runtime) {
- commandLine += QLatin1String(" --runtime");
- }
- commandLine += QLatin1String(" --change-options ");
- commandLine += KShell::quoteArg(mName);
- commandLine += QLatin1String(" < ");
- commandLine += KShell::quoteArg(tmpFile.fileName());
-
- //qCDebug(GPGPME_BACKEND_LOG) << commandLine;
- //system( QCString( "cat " ) + tmpFile.name().toLatin1() ); // DEBUG
-
- KProcess proc;
- proc.setShellCommand(commandLine);
-
- // run the process:
- int rc = proc.execute();
-
- if (rc == -2) {
- QString wmsg = i18n("Could not start gpgconf.\nCheck that gpgconf is in the PATH and that it can be started.");
- qCWarning(GPGPME_BACKEND_LOG) << wmsg;
- KMessageBox::error(0, wmsg);
- } else if (rc != 0) { // Happens due to bugs in gpgconf (e.g. issues 104/115)
- QString wmsg = i18n("Error from gpgconf while saving configuration: %1", QString::fromLocal8Bit(strerror(rc)));
- qCWarning(GPGPME_BACKEND_LOG) << ":" << strerror(rc);
- KMessageBox::error(0, wmsg);
- } else {
- QList<QGpgMECryptoConfigEntry *>::const_iterator it = dirtyEntries.constBegin();
- for (; it != dirtyEntries.constEnd(); ++it) {
- (*it)->setDirty(false);
- }
- }
-}
-
-////
-
-QGpgMECryptoConfigGroup::QGpgMECryptoConfigGroup(QGpgMECryptoConfigComponent *comp, const QString &name, const QString &description, int level)
- :
- mComponent(comp),
- mName(name),
- mDescription(description),
- mLevel(static_cast<Kleo::CryptoConfigEntry::Level>(level))
-{
-}
-
-QGpgMECryptoConfigGroup::~QGpgMECryptoConfigGroup()
-{
- mEntriesNaturalOrder.clear();
- qDeleteAll(mEntriesByName);
- mEntriesByName.clear();
-}
-
-QStringList QGpgMECryptoConfigGroup::entryList() const
-{
- QStringList result;
- std::transform(mEntriesNaturalOrder.begin(), mEntriesNaturalOrder.end(),
- std::back_inserter(result), Select1St());
- return result;
-}
-
-Kleo::CryptoConfigEntry *QGpgMECryptoConfigGroup::entry(const QString &name) const
-{
- return mEntriesByName.value(name);
-}
-
-////
-
-static QString gpgconf_unescape(const QString &str, bool handleComma = true)
-{
- /* See gpgconf_escape */
- QString dec(str);
- dec.replace(QStringLiteral("%25"), QStringLiteral("%"));
- dec.replace(QStringLiteral("%3a"), QStringLiteral(":"));
- if (handleComma) {
- dec.replace(QStringLiteral("%2c"), QStringLiteral(","));
- }
- return dec;
-}
-
-static QString gpgconf_escape(const QString &str, bool handleComma = true)
-{
- /* Gpgconf does not really percent encode. It just
- * encodes , % and : characters. It expects all other
- * chars to be UTF-8 encoded.
- * Except in the Base-DN part where a , may not be percent
- * escaped.
- */
- QString esc(str);
- esc.replace(QLatin1Char('%'), QStringLiteral("%25"));
- esc.replace(QLatin1Char(':'), QStringLiteral("%3a"));
- if (handleComma) {
- esc.replace(QLatin1Char(','), QStringLiteral("%2c"));
- }
- return esc;
-}
-
-static QString urlpart_escape(const QString &str)
-{
- /* We need to double escape here, as a username or password
- * or an LDAP Base-DN may contain : or , and in that
- * case we would break gpgconf's format if we only escaped
- * the : once. As an escaped : is used internaly to split
- * the parts of an url. */
-
- return gpgconf_escape(gpgconf_escape(str, false), false);
-}
-
-static QString urlpart_unescape(const QString &str)
-{
- /* See urlpart_escape */
- return gpgconf_unescape(gpgconf_unescape(str, false), false);
-}
-
-// gpgconf arg type number -> CryptoConfigEntry arg type enum mapping
-static Kleo::CryptoConfigEntry::ArgType knownArgType(int argType, bool &ok)
-{
- ok = true;
- switch (argType) {
- case 0: // none
- return Kleo::CryptoConfigEntry::ArgType_None;
- case 1: // string
- return Kleo::CryptoConfigEntry::ArgType_String;
- case 2: // int32
- return Kleo::CryptoConfigEntry::ArgType_Int;
- case 3: // uint32
- return Kleo::CryptoConfigEntry::ArgType_UInt;
- case 32: // pathname
- return Kleo::CryptoConfigEntry::ArgType_Path;
- case 33: // ldap server
- return Kleo::CryptoConfigEntry::ArgType_LDAPURL;
- default:
- ok = false;
- return Kleo::CryptoConfigEntry::ArgType_None;
- }
-}
-
-QGpgMECryptoConfigEntry::QGpgMECryptoConfigEntry(QGpgMECryptoConfigGroup *group, const QStringList &parsedLine)
- : mGroup(group)
-{
- // Format: NAME:FLAGS:LEVEL:DESCRIPTION:TYPE:ALT-TYPE:ARGNAME:DEFAULT:ARGDEF:VALUE
- assert(parsedLine.count() >= 10); // called checked for it already
- QStringList::const_iterator it = parsedLine.constBegin();
- mName = *it++;
- mFlags = (*it++).toInt();
- mLevel = (*it++).toInt();
- mDescription = *it++;
- bool ok;
- // we keep the real (int) arg type, since it influences the parsing (e.g. for ldap urls)
- mRealArgType = (*it++).toInt();
- mArgType = knownArgType(mRealArgType, ok);
- if (!ok && !(*it).isEmpty()) {
- // use ALT-TYPE
- mRealArgType = (*it).toInt();
- mArgType = knownArgType(mRealArgType, ok);
- }
- if (!ok) {
- qCWarning(GPGPME_BACKEND_LOG) << "Unsupported datatype:" << parsedLine[4] << " :" << *it << " for" << parsedLine[0];
- }
- ++it; // done with alt-type
- ++it; // skip argname (not useful in GUIs)
-
- mSet = false;
- QString value;
- if (mFlags & GPGCONF_FLAG_DEFAULT) {
- value = *it; // get default value
- mDefaultValue = stringToValue(value, true);
- }
- ++it; // done with DEFAULT
- ++it; // ### skip ARGDEF for now. It's only for options with an "optional arg"
- //qCDebug(GPGPME_BACKEND_LOG) <<"Entry" << parsedLine[0] <<" val=" << *it;
-
- if (!(*it).isEmpty()) { // a real value was set
- mSet = true;
- value = *it;
- mValue = stringToValue(value, true);
- } else {
- mValue = mDefaultValue;
- }
-
- mDirty = false;
-}
-
-QVariant QGpgMECryptoConfigEntry::stringToValue(const QString &str, bool unescape) const
-{
- const bool isString = isStringType();
-
- if (isList()) {
- if (argType() == ArgType_None) {
- bool ok = true;
- const QVariant v = str.isEmpty() ? 0U : str.toUInt(&ok);
- if (!ok) {
- qCWarning(GPGPME_BACKEND_LOG) << "list-of-none should have an unsigned int as value:" << str;
- }
- return v;
- }
- QList<QVariant> lst;
- QStringList items = str.split(QLatin1Char(','), QString::SkipEmptyParts);
- for (QStringList::const_iterator valit = items.constBegin(); valit != items.constEnd(); ++valit) {
- QString val = *valit;
- if (isString) {
- if (val.isEmpty()) {
- lst << QVariant(QString());
- continue;
- } else if (unescape) {
- if (val[0] != QLatin1Char('"')) { // see README.gpgconf
- qCWarning(GPGPME_BACKEND_LOG) << "String value should start with '\"' :" << val;
- }
- val = val.mid(1);
- }
- }
- lst << QVariant(unescape ? gpgconf_unescape(val) : val);
- }
- return lst;
- } else { // not a list
- QString val(str);
- if (isString) {
- if (val.isEmpty()) {
- return QVariant(QString()); // not set [ok with lists too?]
- } else if (unescape) {
- if (val[0] != QLatin1Char('"')) { // see README.gpgconf
- qCWarning(GPGPME_BACKEND_LOG) << "String value should start with '\"' :" << val;
- }
- val = val.mid(1);
- }
- }
- return QVariant(unescape ? gpgconf_unescape(val) : val);
- }
-}
-
-QGpgMECryptoConfigEntry::~QGpgMECryptoConfigEntry()
-{
-#ifndef NDEBUG
- if (!s_duringClear && mDirty)
- qCWarning(GPGPME_BACKEND_LOG) << "Deleting a QGpgMECryptoConfigEntry that was modified (" << mDescription << ")"
- << "You forgot to call sync() (to commit) or clear() (to discard)";
-#endif
-}
-
-bool QGpgMECryptoConfigEntry::isOptional() const
-{
- return mFlags & GPGCONF_FLAG_OPTIONAL;
-}
-
-bool QGpgMECryptoConfigEntry::isReadOnly() const
-{
- return mFlags & GPGCONF_FLAG_NO_CHANGE;
-}
-
-bool QGpgMECryptoConfigEntry::isList() const
-{
- return mFlags & GPGCONF_FLAG_LIST;
-}
-
-bool QGpgMECryptoConfigEntry::isRuntime() const
-{
- return mFlags & GPGCONF_FLAG_RUNTIME;
-}
-
-bool QGpgMECryptoConfigEntry::isSet() const
-{
- return mSet;
-}
-
-bool QGpgMECryptoConfigEntry::boolValue() const
-{
- Q_ASSERT(mArgType == ArgType_None);
- Q_ASSERT(!isList());
- return mValue.toBool();
-}
-
-QString QGpgMECryptoConfigEntry::stringValue() const
-{
- return toString(false);
-}
-
-int QGpgMECryptoConfigEntry::intValue() const
-{
- Q_ASSERT(mArgType == ArgType_Int);
- Q_ASSERT(!isList());
- return mValue.toInt();
-}
-
-unsigned int QGpgMECryptoConfigEntry::uintValue() const
-{
- Q_ASSERT(mArgType == ArgType_UInt);
- Q_ASSERT(!isList());
- return mValue.toUInt();
-}
-
-static QUrl parseURL(int mRealArgType, const QString &str)
-{
- if (mRealArgType == 33) { // LDAP server
- // The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN
- QStringList items = str.split(QLatin1Char(':'));
- if (items.count() == 5) {
- QStringList::const_iterator it = items.constBegin();
- QUrl url;
- url.setScheme(QStringLiteral("ldap"));
- url.setHost(gpgconf_unescape(*it++));
-
- bool ok;
- const int port = (*it++).toInt(&ok);
- if (ok) {
- url.setPort(port);
- } else if (!it->isEmpty()) {
- qCWarning(GPGPME_BACKEND_LOG) << "parseURL: malformed LDAP server port, ignoring: \"" << *it << "\"";
- }
-
- const QString userName = urlpart_unescape(*it++);
- if (!userName.isEmpty()) {
- url.setUserName(userName);
- }
- const QString passWord = urlpart_unescape(*it++);
- if (!passWord.isEmpty()) {
- url.setPassword(passWord);
- }
- url.setQuery(urlpart_unescape(*it));
- return url;
- } else {
- qCWarning(GPGPME_BACKEND_LOG) << "parseURL: malformed LDAP server:" << str;
- }
- }
- // other URLs : assume wellformed URL syntax.
- return QUrl(str);
-}
-
-// The opposite of parseURL
-static QString splitURL(int mRealArgType, const QUrl &url)
-{
- if (mRealArgType == 33) { // LDAP server
- // The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN
- Q_ASSERT(url.scheme() == QLatin1String("ldap"));
- return gpgconf_escape(url.host()) + QLatin1Char(':') +
- (url.port() != -1 ? QString::number(url.port()) : QString()) + QLatin1Char(':') + // -1 is used for default ports, omit
- urlpart_escape(url.userName()) + QLatin1Char(':') +
- urlpart_escape(url.password()) + QLatin1Char(':') +
- urlpart_escape(url.query());
- }
- return url.path();
-}
-
-QUrl QGpgMECryptoConfigEntry::urlValue() const
-{
- Q_ASSERT(mArgType == ArgType_Path || mArgType == ArgType_LDAPURL);
- Q_ASSERT(!isList());
- QString str = mValue.toString();
- if (mArgType == ArgType_Path) {
- QUrl url = QUrl::fromUserInput(str, QString(), QUrl::AssumeLocalFile);
- return url;
- }
- return parseURL(mRealArgType, str);
-}
-
-unsigned int QGpgMECryptoConfigEntry::numberOfTimesSet() const
-{
- Q_ASSERT(mArgType == ArgType_None);
- Q_ASSERT(isList());
- return mValue.toUInt();
-}
-
-std::vector<int> QGpgMECryptoConfigEntry::intValueList() const
-{
- Q_ASSERT(mArgType == ArgType_Int);
- Q_ASSERT(isList());
- std::vector<int> ret;
- QList<QVariant> lst = mValue.toList();
- ret.reserve(lst.size());
- for (QList<QVariant>::const_iterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
- ret.push_back((*it).toInt());
- }
- return ret;
-}
-
-std::vector<unsigned int> QGpgMECryptoConfigEntry::uintValueList() const
-{
- Q_ASSERT(mArgType == ArgType_UInt);
- Q_ASSERT(isList());
- std::vector<unsigned int> ret;
- QList<QVariant> lst = mValue.toList();
- ret.reserve(lst.size());
- for (QList<QVariant>::const_iterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
- ret.push_back((*it).toUInt());
- }
- return ret;
-}
-
-QList<QUrl> QGpgMECryptoConfigEntry::urlValueList() const
-{
- Q_ASSERT(mArgType == ArgType_Path || mArgType == ArgType_LDAPURL);
- Q_ASSERT(isList());
- QStringList lst = mValue.toStringList();
-
- QList<QUrl> ret;
- for (QStringList::const_iterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
- if (mArgType == ArgType_Path) {
- QUrl url = QUrl::fromUserInput(*it, QString(), QUrl::AssumeLocalFile);
- } else {
- ret << parseURL(mRealArgType, *it);
- }
- }
- return ret;
-}
-
-void QGpgMECryptoConfigEntry::resetToDefault()
-{
- mSet = false;
- mDirty = true;
- if (mFlags & GPGCONF_FLAG_DEFAULT) {
- mValue = mDefaultValue;
- } else if (mArgType == ArgType_None) {
- if (isList()) {
- mValue = 0U;
- } else {
- mValue = false;
- }
- }
-}
-
-void QGpgMECryptoConfigEntry::setBoolValue(bool b)
-{
- Q_ASSERT(mArgType == ArgType_None);
- Q_ASSERT(!isList());
- // A "no arg" option is either set or not set.
- // Being set means mSet==true + mValue==true, being unset means resetToDefault(), i.e. both false
- mValue = b;
- mSet = b;
- mDirty = true;
-}
-
-void QGpgMECryptoConfigEntry::setStringValue(const QString &str)
-{
- mValue = stringToValue(str, false);
- // When setting a string to empty (and there's no default), we need to act like resetToDefault
- // Otherwise we try e.g. "ocsp-responder:0:" and gpgconf answers:
- // "gpgconf: argument required for option ocsp-responder"
- if (str.isEmpty() && !isOptional()) {
- mSet = false;
- } else {
- mSet = true;
- }
- mDirty = true;
-}
-
-void QGpgMECryptoConfigEntry::setIntValue(int i)
-{
- Q_ASSERT(mArgType == ArgType_Int);
- Q_ASSERT(!isList());
- mValue = i;
- mSet = true;
- mDirty = true;
-}
-
-void QGpgMECryptoConfigEntry::setUIntValue(unsigned int i)
-{
- mValue = i;
- mSet = true;
- mDirty = true;
-}
-
-void QGpgMECryptoConfigEntry::setURLValue(const QUrl &url)
-{
- QString str = splitURL(mRealArgType, url);
- if (str.isEmpty() && !isOptional()) {
- mSet = false;
- } else {
- mSet = true;
- }
- mValue = str;
- mDirty = true;
-}
-
-void QGpgMECryptoConfigEntry::setNumberOfTimesSet(unsigned int i)
-{
- Q_ASSERT(mArgType == ArgType_None);
- Q_ASSERT(isList());
- mValue = i;
- mSet = i > 0;
- mDirty = true;
-}
-
-void QGpgMECryptoConfigEntry::setIntValueList(const std::vector<int> &lst)
-{
- QList<QVariant> ret;
- for (std::vector<int>::const_iterator it = lst.begin(); it != lst.end(); ++it) {
- ret << QVariant(*it);
- }
- mValue = ret;
- if (ret.isEmpty() && !isOptional()) {
- mSet = false;
- } else {
- mSet = true;
- }
- mDirty = true;
-}
-
-void QGpgMECryptoConfigEntry::setUIntValueList(const std::vector<unsigned int> &lst)
-{
- QList<QVariant> ret;
- for (std::vector<unsigned int>::const_iterator it = lst.begin(); it != lst.end(); ++it) {
- ret << QVariant(*it);
- }
- if (ret.isEmpty() && !isOptional()) {
- mSet = false;
- } else {
- mSet = true;
- }
- mValue = ret;
- mDirty = true;
-}
-
-void QGpgMECryptoConfigEntry::setURLValueList(const QList<QUrl> &urls)
-{
- QStringList lst;
- for (QList<QUrl>::const_iterator it = urls.constBegin(); it != urls.constEnd(); ++it) {
- lst << splitURL(mRealArgType, *it);
- }
- mValue = lst;
- if (lst.isEmpty() && !isOptional()) {
- mSet = false;
- } else {
- mSet = true;
- }
- mDirty = true;
-}
-
-QString QGpgMECryptoConfigEntry::toString(bool escape) const
-{
- // Basically the opposite of stringToValue
- if (isStringType()) {
- if (mValue.isNull()) {
- return QString();
- } else if (isList()) { // string list
- QStringList lst = mValue.toStringList();
- if (escape) {
- for (QStringList::iterator it = lst.begin(); it != lst.end(); ++it) {
- if (!(*it).isNull()) {
- *it = gpgconf_escape(*it).prepend(QLatin1String("\""));
- }
- }
- }
- const QString res = lst.join(QStringLiteral(","));
- //qCDebug(GPGPME_BACKEND_LOG) <<"toString:" << res;
- return res;
- } else { // normal string
- QString res = mValue.toString();
- if (escape) {
- res = gpgconf_escape(res).prepend(QLatin1String("\""));
- }
- return res;
- }
- }
- if (!isList()) { // non-list non-string
- if (mArgType == ArgType_None) {
- return mValue.toBool() ? QStringLiteral("1") : QString();
- } else { // some int
- Q_ASSERT(mArgType == ArgType_Int || mArgType == ArgType_UInt);
- return mValue.toString(); // int to string conversion
- }
- }
-
- // Lists (of other types than strings)
- if (mArgType == ArgType_None) {
- return QString::number(numberOfTimesSet());
- }
-
- QStringList ret;
- QList<QVariant> lst = mValue.toList();
- for (QList<QVariant>::const_iterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
- ret << (*it).toString(); // QVariant does the conversion
- }
- return ret.join(QStringLiteral(","));
-}
-
-QString QGpgMECryptoConfigEntry::outputString() const
-{
- Q_ASSERT(mSet);
- return toString(true);
-}
-
-bool QGpgMECryptoConfigEntry::isStringType() const
-{
- return (mArgType == Kleo::CryptoConfigEntry::ArgType_String
- || mArgType == Kleo::CryptoConfigEntry::ArgType_Path
- || mArgType == Kleo::CryptoConfigEntry::ArgType_LDAPURL);
-}
-
-void QGpgMECryptoConfigEntry::setDirty(bool b)
-{
- mDirty = b;
-}
-
diff --git a/src/backends/qgpgme/qgpgmecryptoconfig.h b/src/backends/qgpgme/qgpgmecryptoconfig.h
deleted file mode 100644
index 7a01399..0000000
--- a/src/backends/qgpgme/qgpgmecryptoconfig.h
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- qgpgmecryptoconfig.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_QGPGMECRYPTOCONFIG_H
-#define KLEO_QGPGMECRYPTOCONFIG_H
-
-#include "kleo_export.h"
-#include "libkleo/cryptoconfig.h"
-
-#include <QHash>
-#include <QStringList>
-#include <QObject>
-#include <QVariant>
-#include <QPointer>
-
-#include <vector>
-#include <utility>
-
-class QGpgMECryptoConfigComponent;
-class QGpgMECryptoConfigEntry;
-/**
- * CryptoConfig implementation around the gpgconf command-line tool
- * For method docu, see kleo/cryptoconfig.h
- */
-class KLEO_EXPORT QGpgMECryptoConfig : public QObject, public Kleo::CryptoConfig
-{
-
- Q_OBJECT
-public:
-
- static QString gpgConfPath();
- /**
- * Constructor
- */
- QGpgMECryptoConfig();
- virtual ~QGpgMECryptoConfig();
-
- QStringList componentList() const Q_DECL_OVERRIDE;
-
- Kleo::CryptoConfigComponent *component(const QString &name) const Q_DECL_OVERRIDE;
-
- void clear() Q_DECL_OVERRIDE;
- void sync(bool runtime) Q_DECL_OVERRIDE;
-
-private Q_SLOTS:
- void slotCollectStdOut();
-private:
- /// @param showErrors if true, a messagebox will be shown if e.g. gpgconf wasn't found
- void runGpgConf(bool showErrors);
-
-private:
- std::vector<std::pair<QString, QGpgMECryptoConfigComponent *> > mComponentsNaturalOrder;
- QHash<QString, QGpgMECryptoConfigComponent *> mComponentsByName;
- bool mParsed;
-};
-
-class QGpgMECryptoConfigGroup;
-
-/// For docu, see kleo/cryptoconfig.h
-class QGpgMECryptoConfigComponent : public QObject, public Kleo::CryptoConfigComponent
-{
-
- Q_OBJECT
-public:
- QGpgMECryptoConfigComponent(QGpgMECryptoConfig *, const QString &name, const QString &description);
- ~QGpgMECryptoConfigComponent();
-
- QString name() const Q_DECL_OVERRIDE
- {
- return mName;
- }
- QString iconName() const Q_DECL_OVERRIDE
- {
- return mName;
- }
- QString description() const Q_DECL_OVERRIDE
- {
- return mDescription;
- }
- QStringList groupList() const Q_DECL_OVERRIDE;
- Kleo::CryptoConfigGroup *group(const QString &name) const Q_DECL_OVERRIDE;
-
- void sync(bool runtime);
-
-private Q_SLOTS:
- void slotCollectStdOut();
-private:
- void runGpgConf();
-
-private:
- std::vector< std::pair<QString, QGpgMECryptoConfigGroup *> > mGroupsNaturalOrder;
- QHash<QString, QGpgMECryptoConfigGroup *> mGroupsByName;
- QString mName;
- QString mDescription;
- QGpgMECryptoConfigGroup *mCurrentGroup; // during parsing
- QString mCurrentGroupName; // during parsing
-};
-
-class QGpgMECryptoConfigGroup : public Kleo::CryptoConfigGroup
-{
-
-public:
- QGpgMECryptoConfigGroup(QGpgMECryptoConfigComponent *comp, const QString &name, const QString &description, int level);
- ~QGpgMECryptoConfigGroup();
-
- QString name() const Q_DECL_OVERRIDE
- {
- return mName;
- }
- QString iconName() const Q_DECL_OVERRIDE
- {
- return QString();
- }
- QString description() const Q_DECL_OVERRIDE
- {
- return mDescription;
- }
- QString path() const Q_DECL_OVERRIDE
- {
- return mComponent->name() + QLatin1Char('/') + mName;
- }
- Kleo::CryptoConfigEntry::Level level() const Q_DECL_OVERRIDE
- {
- return mLevel;
- }
- QStringList entryList() const Q_DECL_OVERRIDE;
- Kleo::CryptoConfigEntry *entry(const QString &name) const Q_DECL_OVERRIDE;
-
-private:
- friend class QGpgMECryptoConfigComponent; // it adds the entries
- QPointer<QGpgMECryptoConfigComponent> mComponent;
- std::vector< std::pair<QString, QGpgMECryptoConfigEntry *> > mEntriesNaturalOrder;
- QHash<QString, QGpgMECryptoConfigEntry *> mEntriesByName;
- QString mName;
- QString mDescription;
- Kleo::CryptoConfigEntry::Level mLevel;
-};
-
-class QGpgMECryptoConfigEntry : public Kleo::CryptoConfigEntry
-{
-public:
- QGpgMECryptoConfigEntry(QGpgMECryptoConfigGroup *group, const QStringList &parsedLine);
- ~QGpgMECryptoConfigEntry();
-
- QString name() const Q_DECL_OVERRIDE
- {
- return mName;
- }
- QString description() const Q_DECL_OVERRIDE
- {
- return mDescription;
- }
- QString path() const Q_DECL_OVERRIDE
- {
- return mGroup->path() + QLatin1Char('/') + mName;
- }
- bool isOptional() const Q_DECL_OVERRIDE;
- bool isReadOnly() const Q_DECL_OVERRIDE;
- bool isList() const Q_DECL_OVERRIDE;
- bool isRuntime() const Q_DECL_OVERRIDE;
- Level level() const Q_DECL_OVERRIDE
- {
- return static_cast<Level>(mLevel);
- }
- ArgType argType() const Q_DECL_OVERRIDE
- {
- return static_cast<ArgType>(mArgType);
- }
- bool isSet() const Q_DECL_OVERRIDE;
- bool boolValue() const Q_DECL_OVERRIDE;
- QString stringValue() const Q_DECL_OVERRIDE;
- int intValue() const Q_DECL_OVERRIDE;
- unsigned int uintValue() const Q_DECL_OVERRIDE;
- QUrl urlValue() const Q_DECL_OVERRIDE;
- unsigned int numberOfTimesSet() const Q_DECL_OVERRIDE;
- std::vector<int> intValueList() const Q_DECL_OVERRIDE;
- std::vector<unsigned int> uintValueList() const Q_DECL_OVERRIDE;
- QList<QUrl> urlValueList() const Q_DECL_OVERRIDE;
- void resetToDefault() Q_DECL_OVERRIDE;
- void setBoolValue(bool) Q_DECL_OVERRIDE;
- void setStringValue(const QString &) Q_DECL_OVERRIDE;
- void setIntValue(int) Q_DECL_OVERRIDE;
- void setUIntValue(unsigned int) Q_DECL_OVERRIDE;
- void setURLValue(const QUrl &) Q_DECL_OVERRIDE;
- void setNumberOfTimesSet(unsigned int) Q_DECL_OVERRIDE;
- void setIntValueList(const std::vector<int> &) Q_DECL_OVERRIDE;
- void setUIntValueList(const std::vector<unsigned int> &) Q_DECL_OVERRIDE;
- void setURLValueList(const QList<QUrl> &) Q_DECL_OVERRIDE;
- bool isDirty() const Q_DECL_OVERRIDE
- {
- return mDirty;
- }
-
- void setDirty(bool b);
- QString outputString() const;
-
-protected:
- bool isStringType() const;
- QVariant stringToValue(const QString &value, bool unescape) const;
- QString toString(bool escape) const;
-private:
- QGpgMECryptoConfigGroup *mGroup;
- QString mName;
- QString mDescription;
- QVariant mDefaultValue;
- QVariant mValue;
- uint mFlags : 8; // bitfield with 8 bits
- uint mLevel : 3; // max is 4 (2, in fact) -> 3 bits
- uint mRealArgType : 6; // max is 33 -> 6 bits
- uint mArgType : 3; // max is 6 (ArgType enum) -> 3 bits;
- uint mDirty : 1;
- uint mSet : 1;
-};
-
-#endif /* KLEO_QGPGMECRYPTOCONFIG_H */
diff --git a/src/backends/qgpgme/qgpgmedecryptjob.cpp b/src/backends/qgpgme/qgpgmedecryptjob.cpp
deleted file mode 100644
index fe0728c..0000000
--- a/src/backends/qgpgme/qgpgmedecryptjob.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- qgpgmedecryptjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmedecryptjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/decryptionresult.h>
-#include <gpgme++/data.h>
-
-#include <QBuffer>
-
-#include <boost/weak_ptr.hpp>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEDecryptJob::QGpgMEDecryptJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEDecryptJob::~QGpgMEDecryptJob() {}
-
-static QGpgMEDecryptJob::result_type decrypt(Context *ctx, QThread *thread, const weak_ptr<QIODevice> &cipherText_, const weak_ptr<QIODevice> &plainText_)
-{
-
- const shared_ptr<QIODevice> cipherText = cipherText_.lock();
- const shared_ptr<QIODevice> plainText = plainText_.lock();
-
- const _detail::ToThreadMover ctMover(cipherText, thread);
- const _detail::ToThreadMover ptMover(plainText, thread);
-
- QGpgME::QIODeviceDataProvider in(cipherText);
- const Data indata(&in);
-
- if (!plainText) {
- QGpgME::QByteArrayDataProvider out;
- Data outdata(&out);
-
- const DecryptionResult res = ctx->decrypt(indata, outdata);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, out.data(), log, ae);
- } else {
- QGpgME::QIODeviceDataProvider out(plainText);
- Data outdata(&out);
-
- const DecryptionResult res = ctx->decrypt(indata, outdata);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, QByteArray(), log, ae);
- }
-
-}
-
-static QGpgMEDecryptJob::result_type decrypt_qba(Context *ctx, const QByteArray &cipherText)
-{
- const shared_ptr<QBuffer> buffer(new QBuffer);
- buffer->setData(cipherText);
- if (!buffer->open(QIODevice::ReadOnly)) {
- assert(!"This should never happen: QBuffer::open() failed");
- }
- return decrypt(ctx, 0, buffer, shared_ptr<QIODevice>());
-}
-
-Error QGpgMEDecryptJob::start(const QByteArray &cipherText)
-{
- run(bind(&decrypt_qba, _1, cipherText));
- return Error();
-}
-
-void QGpgMEDecryptJob::start(const shared_ptr<QIODevice> &cipherText, const shared_ptr<QIODevice> &plainText)
-{
- run(bind(&decrypt, _1, _2, _3, _4), cipherText, plainText);
-}
-
-GpgME::DecryptionResult Kleo::QGpgMEDecryptJob::exec(const QByteArray &cipherText,
- QByteArray &plainText)
-{
- const result_type r = decrypt_qba(context(), cipherText);
- plainText = get<1>(r);
- resultHook(r);
- return mResult;
-}
-
-//PENDING(marc) implement showErrorDialog()
-
-void QGpgMEDecryptJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
-}
-
diff --git a/src/backends/qgpgme/qgpgmedecryptjob.h b/src/backends/qgpgme/qgpgmedecryptjob.h
deleted file mode 100644
index a1e9f04..0000000
--- a/src/backends/qgpgme/qgpgmedecryptjob.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- qgpgmedecryptjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEDECRYPTJOB_H__
-#define __KLEO_QGPGMEDECRYPTJOB_H__
-
-#include "libkleo/decryptjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/decryptionresult.h>
-
-namespace Kleo
-{
-
-class QGpgMEDecryptJob
-#ifdef Q_MOC_RUN
- : public DecryptJob
-#else
- : public _detail::ThreadedJobMixin<DecryptJob, boost::tuple<GpgME::DecryptionResult, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-private Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEDecryptJob(GpgME::Context *context);
- ~QGpgMEDecryptJob();
-
- /*! \reimp from DecryptJob */
- GpgME::Error start(const QByteArray &cipherText) Q_DECL_OVERRIDE;
-
- /*! \reimp from DecryptJob */
- void start(const boost::shared_ptr<QIODevice> &cipherText, const boost::shared_ptr<QIODevice> &plainText) Q_DECL_OVERRIDE;
-
- /*! \reimp from DecryptJob */
- GpgME::DecryptionResult exec(const QByteArray &cipherText,
- QByteArray &plainText) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- GpgME::DecryptionResult mResult;
-};
-
-}
-#endif // __KLEO_QGPGMEDECRYPTJOB_H__
diff --git a/src/backends/qgpgme/qgpgmedecryptverifyjob.cpp b/src/backends/qgpgme/qgpgmedecryptverifyjob.cpp
deleted file mode 100644
index 786ea69..0000000
--- a/src/backends/qgpgme/qgpgmedecryptverifyjob.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- qgpgmedecryptverifyjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmedecryptverifyjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/decryptionresult.h>
-#include <gpgme++/verificationresult.h>
-#include <gpgme++/data.h>
-
-#include <QDebug>
-#include "gpgme_backend_debug.h"
-
-#include <QBuffer>
-
-#include <boost/weak_ptr.hpp>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEDecryptVerifyJob::QGpgMEDecryptVerifyJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEDecryptVerifyJob::~QGpgMEDecryptVerifyJob() {}
-
-static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread *thread, const weak_ptr<QIODevice> &cipherText_, const weak_ptr<QIODevice> &plainText_)
-{
-
- qCDebug(GPGPME_BACKEND_LOG);
-
- const shared_ptr<QIODevice> cipherText = cipherText_.lock();
- const shared_ptr<QIODevice> plainText = plainText_.lock();
-
- const _detail::ToThreadMover ctMover(cipherText, thread);
- const _detail::ToThreadMover ptMover(plainText, thread);
-
- QGpgME::QIODeviceDataProvider in(cipherText);
- const Data indata(&in);
-
- if (!plainText) {
- QGpgME::QByteArrayDataProvider out;
- Data outdata(&out);
-
- const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- qCDebug(GPGPME_BACKEND_LOG) << "End no plainText. Error: " << ae;
- return make_tuple(res.first, res.second, out.data(), log, ae);
- } else {
- QGpgME::QIODeviceDataProvider out(plainText);
- Data outdata(&out);
-
- const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- qCDebug(GPGPME_BACKEND_LOG) << "End plainText. Error: " << ae;
- return make_tuple(res.first, res.second, QByteArray(), log, ae);
- }
-
-}
-
-static QGpgMEDecryptVerifyJob::result_type decrypt_verify_qba(Context *ctx, const QByteArray &cipherText)
-{
- const shared_ptr<QBuffer> buffer(new QBuffer);
- buffer->setData(cipherText);
- if (!buffer->open(QIODevice::ReadOnly)) {
- assert(!"This should never happen: QBuffer::open() failed");
- }
- return decrypt_verify(ctx, 0, buffer, shared_ptr<QIODevice>());
-}
-
-Error QGpgMEDecryptVerifyJob::start(const QByteArray &cipherText)
-{
- run(bind(&decrypt_verify_qba, _1, cipherText));
- return Error();
-}
-
-void QGpgMEDecryptVerifyJob::start(const shared_ptr<QIODevice> &cipherText, const shared_ptr<QIODevice> &plainText)
-{
- run(bind(&decrypt_verify, _1, _2, _3, _4), cipherText, plainText);
-}
-
-std::pair<GpgME::DecryptionResult, GpgME::VerificationResult>
-Kleo::QGpgMEDecryptVerifyJob::exec(const QByteArray &cipherText, QByteArray &plainText)
-{
- const result_type r = decrypt_verify_qba(context(), cipherText);
- plainText = get<2>(r);
- resultHook(r);
- return mResult;
-}
-
-//PENDING(marc) implement showErrorDialog()
-
-void QGpgMEDecryptVerifyJob::resultHook(const result_type &tuple)
-{
- mResult = std::make_pair(get<0>(tuple), get<1>(tuple));
-}
-
diff --git a/src/backends/qgpgme/qgpgmedecryptverifyjob.h b/src/backends/qgpgme/qgpgmedecryptverifyjob.h
deleted file mode 100644
index 9f662c9..0000000
--- a/src/backends/qgpgme/qgpgmedecryptverifyjob.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- qgpgmedecryptverifyjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEDECRYPTVERIFYJOB_H__
-#define __KLEO_QGPGMEDECRYPTVERIFYJOB_H__
-
-#include "libkleo/decryptverifyjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/decryptionresult.h>
-#include <gpgme++/verificationresult.h>
-
-namespace Kleo
-{
-
-class QGpgMEDecryptVerifyJob
-#ifdef Q_MOC_RUN
- : public DecryptVerifyJob
-#else
- : public _detail::ThreadedJobMixin<DecryptVerifyJob, boost::tuple<GpgME::DecryptionResult, GpgME::VerificationResult, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-private Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEDecryptVerifyJob(GpgME::Context *context);
- ~QGpgMEDecryptVerifyJob();
-
- /*! \reimp from DecryptVerifyJob */
- GpgME::Error start(const QByteArray &cipherText) Q_DECL_OVERRIDE;
-
- /*! \reimp from DecryptVerifyJob */
- void start(const boost::shared_ptr<QIODevice> &cipherText, const boost::shared_ptr<QIODevice> &plainText) Q_DECL_OVERRIDE;
-
- /*! \reimp from DecryptVerifyJob */
- std::pair<GpgME::DecryptionResult, GpgME::VerificationResult>
- exec(const QByteArray &cipherText, QByteArray &plainText) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- std::pair<GpgME::DecryptionResult, GpgME::VerificationResult> mResult;
-};
-
-}
-#endif // __KLEO_QGPGMEDECRYPTVERIFYJOB_H__
diff --git a/src/backends/qgpgme/qgpgmedeletejob.cpp b/src/backends/qgpgme/qgpgmedeletejob.cpp
deleted file mode 100644
index 5fca8f2..0000000
--- a/src/backends/qgpgme/qgpgmedeletejob.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- qgpgmedeletejob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmedeletejob.h"
-
-#include <gpgme++/context.h>
-#include <gpgme++/key.h>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEDeleteJob::QGpgMEDeleteJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEDeleteJob::~QGpgMEDeleteJob() {}
-
-static QGpgMEDeleteJob::result_type delete_key(Context *ctx, const Key &key, bool allowSecretKeyDeletion)
-{
- const Error err = ctx->deleteKey(key, allowSecretKeyDeletion);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, log, ae);
-}
-
-Error QGpgMEDeleteJob::start(const Key &key, bool allowSecretKeyDeletion)
-{
- run(bind(&delete_key, _1, key, allowSecretKeyDeletion));
- return Error();
-}
-
diff --git a/src/backends/qgpgme/qgpgmedeletejob.h b/src/backends/qgpgme/qgpgmedeletejob.h
deleted file mode 100644
index 878aa8b..0000000
--- a/src/backends/qgpgme/qgpgmedeletejob.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- qgpgmedeletejob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEDELETEJOB_H__
-#define __KLEO_QGPGMEDELETEJOB_H__
-
-#include "libkleo/deletejob.h"
-
-#include "threadedjobmixin.h"
-
-namespace GpgME
-{
-class Key;
-}
-
-namespace Kleo
-{
-
-class QGpgMEDeleteJob
-#ifdef Q_MOC_RUN
- : public DeleteJob
-#else
- : public _detail::ThreadedJobMixin<DeleteJob>
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEDeleteJob(GpgME::Context *context);
- ~QGpgMEDeleteJob();
-
- /*! \reimp from DeleteJob */
- GpgME::Error start(const GpgME::Key &key, bool allowSecretKeyDeletion) Q_DECL_OVERRIDE;
-};
-
-}
-
-#endif // __KLEO_QGPGMEDELETEJOB_H__
diff --git a/src/backends/qgpgme/qgpgmedownloadjob.cpp b/src/backends/qgpgme/qgpgmedownloadjob.cpp
deleted file mode 100644
index 9917425..0000000
--- a/src/backends/qgpgme/qgpgmedownloadjob.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- qgpgmedownloadjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmedownloadjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-
-#include <QStringList>
-
-#include <boost/weak_ptr.hpp>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEDownloadJob::QGpgMEDownloadJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEDownloadJob::~QGpgMEDownloadJob() {}
-
-static QGpgMEDownloadJob::result_type download_qsl(Context *ctx, const QStringList &pats)
-{
- QGpgME::QByteArrayDataProvider dp;
- Data data(&dp);
-
- const _detail::PatternConverter pc(pats);
-
- const Error err = ctx->exportPublicKeys(pc.patterns(), data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, dp.data(), log, ae);
-}
-
-static QGpgMEDownloadJob::result_type download(Context *ctx, QThread *thread, const QByteArray &fpr, const weak_ptr<QIODevice> &keyData_)
-{
- const shared_ptr<QIODevice> keyData = keyData_.lock();
- if (!keyData) {
- return download_qsl(ctx, QStringList(QString::fromUtf8(fpr)));
- }
-
- const _detail::ToThreadMover kdMover(keyData, thread);
-
- QGpgME::QIODeviceDataProvider dp(keyData);
- Data data(&dp);
-
- const _detail::PatternConverter pc(fpr);
-
- const Error err = ctx->exportPublicKeys(pc.patterns(), data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, QByteArray(), log, ae);
-}
-
-Error QGpgMEDownloadJob::start(const QStringList &pats)
-{
- run(bind(&download_qsl, _1, pats));
- return Error();
-}
-
-Error QGpgMEDownloadJob::start(const QByteArray &fpr, const boost::shared_ptr<QIODevice> &keyData)
-{
- run(bind(&download, _1, _2, fpr, _3), keyData);
- return Error();
-}
-
diff --git a/src/backends/qgpgme/qgpgmedownloadjob.h b/src/backends/qgpgme/qgpgmedownloadjob.h
deleted file mode 100644
index 2e7d971..0000000
--- a/src/backends/qgpgme/qgpgmedownloadjob.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- qgpgmedownloadjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEDOWNLOADJOB_H__
-#define __KLEO_QGPGMEDOWNLOADJOB_H__
-
-#include "kleo/downloadjob.h"
-
-#include "threadedjobmixin.h"
-
-namespace Kleo
-{
-
-class QGpgMEDownloadJob
-#ifdef Q_MOC_RUN
- : public DownloadJob
-#else
- : public _detail::ThreadedJobMixin<DownloadJob, boost::tuple<GpgME::Error, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEDownloadJob(GpgME::Context *context);
- ~QGpgMEDownloadJob();
-
- /*! \reimp from DownloadJob */
- GpgME::Error start(const QStringList &fingerprints) Q_DECL_OVERRIDE;
-
- /*! \reimp from DownloadJob */
- GpgME::Error start(const QByteArray &fingerprint, const boost::shared_ptr<QIODevice> &keyData) Q_DECL_OVERRIDE;
-};
-
-}
-
-#endif // __KLEO_QGPGMEDOWNLOADJOB_H__
diff --git a/src/backends/qgpgme/qgpgmeencryptjob.cpp b/src/backends/qgpgme/qgpgmeencryptjob.cpp
deleted file mode 100644
index 2f70a9d..0000000
--- a/src/backends/qgpgme/qgpgmeencryptjob.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- qgpgmeencryptjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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.
-*/
-
-#include "qgpgmeencryptjob.h"
-
-#include "ui/messagebox.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/encryptionresult.h>
-#include <gpgme++/data.h>
-
-#include <QBuffer>
-
-#include <boost/weak_ptr.hpp>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEEncryptJob::QGpgMEEncryptJob(Context *context)
- : mixin_type(context),
- mOutputIsBase64Encoded(false)
-{
- lateInitialization();
-}
-
-QGpgMEEncryptJob::~QGpgMEEncryptJob() {}
-
-void QGpgMEEncryptJob::setOutputIsBase64Encoded(bool on)
-{
- mOutputIsBase64Encoded = on;
-}
-
-static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread,
- const std::vector<Key> &recipients,
- const weak_ptr<QIODevice> &plainText_,
- const weak_ptr<QIODevice> &cipherText_,
- const Context::EncryptionFlags eflags,
- bool outputIsBsse64Encoded)
-{
-
- const shared_ptr<QIODevice> plainText = plainText_.lock();
- const shared_ptr<QIODevice> cipherText = cipherText_.lock();
-
- const _detail::ToThreadMover ctMover(cipherText, thread);
- const _detail::ToThreadMover ptMover(plainText, thread);
-
- QGpgME::QIODeviceDataProvider in(plainText);
- const Data indata(&in);
-
- if (!cipherText) {
- QGpgME::QByteArrayDataProvider out;
- Data outdata(&out);
-
- if (outputIsBsse64Encoded) {
- outdata.setEncoding(Data::Base64Encoding);
- }
-
- const EncryptionResult res = ctx->encrypt(recipients, indata, outdata, eflags);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, out.data(), log, ae);
- } else {
- QGpgME::QIODeviceDataProvider out(cipherText);
- Data outdata(&out);
-
- if (outputIsBsse64Encoded) {
- outdata.setEncoding(Data::Base64Encoding);
- }
-
- const EncryptionResult res = ctx->encrypt(recipients, indata, outdata, eflags);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, QByteArray(), log, ae);
- }
-
-}
-
-static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded)
-{
- const shared_ptr<QBuffer> buffer(new QBuffer);
- buffer->setData(plainText);
- if (!buffer->open(QIODevice::ReadOnly)) {
- assert(!"This should never happen: QBuffer::open() failed");
- }
- return encrypt(ctx, 0, recipients, buffer, shared_ptr<QIODevice>(), eflags, outputIsBsse64Encoded);
-}
-
-Error QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust)
-{
- run(boost::bind(&encrypt_qba, _1, recipients, plainText,
- alwaysTrust ? Context::AlwaysTrust : Context::None, mOutputIsBase64Encoded));
- return Error();
-}
-
-void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const shared_ptr<QIODevice> &plainText,
- const shared_ptr<QIODevice> &cipherText, const Context::EncryptionFlags eflags)
-{
- run(boost::bind(&encrypt,
- _1, _2,
- recipients,
- _3, _4,
- eflags,
- mOutputIsBase64Encoded),
- plainText, cipherText);
-}
-
-EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, const QByteArray &plainText,
- const Context::EncryptionFlags eflags, QByteArray &cipherText)
-{
- const result_type r = encrypt_qba(context(), recipients, plainText, eflags, mOutputIsBase64Encoded);
- cipherText = get<1>(r);
- resultHook(r);
- return mResult;
-}
-
-void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const shared_ptr<QIODevice> &plainText, const shared_ptr<QIODevice> &cipherText, bool alwaysTrust)
-{
- return start(recipients, plainText, cipherText, alwaysTrust ? Context::AlwaysTrust : Context::None);
-}
-
-EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText)
-{
- return exec(recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, cipherText);
-}
-
-void QGpgMEEncryptJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
-}
-
-void QGpgMEEncryptJob::showErrorDialog(QWidget *parent, const QString &caption) const
-{
- if (mResult.error() && !mResult.error().isCanceled()) {
- MessageBox::error(parent, mResult, this, caption);
- }
-}
-
diff --git a/src/backends/qgpgme/qgpgmeencryptjob.h b/src/backends/qgpgme/qgpgmeencryptjob.h
deleted file mode 100644
index 9819022..0000000
--- a/src/backends/qgpgme/qgpgmeencryptjob.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- qgpgmeencryptjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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_QGPGMEENCRYPTJOB_H__
-#define __KLEO_QGPGMEENCRYPTJOB_H__
-
-#include "libkleo/encryptjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/encryptionresult.h>
-#include <gpgme++/key.h>
-
-namespace Kleo
-{
-
-class QGpgMEEncryptJob
-#ifdef Q_MOC_RUN
- : public EncryptJob
-#else
- : public _detail::ThreadedJobMixin<EncryptJob, boost::tuple<GpgME::EncryptionResult, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEEncryptJob(GpgME::Context *context);
- ~QGpgMEEncryptJob();
-
- /*! \reimp from EncryptJob */
- GpgME::Error start(const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText, bool alwaysTrust) Q_DECL_OVERRIDE;
-
- /*! \reimp from EncryptJob */
- void start(const std::vector<GpgME::Key> &recipients,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &cipherText,
- bool alwaysTrust) Q_DECL_OVERRIDE;
-
- /*! \reimp from EncryptJob */
- GpgME::EncryptionResult exec(const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText, bool alwaysTrust,
- QByteArray &cipherText) Q_DECL_OVERRIDE;
- /* from EncryptJob */
- void start(const std::vector<GpgME::Key> &recipients,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &cipherText,
- const GpgME::Context::EncryptionFlags flags) Q_DECL_OVERRIDE;
-
- /* from EncryptJob */
- GpgME::EncryptionResult exec(const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText, const GpgME::Context::EncryptionFlags flags,
- QByteArray &cipherText) Q_DECL_OVERRIDE;
-
- /*! \reimp from Job */
- void showErrorDialog(QWidget *parent, const QString &caption) const Q_DECL_OVERRIDE;
-
- /*! \reimp from EncryptJob */
- void setOutputIsBase64Encoded(bool on) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- bool mOutputIsBase64Encoded;
- GpgME::EncryptionResult mResult;
-};
-
-}
-
-#endif // __KLEO_QGPGMEENCRYPTJOB_H__
diff --git a/src/backends/qgpgme/qgpgmeexportjob.cpp b/src/backends/qgpgme/qgpgmeexportjob.cpp
deleted file mode 100644
index 02337c2..0000000
--- a/src/backends/qgpgme/qgpgmeexportjob.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- qgpgmeexportjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmeexportjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/key.h>
-
-#include <QStringList>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEExportJob::QGpgMEExportJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEExportJob::~QGpgMEExportJob() {}
-
-static QGpgMEExportJob::result_type export_qba(Context *ctx, const QStringList &patterns)
-{
-
- const _detail::PatternConverter pc(patterns);
-
- QGpgME::QByteArrayDataProvider dp;
- Data data(&dp);
-
- const Error err = ctx->exportPublicKeys(pc.patterns(), data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, dp.data(), log, ae);
-}
-
-Error QGpgMEExportJob::start(const QStringList &patterns)
-{
- run(bind(&export_qba, _1, patterns));
- return Error();
-}
-
diff --git a/src/backends/qgpgme/qgpgmeexportjob.h b/src/backends/qgpgme/qgpgmeexportjob.h
deleted file mode 100644
index e6807cf..0000000
--- a/src/backends/qgpgme/qgpgmeexportjob.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- qgpgmeexportjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEEXPORTJOB_H__
-#define __KLEO_QGPGMEEXPORTJOB_H__
-
-#include "libkleo/exportjob.h"
-
-#include "threadedjobmixin.h"
-
-namespace Kleo
-{
-
-class QGpgMEExportJob
-#ifdef Q_MOC_RUN
- : public ExportJob
-#else
- : public _detail::ThreadedJobMixin<ExportJob, boost::tuple<GpgME::Error, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEExportJob(GpgME::Context *context);
- ~QGpgMEExportJob();
-
- /*! \reimp from ExportJob */
- GpgME::Error start(const QStringList &patterns) Q_DECL_OVERRIDE;
-};
-
-}
-
-#endif // __KLEO_QGPGMEEXPORTJOB_H__
diff --git a/src/backends/qgpgme/qgpgmeimportfromkeyserverjob.cpp b/src/backends/qgpgme/qgpgmeimportfromkeyserverjob.cpp
deleted file mode 100644
index 87c4e82..0000000
--- a/src/backends/qgpgme/qgpgmeimportfromkeyserverjob.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- qgpgmeimportfromkeyserverjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmeimportfromkeyserverjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/key.h>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEImportFromKeyserverJob::QGpgMEImportFromKeyserverJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEImportFromKeyserverJob::~QGpgMEImportFromKeyserverJob() {}
-
-static QGpgMEImportFromKeyserverJob::result_type importfromkeyserver(Context *ctx, const std::vector<Key> &keys)
-{
- const ImportResult res = ctx->importKeys(keys);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, log, ae);
-}
-
-Error QGpgMEImportFromKeyserverJob::start(const std::vector<Key> &keys)
-{
- run(boost::bind(&importfromkeyserver, _1, keys));
- return Error();
-}
-
-GpgME::ImportResult Kleo::QGpgMEImportFromKeyserverJob::exec(const std::vector<Key> &keys)
-{
- const result_type r = importfromkeyserver(context(), keys);
- resultHook(r);
- return mResult;
-}
-
-// PENDING(marc) implement showErrorDialog()
-
-void Kleo::QGpgMEImportFromKeyserverJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
-}
-
diff --git a/src/backends/qgpgme/qgpgmeimportfromkeyserverjob.h b/src/backends/qgpgme/qgpgmeimportfromkeyserverjob.h
deleted file mode 100644
index 4869414..0000000
--- a/src/backends/qgpgme/qgpgmeimportfromkeyserverjob.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- qgpgmeimportfromkeyserverjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEIMPORTFROMKEYSERVERJOB_H__
-#define __KLEO_QGPGMEIMPORTFROMKEYSERVERJOB_H__
-
-#include "libkleo/importfromkeyserverjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/importresult.h>
-
-namespace Kleo
-{
-
-class QGpgMEImportFromKeyserverJob
-#ifdef Q_MOC_RUN
- : public ImportFromKeyserverJob
-#else
- : public _detail::ThreadedJobMixin<ImportFromKeyserverJob, boost::tuple<GpgME::ImportResult, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEImportFromKeyserverJob(GpgME::Context *context);
- ~QGpgMEImportFromKeyserverJob();
-
- /*! \reimp from ImportFromKeyserverJob */
- GpgME::Error start(const std::vector<GpgME::Key> &keys) Q_DECL_OVERRIDE;
-
- /*! \reimp from ImportFromKeyserverJob */
- GpgME::ImportResult exec(const std::vector<GpgME::Key> &keys) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- GpgME::ImportResult mResult;
-};
-
-}
-
-#endif // __KLEO_QGPGMEIMPORTFROMKEYSERVERJOB_H__
diff --git a/src/backends/qgpgme/qgpgmeimportjob.cpp b/src/backends/qgpgme/qgpgmeimportjob.cpp
deleted file mode 100644
index a9d0bf4..0000000
--- a/src/backends/qgpgme/qgpgmeimportjob.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- qgpgmeimportjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmeimportjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/key.h>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEImportJob::QGpgMEImportJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEImportJob::~QGpgMEImportJob() {}
-
-static QGpgMEImportJob::result_type import_qba(Context *ctx, const QByteArray &certData)
-{
- QGpgME::QByteArrayDataProvider dp(certData);
- Data data(&dp);
-
- const ImportResult res = ctx->importKeys(data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, log, ae);
-}
-
-Error QGpgMEImportJob::start(const QByteArray &certData)
-{
- run(bind(&import_qba, _1, certData));
- return Error();
-}
-
-GpgME::ImportResult Kleo::QGpgMEImportJob::exec(const QByteArray &keyData)
-{
- const result_type r = import_qba(context(), keyData);
- resultHook(r);
- return mResult;
-}
-
-// PENDING(marc) implement showErrorDialog()
-
-void Kleo::QGpgMEImportJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
-}
-
diff --git a/src/backends/qgpgme/qgpgmeimportjob.h b/src/backends/qgpgme/qgpgmeimportjob.h
deleted file mode 100644
index 2778e80..0000000
--- a/src/backends/qgpgme/qgpgmeimportjob.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- qgpgmeimportjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEIMPORTJOB_H__
-#define __KLEO_QGPGMEIMPORTJOB_H__
-
-#include "libkleo/importjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/importresult.h>
-
-namespace Kleo
-{
-
-class QGpgMEImportJob
-#ifdef Q_MOC_RUN
- : public ImportJob
-#else
- : public _detail::ThreadedJobMixin<ImportJob, boost::tuple<GpgME::ImportResult, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEImportJob(GpgME::Context *context);
- ~QGpgMEImportJob();
-
- /*! \reimp from ImportJob */
- GpgME::Error start(const QByteArray &keyData) Q_DECL_OVERRIDE;
-
- /*! \reimp from ImportJob */
- GpgME::ImportResult exec(const QByteArray &keyData) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- GpgME::ImportResult mResult;
-};
-
-}
-
-#endif // __KLEO_QGPGMEIMPORTJOB_H__
diff --git a/src/backends/qgpgme/qgpgmekeygenerationjob.cpp b/src/backends/qgpgme/qgpgmekeygenerationjob.cpp
deleted file mode 100644
index 71ab933..0000000
--- a/src/backends/qgpgme/qgpgmekeygenerationjob.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- qgpgmekeygenerationjob.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.
-*/
-
-#include "qgpgmekeygenerationjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEKeyGenerationJob::QGpgMEKeyGenerationJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEKeyGenerationJob::~QGpgMEKeyGenerationJob() {}
-
-static QGpgMEKeyGenerationJob::result_type generate_key(Context *ctx, const QString &parameters)
-{
- QGpgME::QByteArrayDataProvider dp;
- Data data = ctx->protocol() == CMS ? Data(&dp) : Data(Data::null);
- assert(data.isNull() == (ctx->protocol() != CMS));
-
- const KeyGenerationResult res = ctx->generateKey(parameters.toUtf8().constData(), data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, dp.data(), log, ae);
-}
-
-Error QGpgMEKeyGenerationJob::start(const QString &parameters)
-{
- run(bind(&generate_key, _1, parameters));
- return Error();
-}
-
diff --git a/src/backends/qgpgme/qgpgmekeygenerationjob.h b/src/backends/qgpgme/qgpgmekeygenerationjob.h
deleted file mode 100644
index cccba45..0000000
--- a/src/backends/qgpgme/qgpgmekeygenerationjob.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- qgpgmekeygenerationjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEKEYGENERATIONJOB_H__
-#define __KLEO_QGPGMEKEYGENERATIONJOB_H__
-
-#include "libkleo/keygenerationjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/keygenerationresult.h>
-
-namespace Kleo
-{
-
-class QGpgMEKeyGenerationJob
-#ifdef Q_MOC_RUN
- : public KeyGenerationJob
-#else
- : public _detail::ThreadedJobMixin<KeyGenerationJob, boost::tuple<GpgME::KeyGenerationResult, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-private Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEKeyGenerationJob(GpgME::Context *context);
- ~QGpgMEKeyGenerationJob();
-
- /*! \reimp from KeygenerationJob */
- GpgME::Error start(const QString &parameters) Q_DECL_OVERRIDE;
-};
-
-}
-
-#endif // __KLEO_QGPGMEKEYGENERATIONJOB_H__
diff --git a/src/backends/qgpgme/qgpgmekeylistjob.cpp b/src/backends/qgpgme/qgpgmekeylistjob.cpp
deleted file mode 100644
index 8e68cf5..0000000
--- a/src/backends/qgpgme/qgpgmekeylistjob.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- qgpgmekeylistjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmekeylistjob.h"
-
-#include <gpgme++/key.h>
-#include <gpgme++/context.h>
-#include <gpgme++/keylistresult.h>
-#include <gpg-error.h>
-
-#include <kmessagebox.h>
-#include <KLocalizedString>
-
-#include <QStringList>
-
-#include <algorithm>
-
-#include <cstdlib>
-#include <cstring>
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEKeyListJob::QGpgMEKeyListJob(Context *context)
- : mixin_type(context),
- mResult(), mSecretOnly(false)
-{
- lateInitialization();
-}
-
-QGpgMEKeyListJob::~QGpgMEKeyListJob() {}
-
-static KeyListResult do_list_keys(Context *ctx, const QStringList &pats, std::vector<Key> &keys, bool secretOnly)
-{
-
- const _detail::PatternConverter pc(pats);
-
- if (const Error err = ctx->startKeyListing(pc.patterns(), secretOnly)) {
- return KeyListResult(0, err);
- }
-
- Error err;
- do {
- keys.push_back(ctx->nextKey(err));
- } while (!err);
-
- keys.pop_back();
-
- const KeyListResult result = ctx->endKeyListing();
- ctx->cancelPendingOperation();
- return result;
-}
-
-static QGpgMEKeyListJob::result_type list_keys(Context *ctx, QStringList pats, bool secretOnly)
-{
- if (pats.size() < 2) {
- std::vector<Key> keys;
- const KeyListResult r = do_list_keys(ctx, pats, keys, secretOnly);
- return boost::make_tuple(r, keys, QString(), Error());
- }
-
- // The communication channel between gpgme and gpgsm is limited in
- // the number of patterns that can be transported, but they won't
- // say to how much, so we need to find out ourselves if we get a
- // LINE_TOO_LONG error back...
-
- // We could of course just feed them single patterns, and that would
- // probably be easier, but the performance penalty would currently
- // be noticeable.
-
- unsigned int chunkSize = pats.size();
-retry:
- std::vector<Key> keys;
- keys.reserve(pats.size());
- KeyListResult result;
- do {
- const KeyListResult this_result = do_list_keys(ctx, pats.mid(0, chunkSize), keys, secretOnly);
- if (this_result.error().code() == GPG_ERR_LINE_TOO_LONG) {
- // got LINE_TOO_LONG, try a smaller chunksize:
- chunkSize /= 2;
- if (chunkSize < 1)
- // chunks smaller than one can't be -> return the error.
- {
- return boost::make_tuple(this_result, keys, QString(), Error());
- } else {
- goto retry;
- }
- } else if (this_result.error().code() == GPG_ERR_EOF) {
- // early end of keylisting (can happen when ~/.gnupg doesn't
- // exist). Fakeing an empty result:
- return boost::make_tuple(KeyListResult(), std::vector<Key>(), QString(), Error());
- }
- // ok, that seemed to work...
- result.mergeWith(this_result);
- if (result.error().code()) {
- break;
- }
- pats = pats.mid(chunkSize);
- } while (!pats.empty());
- return boost::make_tuple(result, keys, QString(), Error());
-}
-
-Error QGpgMEKeyListJob::start(const QStringList &patterns, bool secretOnly)
-{
- mSecretOnly = secretOnly;
- run(boost::bind(&list_keys, _1, patterns, secretOnly));
- return Error();
-}
-
-KeyListResult QGpgMEKeyListJob::exec(const QStringList &patterns, bool secretOnly, std::vector<Key> &keys)
-{
- mSecretOnly = secretOnly;
- const result_type r = list_keys(context(), patterns, secretOnly);
- resultHook(r);
- keys = get<1>(r);
- return get<0>(r);
-}
-
-void QGpgMEKeyListJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
- Q_FOREACH (const Key &key, get<1>(tuple)) {
- Q_EMIT nextKey(key);
- }
-}
-
-void QGpgMEKeyListJob::showErrorDialog(QWidget *parent, const QString &caption) const
-{
- if (!mResult.error() || mResult.error().isCanceled()) {
- return;
- }
- const QString msg = i18n("<qt><p>An error occurred while fetching "
- "the keys from the backend:</p>"
- "<p><b>%1</b></p></qt>",
- QString::fromLocal8Bit(mResult.error().asString()));
- KMessageBox::error(parent, msg, caption);
-}
-
diff --git a/src/backends/qgpgme/qgpgmekeylistjob.h b/src/backends/qgpgme/qgpgmekeylistjob.h
deleted file mode 100644
index 635d6f1..0000000
--- a/src/backends/qgpgme/qgpgmekeylistjob.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- qgpgmekeylistjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMEKEYLISTJOB_H__
-#define __KLEO_QGPGMEKEYLISTJOB_H__
-
-#include "libkleo/keylistjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/keylistresult.h>
-#include <gpgme++/key.h>
-
-namespace Kleo
-{
-
-class QGpgMEKeyListJob
-#ifdef Q_MOC_RUN
- : public KeyListJob
-#else
- : public _detail::ThreadedJobMixin<KeyListJob, boost::tuple<GpgME::KeyListResult, std::vector<GpgME::Key>, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEKeyListJob(GpgME::Context *context);
- ~QGpgMEKeyListJob();
-
- /*! \reimp from KeyListJob */
- GpgME::Error start(const QStringList &patterns, bool secretOnly) Q_DECL_OVERRIDE;
-
- /*! \reimp from KeyListJob */
- GpgME::KeyListResult exec(const QStringList &patterns, bool secretOnly, std::vector<GpgME::Key> &keys) Q_DECL_OVERRIDE;
-
- /*! \reimp from Job */
- void showErrorDialog(QWidget *parent, const QString &caption) const Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &result) Q_DECL_OVERRIDE;
-
-private:
- GpgME::KeyListResult mResult;
- bool mSecretOnly;
-};
-
-}
-
-#endif // __KLEO_QGPGMEKEYLISTJOB_H__
diff --git a/src/backends/qgpgme/qgpgmelistallkeysjob.cpp b/src/backends/qgpgme/qgpgmelistallkeysjob.cpp
deleted file mode 100644
index f4f218c..0000000
--- a/src/backends/qgpgme/qgpgmelistallkeysjob.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- qgpgmelistallkeysjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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.
-*/
-
-#include "qgpgmelistallkeysjob.h"
-
-#include "libkleo/predicates.h"
-
-#include <gpgme++/key.h>
-#include <gpgme++/context.h>
-#include <gpgme++/keylistresult.h>
-#include <gpg-error.h>
-
-#include <kmessagebox.h>
-#include <KLocalizedString>
-
-#include <algorithm>
-
-#include <cstdlib>
-#include <cstring>
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEListAllKeysJob::QGpgMEListAllKeysJob(Context *context)
- : mixin_type(context),
- mResult()
-{
- lateInitialization();
-}
-
-QGpgMEListAllKeysJob::~QGpgMEListAllKeysJob() {}
-
-static KeyListResult do_list_keys(Context *ctx, std::vector<Key> &keys, bool secretOnly)
-{
-
- const char **pat = 0;
- if (const Error err = ctx->startKeyListing(pat, secretOnly)) {
- return KeyListResult(0, err);
- }
-
- Error err;
- do {
- keys.push_back(ctx->nextKey(err));
- } while (!err);
-
- keys.pop_back();
-
- const KeyListResult result = ctx->endKeyListing();
- ctx->cancelPendingOperation();
- return result;
-}
-
-namespace
-{
-
-template <typename ForwardIterator, typename BinaryPredicate>
-ForwardIterator unique_by_merge(ForwardIterator first, ForwardIterator last, BinaryPredicate pred)
-{
- first = std::adjacent_find(first, last, pred);
- if (first == last) {
- return last;
- }
-
- ForwardIterator dest = first;
- dest->mergeWith(*++first);
- while (++first != last)
- if (pred(*dest, *first)) {
- dest->mergeWith(*first);
- } else {
- *++dest = *first;
- }
- return ++dest;
-}
-
-}
-
-static void merge_keys(std::vector<Key> &merged, std::vector<Key> &pub, std::vector<Key> &sec)
-{
- merged.reserve(pub.size() + sec.size());
-
- std::merge(pub.begin(), pub.end(),
- sec.begin(), sec.end(),
- std::back_inserter(merged),
- _detail::ByFingerprint<std::less>());
-
- merged.erase(unique_by_merge(merged.begin(), merged.end(), _detail::ByFingerprint<std::equal_to>()),
- merged.end());
-}
-
-static QGpgMEListAllKeysJob::result_type list_keys(Context *ctx, bool mergeKeys)
-{
- std::vector<Key> pub, sec, merged;
- KeyListResult r;
-
- r.mergeWith(do_list_keys(ctx, pub, false));
- std::sort(pub.begin(), pub.end(), _detail::ByFingerprint<std::less>());
-
- r.mergeWith(do_list_keys(ctx, sec, true));
- std::sort(sec.begin(), sec.end(), _detail::ByFingerprint<std::less>());
-
- if (mergeKeys) {
- merge_keys(merged, pub, sec);
- } else {
- merged.swap(pub);
- }
- return boost::make_tuple(r, merged, sec, QString(), Error());
-}
-
-Error QGpgMEListAllKeysJob::start(bool mergeKeys)
-{
- run(boost::bind(&list_keys, _1, mergeKeys));
- return Error();
-}
-
-KeyListResult QGpgMEListAllKeysJob::exec(std::vector<Key> &pub, std::vector<Key> &sec, bool mergeKeys)
-{
- const result_type r = list_keys(context(), mergeKeys);
- resultHook(r);
- pub = get<1>(r);
- sec = get<2>(r);
- return get<0>(r);
-}
-
-void QGpgMEListAllKeysJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
-}
-
-void QGpgMEListAllKeysJob::showErrorDialog(QWidget *parent, const QString &caption) const
-{
- if (!mResult.error() || mResult.error().isCanceled()) {
- return;
- }
- const QString msg = i18n("<qt><p>An error occurred while fetching "
- "the keys from the backend:</p>"
- "<p><b>%1</b></p></qt>",
- QString::fromLocal8Bit(mResult.error().asString()));
- KMessageBox::error(parent, msg, caption);
-}
-
diff --git a/src/backends/qgpgme/qgpgmelistallkeysjob.h b/src/backends/qgpgme/qgpgmelistallkeysjob.h
deleted file mode 100644
index 4741bad..0000000
--- a/src/backends/qgpgme/qgpgmelistallkeysjob.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- qgpgmelistallkeysjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2008 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_QGPGMELISTALLKEYSJOB_H__
-#define __KLEO_QGPGMELISTALLKEYSJOB_H__
-
-#include "libkleo/listallkeysjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/keylistresult.h>
-#include <gpgme++/key.h>
-
-namespace Kleo
-{
-
-class QGpgMEListAllKeysJob
-#ifdef Q_MOC_RUN
- : public ListAllKeysJob
-#else
- : public _detail::ThreadedJobMixin<ListAllKeysJob, boost::tuple<GpgME::KeyListResult, std::vector<GpgME::Key>, std::vector<GpgME::Key>, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEListAllKeysJob(GpgME::Context *context);
- ~QGpgMEListAllKeysJob();
-
- /*! \reimp from ListAllKeysJob */
- GpgME::Error start(bool mergeKeys) Q_DECL_OVERRIDE;
-
- /*! \reimp from ListAllKeysJob */
- GpgME::KeyListResult exec(std::vector<GpgME::Key> &pub, std::vector<GpgME::Key> &sec, bool mergeKeys) Q_DECL_OVERRIDE;
-
- /*! \reimp from Job */
- void showErrorDialog(QWidget *parent, const QString &caption) const Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &result) Q_DECL_OVERRIDE;
-
-private:
- GpgME::KeyListResult mResult;
-};
-
-}
-
-#endif // __KLEO_QGPGMELISTALLKEYSJOB_H__
diff --git a/src/backends/qgpgme/qgpgmenewcryptoconfig.cpp b/src/backends/qgpgme/qgpgmenewcryptoconfig.cpp
deleted file mode 100644
index edccb35..0000000
--- a/src/backends/qgpgme/qgpgmenewcryptoconfig.cpp
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- qgpgmenewcryptoconfig.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2010 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.
-*/
-
-#include "qgpgmenewcryptoconfig.h"
-
-#include <KLocalizedString>
-#include <KMessageBox>
-#include <QDebug>
-#include "gpgme_backend_debug.h"
-
-#include <QFile>
-
-#include <gpgme++/global.h>
-#include <gpgme++/error.h>
-
-#include <boost/foreach.hpp>
-#include <boost/bind.hpp>
-#include <boost/mem_fn.hpp>
-
-#include <sstream>
-#include <string>
-#include <cassert>
-
-using namespace boost;
-using namespace Kleo;
-using namespace GpgME;
-using namespace GpgME::Configuration;
-
-namespace
-{
-struct Select1St {
- template <typename U, typename V>
- const U &operator()(const std::pair<U, V> &p) const
- {
- return p.first;
- }
- template <typename U, typename V>
- const U &operator()(const QPair<U, V> &p) const
- {
- return p.first;
- }
-};
-}
-
-// Just for the Q_ASSERT in the dtor. Not thread-safe, but who would
-// have 2 threads talking to gpgconf anyway? :)
-static bool s_duringClear = false;
-
-QGpgMENewCryptoConfig::QGpgMENewCryptoConfig()
- : m_parsed(false)
-{
-}
-
-QGpgMENewCryptoConfig::~QGpgMENewCryptoConfig()
-{
- clear();
-}
-
-void QGpgMENewCryptoConfig::reloadConfiguration(bool showErrors)
-{
- clear();
-
- Error error;
- const std::vector<Component> components = Component::load(error);
-#ifndef NDEBUG
- {
- std::stringstream ss;
- ss << "error: " << error
- << "components:\n";
- std::copy(components.begin(), components.end(),
- std::ostream_iterator<Component>(ss, "\n"));
- qCDebug(GPGPME_BACKEND_LOG) << ss.str().c_str();
- }
-#endif
- if (error && showErrors) {
- const QString wmsg = i18n("<qt>Failed to execute gpgconf:<p>%1</p></qt>", QString::fromLocal8Bit(error.asString()));
- qCWarning(GPGPME_BACKEND_LOG) << wmsg; // to see it from test_cryptoconfig.cpp
- KMessageBox::error(0, wmsg);
- }
- BOOST_FOREACH(const Component & c, components) {
- const shared_ptr<QGpgMENewCryptoConfigComponent> comp(new QGpgMENewCryptoConfigComponent);
- comp->setComponent(c);
- m_componentsByName[ comp->name() ] = comp;
- }
- m_parsed = true;
-}
-
-QStringList QGpgMENewCryptoConfig::componentList() const
-{
- if (!m_parsed) {
- const_cast<QGpgMENewCryptoConfig *>(this)->reloadConfiguration(true);
- }
- QStringList result;
- std::transform(m_componentsByName.begin(), m_componentsByName.end(),
- std::back_inserter(result),
- mem_fn(&QGpgMENewCryptoConfigComponent::name));
- return result;
-}
-
-QGpgMENewCryptoConfigComponent *QGpgMENewCryptoConfig::component(const QString &name) const
-{
- if (!m_parsed) {
- const_cast<QGpgMENewCryptoConfig *>(this)->reloadConfiguration(false);
- }
- return m_componentsByName.value(name).get();
-}
-
-void QGpgMENewCryptoConfig::sync(bool runtime)
-{
- BOOST_FOREACH(const shared_ptr<QGpgMENewCryptoConfigComponent> &c, m_componentsByName)
- c->sync(runtime);
-}
-
-void QGpgMENewCryptoConfig::clear()
-{
- s_duringClear = true;
- m_componentsByName.clear();
- s_duringClear = false;
- m_parsed = false; // next call to componentList/component will need to run gpgconf again
-}
-
-////
-
-QGpgMENewCryptoConfigComponent::QGpgMENewCryptoConfigComponent()
- : CryptoConfigComponent(),
- m_component()
-{
-
-}
-
-void QGpgMENewCryptoConfigComponent::setComponent(const Component &component)
-{
- m_component = component;
- m_groupsByName.clear();
-
- shared_ptr<QGpgMENewCryptoConfigGroup> group;
-
- const std::vector<Option> options = m_component.options();
- BOOST_FOREACH(const Option & o, options)
- if (o.flags() & Group) {
- if (group) {
- m_groupsByName[group->name()] = group;
- }
- group.reset(new QGpgMENewCryptoConfigGroup(shared_from_this(), o));
- } else if (group) {
- const shared_ptr<QGpgMENewCryptoConfigEntry> entry(new QGpgMENewCryptoConfigEntry(group, o));
- const QString name = entry->name();
- group->m_entryNames.push_back(name);
- group->m_entriesByName[name] = entry;
- } else {
- qCWarning(GPGPME_BACKEND_LOG) << "found no group for entry" << o.name() << "of component" << name();
- }
- if (group) {
- m_groupsByName[group->name()] = group;
- }
-
-}
-
-QGpgMENewCryptoConfigComponent::~QGpgMENewCryptoConfigComponent() {}
-
-QString QGpgMENewCryptoConfigComponent::name() const
-{
- return QString::fromUtf8(m_component.name());
-}
-
-QString QGpgMENewCryptoConfigComponent::description() const
-{
- return QString::fromUtf8(m_component.description());
-}
-
-QStringList QGpgMENewCryptoConfigComponent::groupList() const
-{
- QStringList result;
- result.reserve(m_groupsByName.size());
- std::transform(m_groupsByName.begin(), m_groupsByName.end(),
- std::back_inserter(result),
- mem_fn(&QGpgMENewCryptoConfigGroup::name));
- return result;
-}
-
-QGpgMENewCryptoConfigGroup *QGpgMENewCryptoConfigComponent::group(const QString &name) const
-{
- return m_groupsByName.value(name).get();
-}
-
-void QGpgMENewCryptoConfigComponent::sync(bool runtime)
-{
- Q_UNUSED(runtime)
- // ### how to pass --runtime to gpgconf? -> marcus: not yet supported (2010-11-20)
- if (const Error err = m_component.save()) {
- const QString wmsg = i18n("Error from gpgconf while saving configuration: %1", QString::fromLocal8Bit(err.asString()));
- qCWarning(GPGPME_BACKEND_LOG) << ":" << wmsg;
- KMessageBox::error(0, wmsg);
- }
- // ### unset dirty state again
-}
-
-////
-
-QGpgMENewCryptoConfigGroup::QGpgMENewCryptoConfigGroup(const shared_ptr<QGpgMENewCryptoConfigComponent> &comp, const Option &option)
- : CryptoConfigGroup(),
- m_component(comp),
- m_option(option)
-{
-}
-
-QGpgMENewCryptoConfigGroup::~QGpgMENewCryptoConfigGroup() {}
-
-QString QGpgMENewCryptoConfigGroup::name() const
-{
- return QString::fromUtf8(m_option.name());
-}
-
-QString QGpgMENewCryptoConfigGroup::description() const
-{
- return QString::fromUtf8(m_option.description());
-}
-
-QString QGpgMENewCryptoConfigGroup::path() const
-{
- if (const shared_ptr<QGpgMENewCryptoConfigComponent> c = m_component.lock()) {
- return c->name() + QLatin1Char('/') + name();
- } else {
- return QString();
- }
-}
-
-CryptoConfigEntry::Level QGpgMENewCryptoConfigGroup::level() const
-{
- // two casts to make SunCC happy:
- return static_cast<CryptoConfigEntry::Level>(static_cast<unsigned int>(m_option.level()));
-}
-
-QStringList QGpgMENewCryptoConfigGroup::entryList() const
-{
- return m_entryNames;
-}
-
-QGpgMENewCryptoConfigEntry *QGpgMENewCryptoConfigGroup::entry(const QString &name) const
-{
- return m_entriesByName.value(name).get();
-}
-
-static QString urlpart_encode(const QString &str)
-{
- QString enc(str);
- enc.replace(QLatin1Char('%'), QStringLiteral("%25")); // first!
- enc.replace(QLatin1Char(':'), QStringLiteral("%3a"));
- //qCDebug(GPGPME_BACKEND_LOG) <<" urlpart_encode:" << str <<" ->" << enc;
- return enc;
-}
-
-static QString urlpart_decode(const QString &str)
-{
- return QUrl::fromPercentEncoding(str.toLatin1());
-}
-
-// gpgconf arg type number -> NewCryptoConfigEntry arg type enum mapping
-static Kleo::CryptoConfigEntry::ArgType knownArgType(int argType, bool &ok)
-{
- ok = true;
- switch (argType) {
- case 0: // none
- return Kleo::CryptoConfigEntry::ArgType_None;
- case 1: // string
- return Kleo::CryptoConfigEntry::ArgType_String;
- case 2: // int32
- return Kleo::CryptoConfigEntry::ArgType_Int;
- case 3: // uint32
- return Kleo::CryptoConfigEntry::ArgType_UInt;
- case 32: // pathname
- return Kleo::CryptoConfigEntry::ArgType_Path;
- case 33: // ldap server
- return Kleo::CryptoConfigEntry::ArgType_LDAPURL;
- default:
- ok = false;
- return Kleo::CryptoConfigEntry::ArgType_None;
- }
-}
-
-QGpgMENewCryptoConfigEntry::QGpgMENewCryptoConfigEntry(const shared_ptr<QGpgMENewCryptoConfigGroup> &group, const Option &option)
- : m_group(group), m_option(option)
-{
-}
-
-#if 0
-QVariant QGpgMENewCryptoConfigEntry::stringToValue(const QString &str, bool unescape) const
-{
- const bool isString = isStringType();
-
- if (isList()) {
- if (argType() == ArgType_None) {
- bool ok = true;
- const QVariant v = str.isEmpty() ? 0U : str.toUInt(&ok);
- if (!ok) {
- qCWarning(GPGPME_BACKEND_LOG) << "list-of-none should have an unsigned int as value:" << str;
- }
- return v;
- }
- QList<QVariant> lst;
- QStringList items = str.split(',', QString::SkipEmptyParts);
- for (QStringList::const_iterator valit = items.constBegin(); valit != items.constEnd(); ++valit) {
- QString val = *valit;
- if (isString) {
- if (val.isEmpty()) {
- lst << QVariant(QString());
- continue;
- } else if (unescape) {
- if (val[0] != '"') { // see README.gpgconf
- qCWarning(GPGPME_BACKEND_LOG) << "String value should start with '\"' :" << val;
- }
- val = val.mid(1);
- }
- }
- lst << QVariant(unescape ? gpgconf_unescape(val) : val);
- }
- return lst;
- } else { // not a list
- QString val(str);
- if (isString) {
- if (val.isEmpty()) {
- return QVariant(QString()); // not set [ok with lists too?]
- } else if (unescape) {
- if (val[0] != '"') { // see README.gpgconf
- qCWarning(GPGPME_BACKEND_LOG) << "String value should start with '\"' :" << val;
- }
- val = val.mid(1);
- }
- }
- return QVariant(unescape ? gpgconf_unescape(val) : val);
- }
-}
-#endif
-
-QGpgMENewCryptoConfigEntry::~QGpgMENewCryptoConfigEntry()
-{
-#ifndef NDEBUG
- if (!s_duringClear && m_option.dirty())
- qCWarning(GPGPME_BACKEND_LOG) << "Deleting a QGpgMENewCryptoConfigEntry that was modified (" << m_option.description() << ")"
- << "You forgot to call sync() (to commit) or clear() (to discard)";
-#endif
-}
-
-QString QGpgMENewCryptoConfigEntry::name() const
-{
- return QString::fromUtf8(m_option.name());
-}
-
-QString QGpgMENewCryptoConfigEntry::description() const
-{
- return QString::fromUtf8(m_option.description());
-}
-
-QString QGpgMENewCryptoConfigEntry::path() const
-{
- if (const shared_ptr<QGpgMENewCryptoConfigGroup> g = m_group.lock()) {
- return g->path() + QLatin1Char('/') + name();
- } else {
- return QString();
- }
-}
-
-bool QGpgMENewCryptoConfigEntry::isOptional() const
-{
- return m_option.flags() & Optional;
-}
-
-bool QGpgMENewCryptoConfigEntry::isReadOnly() const
-{
- return m_option.flags() & NoChange;
-}
-
-bool QGpgMENewCryptoConfigEntry::isList() const
-{
- return m_option.flags() & List;
-}
-
-bool QGpgMENewCryptoConfigEntry::isRuntime() const
-{
- return m_option.flags() & Runtime;
-}
-
-CryptoConfigEntry::Level QGpgMENewCryptoConfigEntry::level() const
-{
- // two casts to make SunCC happy:
- return static_cast<Level>(static_cast<unsigned int>(m_option.level()));
-}
-
-CryptoConfigEntry::ArgType QGpgMENewCryptoConfigEntry::argType() const
-{
- bool ok = false;
- const ArgType type = knownArgType(m_option.type(), ok);
- if (ok) {
- return type;
- } else {
- return knownArgType(m_option.alternateType(), ok);
- }
-}
-
-bool QGpgMENewCryptoConfigEntry::isSet() const
-{
- return m_option.set();
-}
-
-bool QGpgMENewCryptoConfigEntry::boolValue() const
-{
- Q_ASSERT(m_option.alternateType() == NoType);
- Q_ASSERT(!isList());
- return m_option.currentValue().boolValue();
-}
-
-QString QGpgMENewCryptoConfigEntry::stringValue() const
-{
- //return toString( false );
- Q_ASSERT(m_option.alternateType() == StringType);
- Q_ASSERT(!isList());
- return QString::fromUtf8(m_option.currentValue().stringValue());
-}
-
-int QGpgMENewCryptoConfigEntry::intValue() const
-{
- Q_ASSERT(m_option.alternateType() == IntegerType);
- Q_ASSERT(!isList());
- return m_option.currentValue().intValue();
-}
-
-unsigned int QGpgMENewCryptoConfigEntry::uintValue() const
-{
- Q_ASSERT(m_option.alternateType() == UnsignedIntegerType);
- Q_ASSERT(!isList());
- return m_option.currentValue().uintValue();
-}
-
-static QUrl parseURL(int mRealArgType, const QString &str)
-{
- if (mRealArgType == 33) { // LDAP server
- // The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN
- QStringList items = str.split(QLatin1Char(':'));
- if (items.count() == 5) {
- QStringList::const_iterator it = items.constBegin();
- QUrl url;
- url.setScheme(QStringLiteral("ldap"));
- url.setHost(urlpart_decode(*it++));
-
- bool ok;
- const int port = (*it++).toInt(&ok);
- if (ok) {
- url.setPort(port);
- } else if (!it->isEmpty()) {
- qCWarning(GPGPME_BACKEND_LOG) << "parseURL: malformed LDAP server port, ignoring: \"" << *it << "\"";
- }
-
- const QString userName = urlpart_decode(*it++);
- if (!userName.isEmpty()) {
- url.setUserName(userName);
- }
- const QString passWord = urlpart_decode(*it++);
- if (!passWord.isEmpty()) {
- url.setPassword(passWord);
- }
- url.setQuery(urlpart_decode(*it));
- return url;
- } else {
- qCWarning(GPGPME_BACKEND_LOG) << "parseURL: malformed LDAP server:" << str;
- }
- }
- // other URLs : assume wellformed URL syntax.
- return QUrl(str);
-}
-
-// The opposite of parseURL
-static QString splitURL(int mRealArgType, const QUrl &url)
-{
- if (mRealArgType == 33) { // LDAP server
- // The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN
- Q_ASSERT(url.scheme() == QLatin1String("ldap"));
- return urlpart_encode(url.host()) + QLatin1Char(':') +
- (url.port() != -1 ? QString::number(url.port()) : QString()) + QLatin1Char(':') + // -1 is used for default ports, omit
- urlpart_encode(url.userName()) + QLatin1Char(':') +
- urlpart_encode(url.password()) + QLatin1Char(':') +
- urlpart_encode(url.query());
- }
- return url.path();
-}
-
-QUrl QGpgMENewCryptoConfigEntry::urlValue() const
-{
- const Type type = m_option.type();
- Q_ASSERT(type == FilenameType || type == LdapServerType);
- Q_ASSERT(!isList());
- if (type == FilenameType) {
- QUrl url;
- url.setPath(QFile::decodeName(m_option.currentValue().stringValue()));
- return url;
- }
- return parseURL(type, stringValue());
-}
-
-unsigned int QGpgMENewCryptoConfigEntry::numberOfTimesSet() const
-{
- Q_ASSERT(m_option.alternateType() == NoType);
- Q_ASSERT(isList());
- return m_option.currentValue().uintValue();
-}
-
-std::vector<int> QGpgMENewCryptoConfigEntry::intValueList() const
-{
- Q_ASSERT(m_option.alternateType() == IntegerType);
- Q_ASSERT(isList());
- return m_option.currentValue().intValues();
-}
-
-std::vector<unsigned int> QGpgMENewCryptoConfigEntry::uintValueList() const
-{
- Q_ASSERT(m_option.alternateType() == UnsignedIntegerType);
- Q_ASSERT(isList());
- return m_option.currentValue().uintValues();
-}
-
-QList<QUrl> QGpgMENewCryptoConfigEntry::urlValueList() const
-{
- const Type type = m_option.type();
- Q_ASSERT(type == FilenameType || type == LdapServerType);
- Q_ASSERT(isList());
- const Argument arg = m_option.currentValue();
- const std::vector<const char *> values = arg.stringValues();
- QList<QUrl> ret;
- BOOST_FOREACH(const char *value, values)
- if (type == FilenameType) {
- QUrl url;
- url.setPath(QFile::decodeName(value));
- ret << url;
- } else {
- ret << parseURL(type, QString::fromUtf8(value));
- }
- return ret;
-}
-
-void QGpgMENewCryptoConfigEntry::resetToDefault()
-{
- m_option.resetToDefaultValue();
-}
-
-void QGpgMENewCryptoConfigEntry::setBoolValue(bool b)
-{
- Q_ASSERT(m_option.alternateType() == NoType);
- Q_ASSERT(!isList());
- // A "no arg" option is either set or not set.
- // Being set means createNoneArgument(), being unset means resetToDefault()
- m_option.setNewValue(m_option.createNoneArgument(b));
-}
-
-void QGpgMENewCryptoConfigEntry::setStringValue(const QString &str)
-{
- Q_ASSERT(m_option.alternateType() == StringType);
- Q_ASSERT(!isList());
- const Type type = m_option.type();
- // When setting a string to empty (and there's no default), we need to act like resetToDefault
- // Otherwise we try e.g. "ocsp-responder:0:" and gpgconf answers:
- // "gpgconf: argument required for option ocsp-responder"
- if (str.isEmpty() && !isOptional()) {
- m_option.resetToDefaultValue();
- } else if (type == FilenameType) {
- m_option.setNewValue(m_option.createStringArgument(QFile::encodeName(str).constData()));
- } else {
- m_option.setNewValue(m_option.createStringArgument(str.toUtf8().constData()));
- }
-}
-
-void QGpgMENewCryptoConfigEntry::setIntValue(int i)
-{
- Q_ASSERT(m_option.alternateType() == IntegerType);
- Q_ASSERT(!isList());
- m_option.setNewValue(m_option.createIntArgument(i));
-}
-
-void QGpgMENewCryptoConfigEntry::setUIntValue(unsigned int i)
-{
- Q_ASSERT(m_option.alternateType() == UnsignedIntegerType);
- Q_ASSERT(!isList());
- m_option.setNewValue(m_option.createUIntArgument(i));
-}
-
-void QGpgMENewCryptoConfigEntry::setURLValue(const QUrl &url)
-{
- const Type type = m_option.type();
- Q_ASSERT(type == FilenameType || type == LdapServerType);
- Q_ASSERT(!isList());
- const QString str = splitURL(type, url);
- // cf. setStringValue()
- if (str.isEmpty() && !isOptional()) {
- m_option.resetToDefaultValue();
- } else if (type == FilenameType) {
- m_option.setNewValue(m_option.createStringArgument(QFile::encodeName(str).constData()));
- } else {
- m_option.setNewValue(m_option.createStringArgument(str.toUtf8().constData()));
- }
-}
-
-void QGpgMENewCryptoConfigEntry::setNumberOfTimesSet(unsigned int i)
-{
- Q_ASSERT(m_option.alternateType() == NoType);
- Q_ASSERT(isList());
- m_option.setNewValue(m_option.createNoneListArgument(i));
-}
-
-void QGpgMENewCryptoConfigEntry::setIntValueList(const std::vector<int> &lst)
-{
- Q_ASSERT(m_option.alternateType() == IntegerType);
- Q_ASSERT(isList());
- m_option.setNewValue(m_option.createIntListArgument(lst));
-}
-
-void QGpgMENewCryptoConfigEntry::setUIntValueList(const std::vector<unsigned int> &lst)
-{
- Q_ASSERT(m_option.alternateType() == UnsignedIntegerType);
- Q_ASSERT(isList());
- m_option.setNewValue(m_option.createUIntListArgument(lst));
-}
-
-void QGpgMENewCryptoConfigEntry::setURLValueList(const QList<QUrl> &urls)
-{
- const Type type = m_option.type();
- Q_ASSERT(m_option.alternateType() == StringType);
- Q_ASSERT(isList());
- std::vector<std::string> values;
- values.reserve(urls.size());
- Q_FOREACH (const QUrl &url, urls)
- if (type == FilenameType) {
- values.push_back(QFile::encodeName(url.path()).constData());
- } else {
- values.push_back(splitURL(type, url).toUtf8().constData());
- }
- m_option.setNewValue(m_option.createStringListArgument(values));
-}
-
-bool QGpgMENewCryptoConfigEntry::isDirty() const
-{
- return m_option.dirty();
-}
-
-#if 0
-QString QGpgMENewCryptoConfigEntry::toString(bool escape) const
-{
- // Basically the opposite of stringToValue
- if (isStringType()) {
- if (mValue.isNull()) {
- return QString();
- } else if (isList()) { // string list
- QStringList lst = mValue.toStringList();
- if (escape) {
- for (QStringList::iterator it = lst.begin(); it != lst.end(); ++it) {
- if (!(*it).isNull()) {
- *it = gpgconf_escape(*it).prepend("\"");
- }
- }
- }
- QString res = lst.join(",");
- //qCDebug(GPGPME_BACKEND_LOG) <<"toString:" << res;
- return res;
- } else { // normal string
- QString res = mValue.toString();
- if (escape) {
- res = gpgconf_escape(res).prepend("\"");
- }
- return res;
- }
- }
- if (!isList()) { // non-list non-string
- if (mArgType == ArgType_None) {
- return mValue.toBool() ? QString::fromLatin1("1") : QString();
- } else { // some int
- Q_ASSERT(mArgType == ArgType_Int || mArgType == ArgType_UInt);
- return mValue.toString(); // int to string conversion
- }
- }
-
- // Lists (of other types than strings)
- if (mArgType == ArgType_None) {
- return QString::number(numberOfTimesSet());
- }
- QStringList ret;
- QList<QVariant> lst = mValue.toList();
- for (QList<QVariant>::const_iterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
- ret << (*it).toString(); // QVariant does the conversion
- }
- return ret.join(",");
-}
-
-QString QGpgMENewCryptoConfigEntry::outputString() const
-{
- Q_ASSERT(mSet);
- return toString(true);
-}
-
-bool QGpgMENewCryptoConfigEntry::isStringType() const
-{
- return (mArgType == Kleo::NewCryptoConfigEntry::ArgType_String
- || mArgType == Kleo::NewCryptoConfigEntry::ArgType_Path
- || mArgType == Kleo::NewCryptoConfigEntry::ArgType_URL
- || mArgType == Kleo::NewCryptoConfigEntry::ArgType_LDAPURL);
-}
-
-void QGpgMENewCryptoConfigEntry::setDirty(bool b)
-{
- mDirty = b;
-}
-#endif
-
diff --git a/src/backends/qgpgme/qgpgmenewcryptoconfig.h b/src/backends/qgpgme/qgpgmenewcryptoconfig.h
deleted file mode 100644
index 72029fc..0000000
--- a/src/backends/qgpgme/qgpgmenewcryptoconfig.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- qgpgmenewcryptoconfig.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2010 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_QGPGMENEWCRYPTOCONFIG_H
-#define KLEO_QGPGMENEWCRYPTOCONFIG_H
-
-#include "kleo_export.h"
-#include "libkleo/cryptoconfig.h"
-
-#include <QHash>
-#include <QStringList>
-#include <QVariant>
-
-#include <gpgme++/configuration.h>
-
-#include <boost/shared_ptr.hpp>
-#include <boost/weak_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
-
-#include <vector>
-#include <utility>
-
-class QGpgMENewCryptoConfig;
-class QGpgMENewCryptoConfigComponent;
-class QGpgMENewCryptoConfigGroup;
-class QGpgMENewCryptoConfigEntry;
-
-class QGpgMENewCryptoConfigEntry : public Kleo::CryptoConfigEntry
-{
-public:
- QGpgMENewCryptoConfigEntry(const boost::shared_ptr<QGpgMENewCryptoConfigGroup> &group, const GpgME::Configuration::Option &option);
- ~QGpgMENewCryptoConfigEntry();
-
- QString name() const Q_DECL_OVERRIDE;
- QString description() const Q_DECL_OVERRIDE;
- QString path() const Q_DECL_OVERRIDE;
- bool isOptional() const Q_DECL_OVERRIDE;
- bool isReadOnly() const Q_DECL_OVERRIDE;
- bool isList() const Q_DECL_OVERRIDE;
- bool isRuntime() const Q_DECL_OVERRIDE;
- Level level() const Q_DECL_OVERRIDE;
- ArgType argType() const Q_DECL_OVERRIDE;
- bool isSet() const Q_DECL_OVERRIDE;
- bool boolValue() const Q_DECL_OVERRIDE;
- QString stringValue() const Q_DECL_OVERRIDE;
- int intValue() const Q_DECL_OVERRIDE;
- unsigned int uintValue() const Q_DECL_OVERRIDE;
- QUrl urlValue() const Q_DECL_OVERRIDE;
- unsigned int numberOfTimesSet() const Q_DECL_OVERRIDE;
- std::vector<int> intValueList() const Q_DECL_OVERRIDE;
- std::vector<unsigned int> uintValueList() const Q_DECL_OVERRIDE;
- QList<QUrl> urlValueList() const Q_DECL_OVERRIDE;
- void resetToDefault() Q_DECL_OVERRIDE;
- void setBoolValue(bool) Q_DECL_OVERRIDE;
- void setStringValue(const QString &) Q_DECL_OVERRIDE;
- void setIntValue(int) Q_DECL_OVERRIDE;
- void setUIntValue(unsigned int) Q_DECL_OVERRIDE;
- void setURLValue(const QUrl &) Q_DECL_OVERRIDE;
- void setNumberOfTimesSet(unsigned int) Q_DECL_OVERRIDE;
- void setIntValueList(const std::vector<int> &) Q_DECL_OVERRIDE;
- void setUIntValueList(const std::vector<unsigned int> &) Q_DECL_OVERRIDE;
- void setURLValueList(const QList<QUrl> &) Q_DECL_OVERRIDE;
- bool isDirty() const Q_DECL_OVERRIDE;
-
-#if 0
- void setDirty(bool b);
- QString outputString() const;
-
-protected:
- bool isStringType() const;
- QVariant stringToValue(const QString &value, bool unescape) const;
- QString toString(bool escape) const;
-#endif
-private:
- boost::weak_ptr<QGpgMENewCryptoConfigGroup> m_group;
- GpgME::Configuration::Option m_option;
-};
-
-class QGpgMENewCryptoConfigGroup : public Kleo::CryptoConfigGroup
-{
-public:
- QGpgMENewCryptoConfigGroup(const boost::shared_ptr<QGpgMENewCryptoConfigComponent> &parent, const GpgME::Configuration::Option &option);
- ~QGpgMENewCryptoConfigGroup();
-
- QString name() const Q_DECL_OVERRIDE;
- QString iconName() const Q_DECL_OVERRIDE
- {
- return QString();
- }
- QString description() const Q_DECL_OVERRIDE;
- QString path() const Q_DECL_OVERRIDE;
- Kleo::CryptoConfigEntry::Level level() const Q_DECL_OVERRIDE;
- QStringList entryList() const Q_DECL_OVERRIDE;
- QGpgMENewCryptoConfigEntry *entry(const QString &name) const Q_DECL_OVERRIDE;
-
-private:
- friend class QGpgMENewCryptoConfigComponent; // it adds the entries
- boost::weak_ptr<QGpgMENewCryptoConfigComponent> m_component;
- GpgME::Configuration::Option m_option;
- QStringList m_entryNames;
- QHash< QString, boost::shared_ptr<QGpgMENewCryptoConfigEntry> > m_entriesByName;
-};
-
-/// For docu, see kleo/cryptoconfig.h
-class QGpgMENewCryptoConfigComponent : public Kleo::CryptoConfigComponent, public boost::enable_shared_from_this<QGpgMENewCryptoConfigComponent>
-{
-public:
- QGpgMENewCryptoConfigComponent();
- ~QGpgMENewCryptoConfigComponent();
-
- void setComponent(const GpgME::Configuration::Component &component);
-
- QString name() const Q_DECL_OVERRIDE;
- QString iconName() const Q_DECL_OVERRIDE
- {
- return name();
- }
- QString description() const Q_DECL_OVERRIDE;
- QStringList groupList() const Q_DECL_OVERRIDE;
- QGpgMENewCryptoConfigGroup *group(const QString &name) const Q_DECL_OVERRIDE;
-
- void sync(bool runtime);
-
-private:
- GpgME::Configuration::Component m_component;
- QHash< QString, boost::shared_ptr<QGpgMENewCryptoConfigGroup> > m_groupsByName;
-};
-
-/**
- * CryptoConfig implementation around the gpgconf command-line tool
- * For method docu, see kleo/cryptoconfig.h
- */
-class KLEO_EXPORT QGpgMENewCryptoConfig : public Kleo::CryptoConfig
-{
-public:
- /**
- * Constructor
- */
- QGpgMENewCryptoConfig();
- ~QGpgMENewCryptoConfig();
-
- QStringList componentList() const Q_DECL_OVERRIDE;
-
- QGpgMENewCryptoConfigComponent *component(const QString &name) const Q_DECL_OVERRIDE;
-
- void clear() Q_DECL_OVERRIDE;
- void sync(bool runtime) Q_DECL_OVERRIDE;
-
-private:
- /// @param showErrors if true, a messagebox will be shown if e.g. gpgconf wasn't found
- void reloadConfiguration(bool showErrors);
-
-private:
- QHash< QString, boost::shared_ptr<QGpgMENewCryptoConfigComponent> > m_componentsByName;
- bool m_parsed;
-};
-
-#endif /* KLEO_QGPGMENEWCRYPTOCONFIG_H */
diff --git a/src/backends/qgpgme/qgpgmeprogresstokenmapper.cpp b/src/backends/qgpgme/qgpgmeprogresstokenmapper.cpp
deleted file mode 100644
index b9ec443..0000000
--- a/src/backends/qgpgme/qgpgmeprogresstokenmapper.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- qgpgmeprogresstokenmapper.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.
-*/
-
-#include "qgpgmeprogresstokenmapper.h"
-
-#include <KLocalizedString>
-#include <QDebug>
-#include "gpgme_backend_debug.h"
-
-#include <QString>
-
-#include <boost/range.hpp>
-
-#include <cassert>
-
-struct Desc {
- int type; // 0 == fallback
- const char *display; // add %1 for useCur ^ useTot and %1 %2 for useCur == useTot == true
-};
-
-static const struct Desc pk_dsa[] = {
- { 0, I18N_NOOP("Generating DSA key...") }
-};
-
-static const struct Desc pk_elg[] = {
- { 0, I18N_NOOP("Generating ElGamal key...") }
-};
-
-static const struct Desc primegen[] = {
- // FIXME: add all type's?
- { 0, I18N_NOOP("Searching for a large prime number...") }
-};
-
-static const struct Desc need_entropy[] = {
- { 0, I18N_NOOP("Waiting for new entropy from random number generator (you might want to exercise the harddisks or move the mouse)...") }
-};
-
-static const struct Desc tick[] = {
- { 0, I18N_NOOP("Please wait...") }
-};
-
-static const struct Desc starting_agent[] = {
- { 0, I18N_NOOP("Starting gpg-agent (you should consider starting a global instance instead)...") }
-};
-
-static const struct _tokens {
- const char *token;
- const Desc *desc;
- unsigned int numDesc;
-} tokens[] = {
-#define make_token(x) { #x, x, sizeof(x) / sizeof(*x) }
- make_token(pk_dsa),
- make_token(pk_elg),
- make_token(primegen),
- make_token(need_entropy),
- make_token(tick),
- make_token(starting_agent)
-#undef make_token
-};
-
-QString Kleo::QGpgMEProgressTokenMapper::map(const char *tokenUtf8, int subtoken)
-{
- if (!tokenUtf8 || !*tokenUtf8) {
- return QString();
- }
-
- if (qstrcmp(tokenUtf8, "file:") == 0) {
- return QString(); // gpgme's job
- }
-
- return map(QString::fromUtf8(tokenUtf8), subtoken);
-}
-
-QString Kleo::QGpgMEProgressTokenMapper::map(const QString &token, int subtoken)
-{
- if (token.startsWith(QStringLiteral("file:"))) {
- return QString(); // gpgme's job
- }
-
- qCDebug(GPGPME_BACKEND_LOG) << token << subtoken;
-
- for (const _tokens *it = boost::begin(tokens), *end = boost::end(tokens); it != end; ++it) {
- if (token.compare(QLatin1String(it->token), Qt::CaseInsensitive) == 0) {
- if (it->desc && it->numDesc) {
- for (unsigned int i = 0, e = it->numDesc; i != e; ++i)
- if (it->desc[i].type == subtoken) {
- return i18n(it->desc[i].display);
- }
- return i18n(it->desc[0].display);
- } else {
- break;
- }
- }
- }
-
- return token;
-}
-
diff --git a/src/backends/qgpgme/qgpgmeprogresstokenmapper.h b/src/backends/qgpgme/qgpgmeprogresstokenmapper.h
deleted file mode 100644
index 1acd979..0000000
--- a/src/backends/qgpgme/qgpgmeprogresstokenmapper.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- qgpgmeprogresstokenmapper.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_QGPGMEPROGRESSTOKENMAPPER_H__
-#define __KLEO_QGPGMEPROGRESSTOKENMAPPER_H__
-
-class QString;
-
-namespace Kleo
-{
-
-namespace QGpgMEProgressTokenMapper
-{
-QString map(const char *token, int subtoken);
-QString map(const QString &token, int subtoken);
-}
-
-}
-
-#endif // __KLEO_QGPGMEPROGRESSTOKENMAPPER_H__
diff --git a/src/backends/qgpgme/qgpgmerefreshkeysjob.cpp b/src/backends/qgpgme/qgpgmerefreshkeysjob.cpp
deleted file mode 100644
index 5e35c2e..0000000
--- a/src/backends/qgpgme/qgpgmerefreshkeysjob.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- qgpgmerefreshkeysjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004 Klar�vdalens 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.
-*/
-
-#define MAX_CMD_LENGTH 32768
-
-#include "qgpgmerefreshkeysjob.h"
-
-#include "gnupgprocessbase.h"
-#include "qgpgmeprogresstokenmapper.h"
-
-#include <QDebug>
-#include "gpgme_backend_debug.h"
-
-#include <gpgme++/context.h>
-
-#include <QByteArray>
-#include <QStringList>
-
-#include <gpg-error.h>
-
-#include <assert.h>
-
-Kleo::QGpgMERefreshKeysJob::QGpgMERefreshKeysJob()
- : RefreshKeysJob(0),
- mProcess(0),
- mError(0)
-{
-
-}
-
-Kleo::QGpgMERefreshKeysJob::~QGpgMERefreshKeysJob()
-{
-
-}
-
-GpgME::Error Kleo::QGpgMERefreshKeysJob::start(const QStringList &patterns)
-{
- assert(mPatternsToDo.empty());
-
- mPatternsToDo = patterns;
- if (mPatternsToDo.empty()) {
- mPatternsToDo.push_back(QStringLiteral(" ")); // empty list means all -> mae
- }
- // sure to fail the first
- // startAProcess() guard clause
-
- return startAProcess();
-}
-
-#if MAX_CMD_LENGTH < 65 + 128
-#error MAX_CMD_LENGTH is too low
-#endif
-
-GpgME::Error Kleo::QGpgMERefreshKeysJob::startAProcess()
-{
- if (mPatternsToDo.empty()) {
- return GpgME::Error();
- }
- // create and start gpgsm process:
- mProcess = new GnuPGProcessBase(this);
- mProcess->setObjectName(QStringLiteral("gpgsm -k --with-validation --force-crl-refresh --enable-crl-checks"));
-
- // FIXME: obbtain the path to gpgsm from gpgme, so we use the same instance.
- *mProcess << QStringLiteral("gpgsm") << QStringLiteral("-k") << QStringLiteral("--with-validation") << QStringLiteral("--force-crl-refresh")
- << QStringLiteral("--enable-crl-checks");
- unsigned int commandLineLength = MAX_CMD_LENGTH;
- commandLineLength -=
- strlen("gpgsm") + 1 + strlen("-k") + 1 +
- strlen("--with-validation") + 1 + strlen("--force-crl-refresh") + 1 +
- strlen("--enable-crl-checks") + 1;
- while (!mPatternsToDo.empty()) {
- const QByteArray pat = mPatternsToDo.front().toUtf8().trimmed();
- const unsigned int patLength = pat.length();
- if (patLength >= commandLineLength) {
- break;
- }
- mPatternsToDo.pop_front();
- if (pat.isEmpty()) {
- continue;
- }
- *mProcess << QLatin1String(pat);
- commandLineLength -= patLength + 1;
- }
-
- mProcess->setUseStatusFD(true);
-
- connect(mProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
- SLOT(slotProcessExited(int,QProcess::ExitStatus)));
- connect(mProcess, SIGNAL(readyReadStandardOutput()),
- SLOT(slotStdout()));
- connect(mProcess, &QProcess::readyReadStandardError,
- this, &QGpgMERefreshKeysJob::slotStderr);
-
- connect(mProcess, &GnuPGProcessBase::status,
- this, &QGpgMERefreshKeysJob::slotStatus);
-
- mProcess->setOutputChannelMode(KProcess::SeparateChannels);
- mProcess->start();
- if (!mProcess->waitForStarted()) {
- mError = GpgME::Error::fromCode(GPG_ERR_ENOENT, GPG_ERR_SOURCE_GPGSM); // what else?
- deleteLater();
- return mError;
- } else {
- return GpgME::Error();
- }
-}
-
-void Kleo::QGpgMERefreshKeysJob::slotCancel()
-{
- if (mProcess) {
- mProcess->kill();
- }
- mProcess = 0;
- mError = GpgME::Error::fromCode(GPG_ERR_CANCELED, GPG_ERR_SOURCE_GPGSM);
-}
-
-void Kleo::QGpgMERefreshKeysJob::slotStatus(GnuPGProcessBase *proc, const QString &type, const QStringList &args)
-{
- if (proc != mProcess) {
- return;
- }
- QStringList::const_iterator it = args.begin();
- bool ok = false;
-
- if (type == QLatin1String("ERROR")) {
-
- if (args.size() < 2) {
- qCDebug(GPGPME_BACKEND_LOG) << "not recognising ERROR with < 2 args!";
- return;
- }
- const int source = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for first ERROR arg, got something else";
- return;
- }
- ok = false;
- const int code = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for second ERROR arg, got something else";
- return;
- }
- mError = GpgME::Error::fromCode(code, source);
-
- } else if (type == QLatin1String("PROGRESS")) {
-
- if (args.size() < 4) {
- qCDebug(GPGPME_BACKEND_LOG) << "not recognising PROGRESS with < 4 args!";
- return;
- }
- const QString what = *++it;
- ok = false;
- const int typ = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"type\", got something else";
- return;
- }
- ok = false;
- const int cur = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"cur\", got something else";
- return;
- }
- ok = false;
- const int total = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"total\", got something else";
- return;
- }
- Q_EMIT progress(QGpgMEProgressTokenMapper::map(what, typ), cur, total);
-
- }
-}
-
-void Kleo::QGpgMERefreshKeysJob::slotStderr()
-{
- // implement? or not?
-}
-
-void Kleo::QGpgMERefreshKeysJob::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus)
-{
- if (!mError && !mPatternsToDo.empty()) {
- if (const GpgME::Error err = startAProcess()) {
- mError = err;
- } else {
- return;
- }
- }
-
- Q_EMIT done();
- if (!mError &&
- (exitStatus != QProcess::NormalExit || exitCode != 0)) {
- mError = GpgME::Error::fromCode(GPG_ERR_GENERAL, GPG_ERR_SOURCE_GPGSM);
- }
- Q_EMIT result(mError);
- deleteLater();
-}
-
diff --git a/src/backends/qgpgme/qgpgmerefreshkeysjob.h b/src/backends/qgpgme/qgpgmerefreshkeysjob.h
deleted file mode 100644
index 8725346..0000000
--- a/src/backends/qgpgme/qgpgmerefreshkeysjob.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- qgpgmerefreshkeysjob.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_QGPGMEREFRESHKEYSJOB_H__
-#define __KLEO_QGPGMEREFRESHKEYSJOB_H__
-
-#include "kleo/refreshkeysjob.h"
-#include "gpgme++/context.h"
-
-#include <QStringList>
-#include <QProcess>
-
-namespace Kleo
-{
-class GnuPGProcessBase;
-}
-
-namespace Kleo
-{
-
-class QGpgMERefreshKeysJob : public RefreshKeysJob
-{
- Q_OBJECT
-public:
- QGpgMERefreshKeysJob();
- ~QGpgMERefreshKeysJob();
-
- /*! \reimp from RefreshKeysJob */
- GpgME::Error start(const QStringList &patterns) Q_DECL_OVERRIDE;
-
-private Q_SLOTS:
- /*! \reimp from Job */
- void slotCancel() Q_DECL_OVERRIDE;
-
- void slotStatus(Kleo::GnuPGProcessBase *, const QString &, const QStringList &);
- void slotStderr();
- void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus);
-
-private:
- GpgME::Error startAProcess();
-
-private:
- GnuPGProcessBase *mProcess;
- GpgME::Error mError;
- QStringList mPatternsToDo;
-};
-
-}
-
-#endif // __KLEO_QGPGMEREFRESHKEYSJOB_H__
diff --git a/src/backends/qgpgme/qgpgmesecretkeyexportjob.cpp b/src/backends/qgpgme/qgpgmesecretkeyexportjob.cpp
deleted file mode 100644
index e636096..0000000
--- a/src/backends/qgpgme/qgpgmesecretkeyexportjob.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- qgpgmesecretexportjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004 Klar�vdalens 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.
-*/
-
-#include "qgpgmesecretkeyexportjob.h"
-
-#include "gnupgprocessbase.h"
-#include "qgpgmeprogresstokenmapper.h"
-
-#include <QDebug>
-#include "gpgme_backend_debug.h"
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-
-#include <QStringList>
-
-#include <gpg-error.h>
-
-#include <string.h>
-#include <assert.h>
-
-Kleo::QGpgMESecretKeyExportJob::QGpgMESecretKeyExportJob(bool armour, const QString &charset)
- : ExportJob(0),
- mProcess(0),
- mError(0),
- mArmour(armour),
- mCharset(charset)
-{
-
-}
-
-Kleo::QGpgMESecretKeyExportJob::~QGpgMESecretKeyExportJob()
-{
-
-}
-
-GpgME::Error Kleo::QGpgMESecretKeyExportJob::start(const QStringList &patterns)
-{
- assert(mKeyData.isEmpty());
-
- if (patterns.size() != 1 || patterns.front().isEmpty()) {
- deleteLater();
- return mError = GpgME::Error::fromCode(GPG_ERR_INV_VALUE, GPG_ERR_SOURCE_GPGSM);
- }
-
- // create and start gpgsm process:
- mProcess = new GnuPGProcessBase(this);
- mProcess->setObjectName(QStringLiteral("gpgsm --export-secret-key-p12"));
-
- // FIXME: obtain the path to gpgsm from gpgme, so we use the same instance.
- *mProcess << QStringLiteral("gpgsm") << QStringLiteral("--export-secret-key-p12");
- if (mArmour) {
- *mProcess << QStringLiteral("--armor");
- }
- if (!mCharset.isEmpty()) {
- *mProcess << QStringLiteral("--p12-charset") << mCharset;
- }
- *mProcess << QLatin1String(patterns.front().toUtf8());
-
- mProcess->setUseStatusFD(true);
-
- connect(mProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
- SLOT(slotProcessExited(int,QProcess::ExitStatus)));
- connect(mProcess, &QProcess::readyReadStandardOutput,
- this, &QGpgMESecretKeyExportJob::slotStdout);
- connect(mProcess, &QProcess::readyReadStandardError,
- this, &QGpgMESecretKeyExportJob::slotStderr);
-
- connect(mProcess, &GnuPGProcessBase::status,
- this, &QGpgMESecretKeyExportJob::slotStatus);
-
- mProcess->setOutputChannelMode(KProcess::SeparateChannels);
- mProcess->start();
- if (!mProcess->waitForStarted()) {
- mError = GpgME::Error::fromCode(GPG_ERR_ENOENT, GPG_ERR_SOURCE_GPGSM); // what else?
- deleteLater();
- return mError;
- } else {
- return GpgME::Error();
- }
-}
-
-void Kleo::QGpgMESecretKeyExportJob::slotCancel()
-{
- if (mProcess) {
- mProcess->kill();
- }
- mProcess = 0;
- mError = GpgME::Error::fromCode(GPG_ERR_CANCELED, GPG_ERR_SOURCE_GPGSM);
-}
-
-void Kleo::QGpgMESecretKeyExportJob::slotStatus(GnuPGProcessBase *proc, const QString &type, const QStringList &args)
-{
- if (proc != mProcess) {
- return;
- }
- QStringList::const_iterator it = args.begin();
- bool ok = false;
-
- if (type == QLatin1String("ERROR")) {
-
- if (args.size() < 2) {
- qCDebug(GPGPME_BACKEND_LOG) << "Kleo::QGpgMESecretKeyExportJob::slotStatus() not recognising ERROR with < 2 args!";
- return;
- }
- const int source = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "Kleo::QGpgMESecretKeyExportJob::slotStatus() expected number for first ERROR arg, got something else";
- return;
- }
- ok = false;
- const int code = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for second ERROR arg, got something else";
- return;
- }
- mError = GpgME::Error::fromCode(code, source);
-
- } else if (type == QLatin1String("PROGRESS")) {
-
- if (args.size() < 4) {
- qCDebug(GPGPME_BACKEND_LOG) << "not recognising PROGRESS with < 4 args!";
- return;
- }
- const QString what = *++it;
- ok = false;
- const int typ = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"type\", got something else";
- return;
- }
- ok = false;
- const int cur = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"cur\", got something else";
- return;
- }
- ok = false;
- const int total = (*++it).toInt(&ok);
- if (!ok) {
- qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"total\", got something else";
- return;
- }
- Q_EMIT progress(QGpgMEProgressTokenMapper::map(what, typ), cur, total);
-
- }
-}
-
-void Kleo::QGpgMESecretKeyExportJob::slotStdout()
-{
- QString line = QString::fromLocal8Bit(mProcess->readLine());
- if (!line.isEmpty()) {
- return;
- }
- const unsigned int oldlen = mKeyData.size();
- mKeyData.resize(oldlen + line.length());
- memcpy(mKeyData.data() + oldlen, line.toLatin1(), line.length());
-}
-
-void Kleo::QGpgMESecretKeyExportJob::slotStderr()
-{
- // implement? or not?
-}
-
-void Kleo::QGpgMESecretKeyExportJob::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus)
-{
- Q_EMIT done();
- if (!mError &&
- (exitStatus != QProcess::NormalExit || exitCode != 0)) {
- mError = GpgME::Error::fromCode(GPG_ERR_GENERAL, GPG_ERR_SOURCE_GPGSM);
- }
- Q_EMIT result(mError, mKeyData);
- deleteLater();
-}
-
diff --git a/src/backends/qgpgme/qgpgmesecretkeyexportjob.h b/src/backends/qgpgme/qgpgmesecretkeyexportjob.h
deleted file mode 100644
index 207b742..0000000
--- a/src/backends/qgpgme/qgpgmesecretkeyexportjob.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- qgpgmesecretkeyexportjob.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_QGPGMESECRETKEYEXPORTJOB_H__
-#define __KLEO_QGPGMESECRETKEYEXPORTJOB_H__
-
-#include "libkleo/exportjob.h"
-#include "gpgme++/context.h"
-#include <QProcess>
-
-namespace Kleo
-{
-class GnuPGProcessBase;
-}
-
-namespace GpgME
-{
-class Data;
-}
-
-namespace Kleo
-{
-
-class QGpgMESecretKeyExportJob : public ExportJob
-{
- Q_OBJECT
-public:
- QGpgMESecretKeyExportJob(bool armour, const QString &charset);
- ~QGpgMESecretKeyExportJob();
-
- /*! \reimp from ExportJob */
- GpgME::Error start(const QStringList &patterns) Q_DECL_OVERRIDE;
-
-private Q_SLOTS:
- /*! \reimp from Job */
- void slotCancel() Q_DECL_OVERRIDE;
-
- void slotStatus(Kleo::GnuPGProcessBase *, const QString &, const QStringList &);
- void slotStdout();
- void slotStderr();
- void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus);
-
-private:
- GnuPGProcessBase *mProcess;
- QByteArray mKeyData;
- GpgME::Error mError;
- bool mArmour;
- QString mCharset;
-};
-
-}
-
-#endif // __KLEO_QGPGMESECRETKEYEXPORTJOB_H__
diff --git a/src/backends/qgpgme/qgpgmesignencryptjob.cpp b/src/backends/qgpgme/qgpgmesignencryptjob.cpp
deleted file mode 100644
index cd14b06..0000000
--- a/src/backends/qgpgme/qgpgmesignencryptjob.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- qgpgmesignencryptjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004, 2007 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.
-*/
-
-#include "qgpgmesignencryptjob.h"
-
-#include "ui/messagebox.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/key.h>
-#include <gpgme++/exception.h>
-
-#include <QBuffer>
-
-#include <boost/weak_ptr.hpp>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMESignEncryptJob::QGpgMESignEncryptJob(Context *context)
- : mixin_type(context),
- mOutputIsBase64Encoded(false)
-{
- lateInitialization();
-}
-
-QGpgMESignEncryptJob::~QGpgMESignEncryptJob() {}
-
-void QGpgMESignEncryptJob::setOutputIsBase64Encoded(bool on)
-{
- mOutputIsBase64Encoded = on;
-}
-
-static QGpgMESignEncryptJob::result_type sign_encrypt(Context *ctx, QThread *thread, const std::vector<Key> &signers,
- const std::vector<Key> &recipients, const weak_ptr<QIODevice> &plainText_,
- const weak_ptr<QIODevice> &cipherText_, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded)
-{
- const shared_ptr<QIODevice> &plainText = plainText_.lock();
- const shared_ptr<QIODevice> &cipherText = cipherText_.lock();
-
- const _detail::ToThreadMover ctMover(cipherText, thread);
- const _detail::ToThreadMover ptMover(plainText, thread);
-
- QGpgME::QIODeviceDataProvider in(plainText);
- const Data indata(&in);
-
- ctx->clearSigningKeys();
- Q_FOREACH (const Key &signer, signers)
- if (!signer.isNull())
- if (const Error err = ctx->addSigningKey(signer)) {
- return make_tuple(SigningResult(err), EncryptionResult(), QByteArray(), QString(), Error());
- }
-
- if (!cipherText) {
- QGpgME::QByteArrayDataProvider out;
- Data outdata(&out);
-
- if (outputIsBsse64Encoded) {
- outdata.setEncoding(Data::Base64Encoding);
- }
-
- const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res.first, res.second, out.data(), log, ae);
- } else {
- QGpgME::QIODeviceDataProvider out(cipherText);
- Data outdata(&out);
-
- if (outputIsBsse64Encoded) {
- outdata.setEncoding(Data::Base64Encoding);
- }
-
- const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res.first, res.second, QByteArray(), log, ae);
- }
-
-}
-
-static QGpgMESignEncryptJob::result_type sign_encrypt_qba(Context *ctx, const std::vector<Key> &signers,
- const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, bool outputIsBsse64Encoded)
-{
- const shared_ptr<QBuffer> buffer(new QBuffer);
- buffer->setData(plainText);
- if (!buffer->open(QIODevice::ReadOnly)) {
- assert(!"This should never happen: QBuffer::open() failed");
- }
- return sign_encrypt(ctx, 0, signers, recipients, buffer, shared_ptr<QIODevice>(), eflags, outputIsBsse64Encoded);
-}
-
-Error QGpgMESignEncryptJob::start(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust)
-{
- run(boost::bind(&sign_encrypt_qba, _1, signers, recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, mOutputIsBase64Encoded));
- return Error();
-}
-
-void QGpgMESignEncryptJob::start(const std::vector<Key> &signers, const std::vector<Key> &recipients,
- const shared_ptr<QIODevice> &plainText, const shared_ptr<QIODevice> &cipherText, const Context::EncryptionFlags eflags)
-{
- run(boost::bind(&sign_encrypt, _1, _2, signers, recipients, _3, _4, eflags, mOutputIsBase64Encoded), plainText, cipherText);
-}
-
-void QGpgMESignEncryptJob::start(const std::vector<Key> &signers, const std::vector<Key> &recipients, const shared_ptr<QIODevice> &plainText, const shared_ptr<QIODevice> &cipherText, bool alwaysTrust)
-{
- return start(signers, recipients, plainText, cipherText, alwaysTrust ? Context::AlwaysTrust : Context::None);
-}
-
-std::pair<SigningResult, EncryptionResult> QGpgMESignEncryptJob::exec(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, const Context::EncryptionFlags eflags, QByteArray &cipherText)
-{
- const result_type r = sign_encrypt_qba(context(), signers, recipients, plainText, eflags, mOutputIsBase64Encoded);
- cipherText = get<2>(r);
- resultHook(r);
- return mResult;
-}
-
-std::pair<SigningResult, EncryptionResult> QGpgMESignEncryptJob::exec(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText)
-{
- return exec(signers, recipients, plainText, alwaysTrust ? Context::AlwaysTrust : Context::None, cipherText);
-}
-
-
-void QGpgMESignEncryptJob::showErrorDialog(QWidget *parent, const QString &caption) const
-{
- if ((mResult.first.error() && !mResult.first.error().isCanceled()) ||
- (mResult.second.error() && !mResult.second.error().isCanceled())) {
- MessageBox::error(parent, mResult.first, mResult.second, this, caption);
- }
-}
-
-void QGpgMESignEncryptJob::resultHook(const result_type &tuple)
-{
- mResult = std::make_pair(get<0>(tuple), get<1>(tuple));
-}
-
diff --git a/src/backends/qgpgme/qgpgmesignencryptjob.h b/src/backends/qgpgme/qgpgmesignencryptjob.h
deleted file mode 100644
index 3e72716..0000000
--- a/src/backends/qgpgme/qgpgmesignencryptjob.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- qgpgmesignencryptjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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_QGPGMESIGNENCRYPTJOB_H__
-#define __KLEO_QGPGMESIGNENCRYPTJOB_H__
-
-#include "libkleo/signencryptjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/signingresult.h>
-#include <gpgme++/encryptionresult.h>
-#include <gpgme++/key.h>
-
-#include <utility>
-
-namespace Kleo
-{
-
-class QGpgMESignEncryptJob
-#ifdef Q_MOC_RUN
- : public SignEncryptJob
-#else
- : public _detail::ThreadedJobMixin<SignEncryptJob, boost::tuple<GpgME::SigningResult, GpgME::EncryptionResult, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMESignEncryptJob(GpgME::Context *context);
- ~QGpgMESignEncryptJob();
-
- /*! \reimp from SignEncryptJob */
- GpgME::Error start(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText, bool alwaysTrust) Q_DECL_OVERRIDE;
-
- /*! \reimp from SignEncryptJob */
- void start(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &cipherText,
- bool alwaysTrust) Q_DECL_OVERRIDE;
-
- void start(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &cipherText,
- const GpgME::Context::EncryptionFlags flags) Q_DECL_OVERRIDE;
-
- std::pair<GpgME::SigningResult, GpgME::EncryptionResult>
- exec(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText, bool alwaysTrust,
- QByteArray &cipherText) Q_DECL_OVERRIDE;
-
- std::pair<GpgME::SigningResult, GpgME::EncryptionResult>
- exec(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText, const GpgME::Context::EncryptionFlags flags,
- QByteArray &cipherText) Q_DECL_OVERRIDE;
-
- /*! \reimp from Job */
- void showErrorDialog(QWidget *parent, const QString &caption) const Q_DECL_OVERRIDE;
-
- /*! \reimp from SignEncryptJob */
- void setOutputIsBase64Encoded(bool on) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- bool mOutputIsBase64Encoded;
- std::pair<GpgME::SigningResult, GpgME::EncryptionResult> mResult;
-};
-
-}
-
-#endif // __KLEO_QGPGMESIGNENCRYPTJOB_H__
diff --git a/src/backends/qgpgme/qgpgmesignjob.cpp b/src/backends/qgpgme/qgpgmesignjob.cpp
deleted file mode 100644
index 40424e6..0000000
--- a/src/backends/qgpgme/qgpgmesignjob.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- qgpgmesignjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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.
-*/
-
-#include "qgpgmesignjob.h"
-
-#include "ui/messagebox.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/signingresult.h>
-#include <gpgme++/data.h>
-
-#include <QBuffer>
-
-#include <boost/weak_ptr.hpp>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMESignJob::QGpgMESignJob(Context *context)
- : mixin_type(context),
- mOutputIsBase64Encoded(false)
-{
- lateInitialization();
-}
-
-QGpgMESignJob::~QGpgMESignJob() {}
-
-void QGpgMESignJob::setOutputIsBase64Encoded(bool on)
-{
- mOutputIsBase64Encoded = on;
-}
-
-static QGpgMESignJob::result_type sign(Context *ctx, QThread *thread,
- const std::vector<Key> &signers,
- const weak_ptr<QIODevice> &plainText_,
- const weak_ptr<QIODevice> &signature_,
- SignatureMode mode,
- bool outputIsBsse64Encoded)
-{
-
- const shared_ptr<QIODevice> plainText = plainText_.lock();
- const shared_ptr<QIODevice> signature = signature_.lock();
-
- const _detail::ToThreadMover ptMover(plainText, thread);
- const _detail::ToThreadMover sgMover(signature, thread);
-
- QGpgME::QIODeviceDataProvider in(plainText);
- const Data indata(&in);
-
- ctx->clearSigningKeys();
- Q_FOREACH (const Key &signer, signers)
- if (!signer.isNull())
- if (const Error err = ctx->addSigningKey(signer)) {
- return make_tuple(SigningResult(err), QByteArray(), QString(), Error());
- }
-
- if (!signature) {
- QGpgME::QByteArrayDataProvider out;
- Data outdata(&out);
-
- if (outputIsBsse64Encoded) {
- outdata.setEncoding(Data::Base64Encoding);
- }
-
- const SigningResult res = ctx->sign(indata, outdata, mode);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, out.data(), log, ae);
- } else {
- QGpgME::QIODeviceDataProvider out(signature);
- Data outdata(&out);
-
- if (outputIsBsse64Encoded) {
- outdata.setEncoding(Data::Base64Encoding);
- }
-
- const SigningResult res = ctx->sign(indata, outdata, mode);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, QByteArray(), log, ae);
- }
-
-}
-
-static QGpgMESignJob::result_type sign_qba(Context *ctx,
- const std::vector<Key> &signers,
- const QByteArray &plainText,
- SignatureMode mode,
- bool outputIsBsse64Encoded)
-{
- const shared_ptr<QBuffer> buffer(new QBuffer);
- buffer->setData(plainText);
- if (!buffer->open(QIODevice::ReadOnly)) {
- assert(!"This should never happen: QBuffer::open() failed");
- }
- return sign(ctx, 0, signers, buffer, shared_ptr<QIODevice>(), mode, outputIsBsse64Encoded);
-}
-
-Error QGpgMESignJob::start(const std::vector<Key> &signers, const QByteArray &plainText, SignatureMode mode)
-{
- run(boost::bind(&sign_qba, _1, signers, plainText, mode, mOutputIsBase64Encoded));
- return Error();
-}
-
-void QGpgMESignJob::start(const std::vector<Key> &signers, const shared_ptr<QIODevice> &plainText, const shared_ptr<QIODevice> &signature, SignatureMode mode)
-{
- run(boost::bind(&sign, _1, _2, signers, _3, _4, mode, mOutputIsBase64Encoded), plainText, signature);
-}
-
-SigningResult QGpgMESignJob::exec(const std::vector<Key> &signers, const QByteArray &plainText, SignatureMode mode, QByteArray &signature)
-{
- const result_type r = sign_qba(context(), signers, plainText, mode, mOutputIsBase64Encoded);
- signature = get<1>(r);
- resultHook(r);
- return mResult;
-}
-
-void QGpgMESignJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
-}
-
-void QGpgMESignJob::showErrorDialog(QWidget *parent, const QString &caption) const
-{
- if (mResult.error() && !mResult.error().isCanceled()) {
- MessageBox::error(parent, mResult, this, caption);
- }
-}
-
diff --git a/src/backends/qgpgme/qgpgmesignjob.h b/src/backends/qgpgme/qgpgmesignjob.h
deleted file mode 100644
index 4970c51..0000000
--- a/src/backends/qgpgme/qgpgmesignjob.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- qgpgmesignjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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_QGPGMESIGNJOB_H__
-#define __KLEO_QGPGMESIGNJOB_H__
-
-#include "libkleo/signjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/signingresult.h>
-#include <gpgme++/key.h>
-
-namespace Kleo
-{
-
-class QGpgMESignJob
-#ifdef Q_MOC_RUN
- : public SignJob
-#else
- : public _detail::ThreadedJobMixin<SignJob, boost::tuple<GpgME::SigningResult, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMESignJob(GpgME::Context *context);
- ~QGpgMESignJob();
-
- /*! \reimp from SignJob */
- GpgME::Error start(const std::vector<GpgME::Key> &signers,
- const QByteArray &plainText,
- GpgME::SignatureMode mode) Q_DECL_OVERRIDE;
-
- /*! \reimp from SignJob */
- void start(const std::vector<GpgME::Key> &signers,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &signature,
- GpgME::SignatureMode mode) Q_DECL_OVERRIDE;
-
- /*! \reimp from SignJob */
- GpgME::SigningResult exec(const std::vector<GpgME::Key> &signers,
- const QByteArray &plainText,
- GpgME::SignatureMode mode,
- QByteArray &signature) Q_DECL_OVERRIDE;
-
- /*! \reimp from Job */
- void showErrorDialog(QWidget *parent, const QString &caption) const Q_DECL_OVERRIDE;
-
- /*! \reimp from SignJob */
- void setOutputIsBase64Encoded(bool on) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- GpgME::SigningResult mResult;
- bool mOutputIsBase64Encoded;
-};
-
-}
-
-#endif // __KLEO_QGPGMESIGNJOB_H__
diff --git a/src/backends/qgpgme/qgpgmesignkeyjob.cpp b/src/backends/qgpgme/qgpgmesignkeyjob.cpp
deleted file mode 100644
index c4bf08a..0000000
--- a/src/backends/qgpgme/qgpgmesignkeyjob.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- qgpgmesignkeyjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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.
-*/
-
-#include "qgpgmesignkeyjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-#include <gpgme++/gpgsignkeyeditinteractor.h>
-
-#include <cassert>
-#include <memory>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMESignKeyJob::QGpgMESignKeyJob(Context *context)
- : mixin_type(context),
- m_userIDsToSign(),
- m_signingKey(),
- m_checkLevel(0),
- m_exportable(false),
- m_nonRevocable(false),
- m_started(false)
-{
- lateInitialization();
-}
-
-QGpgMESignKeyJob::~QGpgMESignKeyJob() {}
-
-static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, const std::vector<unsigned int> &uids, unsigned int checkLevel, const Key &signer, unsigned int opts)
-{
- QGpgME::QByteArrayDataProvider dp;
- Data data(&dp);
-
- std::auto_ptr<GpgSignKeyEditInteractor> skei(new GpgSignKeyEditInteractor);
- skei->setUserIDsToSign(uids);
- skei->setCheckLevel(checkLevel);
- skei->setSigningOptions(opts);
-
- std::auto_ptr<EditInteractor> ei(skei);
-
- if (!signer.isNull())
- if (const Error err = ctx->addSigningKey(signer)) {
- return make_tuple(err, QString(), Error());
- }
- const Error err = ctx->edit(key, ei, data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(err, log, ae);
-}
-
-Error QGpgMESignKeyJob::start(const Key &key)
-{
- unsigned int opts = 0;
- if (m_nonRevocable) {
- opts |= GpgSignKeyEditInteractor::NonRevocable;
- }
- if (m_exportable) {
- opts |= GpgSignKeyEditInteractor::Exportable;
- }
- run(boost::bind(&sign_key, _1, key, m_userIDsToSign, m_checkLevel, m_signingKey, opts));
- m_started = true;
- return Error();
-}
-
-void QGpgMESignKeyJob::setUserIDsToSign(const std::vector<unsigned int> &idsToSign)
-{
- assert(!m_started);
- m_userIDsToSign = idsToSign;
-}
-
-void QGpgMESignKeyJob::setCheckLevel(unsigned int checkLevel)
-{
- assert(!m_started);
- m_checkLevel = checkLevel;
-}
-
-void QGpgMESignKeyJob::setExportable(bool exportable)
-{
- assert(!m_started);
- m_exportable = exportable;
-}
-
-void QGpgMESignKeyJob::setSigningKey(const Key &key)
-{
- assert(!m_started);
- m_signingKey = key;
-}
-
-void QGpgMESignKeyJob::setNonRevocable(bool nonRevocable)
-{
- assert(!m_started);
- m_nonRevocable = nonRevocable;
-}
-
diff --git a/src/backends/qgpgme/qgpgmesignkeyjob.h b/src/backends/qgpgme/qgpgmesignkeyjob.h
deleted file mode 100644
index 06499b8..0000000
--- a/src/backends/qgpgme/qgpgmesignkeyjob.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- qgpgmesignkeyjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_QGPGMESIGNKEYJOB_H__
-#define __KLEO_QGPGMESIGNKEYJOB_H__
-
-#include "libkleo/signkeyjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/key.h>
-
-namespace Kleo
-{
-
-class QGpgMESignKeyJob
-#ifdef Q_MOC_RUN
- : public SignKeyJob
-#else
- : public _detail::ThreadedJobMixin<SignKeyJob>
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMESignKeyJob(GpgME::Context *context);
- ~QGpgMESignKeyJob();
-
- /*! \reimp from SignKeyJob */
- GpgME::Error start(const GpgME::Key &key) Q_DECL_OVERRIDE;
-
- /*! \reimp from SignKeyJob */
- void setUserIDsToSign(const std::vector<unsigned int> &idsToSign) Q_DECL_OVERRIDE;
-
- /*! \reimp from SignKeyJob */
- void setCheckLevel(unsigned int checkLevel) Q_DECL_OVERRIDE;
-
- /*! \reimp from SignKeyJob */
- void setExportable(bool exportable) Q_DECL_OVERRIDE;
-
- /*! \reimp from SignKeyJob */
- void setSigningKey(const GpgME::Key &key) Q_DECL_OVERRIDE;
-
- /*! \reimp from SignKeyJob */
- void setNonRevocable(bool nonRevocable) Q_DECL_OVERRIDE;
-
-private:
- std::vector<unsigned int> m_userIDsToSign;
- GpgME::Key m_signingKey;
- unsigned int m_checkLevel;
- bool m_exportable;
- bool m_nonRevocable;
- bool m_started;
-};
-}
-
-#endif // __KLEO_QGPGMESIGNKEYJOB_H__
diff --git a/src/backends/qgpgme/qgpgmeverifydetachedjob.cpp b/src/backends/qgpgme/qgpgmeverifydetachedjob.cpp
deleted file mode 100644
index ebe702d..0000000
--- a/src/backends/qgpgme/qgpgmeverifydetachedjob.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- qgpgmeverifydetachedjob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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.
-*/
-
-#include "qgpgmeverifydetachedjob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/verificationresult.h>
-#include <gpgme++/data.h>
-
-#include <cassert>
-
-#include <boost/weak_ptr.hpp>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEVerifyDetachedJob::QGpgMEVerifyDetachedJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEVerifyDetachedJob::~QGpgMEVerifyDetachedJob() {}
-
-static QGpgMEVerifyDetachedJob::result_type verify_detached(Context *ctx, QThread *thread, const weak_ptr<QIODevice> &signature_, const weak_ptr<QIODevice> &signedData_)
-{
- const shared_ptr<QIODevice> signature = signature_.lock();
- const shared_ptr<QIODevice> signedData = signedData_.lock();
-
- const _detail::ToThreadMover sgMover(signature, thread);
- const _detail::ToThreadMover sdMover(signedData, thread);
-
- QGpgME::QIODeviceDataProvider sigDP(signature);
- Data sig(&sigDP);
-
- QGpgME::QIODeviceDataProvider dataDP(signedData);
- Data data(&dataDP);
-
- const VerificationResult res = ctx->verifyDetachedSignature(sig, data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
-
- return make_tuple(res, log, ae);
-}
-
-static QGpgMEVerifyDetachedJob::result_type verify_detached_qba(Context *ctx, const QByteArray &signature, const QByteArray &signedData)
-{
- QGpgME::QByteArrayDataProvider sigDP(signature);
- Data sig(&sigDP);
-
- QGpgME::QByteArrayDataProvider dataDP(signedData);
- Data data(&dataDP);
-
- const VerificationResult res = ctx->verifyDetachedSignature(sig, data);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
-
- return make_tuple(res, log, ae);
-
-}
-
-Error QGpgMEVerifyDetachedJob::start(const QByteArray &signature, const QByteArray &signedData)
-{
- run(bind(&verify_detached_qba, _1, signature, signedData));
- return Error();
-}
-
-void QGpgMEVerifyDetachedJob::start(const shared_ptr<QIODevice> &signature, const shared_ptr<QIODevice> &signedData)
-{
- run(bind(&verify_detached, _1, _2, _3, _4), signature, signedData);
-}
-
-GpgME::VerificationResult Kleo::QGpgMEVerifyDetachedJob::exec(const QByteArray &signature,
- const QByteArray &signedData)
-{
- const result_type r = verify_detached_qba(context(), signature, signedData);
- resultHook(r);
- return mResult;
-}
-
-//PENDING(marc) implement showErrorDialog()
-
-void Kleo::QGpgMEVerifyDetachedJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
-}
-
diff --git a/src/backends/qgpgme/qgpgmeverifydetachedjob.h b/src/backends/qgpgme/qgpgmeverifydetachedjob.h
deleted file mode 100644
index 7f98635..0000000
--- a/src/backends/qgpgme/qgpgmeverifydetachedjob.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- qgpgmeverifydetachedjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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_QGPGMEVERIFYDETACHEDJOB_H__
-#define __KLEO_QGPGMEVERIFYDETACHEDJOB_H__
-
-#include "libkleo/verifydetachedjob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/verificationresult.h>
-
-namespace Kleo
-{
-
-class QGpgMEVerifyDetachedJob
-#ifdef Q_MOC_RUN
- : public VerifyDetachedJob
-#else
- : public _detail::ThreadedJobMixin<VerifyDetachedJob, boost::tuple<GpgME::VerificationResult, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEVerifyDetachedJob(GpgME::Context *context);
- ~QGpgMEVerifyDetachedJob();
-
- /*! \reimp from VerifyDetachedJob */
- GpgME::Error start(const QByteArray &signature, const QByteArray &signedData) Q_DECL_OVERRIDE;
-
- /*! \reimp from VerifyDetachedJob */
- void start(const boost::shared_ptr<QIODevice> &signature, const boost::shared_ptr<QIODevice> &signedData) Q_DECL_OVERRIDE;
-
- /*! \reimp from VerifyDetachedJob */
- GpgME::VerificationResult exec(const QByteArray &signature,
- const QByteArray &signedData) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- GpgME::VerificationResult mResult;
-};
-
-}
-
-#endif // __KLEO_QGPGMEVERIFYDETACHEDJOB_H__
diff --git a/src/backends/qgpgme/qgpgmeverifyopaquejob.cpp b/src/backends/qgpgme/qgpgmeverifyopaquejob.cpp
deleted file mode 100644
index 2a25a44..0000000
--- a/src/backends/qgpgme/qgpgmeverifyopaquejob.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- qgpgmeverifyopaquejob.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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.
-*/
-
-#include "qgpgmeverifyopaquejob.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/context.h>
-#include <gpgme++/verificationresult.h>
-#include <gpgme++/data.h>
-
-#include <QBuffer>
-
-#include <boost/weak_ptr.hpp>
-
-#include <cassert>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-QGpgMEVerifyOpaqueJob::QGpgMEVerifyOpaqueJob(Context *context)
- : mixin_type(context)
-{
- lateInitialization();
-}
-
-QGpgMEVerifyOpaqueJob::~QGpgMEVerifyOpaqueJob() {}
-
-static QGpgMEVerifyOpaqueJob::result_type verify_opaque(Context *ctx, QThread *thread, const weak_ptr<QIODevice> &signedData_, const weak_ptr<QIODevice> &plainText_)
-{
-
- const shared_ptr<QIODevice> plainText = plainText_.lock();
- const shared_ptr<QIODevice> signedData = signedData_.lock();
-
- const _detail::ToThreadMover ptMover(plainText, thread);
- const _detail::ToThreadMover sdMover(signedData, thread);
-
- QGpgME::QIODeviceDataProvider in(signedData);
- const Data indata(&in);
-
- if (!plainText) {
- QGpgME::QByteArrayDataProvider out;
- Data outdata(&out);
-
- const VerificationResult res = ctx->verifyOpaqueSignature(indata, outdata);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, out.data(), log, ae);
- } else {
- QGpgME::QIODeviceDataProvider out(plainText);
- Data outdata(&out);
-
- const VerificationResult res = ctx->verifyOpaqueSignature(indata, outdata);
- Error ae;
- const QString log = _detail::audit_log_as_html(ctx, ae);
- return make_tuple(res, QByteArray(), log, ae);
- }
-
-}
-
-static QGpgMEVerifyOpaqueJob::result_type verify_opaque_qba(Context *ctx, const QByteArray &signedData)
-{
- const shared_ptr<QBuffer> buffer(new QBuffer);
- buffer->setData(signedData);
- if (!buffer->open(QIODevice::ReadOnly)) {
- assert(!"This should never happen: QBuffer::open() failed");
- }
- return verify_opaque(ctx, 0, buffer, shared_ptr<QIODevice>());
-}
-
-Error QGpgMEVerifyOpaqueJob::start(const QByteArray &signedData)
-{
- run(bind(&verify_opaque_qba, _1, signedData));
- return Error();
-}
-
-void QGpgMEVerifyOpaqueJob::start(const shared_ptr<QIODevice> &signedData, const shared_ptr<QIODevice> &plainText)
-{
- run(bind(&verify_opaque, _1, _2, _3, _4), signedData, plainText);
-}
-
-GpgME::VerificationResult Kleo::QGpgMEVerifyOpaqueJob::exec(const QByteArray &signedData, QByteArray &plainText)
-{
- const result_type r = verify_opaque_qba(context(), signedData);
- plainText = get<1>(r);
- resultHook(r);
- return mResult;
-}
-
-//PENDING(marc) implement showErrorDialog()
-
-void Kleo::QGpgMEVerifyOpaqueJob::resultHook(const result_type &tuple)
-{
- mResult = get<0>(tuple);
-}
-
diff --git a/src/backends/qgpgme/qgpgmeverifyopaquejob.h b/src/backends/qgpgme/qgpgmeverifyopaquejob.h
deleted file mode 100644
index 1d3c701..0000000
--- a/src/backends/qgpgme/qgpgmeverifyopaquejob.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- qgpgmeverifyopaquejob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2007,2008 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_QGPGMEVERIFYOPAQUEJOB_H__
-#define __KLEO_QGPGMEVERIFYOPAQUEJOB_H__
-
-#include "libkleo/verifyopaquejob.h"
-
-#include "threadedjobmixin.h"
-
-#include <gpgme++/verificationresult.h>
-
-namespace Kleo
-{
-
-class QGpgMEVerifyOpaqueJob
-#ifdef Q_MOC_RUN
- : public VerifyOpaqueJob
-#else
- : public _detail::ThreadedJobMixin<VerifyOpaqueJob, boost::tuple<GpgME::VerificationResult, QByteArray, QString, GpgME::Error> >
-#endif
-{
- Q_OBJECT
-#ifdef Q_MOC_RUN
-public Q_SLOTS:
- void slotFinished();
-#endif
-public:
- explicit QGpgMEVerifyOpaqueJob(GpgME::Context *context);
- ~QGpgMEVerifyOpaqueJob();
-
- /*! \reimp from VerifyOpaqueJob */
- GpgME::Error start(const QByteArray &signedData) Q_DECL_OVERRIDE;
-
- /*! \reimp from VerifyOpaqueJob */
- void start(const boost::shared_ptr<QIODevice> &signedData, const boost::shared_ptr<QIODevice> &plainText) Q_DECL_OVERRIDE;
-
- /*! \reimp form VerifyOpaqueJob */
- GpgME::VerificationResult exec(const QByteArray &signedData, QByteArray &plainData) Q_DECL_OVERRIDE;
-
- /*! \reimp from ThreadedJobMixin */
- void resultHook(const result_type &r) Q_DECL_OVERRIDE;
-
-private:
- GpgME::VerificationResult mResult;
-};
-
-}
-
-#endif // __KLEO_QGPGMEVERIFYOPAQUEJOB_H__
diff --git a/src/backends/qgpgme/threadedjobmixin.cpp b/src/backends/qgpgme/threadedjobmixin.cpp
deleted file mode 100644
index 3b2404e..0000000
--- a/src/backends/qgpgme/threadedjobmixin.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- threadedjobmixin.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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.
-*/
-
-#include "threadedjobmixin.h"
-
-#include <qgpgme/dataprovider.h>
-
-#include <gpgme++/data.h>
-
-#include <QString>
-#include <QStringList>
-#include <QByteArray>
-
-#include <boost/mem_fn.hpp>
-
-#include <algorithm>
-#include <iterator>
-
-using namespace Kleo;
-using namespace GpgME;
-using namespace boost;
-
-static const unsigned int GetAuditLogFlags = Context::AuditLogWithHelp | Context::HtmlAuditLog;
-
-QString _detail::audit_log_as_html(Context *ctx, GpgME::Error &err)
-{
- assert(ctx);
- QGpgME::QByteArrayDataProvider dp;
- Data data(&dp);
- assert(!data.isNull());
- if ((err = ctx->lastError()) || (err = ctx->getAuditLog(data, GetAuditLogFlags))) {
- return QString::fromLocal8Bit(err.asString());
- }
- const QByteArray ba = dp.data();
- return QString::fromUtf8(ba.data(), ba.size());
-}
-
-static QList<QByteArray> from_sl(const QStringList &sl)
-{
- QList<QByteArray> result;
- Q_FOREACH (const QString &str, sl) {
- result.append(str.toUtf8());
- }
-
-#if 0
- std::transform(sl.begin(), sl.end(), std::back_inserter(result),
- mem_fn(static_cast<QByteArray()const>(&QString::toUtf8)));
-#endif
- return result;
-}
-
-static QList<QByteArray> single(const QByteArray &ba)
-{
- QList<QByteArray> result;
- result.push_back(ba);
- return result;
-}
-
-_detail::PatternConverter::PatternConverter(const QByteArray &ba)
- : m_list(single(ba)), m_patterns(0) {}
-_detail::PatternConverter::PatternConverter(const QString &s)
- : m_list(single(s.toUtf8())), m_patterns(0) {}
-_detail::PatternConverter::PatternConverter(const QList<QByteArray> &lba)
- : m_list(lba), m_patterns(0) {}
-_detail::PatternConverter::PatternConverter(const QStringList &sl)
- : m_list(from_sl(sl)), m_patterns(0) {}
-
-const char **_detail::PatternConverter::patterns() const
-{
- if (!m_patterns) {
- m_patterns = new const char *[ m_list.size() + 1 ];
- const char **end = std::transform(m_list.begin(), m_list.end(), m_patterns,
- mem_fn(&QByteArray::constData));
- *end = 0;
- }
- return m_patterns;
-}
-
-_detail::PatternConverter::~PatternConverter()
-{
- delete [] m_patterns;
-}
diff --git a/src/backends/qgpgme/threadedjobmixin.h b/src/backends/qgpgme/threadedjobmixin.h
deleted file mode 100644
index 73712bb..0000000
--- a/src/backends/qgpgme/threadedjobmixin.h
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- threadedjobmixin.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_THREADEDJOBMIXING_H__
-#define __KLEO_THREADEDJOBMIXING_H__
-
-#include "qgpgmeprogresstokenmapper.h"
-
-#include <QMutex>
-#include <QMutexLocker>
-#include <QThread>
-#include <QString>
-#include <QIODevice>
-
-#include <gpgme++/context.h>
-#include <gpgme++/interfaces/progressprovider.h>
-
-#include <boost/shared_ptr.hpp>
-#include <boost/weak_ptr.hpp>
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/tuple/tuple.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/type_traits/is_same.hpp>
-
-#include <cassert>
-
-namespace Kleo
-{
-namespace _detail
-{
-
-QString audit_log_as_html(GpgME::Context *ctx, GpgME::Error &err);
-
-class PatternConverter
-{
- const QList<QByteArray> m_list;
- mutable const char **m_patterns;
-public:
- explicit PatternConverter(const QByteArray &ba);
- explicit PatternConverter(const QString &s);
- explicit PatternConverter(const QList<QByteArray> &lba);
- explicit PatternConverter(const QStringList &sl);
- ~PatternConverter();
-
- const char **patterns() const;
-};
-
-class ToThreadMover
-{
- QObject *const m_object;
- QThread *const m_thread;
-public:
- ToThreadMover(QObject *o, QThread *t) : m_object(o), m_thread(t) {}
- ToThreadMover(QObject &o, QThread *t) : m_object(&o), m_thread(t) {}
- ToThreadMover(const boost::shared_ptr<QObject> &o, QThread *t) : m_object(o.get()), m_thread(t) {}
- ~ToThreadMover()
- {
- if (m_object && m_thread) {
- m_object->moveToThread(m_thread);
- }
- }
-};
-
-template <typename T_result>
-class Thread : public QThread
-{
-public:
- explicit Thread(QObject *parent = Q_NULLPTR) : QThread(parent) {}
-
- void setFunction(const boost::function<T_result()> &function)
- {
- const QMutexLocker locker(&m_mutex);
- m_function = function;
- }
-
- T_result result() const
- {
- const QMutexLocker locker(&m_mutex);
- return m_result;
- }
-
-private:
- void run() Q_DECL_OVERRIDE {
- const QMutexLocker locker(&m_mutex);
- m_result = m_function();
- }
-private:
- mutable QMutex m_mutex;
- boost::function<T_result()> m_function;
- T_result m_result;
-};
-
-template <typename T_base, typename T_result = boost::tuple<GpgME::Error, QString, GpgME::Error> >
-class ThreadedJobMixin : public T_base, public GpgME::ProgressProvider
-{
-public:
- typedef ThreadedJobMixin<T_base, T_result> mixin_type;
- typedef T_result result_type;
-
-protected:
- BOOST_STATIC_ASSERT((boost::tuples::length<T_result>::value > 2));
- BOOST_STATIC_ASSERT((
- boost::is_same <
- typename boost::tuples::element <
- boost::tuples::length<T_result>::value - 2,
- T_result
- >::type,
- QString
- >::value
- ));
- BOOST_STATIC_ASSERT((
- boost::is_same <
- typename boost::tuples::element <
- boost::tuples::length<T_result>::value - 1,
- T_result
- >::type,
- GpgME::Error
- >::value
- ));
-
- explicit ThreadedJobMixin(GpgME::Context *ctx)
- : T_base(0), m_ctx(ctx), m_thread(), m_auditLog(), m_auditLogError()
- {
-
- }
-
- void lateInitialization()
- {
- assert(m_ctx);
- QObject::connect(&m_thread, SIGNAL(finished()), this, SLOT(slotFinished()));
- m_ctx->setProgressProvider(this);
- }
-
- template <typename T_binder>
- void run(const T_binder &func)
- {
- m_thread.setFunction(boost::bind(func, this->context()));
- m_thread.start();
- }
- template <typename T_binder>
- void run(const T_binder &func, const boost::shared_ptr<QIODevice> &io)
- {
- if (io) {
- io->moveToThread(&m_thread);
- }
- // the arguments passed here to the functor are stored in a QThread, and are not
- // necessarily destroyed (living outside the UI thread) at the time the result signal
- // is emitted and the signal receiver wants to clean up IO devices.
- // To avoid such races, we pass weak_ptr's to the functor.
- m_thread.setFunction(boost::bind(func, this->context(), this->thread(), boost::weak_ptr<QIODevice>(io)));
- m_thread.start();
- }
- template <typename T_binder>
- void run(const T_binder &func, const boost::shared_ptr<QIODevice> &io1, const boost::shared_ptr<QIODevice> &io2)
- {
- if (io1) {
- io1->moveToThread(&m_thread);
- }
- if (io2) {
- io2->moveToThread(&m_thread);
- }
- // the arguments passed here to the functor are stored in a QThread, and are not
- // necessarily destroyed (living outside the UI thread) at the time the result signal
- // is emitted and the signal receiver wants to clean up IO devices.
- // To avoid such races, we pass weak_ptr's to the functor.
- m_thread.setFunction(boost::bind(func, this->context(), this->thread(), boost::weak_ptr<QIODevice>(io1), boost::weak_ptr<QIODevice>(io2)));
- m_thread.start();
- }
- GpgME::Context *context() const
- {
- return m_ctx.get();
- }
-
- virtual void resultHook(const result_type &) {}
-
- void slotFinished()
- {
- const T_result r = m_thread.result();
- m_auditLog = boost::get < boost::tuples::length<T_result>::value - 2 > (r);
- m_auditLogError = boost::get < boost::tuples::length<T_result>::value - 1 > (r);
- resultHook(r);
- Q_EMIT this->done();
- doEmitResult(r);
- this->deleteLater();
- }
- void slotCancel() Q_DECL_OVERRIDE {
- if (m_ctx)
- {
- m_ctx->cancelPendingOperation();
- }
- }
- QString auditLogAsHtml() const Q_DECL_OVERRIDE
- {
- return m_auditLog;
- }
- GpgME::Error auditLogError() const Q_DECL_OVERRIDE
- {
- return m_auditLogError;
- }
- void showProgress(const char *what, int type, int current, int total) Q_DECL_OVERRIDE {
- // will be called from the thread exec'ing the operation, so
- // just bounce everything to the owning thread:
- // ### hope this is thread-safe (meta obj is const, and
- // ### portEvent is thread-safe, so should be ok)
- QMetaObject::invokeMethod(this, "progress", Qt::QueuedConnection,
- Q_ARG(QString, QGpgMEProgressTokenMapper::map(what, type)),
- Q_ARG(int, current),
- Q_ARG(int, total));
- }
-private:
- template <typename T1, typename T2>
- void doEmitResult(const boost::tuple<T1, T2> &tuple)
- {
- Q_EMIT this->result(boost::get<0>(tuple), boost::get<1>(tuple));
- }
-
- template <typename T1, typename T2, typename T3>
- void doEmitResult(const boost::tuple<T1, T2, T3> &tuple)
- {
- Q_EMIT this->result(boost::get<0>(tuple), boost::get<1>(tuple), boost::get<2>(tuple));
- }
-
- template <typename T1, typename T2, typename T3, typename T4>
- void doEmitResult(const boost::tuple<T1, T2, T3, T4> &tuple)
- {
- Q_EMIT this->result(boost::get<0>(tuple), boost::get<1>(tuple), boost::get<2>(tuple), boost::get<3>(tuple));
- }
-
- template <typename T1, typename T2, typename T3, typename T4, typename T5>
- void doEmitResult(const boost::tuple<T1, T2, T3, T4, T5> &tuple)
- {
- Q_EMIT this->result(boost::get<0>(tuple), boost::get<1>(tuple), boost::get<2>(tuple), boost::get<3>(tuple), boost::get<4>(tuple));
- }
-
-private:
- boost::shared_ptr<GpgME::Context> m_ctx;
- Thread<T_result> m_thread;
- QString m_auditLog;
- GpgME::Error m_auditLogError;
-};
-
-}
-}
-
-#endif /* __KLEO_THREADEDJOBMIXING_H__ */
-
diff --git a/src/kleo/abstractimportjob.h b/src/kleo/abstractimportjob.h
deleted file mode 100644
index 0b07ac0..0000000
--- a/src/kleo/abstractimportjob.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- abstractimportjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2009 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_ABSTRACTIMPORTJOB_H__
-#define __KLEO_ABSTRACTIMPORTJOB_H__
-
-#include "job.h"
-
-namespace GpgME
-{
-class Error;
-class ImportResult;
-}
-
-namespace Kleo
-{
-
-class KLEO_EXPORT AbstractImportJob : public Job
-{
- Q_OBJECT
-protected:
- explicit AbstractImportJob(QObject *parent);
-public:
- ~AbstractImportJob();
-
-Q_SIGNALS:
- void result(const GpgME::ImportResult &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_IMPORTJOB_H__
diff --git a/src/kleo/adduseridjob.h b/src/kleo/adduseridjob.h
deleted file mode 100644
index 2cdffde..0000000
--- a/src/kleo/adduseridjob.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- adduseridjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_ADDUSERIDJOB_H__
-#define __KLEO_ADDUSERIDJOB_H__
-
-#include "job.h"
-
-#include <QtCore/QString>
-
-namespace GpgME
-{
-class Error;
-class Key;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class to asynchronously add UIDs to OpenPGP keys
-
- To use a AddUserIDJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the job with a call
- to start(). This call might fail, in which case the AddUserIDJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the AddUserIDJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT AddUserIDJob : public Job
-{
- Q_OBJECT
-protected:
- explicit AddUserIDJob(QObject *parent);
-public:
- ~AddUserIDJob();
-
- /**
- Starts the operation. \a key is the key to add the UID to. \a
- name, \a email and \a comment are the components of the user id.
- */
- virtual GpgME::Error start(const GpgME::Key &key, const QString &name,
- const QString &email, const QString &comment = QString()) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_ADDUSERIDJOB_H__
diff --git a/src/kleo/changeexpiryjob.h b/src/kleo/changeexpiryjob.h
deleted file mode 100644
index 721c09c..0000000
--- a/src/kleo/changeexpiryjob.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- changeexpiryjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_CHANGEEXPIRYJOB_H__
-#define __KLEO_CHANGEEXPIRYJOB_H__
-
-#include "job.h"
-
-namespace GpgME
-{
-class Error;
-class Key;
-}
-
-class QDateTime;
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class to change expiry asynchronously
-
- To use a ChangeExpiryJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the job with a call
- to start(). This call might fail, in which case the ChangeExpiryJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the ChangeExpiryJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT ChangeExpiryJob : public Job
-{
- Q_OBJECT
-protected:
- explicit ChangeExpiryJob(QObject *parent);
-public:
- ~ChangeExpiryJob();
-
- /**
- Starts the change-expiry operation. \a key is the key to change
- the expiry of. \a expiry is the new expiry time. If \a expiry
- is not valid, \a key is set to never expire.
- */
- virtual GpgME::Error start(const GpgME::Key &key, const QDateTime &expiry) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_CHANGEEXPIRYJOB_H__
diff --git a/src/kleo/changeownertrustjob.h b/src/kleo/changeownertrustjob.h
deleted file mode 100644
index 9d35488..0000000
--- a/src/kleo/changeownertrustjob.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- changeownertrustjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_CHANGEOWNERTRUST_H__
-#define __KLEO_CHANGEOWNERTRUST_H__
-
-#include "job.h"
-
-#include <gpgme++/key.h>
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class to change owner trust asynchronously
-
- To use a ChangeOwnerTrustJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the job with a call
- to start(). This call might fail, in which case the ChangeOwnerTrustJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the ChangeOwnerTrustJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT ChangeOwnerTrustJob : public Job
-{
- Q_OBJECT
-protected:
- explicit ChangeOwnerTrustJob(QObject *parent);
-public:
- ~ChangeOwnerTrustJob();
-
- /**
- Starts the change-owner trust operation. \a key is the key to change
- the owner trust of . \a trust is the new trust level.
- */
- virtual GpgME::Error start(const GpgME::Key &key, GpgME::Key::OwnerTrust trust) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_CHANGEOWNERTRUSTJOB_H__
diff --git a/src/kleo/changepasswdjob.h b/src/kleo/changepasswdjob.h
deleted file mode 100644
index 02e268d..0000000
--- a/src/kleo/changepasswdjob.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- changepasswdjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2010 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_CHANGEPASSWDJOB_H__
-#define __KLEO_CHANGEPASSWDJOB_H__
-
-#include "job.h"
-
-namespace GpgME
-{
-class Error;
-class Key;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class to change a key's passphrase asynchronously
-
- To use a ChangePasswdJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the job with a call
- to start(). This call might fail, in which case the ChangePasswdJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the ChangePasswdJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT ChangePasswdJob : public Job
-{
- Q_OBJECT
-protected:
- explicit ChangePasswdJob(QObject *parent);
-public:
- ~ChangePasswdJob();
-
- /**
- Starts the passphrase-change operation. \a key is the key to
- change the passphrase of. The passphrase is queried by the
- backend directly, you cannot give it to the job beforehand.
- */
- virtual GpgME::Error start(const GpgME::Key &key) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_CHANGEPASSWDJOB_H__
diff --git a/src/kleo/checksumdefinition.cpp b/src/kleo/checksumdefinition.cpp
index bfeb92f..eb92e24 100644
--- a/src/kleo/checksumdefinition.cpp
+++ b/src/kleo/checksumdefinition.cpp
@@ -33,7 +33,6 @@
#include "checksumdefinition.h"
#include "exception.h"
-#include "cryptobackendfactory.h"
#include "libkleo_debug.h"
@@ -384,20 +383,19 @@ std::vector< shared_ptr<ChecksumDefinition> > ChecksumDefinition::getChecksumDef
std::vector< shared_ptr<ChecksumDefinition> > ChecksumDefinition::getChecksumDefinitions(QStringList &errors)
{
std::vector< shared_ptr<ChecksumDefinition> > result;
- if (KConfig *config = CryptoBackendFactory::instance()->configObject()) {
- const QStringList groups = config->groupList().filter(QRegularExpression(QStringLiteral("^Checksum Definition #")));
- result.reserve(groups.size());
- Q_FOREACH (const QString &group, groups)
- try {
- const shared_ptr<ChecksumDefinition> ad(new KConfigBasedChecksumDefinition(KConfigGroup(config, group)));
- result.push_back(ad);
- } catch (const std::exception &e) {
- qCDebug(LIBKLEO_LOG) << e.what();
- errors.push_back(QString::fromLocal8Bit(e.what()));
- } catch (...) {
- errors.push_back(i18n("Caught unknown exception in group %1", group));
- }
- }
+ KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("libkleopatrarc"));
+ const QStringList groups = config->groupList().filter(QRegularExpression(QStringLiteral("^Checksum Definition #")));
+ result.reserve(groups.size());
+ Q_FOREACH (const QString &group, groups)
+ try {
+ const shared_ptr<ChecksumDefinition> ad(new KConfigBasedChecksumDefinition(KConfigGroup(config, group)));
+ result.push_back(ad);
+ } catch (const std::exception &e) {
+ qDebug() << e.what();
+ errors.push_back(QString::fromLocal8Bit(e.what()));
+ } catch (...) {
+ errors.push_back(i18n("Caught unknown exception in group %1", group));
+ }
return result;
}
diff --git a/src/kleo/cryptobackend.cpp b/src/kleo/cryptobackend.cpp
deleted file mode 100644
index ac2099e..0000000
--- a/src/kleo/cryptobackend.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- kleo/cryptobackend.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2005,2010 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.
-*/
-
-#include "cryptobackend.h"
-
-const char Kleo::CryptoBackend::OpenPGP[] = "OpenPGP";
-const char Kleo::CryptoBackend::SMIME[] = "SMIME";
-
-Kleo::ChangeExpiryJob *Kleo::CryptoBackend::Protocol::changeExpiryJob() const
-{
- return 0;
-}
-Kleo::ChangeOwnerTrustJob *Kleo::CryptoBackend::Protocol::changeOwnerTrustJob() const
-{
- return 0;
-}
-Kleo::ChangePasswdJob *Kleo::CryptoBackend::Protocol::changePasswdJob() const
-{
- return 0;
-}
-Kleo::SignKeyJob *Kleo::CryptoBackend::Protocol::signKeyJob() const
-{
- return 0;
-}
-Kleo::AddUserIDJob *Kleo::CryptoBackend::Protocol::addUserIDJob() const
-{
- return 0;
-}
diff --git a/src/kleo/cryptobackend.h b/src/kleo/cryptobackend.h
deleted file mode 100644
index 39725f2..0000000
--- a/src/kleo/cryptobackend.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- kleo/cryptobackend.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2005,2010 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_CRYPTOBACKEND_H__
-#define __KLEO_CRYPTOBACKEND_H__
-
-#include <QString>
-
-#include <kleo_export.h>
-
-namespace Kleo
-{
-class CryptoConfig;
-class KeyListJob;
-class ListAllKeysJob;
-class KeyGenerationJob;
-class ImportJob;
-class ImportFromKeyserverJob;
-class ExportJob;
-class DownloadJob;
-class DeleteJob;
-class EncryptJob;
-class DecryptJob;
-class SignJob;
-class SignKeyJob;
-class VerifyDetachedJob;
-class VerifyOpaqueJob;
-class SignEncryptJob;
-class DecryptVerifyJob;
-class RefreshKeysJob;
-class ChangeExpiryJob;
-class ChangeOwnerTrustJob;
-class ChangePasswdJob;
-class AddUserIDJob;
-class SpecialJob;
-class KeyForMailboxJob;
-}
-
-class QString;
-class QVariant;
-template <typename T_Key, typename T_Value> class QMap;
-
-namespace Kleo
-{
-
-class KLEO_EXPORT CryptoBackend
-{
-public:
- class Protocol;
-
- static const char OpenPGP[];
- static const char SMIME[];
-
- virtual ~CryptoBackend() {}
-
- virtual QString name() const = 0;
- virtual QString displayName() const = 0;
-
- virtual bool checkForOpenPGP(QString *reason = Q_NULLPTR) const = 0;
- virtual bool checkForSMIME(QString *reason = Q_NULLPTR) const = 0;
- virtual bool checkForProtocol(const char *name, QString *reason = Q_NULLPTR) const = 0;
-
- virtual bool supportsOpenPGP() const = 0;
- virtual bool supportsSMIME() const = 0;
- virtual bool supportsProtocol(const char *name) const = 0;
-
- virtual CryptoConfig *config() const = 0;
-
- virtual Protocol *openpgp() const = 0;
- virtual Protocol *smime() const = 0;
- virtual Protocol *protocol(const char *name) const = 0;
-
- virtual const char *enumerateProtocols(int i) const = 0;
-};
-
-class KLEO_EXPORT CryptoBackend::Protocol
-{
-public:
- virtual ~Protocol() {}
-
- virtual QString name() const = 0;
-
- virtual QString displayName() const = 0;
-
- virtual KeyListJob *keyListJob(bool remote = false, bool includeSigs = false, bool validate = false) const = 0;
- virtual ListAllKeysJob *listAllKeysJob(bool includeSigs = false, bool validate = false) const = 0;
- virtual EncryptJob *encryptJob(bool armor = false, bool textmode = false) const = 0;
- virtual DecryptJob *decryptJob() const = 0;
- virtual SignJob *signJob(bool armor = false, bool textMode = false) const = 0;
- virtual VerifyDetachedJob *verifyDetachedJob(bool textmode = false) const = 0;
- virtual VerifyOpaqueJob *verifyOpaqueJob(bool textmode = false) const = 0;
- virtual KeyGenerationJob *keyGenerationJob() const = 0;
- virtual ImportJob *importJob() const = 0;
- virtual ImportFromKeyserverJob *importFromKeyserverJob() const = 0;
- virtual ExportJob *publicKeyExportJob(bool armor = false) const = 0;
- // @param charset the encoding of the passphrase in the exported file
- virtual ExportJob *secretKeyExportJob(bool armor = false, const QString &charset = QString()) const = 0;
- virtual DownloadJob *downloadJob(bool armor = false) const = 0;
- virtual DeleteJob *deleteJob() const = 0;
- virtual SignEncryptJob *signEncryptJob(bool armor = false, bool textMode = false) const = 0;
- virtual DecryptVerifyJob *decryptVerifyJob(bool textmode = false) const = 0;
- virtual RefreshKeysJob *refreshKeysJob() const = 0;
- virtual ChangeExpiryJob *changeExpiryJob() const;
- virtual ChangeOwnerTrustJob *changeOwnerTrustJob() const;
- virtual ChangePasswdJob *changePasswdJob() const;
- virtual SignKeyJob *signKeyJob() const;
- virtual AddUserIDJob *addUserIDJob() const;
- virtual SpecialJob *specialJob(const char *type, const QMap<QString, QVariant> &args) const = 0;
- /** A key locate job.
- *
- * This tries to find a key in local
- * and remote sources, if the key was remote it is imported
- * by GnuPG. Same as KeyListJob but intended to be used
- * to locate keys automatically. This ends up calling --locate-keys.
- *
- * Only available for OpenPGP
- *
- * Results are validated. As if keyListJob was called
- * with both includeSigs and validate options.
- */
- virtual KeyListJob *locateKeysJob() const = 0;
- /** Find the best key to use for a mailbox. */
- virtual KeyForMailboxJob *keyForMailboxJob() const = 0;
-};
-
-}
-
-#endif // __KLEO_CRYPTOBACKEND_H__
diff --git a/src/kleo/cryptobackendfactory.cpp b/src/kleo/cryptobackendfactory.cpp
deleted file mode 100644
index 0e4c4e0..0000000
--- a/src/kleo/cryptobackendfactory.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- cryptobackendfactory.cpp
-
- This file is part of libkleopatra, the KDE key management library
- Copyright (c) 2001,2004,2005 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.
-*/
-
-#include "cryptobackendfactory.h"
-
-#include "backends/qgpgme/qgpgmebackend.h"
-#if 0 // disabled for kde-3.3
-#include "backends/kpgp/pgp2backend.h"
-#include "backends/kpgp/pgp5backend.h"
-#include "backends/kpgp/pgp6backend.h"
-#include "backends/kpgp/gpg1backend.h"
-#endif
-
-#include "backends/chiasmus/chiasmusbackend.h"
-
-#include <kconfig.h>
-#include <KLocalizedString>
-#include <kmessagebox.h>
-#include <kconfiggroup.h>
-
-#include <QApplication>
-#include <iterator>
-#include <algorithm>
-
-#include <cassert>
-
-Kleo::CryptoBackendFactory *Kleo::CryptoBackendFactory::mSelf = 0;
-
-static const char *const availableProtocols[] = {
- "Chiasmus", "OpenPGP", "SMIME",
-};
-static const unsigned int numAvailableProtocols = sizeof availableProtocols / sizeof * availableProtocols;
-
-Kleo::CryptoBackendFactory::CryptoBackendFactory()
- : QObject(qApp),
- mConfigObject(0),
- mAvailableProtocols(availableProtocols, availableProtocols + numAvailableProtocols)
-{
- setObjectName(QStringLiteral("CryptoBackendFactory::instance()"));
- mBackendList.push_back(new QGpgMEBackend());
-#if 0 // disabled for kde-3.3
- mBackendList.push_back(new PGP2Backend());
- mBackendList.push_back(new PGP5Backend());
- mBackendList.push_back(new PGP6Backend());
- mBackendList.push_back(new GPG1Backend());
-#endif
- mBackendList.push_back(new ChiasmusBackend());
- scanForBackends();
- readConfig();
-
- mSelf = this; // last!
-}
-
-Kleo::CryptoBackendFactory::~CryptoBackendFactory()
-{
- mSelf = 0; // first!
-
- for (std::vector<CryptoBackend *>::iterator it = mBackendList.begin(); it != mBackendList.end(); ++it) {
- delete *it;
- *it = 0;
- }
- delete mConfigObject;
- mConfigObject = 0;
-}
-
-Kleo::CryptoBackendFactory *Kleo::CryptoBackendFactory::instance()
-{
- if (!mSelf) {
- mSelf = new CryptoBackendFactory();
- }
- return mSelf;
-}
-
-// const Kleo::CryptoBackend* Kleo::CryptoBackendFactory::smimeBackend() const {
-// return mSMIMEBackend;
-// }
-
-// const Kleo::CryptoBackend* Kleo::CryptoBackendFactory::openpgpBackend() const {
-// return mOpenPGPBackend;
-// }
-
-const Kleo::CryptoBackend::Protocol *Kleo::CryptoBackendFactory::smime() const
-{
- const BackendMap::const_iterator it = mBackends.find("SMIME");
- if (it == mBackends.end()) {
- return 0;
- }
- if (!it->second) {
- return 0;
- }
- return it->second->smime();
-}
-
-const Kleo::CryptoBackend::Protocol *Kleo::CryptoBackendFactory::openpgp() const
-{
- const BackendMap::const_iterator it = mBackends.find("OpenPGP");
- if (it == mBackends.end()) {
- return 0;
- }
- if (!it->second) {
- return 0;
- }
- return it->second->openpgp();
-}
-
-const Kleo::CryptoBackend::Protocol *Kleo::CryptoBackendFactory::protocol(const char *name) const
-{
- const BackendMap::const_iterator it = mBackends.find(name);
- if (it == mBackends.end()) {
- return 0;
- }
- if (!it->second) {
- return 0;
- }
- return it->second->protocol(name);
-}
-
-const Kleo::CryptoBackend::Protocol *Kleo::CryptoBackendFactory::protocol(GpgME::Protocol proto) const
-{
- if (proto == GpgME::OpenPGP) {
- return openpgp();
- } else if (proto == GpgME::CMS) {
- return smime();
- } else {
- return 0;
- }
-}
-
-Kleo::CryptoConfig *Kleo::CryptoBackendFactory::config() const
-{
- // ## should we use mSMIMEBackend? mOpenPGPBackend? backend(0) i.e. always qgpgme?
- return backend(0) ? backend(0)->config() : 0;
-}
-
-bool Kleo::CryptoBackendFactory::hasBackends() const
-{
- return !mBackendList.empty();
-}
-
-void Kleo::CryptoBackendFactory::scanForBackends(QStringList *reasons)
-{
- for (std::vector<CryptoBackend *>::const_iterator it = mBackendList.begin(); it != mBackendList.end(); ++it) {
- assert(*it);
- for (int i = 0;; ++i) {
- const char *protocol = (*it)->enumerateProtocols(i);
- if (!protocol) {
- break;
- }
- QString reason;
- if ((*it)->supportsProtocol(protocol) && !(*it)->checkForProtocol(protocol, &reason)) {
- if (reasons) {
- reasons->push_back(i18n("While scanning for %1 support in backend %2:",
- QLatin1String(protocol), (*it)->displayName()));
- reasons->push_back(QLatin1String(" ") + reason);
- }
- }
- }
- }
-}
-
-const Kleo::CryptoBackend *Kleo::CryptoBackendFactory::backend(unsigned int idx) const
-{
- return (idx < mBackendList.size()) ? mBackendList[idx] : 0;
-}
-
-const Kleo::CryptoBackend *Kleo::CryptoBackendFactory::backendByName(const QString &name) const
-{
- for (std::vector<CryptoBackend *>::const_iterator it = mBackendList.begin(); it != mBackendList.end(); ++it) {
- if ((*it)->name() == name) {
- return *it;
- }
- }
- return 0;
-}
-
-KConfig *Kleo::CryptoBackendFactory::configObject() const
-{
- if (!mConfigObject)
- // this is unsafe. We're a lib, used by concurrent apps.
- {
- mConfigObject = new KConfig(QStringLiteral("libkleopatrarc"));
- }
- return mConfigObject;
-}
-
-void Kleo::CryptoBackendFactory::setSMIMEBackend(const CryptoBackend *backend)
-{
- setProtocolBackend("SMIME", backend);
-}
-
-void Kleo::CryptoBackendFactory::setOpenPGPBackend(const CryptoBackend *backend)
-{
- setProtocolBackend("OpenPGP", backend);
-}
-
-void Kleo::CryptoBackendFactory::setProtocolBackend(const char *protocol, const CryptoBackend *backend)
-{
- const QString name = backend ? backend->name() : QString();
- KConfigGroup group(configObject(), "Backends");
- group.writeEntry(protocol, name);
- configObject()->sync();
- mBackends[protocol] = backend;
-}
-
-static const char *defaultBackend(const char *proto)
-{
- static const struct {
- const char *proto;
- const char *backend;
- } defaults[] = {
- { "OpenPGP", "gpgme" },
- { "SMIME", "gpgme" },
- { "Chiasmus", "chiasmus" },
- };
- for (unsigned int i = 0; i < sizeof defaults / sizeof * defaults; ++i)
- if (qstricmp(proto, defaults[i].proto) == 0) {
- return defaults[i].backend;
- }
- return 0;
-}
-
-void Kleo::CryptoBackendFactory::readConfig()
-{
- mBackends.clear();
- const KConfigGroup group(configObject(), "Backends");
- for (ProtocolSet::const_iterator it = mAvailableProtocols.begin(), end = mAvailableProtocols.end(); it != end; ++it) {
- const QString backend = group.readEntry(*it);
- mBackends[*it] = backendByName(backend.isEmpty() ? QString::fromLatin1(defaultBackend(*it)) : backend);
- }
-}
-
-const char *Kleo::CryptoBackendFactory::enumerateProtocols(int i) const
-{
- if (i < 0 || static_cast<unsigned int>(i) >= mAvailableProtocols.size()) {
- return 0;
- }
- return mAvailableProtocols[i];
-}
-
-namespace
-{
-class CaseInsensitiveString
-{
- const char *m;
-public:
- CaseInsensitiveString(const char *s) : m(s) {}
-#define make_operator( op ) \
- bool operator op( const CaseInsensitiveString & other ) const { \
- return qstricmp( m, other.m ) op 0; \
- } \
- bool operator op( const char * other ) const { \
- return qstricmp( m, other ) op 0; \
- }
- make_operator( ==)
- make_operator( !=)
- make_operator( <)
- make_operator( >)
- make_operator( <=)
- make_operator( >=)
-#undef make_operator
- operator const char *() const
- {
- return m;
- }
-};
-#define make_ext_operator( op, inv_op ) \
- inline bool operator op( const char * lhs, const CaseInsensitiveString & rhs ) { \
- return rhs.operator inv_op( lhs ); \
- }
-make_ext_operator( ==, ==)
-make_ext_operator( !=, !=)
-make_ext_operator(<, >)
-make_ext_operator( >, <)
-make_ext_operator( <=, >=)
-make_ext_operator( >=, <=)
-#undef make_ext_operator
-
-}
-
-bool Kleo::CryptoBackendFactory::knowsAboutProtocol(const char *name) const
-{
- return std::find(mAvailableProtocols.begin(), mAvailableProtocols.end(),
- CaseInsensitiveString(name)) != mAvailableProtocols.end();
-}
-
diff --git a/src/kleo/cryptobackendfactory.h b/src/kleo/cryptobackendfactory.h
deleted file mode 100644
index a2682f9..0000000
--- a/src/kleo/cryptobackendfactory.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- kleo/cryptobackendfactory.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2005 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_CRYPTOBACKENDFACTORY_H__
-#define __KLEO_CRYPTOBACKENDFACTORY_H__
-
-#include "kleo_export.h"
-#include "cryptobackend.h"
-
-#include <gpgme++/global.h>
-
-#include <QObject>
-
-#include <vector>
-#include <map>
-
-class QString;
-class KConfig;
-
-namespace Kleo
-{
-
-struct lt_i_str {
- bool operator()(const char *one, const char *two) const
- {
- return qstricmp(one, two) < 0;
- }
-};
-
-class KLEO_EXPORT CryptoBackendFactory : public QObject
-{
- Q_OBJECT
-protected:
- CryptoBackendFactory();
- ~CryptoBackendFactory();
-public:
- static CryptoBackendFactory *instance();
-
- const CryptoBackend::Protocol *smime() const;
- const CryptoBackend::Protocol *openpgp() const;
- const CryptoBackend::Protocol *protocol(const char *name) const;
- const CryptoBackend::Protocol *protocol(GpgME::Protocol proto) const;
-
- CryptoConfig *config() const;
-
- const CryptoBackend *backend(unsigned int idx) const;
-
- bool hasBackends() const;
-
- KConfig *configObject() const;
-
- // The preferred backend for smime (can be 0) - currently unused
- //const CryptoBackend* smimeBackend() const;
- // The preferred backend for openpgp (can be 0) - currently unused
- //const CryptoBackend* openpgpBackend() const;
-
- // For BackendConfigWidget to save the configuration
- // 0 means no backend selected.
- void setSMIMEBackend(const CryptoBackend *backend);
- void setOpenPGPBackend(const CryptoBackend *backend);
- void setProtocolBackend(const char *name, const CryptoBackend *backend);
-
- void scanForBackends(QStringList *reasons = 0);
-
- const char *enumerateProtocols(int i) const;
-
- bool knowsAboutProtocol(const char *name) const;
-
-protected:
- std::vector<CryptoBackend *> mBackendList;
- mutable KConfig *mConfigObject;
- typedef std::map<const char *, const CryptoBackend *, lt_i_str> BackendMap;
- BackendMap mBackends;
- typedef std::vector<const char *> ProtocolSet;
- ProtocolSet mAvailableProtocols;
-
-private:
- const CryptoBackend *backendByName(const QString &name) const;
- void readConfig();
- CryptoBackendFactory(const CryptoBackendFactory &);
- void operator=(const CryptoBackendFactory &);
-
- static CryptoBackendFactory *mSelf;
-};
-
-}
-
-#endif // __KLEO_CRYPTOBACKENDFACTORY_H__
diff --git a/src/kleo/cryptoconfig.h b/src/kleo/cryptoconfig.h
deleted file mode 100644
index a43266a..0000000
--- a/src/kleo/cryptoconfig.h
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- cryptoconfig.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 CRYPTOCONFIG_H
-#define CRYPTOCONFIG_H
-
-#ifdef __cplusplus
-/* we read this file from a C compiler, and are only interested in the
- * enums... */
-
-#include <QUrl>
-
-#include <vector>
-
-/* Start reading this file from the bottom up :) */
-
-#include <kleo_export.h>
-
-namespace Kleo
-{
-
-/**
- * Description of a single option
- */
-class KLEO_EXPORT CryptoConfigEntry
-{
-
-public:
-#endif /* __cplusplus */
- /**
- @li basic This option should always be offered to the user.
- @li advanced This option may be offered to advanced users.
- @li expert This option should only be offered to expert users.
- */
- enum Level { Level_Basic = 0,
- Level_Advanced = 1,
- Level_Expert = 2
- };
-
- /**
- Type of the argument
- @li ArgType_None The option is set or not set, but no argument.
- @li ArgType_String An unformatted string.
- @li ArgType_Int A signed integer number.
- @li ArgType_UInt An unsigned integer number.
- @li ArgType_Path A string that describes the pathname of a file.
- The file does not necessarily need to exist.
- Separated from string so that e.g. a FileDialog can be used.
- @li ArgType_DirPath A string that describes the pathname of a directory.
- The directory does not necessarily need to exist.
- Separated from path so that e.g. a FileDialog can be used which only
- allows directories to be selected.
- @li ArgType_LDAPURL A LDAP URL
- Separated from URL so that a more specific widget can be shown, hiding the url syntax
- */
- enum ArgType { ArgType_None = 0,
- ArgType_String = 1,
- ArgType_Int = 2,
- ArgType_UInt = 3,
- ArgType_Path = 4,
- /* Nr. 5 was URL historically. */
- ArgType_LDAPURL = 6,
- ArgType_DirPath = 7,
-
- NumArgType
- };
-
-#ifdef __cplusplus
- virtual ~CryptoConfigEntry() {}
-
- /**
- * Return the internal name of this entry
- */
- virtual QString name() const = 0;
-
- /**
- * @return user-visible description of this entry
- */
- virtual QString description() const = 0;
-
- /**
- * @return "component/group/name"
- */
- virtual QString path() const = 0;
-
- /**
- * @return true if the argument is optional
- */
- virtual bool isOptional() const = 0;
-
- /**
- * @return true if the entry is readonly
- */
- virtual bool isReadOnly() const = 0;
-
- /**
- * @return true if the argument can be given multiple times
- */
- virtual bool isList() const = 0;
-
- /**
- * @return true if the argument can be changed at runtime
- */
- virtual bool isRuntime() const = 0;
-
- /**
- * User level
- */
- virtual Level level() const = 0;
-
- /**
- * Argument type
- */
- virtual ArgType argType() const = 0;
-
- /**
- * Return true if the option is set, i.e. different from default
- */
- virtual bool isSet() const = 0;
-
- /**
- * Return value as a bool (only allowed for ArgType_None)
- */
- virtual bool boolValue() const = 0;
-
- /**
- * Return value as a string (available for all argtypes)
- * The returned string can be empty (explicitly set to empty) or null (not set).
- */
- virtual QString stringValue() const = 0;
-
- /**
- * Return value as a signed int
- */
- virtual int intValue() const = 0;
-
- /**
- * Return value as an unsigned int
- */
- virtual unsigned int uintValue() const = 0;
-
- /**
- * Return value as a URL (only meaningful for Path and URL argtypes)
- */
- virtual QUrl urlValue() const = 0;
-
- /**
- * Return number of times the option is set (only valid for ArgType_None, if isList())
- */
- virtual unsigned int numberOfTimesSet() const = 0;
-
- /**
- * Return value as a list of signed ints
- */
- virtual std::vector<int> intValueList() const = 0;
-
- /**
- * Return value as a list of unsigned ints
- */
- virtual std::vector<unsigned int> uintValueList() const = 0;
-
- /**
- * Return value as a list of URLs (only meaningful for Path and URL argtypes, if isList())
- */
- virtual QList<QUrl> urlValueList() const = 0;
-
- /**
- * Reset an option to its default value
- */
- virtual void resetToDefault() = 0;
-
- /**
- * Define whether the option is set or not (only allowed for ArgType_None)
- * #### TODO: and for options with optional args
- */
- virtual void setBoolValue(bool) = 0;
-
- /**
- * Set string value (allowed for all argtypes)
- */
- virtual void setStringValue(const QString &) = 0;
-
- /**
- * Set a new signed int value
- */
- virtual void setIntValue(int) = 0;
-
- /**
- * Set a new unsigned int value
- */
- virtual void setUIntValue(unsigned int) = 0;
-
- /**
- * Set value as a URL (only meaningful for Path (if local) and URL argtypes)
- */
- virtual void setURLValue(const QUrl &) = 0;
-
- /**
- * Set the number of times the option is set (only valid for ArgType_None, if isList())
- */
- virtual void setNumberOfTimesSet(unsigned int) = 0;
-
- /**
- * Set a new list of signed int values
- */
- virtual void setIntValueList(const std::vector<int> &) = 0;
-
- /**
- * Set a new list of unsigned int values
- */
- virtual void setUIntValueList(const std::vector<unsigned int> &) = 0;
-
- /**
- * Set value as a URL list (only meaningful for Path (if all URLs are local) and URL argtypes, if isList())
- */
- virtual void setURLValueList(const QList<QUrl> &) = 0;
-
- /**
- * @return true if the value was changed
- */
- virtual bool isDirty() const = 0;
-};
-
-/**
- * Group containing a set of config options
- */
-class KLEO_EXPORT CryptoConfigGroup
-{
-
-public:
- virtual ~CryptoConfigGroup() {}
-
- /**
- * Return the internal name of this group
- */
- virtual QString name() const = 0;
-
- /**
- * Return the name of the icon for this group
- */
- virtual QString iconName() const = 0;
-
- /**
- * @return user-visible description of this group
- */
- virtual QString description() const = 0;
-
- /**
- * @return "component/group"
- */
- virtual QString path() const = 0;
-
- /**
- * User level
- */
- virtual CryptoConfigEntry::Level level() const = 0;
-
- /**
- * Returns the list of entries that are known by this group.
- *
- * @return list of group entry names.
- **/
- virtual QStringList entryList() const = 0;
-
- /**
- * @return the configuration object for a given entry in this group
- * The object is owned by CryptoConfigGroup, don't delete it.
- * Groups cannot be nested, so all entries returned here are pure entries, no groups.
- */
- virtual CryptoConfigEntry *entry(const QString &name) const = 0;
-};
-
-/**
- * Crypto config for one component (e.g. gpg-agent, dirmngr etc.)
- */
-class KLEO_EXPORT CryptoConfigComponent
-{
-
-public:
- virtual ~CryptoConfigComponent() {}
-
- /**
- * Return the internal name of this component
- */
- virtual QString name() const = 0;
-
- /**
- * Return the name of the icon for this component
- */
- virtual QString iconName() const = 0;
-
- /**
- * Return user-visible description of this component
- */
- virtual QString description() const = 0;
-
- /**
- * Returns the list of groups that are known about.
- *
- * @return list of group names. One of them can be "<nogroup>", which is the group where all
- * "toplevel" options (belonging to no group) are.
- */
- virtual QStringList groupList() const = 0;
-
- /**
- * @return the configuration object for a given group
- * The object is owned by CryptoConfigComponent, don't delete it.
- */
- virtual CryptoConfigGroup *group(const QString &name) const = 0;
-
-};
-
-/**
- * Main interface to crypto configuration.
- */
-class KLEO_EXPORT CryptoConfig
-{
-
-public:
- virtual ~CryptoConfig() {}
-
- /**
- * Returns the list of known components (e.g. "gpg-agent", "dirmngr" etc.).
- * Use @ref component() to retrieve more information about each one.
- * @return list of component names.
- **/
- virtual QStringList componentList() const = 0;
-
- /**
- * @return the configuration object for a given component
- * The object is owned by CryptoConfig, don't delete it.
- */
- virtual CryptoConfigComponent *component(const QString &name) const = 0;
-
- /**
- * Convenience method to get hold of a single configuration entry when
- * its component, group and name are known. This can be used to read
- * the value and/or to set a value to it.
- *
- * @return the configuration object for a single configuration entry, 0 if not found.
- * The object is owned by CryptoConfig, don't delete it.
- */
- CryptoConfigEntry *entry(const QString &componentName, const QString &groupName, const QString &entryName) const
- {
- const Kleo::CryptoConfigComponent *comp = component(componentName);
- const Kleo::CryptoConfigGroup *group = comp ? comp->group(groupName) : 0;
- return group ? group->entry(entryName) : 0;
- }
-
- /**
- * Write back changes
- *
- * @param runtime If this option is set, the changes will take effect at run-time, as
- * far as this is possible. Otherwise, they will take effect at the next
- * start of the respective backend programs.
- */
- virtual void sync(bool runtime) = 0;
-
- /**
- * Tells the CryptoConfig to discard any cached information, including
- * all components, groups and entries.
- * Call this to free some memory when you won't be using the object
- * for some time.
- * DON'T call this if you're holding pointers to components, groups or entries.
- */
- virtual void clear() = 0;
-};
-
-}
-#endif /* __cplusplus */
-#endif /* CRYPTOCONFIG_H */
diff --git a/src/kleo/decryptjob.h b/src/kleo/decryptjob.h
deleted file mode 100644
index 41d7c74..0000000
--- a/src/kleo/decryptjob.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- decryptjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004, 2007 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_DECRYPTJOB_H__
-#define __KLEO_DECRYPTJOB_H__
-
-#include "job.h"
-
-#include <boost/shared_ptr.hpp>
-
-class QByteArray;
-class QIODevice;
-
-namespace GpgME
-{
-class Error;
-class DecryptionResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous decrypters
-
- To use a DecryptJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the decryption with a
- call to start(). This call might fail, in which case the
- DecryptJob instance will have scheduled it's own destruction with
- a call to QObject::deleteLater().
-
- After result() is emitted, the DecryptJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT DecryptJob : public Job
-{
- Q_OBJECT
-protected:
- explicit DecryptJob(QObject *parent);
-public:
- ~DecryptJob();
-
- /**
- Starts the decryption operation. \a cipherText is the data to
- decrypt.
- */
- virtual KLEO_DEPRECATED_EXPORT GpgME::Error start(const QByteArray &cipherText) = 0;
-
- /*!
- \overload
-
- If \a plainText is non-null, the plaintext is written
- there. Otherwise, it will be delivered in the second argument
- of result().
-
- \throws GpgME::Exception if starting fails
- */
- virtual void start(const boost::shared_ptr<QIODevice> &cipherText, const boost::shared_ptr<QIODevice> &plainText = boost::shared_ptr<QIODevice>()) = 0;
-
- virtual GpgME::DecryptionResult exec(const QByteArray &cipherText,
- QByteArray &plainText) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::DecryptionResult &result, const QByteArray &plainText, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_DECRYPTJOB_H__
diff --git a/src/kleo/decryptverifyjob.h b/src/kleo/decryptverifyjob.h
deleted file mode 100644
index 3cd9bd3..0000000
--- a/src/kleo/decryptverifyjob.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- decryptverifyjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004, 2007 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_DECRYPTVERIFYJOB_H__
-#define __KLEO_DECRYPTVERIFYJOB_H__
-
-#include "job.h"
-
-#include <boost/shared_ptr.hpp>
-
-class QByteArray;
-class QIODevice;
-
-namespace GpgME
-{
-class Error;
-class DecryptionResult;
-class VerificationResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous combined decrypters and verifiers
-
- To use a DecryptVerifyJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the operation with a
- call to start(). This call might fail, in which case the
- DecryptVerifyJob instance will have scheduled it's own destruction with
- a call to QObject::deleteLater().
-
- After result() is emitted, the DecryptVerifyJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT DecryptVerifyJob : public Job
-{
- Q_OBJECT
-protected:
- explicit DecryptVerifyJob(QObject *parent);
-public:
- ~DecryptVerifyJob();
-
- /**
- Starts the combined decryption and verification operation.
- \a cipherText is the data to decrypt and later verify.
- */
- virtual KLEO_DEPRECATED_EXPORT GpgME::Error start(const QByteArray &cipherText) = 0;
-
- /*!
- \overload
-
- If \a plainText is non-null, the plaintext is written
- there. Otherwise, it will be delivered in the third argument
- of result().
-
- \throws GpgME::Exception if starting fails
- */
- virtual void start(const boost::shared_ptr<QIODevice> &cipherText, const boost::shared_ptr<QIODevice> &plainText = boost::shared_ptr<QIODevice>()) = 0;
-
- /** Synchronous equivalent of start() */
- virtual std::pair<GpgME::DecryptionResult, GpgME::VerificationResult>
- exec(const QByteArray &cipherText, QByteArray &plainText) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::DecryptionResult &decryptionresult,
- const GpgME::VerificationResult &verificationresult,
- const QByteArray &plainText, const QString &auditLogAsHtml = QString(),
- const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_DECRYPTVERIFYJOB_H__
diff --git a/src/kleo/deletejob.h b/src/kleo/deletejob.h
deleted file mode 100644
index 44308dc..0000000
--- a/src/kleo/deletejob.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- deletejob.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_DELETEJOB_H__
-#define __KLEO_DELETEJOB_H__
-
-#include "job.h"
-
-namespace GpgME
-{
-class Error;
-class Key;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous deleters
-
- To use a DeleteJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the delete with a call
- to start(). This call might fail, in which case the DeleteJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the DeleteJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT DeleteJob : public Job
-{
- Q_OBJECT
-protected:
- explicit DeleteJob(QObject *parent);
-public:
- ~DeleteJob();
-
- /**
- Starts the delete operation. \a key represents the key to
- delete, \a allowSecretKeyDeletion specifies if a key may also
- be deleted if the secret key part is available, too.
- */
- virtual GpgME::Error start(const GpgME::Key &key, bool allowSecretKeyDeletion = false) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_DELETEJOB_H__
diff --git a/src/kleo/downloadjob.h b/src/kleo/downloadjob.h
deleted file mode 100644
index 100c856..0000000
--- a/src/kleo/downloadjob.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- downloadjob.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_DOWNLOADJOB_H__
-#define __KLEO_DOWNLOADJOB_H__
-
-#include "job.h"
-
-#include <QtCore/QByteArray>
-
-namespace GpgME
-{
-class Error;
-}
-
-namespace boost
-{
-template <typename T> class shared_ptr;
-}
-
-class QStringList;
-class QIODevice;
-class QByteArray;
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous downloaders
-
- To use a DownloadJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the download with a call
- to start(). This call might fail, in which case the DownloadJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the DownloadJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT DownloadJob : public Job
-{
- Q_OBJECT
-protected:
- explicit DownloadJob(QObject *parent);
-public:
- ~DownloadJob();
-
- /**
- Starts the download operation. \a fingerprint is the
- fingerprint of the key to download. If \a fingerprint is empty,
- contains only whitespace or anything other than a fingerprint,
- the result is undefined.
-
- Output is written to \a keyData, if given. Otherwise, it is
- passed as the second argument of result().
- */
- virtual GpgME::Error start(const QByteArray &fingerprint,
- const boost::shared_ptr<QIODevice> &keyData) = 0;
-
- /**
- Starts the download operation. \a fingerprints is a list of
- fingerprints used to specify the list of keys downloaded. Empty
- patterns are ignored. If \a fingerprints is empty, contains
- only empty strings or anything other than fingerprints, the
- result is undefined.
- */
- virtual KLEO_DEPRECATED_EXPORT GpgME::Error start(const QStringList &fingerprints) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QByteArray &keyData, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_DOWNLOADJOB_H__
diff --git a/src/kleo/encryptjob.h b/src/kleo/encryptjob.h
deleted file mode 100644
index 75cc3b4..0000000
--- a/src/kleo/encryptjob.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- encryptjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004, 2007 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_ENCRYPTJOB_H__
-#define __KLEO_ENCRYPTJOB_H__
-
-#include "job.h"
-
-#include <boost/shared_ptr.hpp>
-
-#include <vector>
-
-#include <gpgme++/context.h>
-
-class QByteArray;
-class QIODevice;
-
-namespace GpgME
-{
-class Error;
-class Key;
-class EncryptionResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous encrypters
-
- To use a EncryptJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the encryption with a
- call to start(). This call might fail, in which case the
- EncryptJob instance will have scheduled it's own destruction with
- a call to QObject::deleteLater().
-
- After result() is emitted, the EncryptJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT EncryptJob : public Job
-{
- Q_OBJECT
-protected:
- explicit EncryptJob(QObject *parent);
-public:
- ~EncryptJob();
-
- /**
- Starts the encryption operation. \a recipients is the a list of
- keys to encrypt \a plainText to. Empty (null) keys are
- ignored. If \a recipients is empty, performs symmetric
- (passphrase) encryption.
-
- If \a alwaysTrust is true, validity checking for the keys will
- not be performed, but full validity assumed for all keys
- without further checks.
- */
- virtual KLEO_DEPRECATED_EXPORT GpgME::Error start(const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText, bool alwaysTrust = false) = 0;
-
- /*!
- \overload
-
- If \a cipherText is non-null, the ciphertext is written
- there. Otherwise, it will be delivered in the second argument of
- result().
-
- \throws GpgME::Exception if starting fails
- */
- virtual void start(const std::vector<GpgME::Key> &recipients,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &cipherText = boost::shared_ptr<QIODevice>(),
- bool alwaysTrust = false) = 0;
-
- virtual GpgME::EncryptionResult exec(const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText,
- bool alwaysTrust, QByteArray &cipherText) = 0;
-
- /*!
- This is a hack to request BASE64 output (instead of whatever
- comes out normally).
- */
- virtual void setOutputIsBase64Encoded(bool) = 0;
-
- /** Like start but with an additional argument for EncryptionFlags for
- * more flexibility. */
- virtual void start(const std::vector<GpgME::Key> &recipients,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &cipherText = boost::shared_ptr<QIODevice>(),
- const GpgME::Context::EncryptionFlags flags = GpgME::Context::None) = 0;
-
- /** Like exec but with an additional argument for EncryptionFlags for
- * more flexibility. */
- virtual GpgME::EncryptionResult exec(const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText,
- const GpgME::Context::EncryptionFlags flags, QByteArray &cipherText) = 0;
-Q_SIGNALS:
- void result(const GpgME::EncryptionResult &result, const QByteArray &cipherText, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_ENCRYPTJOB_H__
diff --git a/src/kleo/exportjob.h b/src/kleo/exportjob.h
deleted file mode 100644
index 9fd5a4d..0000000
--- a/src/kleo/exportjob.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- exportjob.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_EXPORTJOB_H__
-#define __KLEO_EXPORTJOB_H__
-
-#include "job.h"
-
-#include <QtCore/QByteArray>
-
-namespace GpgME
-{
-class Error;
-}
-
-class QStringList;
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous exporters
-
- To use a ExportJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the export with a call
- to start(). This call might fail, in which case the ExportJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the ExportJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT ExportJob : public Job
-{
- Q_OBJECT
-protected:
- explicit ExportJob(QObject *parent);
-public:
- ~ExportJob();
-
- /**
- Starts the export operation. \a patterns is a list of patterns
- used to restrict the list of keys exported. Empty patterns are
- ignored. If \a patterns is empty or contains only empty
- strings, all available keys are exported.
- */
- virtual GpgME::Error start(const QStringList &patterns) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QByteArray &keyData, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_EXPORTJOB_H__
diff --git a/src/kleo/hierarchicalkeylistjob.cpp b/src/kleo/hierarchicalkeylistjob.cpp
deleted file mode 100644
index c4ae620..0000000
--- a/src/kleo/hierarchicalkeylistjob.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- hierarchicalkeylistjob.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.
-*/
-
-#include "hierarchicalkeylistjob.h"
-#include "cryptobackend.h"
-#include "keylistjob.h"
-
-#include <KLocalizedString>
-
-#include <QStringList>
-
-#include <gpgme++/key.h>
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-
-#include <gpg-error.h>
-
-#include <iterator>
-#include <algorithm>
-
-#include <assert.h>
-
-Kleo::HierarchicalKeyListJob::HierarchicalKeyListJob(const CryptoBackend::Protocol *protocol,
- bool remote, bool includeSigs, bool validating)
- : KeyListJob(0),
- mProtocol(protocol),
- mRemote(remote),
- mIncludeSigs(includeSigs),
- mValidating(validating),
- mTruncated(false),
- mIntermediateResult(),
- mJob(0)
-{
- assert(protocol);
-}
-
-Kleo::HierarchicalKeyListJob::~HierarchicalKeyListJob()
-{
-
-}
-
-GpgME::Error Kleo::HierarchicalKeyListJob::start(const QStringList &patterns, bool secretOnly)
-{
- if (secretOnly || patterns.empty()) {
- return GpgME::Error::fromCode(GPG_ERR_UNSUPPORTED_OPERATION, GPG_ERR_SOURCE_GPGME);
- }
- qCopy(patterns.begin(), patterns.end(),
- std::inserter(mNextSet, mNextSet.begin()));
- const GpgME::Error err = startAJob();
- if (err) {
- deleteLater();
- }
- return err;
-}
-
-GpgME::KeyListResult Kleo::HierarchicalKeyListJob::exec(const QStringList &, bool,
- std::vector<GpgME::Key> &keys)
-{
- keys.clear();
- return GpgME::KeyListResult(GpgME::Error::fromCode(GPG_ERR_UNSUPPORTED_OPERATION, GPG_ERR_SOURCE_GPGME));
-}
-
-void Kleo::HierarchicalKeyListJob::slotNextKey(const GpgME::Key &key)
-{
- if (const char *chain_id = key.chainID()) {
- mNextSet.insert(QLatin1String(chain_id));
- }
- if (const char *fpr = key.primaryFingerprint())
- if (mSentSet.find(QLatin1String(fpr)) == mSentSet.end()) {
- mSentSet.insert(QLatin1String(fpr));
- Q_EMIT nextKey(key);
- }
-}
-
-void Kleo::HierarchicalKeyListJob::slotCancel()
-{
- if (mJob) {
- mJob->slotCancel();
- }
- mNextSet.clear();
-}
-
-void Kleo::HierarchicalKeyListJob::slotResult(const GpgME::KeyListResult &res)
-{
- mJob = 0;
- mIntermediateResult.mergeWith(res);
- std::set<QString> tmp;
- std::set_difference(mNextSet.begin(), mNextSet.end(),
- mScheduledSet.begin(), mScheduledSet.end(),
- std::inserter(tmp, tmp.begin()));
- mNextSet.clear();
- std::set_difference(tmp.begin(), tmp.end(),
- mSentSet.begin(), mSentSet.end(),
- std::inserter(mNextSet, mNextSet.begin()));
- if (mIntermediateResult.error() || mNextSet.empty()) {
- Q_EMIT done();
- Q_EMIT result(mIntermediateResult);
- deleteLater();
- return;
- }
- if (const GpgME::Error error = startAJob()) { // error starting the job for next keys
- mIntermediateResult.mergeWith(GpgME::KeyListResult(error));
- Q_EMIT done();
- Q_EMIT result(mIntermediateResult);
- deleteLater();
- return;
- }
-#if 0 // FIXME
- const int current = mIt - mKeys.begin();
- const int total = mKeys.size();
- Q_EMIT progress(i18nc("progress info: \"%1 of %2\"", "%1/%2", current, total), current, total);
-#endif
-}
-
-GpgME::Error Kleo::HierarchicalKeyListJob::startAJob()
-{
- if (mNextSet.empty()) {
- return GpgME::Error(0);
- }
- mJob = mProtocol->keyListJob(mRemote, mIncludeSigs, mValidating);
- assert(mJob); // FIXME: we need a way to generate errors ourselves,
- // but I don't like the dependency on gpg-error :/
-
- connect(mJob.data(), &KeyListJob::nextKey, this, &HierarchicalKeyListJob::slotNextKey);
- connect(mJob.data(), &KeyListJob::result, this, &HierarchicalKeyListJob::slotResult);
-
- QStringList patterns;
- for (std::set<QString>::const_iterator it = mNextSet.begin(); it != mNextSet.end(); ++it) {
- patterns.push_back(*it);
- }
-
- mScheduledSet.insert(mNextSet.begin(), mNextSet.end());
- mNextSet.clear();
-
- return mJob->start(patterns, false);
-}
-
-#include "moc_hierarchicalkeylistjob.cpp"
diff --git a/src/kleo/hierarchicalkeylistjob.h b/src/kleo/hierarchicalkeylistjob.h
deleted file mode 100644
index bf16eff..0000000
--- a/src/kleo/hierarchicalkeylistjob.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- hierarchicalkeylistjob.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_HIERARCHICALKEYLISTJOB_H__
-#define __KLEO_HIERARCHICALKEYLISTJOB_H__
-
-#include "kleo_export.h"
-#include "libkleo/keylistjob.h"
-#include "libkleo/cryptobackend.h"
-
-#include <gpgme++/keylistresult.h>
-
-#include <QPointer>
-
-#include <set>
-
-namespace GpgME
-{
-class Error;
-class Key;
-}
-
-namespace Kleo
-{
-class KeyListJob;
-}
-
-namespace Kleo
-{
-
-/**
- @short A convenience job that additionally fetches all available issuers.
-
- To use a HierarchicalKeyListJob, pass it a CryptoBackend
- implementation, connect the progress() and result() signals to
- suitable slots and then start the keylisting with a call to
- start(). This call might fail, in which case the
- HierarchicalKeyListJob instance will have scheduled it's own
- destruction with a call to QObject::deleteLater().
-
- After result() is emitted, the HierarchicalKeyListJob will
- schedule its own destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT HierarchicalKeyListJob : public KeyListJob
-{
- Q_OBJECT
-public:
- explicit HierarchicalKeyListJob(const CryptoBackend::Protocol *protocol,
- bool remote = false, bool includeSigs = false,
- bool validating = false);
- ~HierarchicalKeyListJob();
-
- /**
- Starts the keylist operation. \a patterns is a list of patterns
- used to restrict the list of keys returned. Empty patterns are
- ignored. \a patterns must not be empty or contain only empty
- patterns; use the normal KeyListJob for a full listing.
-
- The \a secretOnly parameter is ignored by
- HierarchicalKeyListJob and must be set to false.
- */
- GpgME::Error start(const QStringList &patterns, bool secretOnly = false) Q_DECL_OVERRIDE;
-
- GpgME::KeyListResult exec(const QStringList &patterns, bool secretOnly,
- std::vector<GpgME::Key> &keys) Q_DECL_OVERRIDE;
-
-private Q_SLOTS:
- void slotResult(const GpgME::KeyListResult &);
- void slotNextKey(const GpgME::Key &key);
- /*! \reimp from Job */
- void slotCancel() Q_DECL_OVERRIDE;
-
-private:
- GpgME::Error startAJob();
-
-private:
- const CryptoBackend::Protocol *const mProtocol;
- const bool mRemote;
- const bool mIncludeSigs;
- const bool mValidating;
- bool mTruncated;
- std::set<QString> mSentSet; // keys already sent (prevent duplicates even if the backend should return them)
- std::set<QString> mScheduledSet; // keys already scheduled (by starting a job for them)
- std::set<QString> mNextSet; // keys to schedule for the next iteraton
- GpgME::KeyListResult mIntermediateResult;
- QPointer<KeyListJob> mJob;
-};
-
-}
-
-#endif // __KLEO_HIERARCHICALKEYLISTJOB_H__
diff --git a/src/kleo/importfromkeyserverjob.h b/src/kleo/importfromkeyserverjob.h
deleted file mode 100644
index 74d7ab3..0000000
--- a/src/kleo/importfromkeyserverjob.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- importfromkeyserverjob.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_IMPORTFROMKEYSERVERJOB_H__
-#define __KLEO_IMPORTFROMKEYSERVERJOB_H__
-
-#include "abstractimportjob.h"
-
-namespace GpgME
-{
-class Key;
-class Error;
-class ImportResult;
-}
-
-#include <vector>
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous keyserver-importers
-
- To use a ImportJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the import with a call
- to start(). This call might fail, in which case the ImportJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the ImportJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT ImportFromKeyserverJob : public AbstractImportJob
-{
- Q_OBJECT
-protected:
- explicit ImportFromKeyserverJob(QObject *parent);
-public:
- ~ImportFromKeyserverJob();
-
- /**
- Starts the importing operation. \a keyData contains the data to
- import from.
- */
- virtual GpgME::Error start(const std::vector<GpgME::Key> &keys) = 0;
-
- virtual GpgME::ImportResult exec(const std::vector<GpgME::Key> &keys) = 0;
-};
-
-}
-
-#endif // __KLEO_IMPORTFROMKEYSERVERJOB_H__
diff --git a/src/kleo/importjob.h b/src/kleo/importjob.h
deleted file mode 100644
index 8b34bdb..0000000
--- a/src/kleo/importjob.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- importjob.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_IMPORTJOB_H__
-#define __KLEO_IMPORTJOB_H__
-
-#include "abstractimportjob.h"
-
-#include <QtCore/QByteArray>
-
-namespace GpgME
-{
-class Error;
-class ImportResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous importers
-
- To use a ImportJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the import with a call
- to start(). This call might fail, in which case the ImportJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the ImportJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT ImportJob : public AbstractImportJob
-{
- Q_OBJECT
-protected:
- explicit ImportJob(QObject *parent);
-public:
- ~ImportJob();
-
- /**
- Starts the importing operation. \a keyData contains the data to
- import from.
- */
- virtual GpgME::Error start(const QByteArray &keyData) = 0;
-
- virtual GpgME::ImportResult exec(const QByteArray &keyData) = 0;
-};
-
-}
-
-#endif // __KLEO_IMPORTJOB_H__
diff --git a/src/kleo/job.cpp b/src/kleo/job.cpp
deleted file mode 100644
index be4a52c..0000000
--- a/src/kleo/job.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- job.cpp
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004,2005 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.
-*/
-
-#include "job.h"
-
-#include "keylistjob.h"
-#include "listallkeysjob.h"
-#include "encryptjob.h"
-#include "decryptjob.h"
-#include "decryptverifyjob.h"
-#include "signjob.h"
-#include "signkeyjob.h"
-#include "signencryptjob.h"
-#include "verifydetachedjob.h"
-#include "verifyopaquejob.h"
-#include "keygenerationjob.h"
-#include "importjob.h"
-#include "importfromkeyserverjob.h"
-#include "exportjob.h"
-#include "changeexpiryjob.h"
-#include "changeownertrustjob.h"
-#include "changepasswdjob.h"
-#include "downloadjob.h"
-#include "deletejob.h"
-#include "refreshkeysjob.h"
-#include "adduseridjob.h"
-#include "specialjob.h"
-#include "keyformailboxjob.h"
-
-#include "libkleo_debug.h"
-
-#include <gpgme++/error.h>
-
-#include <QCoreApplication>
-#include <qdebug.h>
-
-#include <gpg-error.h>
-
-Kleo::Job::Job(QObject *parent)
- : QObject(parent)
-{
- if (QCoreApplication *app = QCoreApplication::instance()) {
- connect(app, &QCoreApplication::aboutToQuit, this, &Job::slotCancel);
- }
-}
-
-Kleo::Job::~Job()
-{
-
-}
-
-void Kleo::Job::showErrorDialog(QWidget *, const QString &) const
-{
- qCDebug(LIBKLEO_LOG) << "Kleo::Job::showErrorDialog() should be reimplemented in Kleo::Job subclasses!";
-}
-
-QString Kleo::Job::auditLogAsHtml() const
-{
- qCDebug(LIBKLEO_LOG) << "Kleo::Job::auditLogAsHtml() should be reimplemented in Kleo::Job subclasses!";
- return QString();
-}
-
-GpgME::Error Kleo::Job::auditLogError() const
-{
- qCDebug(LIBKLEO_LOG) << "Kleo::Job::auditLogError() should be reimplemented in Kleo::Job subclasses!";
- return GpgME::Error::fromCode(GPG_ERR_NOT_IMPLEMENTED);
-}
-
-bool Kleo::Job::isAuditLogSupported() const
-{
- return auditLogError().code() != GPG_ERR_NOT_IMPLEMENTED;
-}
-
-#define make_job_subclass_ext(x,y) \
- Kleo::x::x( QObject * parent ) : y( parent ) {} \
- Kleo::x::~x() {}
-
-#define make_job_subclass(x) make_job_subclass_ext(x,Job)
-
-make_job_subclass(KeyListJob)
-make_job_subclass(ListAllKeysJob)
-make_job_subclass(EncryptJob)
-make_job_subclass(DecryptJob)
-make_job_subclass(DecryptVerifyJob)
-make_job_subclass(SignJob)
-make_job_subclass(SignEncryptJob)
-make_job_subclass(SignKeyJob)
-make_job_subclass(VerifyDetachedJob)
-make_job_subclass(VerifyOpaqueJob)
-make_job_subclass(KeyGenerationJob)
-make_job_subclass(AbstractImportJob)
-make_job_subclass_ext(ImportJob, AbstractImportJob)
-make_job_subclass_ext(ImportFromKeyserverJob, AbstractImportJob)
-make_job_subclass(ExportJob)
-make_job_subclass(ChangeExpiryJob)
-make_job_subclass(ChangeOwnerTrustJob)
-make_job_subclass(ChangePasswdJob)
-make_job_subclass(DownloadJob)
-make_job_subclass(DeleteJob)
-make_job_subclass(RefreshKeysJob)
-make_job_subclass(AddUserIDJob)
-make_job_subclass(SpecialJob)
-make_job_subclass(KeyForMailboxJob)
-
-#undef make_job_subclass
-
-#include "moc_job.cpp"
-
-#include "moc_keylistjob.cpp"
-#include "moc_listallkeysjob.cpp"
-#include "moc_encryptjob.cpp"
-#include "moc_decryptjob.cpp"
-#include "moc_decryptverifyjob.cpp"
-#include "moc_signjob.cpp"
-#include "moc_signencryptjob.cpp"
-#include "moc_signkeyjob.cpp"
-#include "moc_verifydetachedjob.cpp"
-#include "moc_verifyopaquejob.cpp"
-#include "moc_keygenerationjob.cpp"
-#include "moc_abstractimportjob.cpp"
-#include "moc_importjob.cpp"
-#include "moc_importfromkeyserverjob.cpp"
-#include "moc_exportjob.cpp"
-#include "moc_changeexpiryjob.cpp"
-#include "moc_changeownertrustjob.cpp"
-#include "moc_changepasswdjob.cpp"
-#include "moc_downloadjob.cpp"
-#include "moc_deletejob.cpp"
-#include "moc_refreshkeysjob.cpp"
-#include "moc_adduseridjob.cpp"
-#include "moc_specialjob.cpp"
-#include "moc_keyformailboxjob.cpp"
diff --git a/src/kleo/job.h b/src/kleo/job.h
deleted file mode 100644
index 216dc03..0000000
--- a/src/kleo/job.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- job.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_JOB_H__
-#define __KLEO_JOB_H__
-
-#include "kleo_export.h"
-
-#include <QObject>
-#include <QString>
-
-#include <gpgme++/error.h>
-
-class QWidget;
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous crypto operations
-
- During the operation, you might receive progress updates through
- the progress() signal as they arrive, but an implementation is
- free to not send progress information. You should show a busy
- progressbar until the first progress() signal is received.
-
- The done() signal is emitted _before_ the result() signals of
- subclasses and should be used to hide and/or reset progress bars,
- not to learn of the end of the operation. Use the result()
- signals for that.
-
- To cancel the operation, simply call slotCancel(). The result()
- signal of subclasses will still be emitted, though, and will
- carry the information that the operation was canceled.
-*/
-class KLEO_EXPORT Job : public QObject
-{
- Q_OBJECT
-protected:
- explicit Job(QObject *parent);
-public:
- ~Job();
-
- virtual void showErrorDialog(QWidget *parent = Q_NULLPTR, const QString &caption = QString()) const;
-
- virtual QString auditLogAsHtml() const;
- virtual GpgME::Error auditLogError() const;
- bool isAuditLogSupported() const;
-
-public Q_SLOTS:
- virtual void slotCancel() = 0;
-
-Q_SIGNALS:
- void progress(const QString &what, int current, int total);
- void done();
-};
-
-}
-
-#endif // __KLEO_JOB_H__
diff --git a/src/kleo/keyfiltermanager.cpp b/src/kleo/keyfiltermanager.cpp
index 8962c65..0305745 100644
--- a/src/kleo/keyfiltermanager.cpp
+++ b/src/kleo/keyfiltermanager.cpp
@@ -34,13 +34,13 @@
#include "kconfigbasedkeyfilter.h"
#include "defaultkeyfilter.h"
-#include "cryptobackendfactory.h"
#include "stl_util.h"
#include "libkleo_debug.h"
#include <kconfig.h>
#include <kconfiggroup.h>
+#include <KSharedConfig>
#include <KLocalizedString>
#include <QIcon>
#include <QDebug>
@@ -233,13 +233,12 @@ void KeyFilterManager::reload()
d->clear();
d->filters = defaultFilters();
+ KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("libkleopatrarc"));
- if (KConfig *config = CryptoBackendFactory::instance()->configObject()) {
- const QStringList groups = config->groupList().filter(QRegularExpression(QStringLiteral("^Key Filter #\\d+$")));
- for (QStringList::const_iterator it = groups.begin(); it != groups.end(); ++it) {
- const KConfigGroup cfg(config, *it);
- d->filters.push_back(shared_ptr<KeyFilter>(new KConfigBasedKeyFilter(cfg)));
- }
+ const QStringList groups = config->groupList().filter(QRegularExpression(QStringLiteral("^Key Filter #\\d+$")));
+ for (QStringList::const_iterator it = groups.begin(); it != groups.end(); ++it) {
+ const KConfigGroup cfg(config, *it);
+ d->filters.push_back(shared_ptr<KeyFilter>(new KConfigBasedKeyFilter(cfg)));
}
std::stable_sort(d->filters.begin(), d->filters.end(), ByDecreasingSpecificity());
qCDebug(LIBKLEO_LOG) << "final filter count is" << d->filters.size();
diff --git a/src/kleo/keygenerationjob.h b/src/kleo/keygenerationjob.h
deleted file mode 100644
index 2593582..0000000
--- a/src/kleo/keygenerationjob.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- keygenerationjob.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_KEYGENERATIONJOB_H__
-#define __KLEO_KEYGENERATIONJOB_H__
-
-#include "job.h"
-
-#include <QtCore/QByteArray>
-
-#include <kleo_export.h>
-
-namespace GpgME
-{
-class Error;
-class KeyGenerationResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous key generation
-
- To use a KeyGenerationJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the key generation with
- a call to start(). This call might fail, in which case the
- KeyGenerationJob instance will have scheduled it's own
- destruction with a call to QObject::deleteLater().
-
- After result() is emitted, the KeyGenerationJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT KeyGenerationJob : public Job
-{
- Q_OBJECT
-protected:
- explicit KeyGenerationJob(QObject *parent);
-public:
- ~KeyGenerationJob();
-
- /**
- Starts the key generation operation. \a parameters is a
- backend-specific string containing the parameters of the key to
- create (length, capabilities, etc).
- */
- virtual GpgME::Error start(const QString &parameters) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::KeyGenerationResult &result, const QByteArray &pubKeyData, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_KEYGENERATIONJOB_H__
diff --git a/src/kleo/keylistjob.h b/src/kleo/keylistjob.h
deleted file mode 100644
index 4bfa816..0000000
--- a/src/kleo/keylistjob.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- keylistjob.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_KEYLISTJOB_H__
-#define __KLEO_KEYLISTJOB_H__
-
-#include "job.h"
-
-#include <gpgme++/key.h>
-
-#include <vector>
-
-namespace GpgME
-{
-class Error;
-class KeyListResult;
-}
-
-class QStringList;
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous key listers
-
- To use a KeyListJob, first obtain an instance from the
- CryptoBackend implementation, connect the nextKey(), progress()
- and result() signals to suitable slots and then start the key
- listing with a call to start(). This call might fail, in which
- case the KeylistJob instance will have schedules it's own
- destruction with a call to QObject::deleteLater().
-
- During keylisting, you will receive new key objects through the
- nextKey() signal as they arrive. After result() is emitted, the
- KeyListJob will schedule it's own destruction by calling
- QObject::deleteLater().
-*/
-class KLEO_EXPORT KeyListJob : public Job
-{
- Q_OBJECT
-protected:
- explicit KeyListJob(QObject *parent);
-
-public:
- ~KeyListJob();
-
- /**
- Starts the keylist operation. \a pattern is a list of patterns
- used to restrict the list of keys returned. Empty patterns are
- ignored. If \a pattern is empty or contains only empty strings,
- all keys are returned (however, the backend is free to truncate
- the result and should do so; when this happens, it will be
- reported by the reult object).
-
- If \a secretOnly is true, only keys for which the secret key is
- also available are returned. Use this if you need to select a
- key for signing.
- */
- virtual GpgME::Error start(const QStringList &patterns, bool secretOnly = false) = 0;
-
- virtual GpgME::KeyListResult exec(const QStringList &patterns, bool secretOnly, std::vector<GpgME::Key> &keys) = 0;
-
-Q_SIGNALS:
- void nextKey(const GpgME::Key &key);
- void result(const GpgME::KeyListResult &result, const std::vector<GpgME::Key> &keys = std::vector<GpgME::Key>(), const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_KEYLISTJOB_H__
diff --git a/src/kleo/listallkeysjob.h b/src/kleo/listallkeysjob.h
deleted file mode 100644
index a1831b1..0000000
--- a/src/kleo/listallkeysjob.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- listallkeysjob.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_LISTALLKEYSJOB_H__
-#define __KLEO_LISTALLKEYSJOB_H__
-
-#include "job.h"
-
-#include <gpgme++/key.h>
-
-#include <vector>
-
-namespace GpgME
-{
-class Error;
-class KeyListResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronously listing all keys
-
- To use a ListAllKeysJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress()
- and result() signals to suitable slots and then start the key
- listing with a call to start(). This call might fail, in which
- case the ListAllKeysJob instance will have schedules it's own
- destruction with a call to QObject::deleteLater().
-
- After result() is emitted, the ListAllKeysJob will schedule it's
- own destruction by calling QObject::deleteLater().
-
- This is potentially much faster than a KeyListJob with empty
- pattern.
-*/
-class KLEO_EXPORT ListAllKeysJob : public Job
-{
- Q_OBJECT
-protected:
- explicit ListAllKeysJob(QObject *parent);
-
-public:
- ~ListAllKeysJob();
-
- /**
- Starts the listallkeys operation. In general, all keys are
- returned (however, the backend is free to truncate the result
- and should do so; when this happens, it will be reported by the
- result object).
-
- If \a mergeKeys is true, secret keys are merged into public
- keys.
- */
- virtual GpgME::Error start(bool mergeKeys = false) = 0;
-
- /**
- Synchronous version of start().
- */
- virtual GpgME::KeyListResult exec(std::vector<GpgME::Key> &pub, std::vector<GpgME::Key> &sec, bool mergeKeys = false) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::KeyListResult &result, const std::vector<GpgME::Key> &pub = std::vector<GpgME::Key>(), const std::vector<GpgME::Key> &sec = std::vector<GpgME::Key>(), const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_LISTALLKEYSJOB_H__
diff --git a/src/kleo/multideletejob.cpp b/src/kleo/multideletejob.cpp
deleted file mode 100644
index 4531e1c..0000000
--- a/src/kleo/multideletejob.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- multideletejob.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.
-*/
-
-#include "multideletejob.h"
-#include "cryptobackend.h"
-#include "deletejob.h"
-
-#include <KLocalizedString>
-
-#include <gpgme++/key.h>
-#include <gpgme++/context.h>
-#include <gpgme++/data.h>
-
-#include <iterator>
-
-#include <assert.h>
-
-Kleo::MultiDeleteJob::MultiDeleteJob(const CryptoBackend::Protocol *protocol)
- : Job(0),
- mProtocol(protocol),
- mJob(0)
-{
- assert(protocol);
-}
-
-Kleo::MultiDeleteJob::~MultiDeleteJob()
-{
-
-}
-
-GpgME::Error Kleo::MultiDeleteJob::start(const std::vector<GpgME::Key> &keys, bool allowSecretKeyDeletion)
-{
- mKeys = keys;
- mAllowSecretKeyDeletion = allowSecretKeyDeletion;
- mIt = mKeys.begin();
-
- const GpgME::Error err = startAJob();
-
- if (err) {
- deleteLater();
- }
- return err;
-}
-
-void Kleo::MultiDeleteJob::slotCancel()
-{
- if (mJob) {
- mJob->slotCancel();
- }
- mIt = mKeys.end();
-}
-
-void Kleo::MultiDeleteJob::slotResult(const GpgME::Error &err)
-{
- mJob = 0;
- GpgME::Error error = err;
- if (error || // error in last op
- mIt == mKeys.end() || // (shouldn't happen)
- ++mIt == mKeys.end() || // was the last key
- (error = startAJob())) { // error starting the job for the new key
- Q_EMIT done();
- Q_EMIT result(error, error && mIt != mKeys.end() ? *mIt : GpgME::Key::null);
- deleteLater();
- return;
- }
-
- const int current = mIt - mKeys.begin();
- const int total = mKeys.size();
- Q_EMIT progress(i18nc("progress info: \"%1 of %2\"", "%1/%2", current, total), current, total);
-}
-
-GpgME::Error Kleo::MultiDeleteJob::startAJob()
-{
- if (mIt == mKeys.end()) {
- return GpgME::Error(0);
- }
- mJob = mProtocol->deleteJob();
- assert(mJob); // FIXME: we need a way to generate errors ourselves,
- // but I don't like the dependency on gpg-error :/
-
- connect(mJob.data(), &DeleteJob::result, this, &MultiDeleteJob::slotResult);
-
- return mJob->start(*mIt, mAllowSecretKeyDeletion);
-}
-
diff --git a/src/kleo/multideletejob.h b/src/kleo/multideletejob.h
deleted file mode 100644
index e7f41c1..0000000
--- a/src/kleo/multideletejob.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- multideletejob.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_MULTIDELETEJOB_H__
-#define __KLEO_MULTIDELETEJOB_H__
-
-#include "kleo_export.h"
-#include "libkleo/job.h"
-#include "libkleo/cryptobackend.h"
-
-#include <QPointer>
-
-#include <vector>
-
-namespace GpgME
-{
-class Error;
-class Key;
-}
-
-namespace Kleo
-{
-class DeleteJob;
-}
-
-namespace Kleo
-{
-
-/**
- @short A convenience class bundling together multiple DeleteJobs.
-
- To use a MultiDeleteJob, pass it a CryptoBackend implementation,
- connect the progress() and result() signals to suitable slots and
- then start the delete with a call to start(). This call might
- fail, in which case the MultiDeleteJob instance will have scheduled
- it's own destruction with a call to QObject::deleteLater().
-
- After result() is emitted, the MultiDeleteJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT MultiDeleteJob : public Job
-{
- Q_OBJECT
-public:
- explicit MultiDeleteJob(const CryptoBackend::Protocol *protocol);
- ~MultiDeleteJob();
-
- /**
- Starts the delete operation. \a keys is the list of keys to
- delete, \a allowSecretKeyDeletion specifies if a key may also
- be deleted if the secret key part is available, too.
- */
- GpgME::Error start(const std::vector<GpgME::Key> &keys, bool allowSecretKeyDeletion = false);
-
- /*! \reimp from Job */
- void slotCancel() Q_DECL_OVERRIDE;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const GpgME::Key &errorKey);
-
-private Q_SLOTS:
- void slotResult(const GpgME::Error &);
-
-private:
- GpgME::Error startAJob();
-
-private:
- const CryptoBackend::Protocol *mProtocol;
- QPointer<DeleteJob> mJob;
- std::vector<GpgME::Key> mKeys;
- std::vector<GpgME::Key>::const_iterator mIt;
- bool mAllowSecretKeyDeletion;
-};
-
-}
-
-#endif // __KLEO_MULTIDELETEJOB_H__
diff --git a/src/kleo/refreshkeysjob.h b/src/kleo/refreshkeysjob.h
deleted file mode 100644
index 2b8add5..0000000
--- a/src/kleo/refreshkeysjob.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- refreshkeysjob.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_REFRESHKEYSJOB_H__
-#define __KLEO_REFRESHKEYSJOB_H__
-
-#include "job.h"
-
-#include <vector>
-
-namespace GpgME
-{
-class Error;
-class Key;
-}
-
-class QStringList;
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous key refreshers.
-
- To use a RefreshKeysJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the key refresh with a
- call to start(). This call might fail, in which case the
- RefreshKeysJob instance will have scheduled its own destruction
- with a call to QObject::deleteLater().
-
- After result() is emitted, the KeyListJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT RefreshKeysJob : public Job
-{
- Q_OBJECT
-protected:
- explicit RefreshKeysJob(QObject *parent);
-public:
- ~RefreshKeysJob();
-
- /**
- Starts the keylist operation. \a pattern is a list of patterns
- used to restrict the list of keys returned. Empty patterns are
- ignored. If \a pattern is empty or contains only empty strings,
- all keys are returned (however, the backend is free to truncate
- the result and should do so; when this happens, it will be
- reported by the reult object).
-
- If \a secretOnly is true, only keys for which the secret key is
- also available are returned. Use this if you need to select a
- key for signing.
- */
- virtual GpgME::Error start(const QStringList &patterns) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &error);
-};
-
-}
-
-#endif // __KLEO_REFRESHKEYSJOB_H__
diff --git a/src/kleo/signencryptjob.h b/src/kleo/signencryptjob.h
deleted file mode 100644
index 57e9b75..0000000
--- a/src/kleo/signencryptjob.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- signencryptjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004, 2007 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_SIGNENCRYPTJOB_H__
-#define __KLEO_SIGNENCRYPTJOB_H__
-
-#include "job.h"
-
-#include <gpgme++/global.h>
-#include <gpgme++/context.h>
-
-#include <boost/shared_ptr.hpp>
-
-#include <vector>
-#include <utility>
-
-class QByteArray;
-class QIODevice;
-
-namespace GpgME
-{
-class Error;
-class Key;
-class SigningResult;
-class EncryptionResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous combined signing and encrypting
-
- To use a SignEncryptJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the operation with a
- call to start(). This call might fail, in which case the
- SignEncryptJob instance will have scheduled it's own destruction
- with a call to QObject::deleteLater().
-
- After result() is emitted, the SignEncryptJob will schedule it's
- own destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT SignEncryptJob : public Job
-{
- Q_OBJECT
-protected:
- explicit SignEncryptJob(QObject *parent);
-public:
- ~SignEncryptJob();
-
- /**
- Starts the combined signing and encrypting operation. \a signers
- is the list of keys to sign \a plainText with. \a recipients is
- a list of keys to encrypt the signed \a plainText to. In both
- lists, empty (null) keys are ignored.
-
- If \a alwaysTrust is true, validity checking for the
- \em recipient keys will not be performed, but full validity
- assumed for all \em recipient keys without further checks.
- */
- virtual KLEO_DEPRECATED_EXPORT GpgME::Error start(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText,
- bool alwaysTrust = false) = 0;
-
- /*!
- \overload
-
- If \a cipherText is non-null, the ciphertext is written
- there. Otherwise, it will be delivered in the third argument of
- result().
-
- \throws GpgME::Exception if starting fails
- */
- virtual void start(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &cipherText = boost::shared_ptr<QIODevice>(),
- bool alwaysTrust = false) = 0;
-
- virtual std::pair<GpgME::SigningResult, GpgME::EncryptionResult>
- exec(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText,
- bool alwaysTrust, QByteArray &cipherText) = 0;
-
- /*!
- This is a hack to request BASE64 output (instead of whatever
- comes out normally).
- */
- virtual void setOutputIsBase64Encoded(bool) = 0;
-
- /** Like start but with an additional argument for EncryptionFlags for
- * more flexibility. */
- virtual void start(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &cipherText = boost::shared_ptr<QIODevice>(),
- const GpgME::Context::EncryptionFlags flags = GpgME::Context::None) = 0;
-
- /** Like exec but with an additional argument for EncryptionFlags for
- * more flexibility. */
- virtual std::pair<GpgME::SigningResult, GpgME::EncryptionResult>
- exec(const std::vector<GpgME::Key> &signers,
- const std::vector<GpgME::Key> &recipients,
- const QByteArray &plainText,
- const GpgME::Context::EncryptionFlags flags, QByteArray &cipherText) = 0;
-Q_SIGNALS:
- void result(const GpgME::SigningResult &signingresult,
- const GpgME::EncryptionResult &encryptionresult,
- const QByteArray &cipherText, const QString &auditLogAsHtml = QString(),
- const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_SIGNENCRYPTJOB_H__
diff --git a/src/kleo/signjob.h b/src/kleo/signjob.h
deleted file mode 100644
index 0ceb404..0000000
--- a/src/kleo/signjob.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- signjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004, 2007 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_SIGNJOB_H__
-#define __KLEO_SIGNJOB_H__
-
-#include "job.h"
-
-#include <gpgme++/global.h>
-
-#include <boost/shared_ptr.hpp>
-
-#include <vector>
-
-class QByteArray;
-class QIODevice;
-
-namespace GpgME
-{
-class Error;
-class Key;
-class SigningResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous signing
-
- To use a SignJob, first obtain an instance from the CryptoBackend
- implementation, connect the progress() and result() signals to
- suitable slots and then start the signing with a call to
- start(). This call might fail, in which case the SignJob instance
- will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the SignJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT SignJob : public Job
-{
- Q_OBJECT
-protected:
- explicit SignJob(QObject *parent);
-public:
- ~SignJob();
-
- /**
- Starts the signing operation. \a signers is the list of keys to
- sign \a plainText with. Empty (null) keys are ignored.
- */
- virtual KLEO_DEPRECATED_EXPORT GpgME::Error start(const std::vector<GpgME::Key> &signers,
- const QByteArray &plainText,
- GpgME::SignatureMode mode) = 0;
-
- /*!
- \overload
-
- If \a signature is non-null the signature is written
- there. Otherwise, it will be delivered in the second argument of
- result().
-
- \throws GpgME::Exception if starting fails
- */
- virtual void start(const std::vector<GpgME::Key> &signers,
- const boost::shared_ptr<QIODevice> &plainText,
- const boost::shared_ptr<QIODevice> &signature,
- GpgME::SignatureMode mode) = 0;
-
- virtual GpgME::SigningResult exec(const std::vector<GpgME::Key> &signers,
- const QByteArray &plainText,
- GpgME::SignatureMode mode,
- QByteArray &signature) = 0;
-
- /*!
- This is a hack to request BASE64 output (instead of whatever
- comes out normally).
- */
- virtual void setOutputIsBase64Encoded(bool) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::SigningResult &result, const QByteArray &signature, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_SIGNJOB_H__
diff --git a/src/kleo/signkeyjob.h b/src/kleo/signkeyjob.h
deleted file mode 100644
index c1ff264..0000000
--- a/src/kleo/signkeyjob.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- signkeyjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2008 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_SIGNKEYJOB_H__
-#define __KLEO_SIGNKEYJOB_H__
-
-#include "job.h"
-
-#include <vector>
-
-namespace GpgME
-{
-class Error;
-class Key;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class to sign keys asynchronously
-
- To use a SignKeyJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the job with a call
- to start(). This call might fail, in which case the ChangeExpiryJob
- instance will have scheduled it's own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the SignKeyJob will schedule it's own
- destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT SignKeyJob : public Job
-{
- Q_OBJECT
-protected:
- explicit SignKeyJob(QObject *parent);
-public:
- ~SignKeyJob();
-
- /**
- Starts the key signing operation. \a key is the key to sign.
- @param keyToSign the key to be signed
- @param idsToSign the user IDs to sign
- @param signingKey the secret key to use for signing
- @param option the signing mode, either local or exportable
- */
- virtual GpgME::Error start(const GpgME::Key &keyToSign) = 0;
-
- /**
- * If explicitly specified, only the listed user IDs will be signed. Otherwise all user IDs
- * are signed.
- * @param list of user ID indexes (of the key to be signed).
- */
- virtual void setUserIDsToSign(const std::vector<unsigned int> &idsToSign) = 0;
-
- /**
- * sets the check level
- * @param the check level, ranges from 0 (no claim) and 3 (extensively checked),
- * default is 0
- */
- virtual void setCheckLevel(unsigned int checkLevel) = 0;
-
- /**
- * sets whether the signature should be exportable, or local only.
- * default is local.
- */
- virtual void setExportable(bool exportable) = 0;
-
- /**
- * sets an alternate signing key
- */
- virtual void setSigningKey(const GpgME::Key &key) = 0;
-
- /**
- * if set, the created signature won't be revocable. By default signatures
- * can be revoked.
- */
- virtual void setNonRevocable(bool nonRevocable) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_SIGNKEYJOB_H__
diff --git a/src/kleo/specialjob.h b/src/kleo/specialjob.h
deleted file mode 100644
index 16b1772..0000000
--- a/src/kleo/specialjob.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- specialjob.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_SPECIALJOB_H__
-#define __KLEO_SPECIALJOB_H__
-
-#include "job.h"
-
-namespace GpgME
-{
-class Error;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for protocol-specific jobs
-
- To use a SpecialJob, first obtain an instance from the
- CryptoBackend implementation, connect progress() and result()
- signals to suitable slots and then start the job with a call to
- start(). This call might fail, in which case the SpecialJob
- instance will have schedules its own destruction with a call to
- QObject::deleteLater().
-
- After result() is emitted, the SpecialJob will schedule its own
- destruction by calling QObject::deleteLater().
-
- Parameters are set using the Qt property system. More general, or
- constructor parameters are given in the call to
- Kleo::CryptoBackend::Protocol::specialJob().
-
- The result is made available through the result signal, and
- through the read-only result property, the latter of which needs
- to be defined in each SpecialJob subclass.
-*/
-class KLEO_EXPORT SpecialJob : public Job
-{
- Q_OBJECT
-protected:
- explicit SpecialJob(QObject *parent);
-
-public:
- ~SpecialJob();
-
- /**
- Starts the special operation.
- */
- virtual GpgME::Error start() = 0;
-
- virtual GpgME::Error exec() = 0;
-
-Q_SIGNALS:
- void result(const GpgME::Error &result, const QVariant &data);
-};
-
-}
-
-#endif // __KLEO_SPECIALJOB_H__
diff --git a/src/kleo/verifydetachedjob.h b/src/kleo/verifydetachedjob.h
deleted file mode 100644
index 46582af..0000000
--- a/src/kleo/verifydetachedjob.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- verifydetachedjob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004, 2007 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_VERIFYDETACHEDJOB_H__
-#define __KLEO_VERIFYDETACHEDJOB_H__
-
-#include "job.h"
-
-#include <boost/shared_ptr.hpp>
-
-class QByteArray;
-class QIODevice;
-
-namespace GpgME
-{
-class Error;
-class VerificationResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous verification of detached signatures
-
- To use a VerifyDetachedJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the verification with a
- call to start(). This call might fail, in which case the
- VerifyDetachedJob instance will have scheduled it's own
- destruction with a call to QObject::deleteLater().
-
- After result() is emitted, the VerifyDetachedJob will schedule
- it's own destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT VerifyDetachedJob : public Job
-{
- Q_OBJECT
-protected:
- explicit VerifyDetachedJob(QObject *parent);
-public:
- ~VerifyDetachedJob();
-
- /**
- Starts the verification operation. \a signature contains the
- signature data, while \a signedData contains the data over
- which the signature was made.
- */
- virtual KLEO_DEPRECATED_EXPORT GpgME::Error start(const QByteArray &signature,
- const QByteArray &signedData) = 0;
-
- /*!
- \overload
-
- \throws GpgME::Exception if starting fails.
- */
- virtual void start(const boost::shared_ptr<QIODevice> &signature, const boost::shared_ptr<QIODevice> &signedData) = 0;
-
- virtual GpgME::VerificationResult exec(const QByteArray &signature,
- const QByteArray &signedData) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::VerificationResult &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_VERIFYDETACHEDJOB_H__
diff --git a/src/kleo/verifyopaquejob.h b/src/kleo/verifyopaquejob.h
deleted file mode 100644
index 4cfebec..0000000
--- a/src/kleo/verifyopaquejob.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- verifyopaquejob.h
-
- This file is part of libkleopatra, the KDE keymanagement library
- Copyright (c) 2004, 2007 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_VERIFYOPAQUEJOB_H__
-#define __KLEO_VERIFYOPAQUEJOB_H__
-
-#include "job.h"
-
-#include <boost/shared_ptr.hpp>
-
-class QByteArray;
-class QIODevice;
-
-namespace GpgME
-{
-class Error;
-class VerificationResult;
-}
-
-namespace Kleo
-{
-
-/**
- @short An abstract base class for asynchronous verification of opaque signatures
-
- To use a VerifyOpaqueJob, first obtain an instance from the
- CryptoBackend implementation, connect the progress() and result()
- signals to suitable slots and then start the verification with a
- call to start(). This call might fail, in which case the
- VerifyOpaqueJob instance will have scheduled it's own
- destruction with a call to QObject::deleteLater().
-
- After result() is emitted, the VerifyOpaqueJob will schedule
- it's own destruction by calling QObject::deleteLater().
-*/
-class KLEO_EXPORT VerifyOpaqueJob : public Job
-{
- Q_OBJECT
-protected:
- explicit VerifyOpaqueJob(QObject *parent);
-public:
- ~VerifyOpaqueJob();
-
- /**
- Starts the verification operation. \a signature contains the
- signature data, while \a signedData contains the data over
- which the signature was made.
- */
- virtual KLEO_DEPRECATED_EXPORT GpgME::Error start(const QByteArray &signedData) = 0;
-
- /*!
- \overload
-
- If \a plainText is non-null, the plaintext is written
- there. Otherwise, it will be delivered in the second argument
- of result().
-
- \throws GpgME::Exception if starting fails
- */
- virtual void start(const boost::shared_ptr<QIODevice> &signedData, const boost::shared_ptr<QIODevice> &plainText = boost::shared_ptr<QIODevice>()) = 0;
-
- /** Synchronous version of @ref start */
- virtual GpgME::VerificationResult exec(const QByteArray &signedData, QByteArray &plainText) = 0;
-
-Q_SIGNALS:
- void result(const GpgME::VerificationResult &result, const QByteArray &plainText, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
-};
-
-}
-
-#endif // __KLEO_VERIFYOPAQUEJOB_H__
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index d08ddc4..06f474c 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -10,7 +10,6 @@ endmacro()
add_kleo_test(test_kdhorizontalline.cpp)
add_kleo_test(test_jobs.cpp)
-add_kleo_test(test_gnupgprocessbase.cpp)
add_kleo_test(test_cryptoconfig.cpp)
add_kleo_test(test_keyselectiondialog.cpp)
add_kleo_test(test_keygen.cpp)
diff --git a/src/tests/test_cryptoconfig.cpp b/src/tests/test_cryptoconfig.cpp
index 0569338..587115f 100644
--- a/src/tests/test_cryptoconfig.cpp
+++ b/src/tests/test_cryptoconfig.cpp
@@ -29,13 +29,13 @@
your version.
*/
-#include "backends/qgpgme/qgpgmecryptoconfig.h"
-#include "backends/qgpgme/qgpgmenewcryptoconfig.h"
+#include <qgpgme/qgpgmenewcryptoconfig.h>
#include <QCoreApplication>
#include <iostream>
using namespace std;
+using namespace QGpgME;
#include <gpgme++/global.h>
#include <gpgme++/error.h>
@@ -50,20 +50,10 @@ int main(int argc, char **argv)
return 1;
}
- const bool newCryptoConfig = argc == 2 && qstrcmp(argv[1], "--new") == 0;
- if (newCryptoConfig) {
- argc = 1; // hide from KDE
- }
-
QCoreApplication::setApplicationName(QStringLiteral("test_cryptoconfig"));
QCoreApplication app(argc, argv);
- Kleo::CryptoConfig *config = 0;
- if (newCryptoConfig) {
- config = new QGpgMENewCryptoConfig;
- } else {
- config = new QGpgMECryptoConfig;
- }
+ QGpgME::CryptoConfig *config = new QGpgMENewCryptoConfig;
// Dynamic querying of the options
cout << "Components:" << endl;
@@ -71,51 +61,51 @@ int main(int argc, char **argv)
for (QStringList::Iterator compit = components.begin(); compit != components.end(); ++compit) {
cout << "Component " << (*compit).toLocal8Bit().constData() << ":" << endl;
- const Kleo::CryptoConfigComponent *comp = config->component(*compit);
+ const QGpgME::CryptoConfigComponent *comp = config->component(*compit);
assert(comp);
QStringList groups = comp->groupList();
for (QStringList::Iterator groupit = groups.begin(); groupit != groups.end(); ++groupit) {
- const Kleo::CryptoConfigGroup *group = comp->group(*groupit);
+ const QGpgME::CryptoConfigGroup *group = comp->group(*groupit);
assert(group);
cout << " Group " << (*groupit).toLocal8Bit().constData() << ": descr=\"" << group->description().toLocal8Bit().constData() << "\""
<< " level=" << group->level() << endl;
QStringList entries = group->entryList();
for (QStringList::Iterator entryit = entries.begin(); entryit != entries.end(); ++entryit) {
- const Kleo::CryptoConfigEntry *entry = group->entry(*entryit);
+ const QGpgME::CryptoConfigEntry *entry = group->entry(*entryit);
assert(entry);
cout << " Entry " << (*entryit).toLocal8Bit().constData() << ":"
<< " descr=\"" << entry->description().toLocal8Bit().constData() << "\""
<< " " << (entry->isSet() ? "is set" : "is not set");
if (!entry->isList())
switch (entry->argType()) {
- case Kleo::CryptoConfigEntry::ArgType_None:
+ case QGpgME::CryptoConfigEntry::ArgType_None:
break;
- case Kleo::CryptoConfigEntry::ArgType_Int:
+ case QGpgME::CryptoConfigEntry::ArgType_Int:
cout << " int value=" << entry->intValue();
break;
- case Kleo::CryptoConfigEntry::ArgType_UInt:
+ case QGpgME::CryptoConfigEntry::ArgType_UInt:
cout << " uint value=" << entry->uintValue();
break;
- case Kleo::CryptoConfigEntry::ArgType_LDAPURL:
- case Kleo::CryptoConfigEntry::ArgType_Path:
+ case QGpgME::CryptoConfigEntry::ArgType_LDAPURL:
+ case QGpgME::CryptoConfigEntry::ArgType_Path:
// fallthrough
- case Kleo::CryptoConfigEntry::ArgType_DirPath:
+ case QGpgME::CryptoConfigEntry::ArgType_DirPath:
// fallthrough
- case Kleo::CryptoConfigEntry::ArgType_String:
+ case QGpgME::CryptoConfigEntry::ArgType_String:
cout << " string value=" << entry->stringValue().toLocal8Bit().constData();
break;
- case Kleo::CryptoConfigEntry::NumArgType:
+ case QGpgME::CryptoConfigEntry::NumArgType:
// just metadata and should never actually occur in the switch
break;
}
else { // lists
switch (entry->argType()) {
- case Kleo::CryptoConfigEntry::ArgType_None: {
+ case QGpgME::CryptoConfigEntry::ArgType_None: {
cout << " set " << entry->numberOfTimesSet() << " times";
break;
}
- case Kleo::CryptoConfigEntry::ArgType_Int: {
+ case QGpgME::CryptoConfigEntry::ArgType_Int: {
// (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this assert is wrong:
// assert( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
std::vector<int> lst = entry->intValueList();
@@ -126,7 +116,7 @@ int main(int argc, char **argv)
cout << " int values=" << str.toLocal8Bit().constData();
break;
}
- case Kleo::CryptoConfigEntry::ArgType_UInt: {
+ case QGpgME::CryptoConfigEntry::ArgType_UInt: {
// (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this assert is wrong:
// assert( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
std::vector<uint> lst = entry->uintValueList();
@@ -137,7 +127,7 @@ int main(int argc, char **argv)
cout << " uint values=" << str.toLocal8Bit().constData();
break;
}
- case Kleo::CryptoConfigEntry::ArgType_LDAPURL: {
+ case QGpgME::CryptoConfigEntry::ArgType_LDAPURL: {
// (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this assert is wrong:
// assert( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
QList<QUrl> urls = entry->urlValueList();
@@ -148,14 +138,14 @@ int main(int argc, char **argv)
cout << endl;
}
// fallthrough
- case Kleo::CryptoConfigEntry::ArgType_Path:
+ case QGpgME::CryptoConfigEntry::ArgType_Path:
// fallthrough
- case Kleo::CryptoConfigEntry::ArgType_DirPath:
+ case QGpgME::CryptoConfigEntry::ArgType_DirPath:
// fallthrough
- case Kleo::CryptoConfigEntry::ArgType_String:
+ case QGpgME::CryptoConfigEntry::ArgType_String:
// fallthrough string value lists were removed from
// gpgconf in 2008
- case Kleo::CryptoConfigEntry::NumArgType:
+ case QGpgME::CryptoConfigEntry::NumArgType:
// just metadata and should never actually occur in the switch
break;
}
@@ -170,9 +160,9 @@ int main(int argc, char **argv)
// Static querying of a single boolean option
static const char s_groupName[] = "Monitor";
static const char s_entryName[] = "quiet";
- Kleo::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
+ QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
if (entry) {
- assert(entry->argType() == Kleo::CryptoConfigEntry::ArgType_None);
+ assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_None);
bool val = entry->boolValue();
cout << "quiet option initially: " << (val ? "is set" : "is not set") << endl;
@@ -184,9 +174,9 @@ int main(int argc, char **argv)
config->clear();
// Check new value
- Kleo::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
+ QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
assert(entry);
- assert(entry->argType() == Kleo::CryptoConfigEntry::ArgType_None);
+ assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_None);
cout << "quiet option now: " << (val ? "is set" : "is not set") << endl;
assert(entry->boolValue() == !val);
@@ -220,9 +210,9 @@ int main(int argc, char **argv)
// Static querying and setting of a single int option
static const char s_groupName[] = "LDAP";
static const char s_entryName[] = "ldaptimeout";
- Kleo::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
+ QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
if (entry) {
- assert(entry->argType() == Kleo::CryptoConfigEntry::ArgType_UInt);
+ assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_UInt);
uint val = entry->uintValue();
cout << "LDAP timeout initially: " << val << " seconds." << endl;
@@ -237,9 +227,9 @@ int main(int argc, char **argv)
config->clear();
// Check new value
- Kleo::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
+ QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
assert(entry);
- assert(entry->argType() == Kleo::CryptoConfigEntry::ArgType_UInt);
+ assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_UInt);
cout << "LDAP timeout now: " << entry->uintValue() << " seconds." << endl;
assert(entry->uintValue() == 101);
@@ -273,9 +263,9 @@ int main(int argc, char **argv)
// Static querying and setting of a single string option
static const char s_groupName[] = "Debug";
static const char s_entryName[] = "log-file";
- Kleo::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
+ QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
if (entry) {
- assert(entry->argType() == Kleo::CryptoConfigEntry::ArgType_Path);
+ assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_Path);
QString val = entry->stringValue();
cout << "Log-file initially: " << val.toLocal8Bit().constData() << endl;
@@ -291,9 +281,9 @@ int main(int argc, char **argv)
config->clear();
// Check new value
- Kleo::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
+ QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
assert(entry);
- assert(entry->argType() == Kleo::CryptoConfigEntry::ArgType_Path);
+ assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_Path);
cout << "Log-file now: " << entry->stringValue().toLocal8Bit().constData() << endl;
assert(entry->stringValue() == QStringLiteral("/tmp/test:%e5ä")); // (or even with %e5 decoded)
@@ -321,9 +311,9 @@ int main(int argc, char **argv)
// Static querying and setting of the LDAP URL list option
static const char s_groupName[] = "LDAP";
static const char s_entryName[] = "LDAP Server";
- Kleo::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
+ QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
if (entry) {
- assert(entry->argType() == Kleo::CryptoConfigEntry::ArgType_LDAPURL);
+ assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_LDAPURL);
assert(entry->isList());
QList<QUrl> val = entry->urlValueList();
cout << "URL list initially: ";
@@ -351,9 +341,9 @@ int main(int argc, char **argv)
config->clear();
// Check new value
- Kleo::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
+ QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
assert(entry);
- assert(entry->argType() == Kleo::CryptoConfigEntry::ArgType_LDAPURL);
+ assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_LDAPURL);
assert(entry->isList());
// Get QUrl form
QList<QUrl> newlst = entry->urlValueList();
diff --git a/src/tests/test_gnupgprocessbase.cpp b/src/tests/test_gnupgprocessbase.cpp
deleted file mode 100644
index 571d98e..0000000
--- a/src/tests/test_gnupgprocessbase.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- gnupgviewer.cpp
-
- This file is part of libkleopatra's test suite.
- 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.
-*/
-
-#include "gnupgviewer.h"
-
-#include "backends/qgpgme/gnupgprocessbase.h"
-
-#include <KAboutData>
-
-#include <kmessagebox.h>
-#include <QDebug>
-
-#include <QStringList>
-#include <QApplication>
-#include <KLocalizedString>
-#include <QCommandLineParser>
-
-GnuPGViewer::GnuPGViewer(QWidget *parent)
- : QTextEdit(parent), mProcess(0)
-{
- setAcceptRichText(false);
- document()->setMaximumBlockCount(10000);
-}
-
-GnuPGViewer::~GnuPGViewer()
-{
- if (mProcess) {
- mProcess->kill();
- }
-}
-
-void GnuPGViewer::setProcess(Kleo::GnuPGProcessBase *process)
-{
- if (!process) {
- return;
- }
- mProcess = process;
- connect(mProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
- SLOT(slotProcessExited(int,QProcess::ExitStatus)));
- connect(mProcess, &QProcess::readyReadStandardOutput,
- this, &GnuPGViewer::slotStdout);
- connect(mProcess, &QProcess::readyReadStandardError,
- this, &GnuPGViewer::slotStderr);
- connect(mProcess, &Kleo::GnuPGProcessBase::status,
- this, &GnuPGViewer::slotStatus);
-}
-
-static QStringList split(const QString &newLine, QString &old)
-{
- // when done right, this would need to use QTextCodec...
- const QString str = old + newLine;
- QStringList l = str.split('\n');
- if (l.empty()) {
- return l;
- }
- if (str.endsWith('\n')) {
- old.clear();
- } else {
- old = l.back();
- l.pop_back();
- }
- return l;
-}
-
-static QString escape(QString str)
-{
- return str.replace('&', QLatin1String("&amp")).replace('<', QLatin1String("&lt;")).replace('>', QLatin1String("&gt;"));
-}
-
-void GnuPGViewer::slotStdout()
-{
- QString line = mProcess-> readAllStandardOutput();
- const QStringList l = split(line, mLastStdout);
- for (QStringList::const_iterator it = l.begin(); it != l.end(); ++it) {
- append("stdout: " + escape(*it));
- }
-}
-
-void GnuPGViewer::slotStderr()
-{
- QString line = mProcess->readAllStandardError();
- const QStringList l = split(line, mLastStderr);
- for (QStringList::const_iterator it = l.begin(); it != l.end(); ++it) {
- append("<b>stderr: " + escape(*it) + "</b>");
- }
-}
-void GnuPGViewer::slotStatus(Kleo::GnuPGProcessBase *, const QString &type, const QStringList &args)
-{
- append("<b><font color=\"red\">status: " + escape(type + ' ' + args.join(QStringLiteral(" "))) + "</font></b>");
-}
-void GnuPGViewer::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus)
-{
- if (exitStatus == QProcess::NormalExit) {
- append(QStringLiteral("<b>Process exit: return code %1</b>").arg(exitCode));
- } else {
- append(QStringLiteral("<b>Process exit: killed</b>"));
- }
-}
-
-int main(int argc, char **argv)
-{
- if (argc < 3) {
- qDebug() << "Need at least two arguments";
- return 1;
- }
- QApplication app(argc, argv);
- KAboutData aboutData(QStringLiteral("test_gnupgprocessbase"), i18n("GnuPGProcessBase Test"), QStringLiteral("0.1"));
- QCommandLineParser parser;
- KAboutData::setApplicationData(aboutData);
- parser.addVersionOption();
- parser.addHelpOption();
- aboutData.setupCommandLine(&parser);
- parser.process(app);
- aboutData.processCommandLine(&parser);
-
- Kleo::GnuPGProcessBase gpg;
- for (int i = 1; i < argc; ++i) {
- gpg << argv[i];
- }
-
- gpg.setUseStatusFD(true);
-
- GnuPGViewer *gv = new GnuPGViewer();
- gv->setProcess(&gpg);
-
- gv->show();
-
- gpg.setOutputChannelMode(KProcess::SeparateChannels);
- gpg.start();
-
- return app.exec();
-}
-
-#include "moc_gnupgviewer.cpp"
diff --git a/src/tests/test_jobs.cpp b/src/tests/test_jobs.cpp
index a2ce6f8..2f0cddc 100644
--- a/src/tests/test_jobs.cpp
+++ b/src/tests/test_jobs.cpp
@@ -29,9 +29,9 @@
your version.
*/
-#include "libkleo/cryptobackendfactory.h"
-#include "libkleo/signjob.h"
-#include "libkleo/keylistjob.h"
+#include <qgpgme/qgpgmebackend.h>
+#include <qgpgme/signjob.h>
+#include <qgpgme/keylistjob.h>
#include <gpgme++/key.h>
#include <gpgme++/signingresult.h>
@@ -50,14 +50,14 @@ static const char *protocol = 0;
static void testSign()
{
- const Kleo::CryptoBackend::Protocol *proto = !strcmp(protocol, "openpgp") ? Kleo::CryptoBackendFactory::instance()->openpgp() : Kleo::CryptoBackendFactory::instance()->smime();
+ const QGpgME::Protocol *proto = !strcmp(protocol, "openpgp") ? QGpgME::openpgp() : QGpgME::smime();
assert(proto);
qDebug() << "Using protocol" << proto->name();
std::vector<GpgME::Key> signingKeys;
- std::unique_ptr<Kleo::KeyListJob> listJob(proto->keyListJob(false, false, true)); // use validating keylisting
+ std::unique_ptr<QGpgME::KeyListJob> listJob(proto->keyListJob(false, false, true)); // use validating keylisting
if (listJob.get()) {
// ##### Adjust this to your own identity
listJob->exec(QStringList(QStringLiteral("kloecker@kde.org")), true /*secret*/, signingKeys);
@@ -66,7 +66,7 @@ static void testSign()
assert(0); // job failed
}
- Kleo::SignJob *job = proto->signJob(true, true);
+ QGpgME::SignJob *job = proto->signJob(true, true);
QByteArray plainText = "Hallo Leute\n"; // like gpgme's t-sign.c
qDebug() << "plainText=" << plainText;
diff --git a/src/tests/test_keygen.cpp b/src/tests/test_keygen.cpp
index 40e2e96..b44d62b 100644
--- a/src/tests/test_keygen.cpp
+++ b/src/tests/test_keygen.cpp
@@ -31,9 +31,9 @@
#include "test_keygen.h"
-#include "libkleo/keylistjob.h"
-#include "libkleo/keygenerationjob.h"
-#include "libkleo/cryptobackendfactory.h"
+#include <qgpgme/keylistjob.h>
+#include <qgpgme/keygenerationjob.h>
+#include <qgpgme/qgpgmebackend.h>
#include "ui/progressdialog.h"
#include <gpgme++/keygenerationresult.h>
@@ -120,18 +120,18 @@ void KeyGenerator::slotStartKeyGeneration()
}
params += "</GnupgKeyParms>\n";
- const Kleo::CryptoBackend::Protocol *proto = 0;
+ const QGpgME::Protocol *proto = 0;
if (protocol) {
- proto = !strcmp(protocol, "openpgp") ? Kleo::CryptoBackendFactory::instance()->openpgp() : Kleo::CryptoBackendFactory::instance()->smime();
+ proto = !strcmp(protocol, "openpgp") ? QGpgME::openpgp() : QGpgME::smime();
}
if (!proto) {
- proto = Kleo::CryptoBackendFactory::instance()->smime();
+ proto = QGpgME::smime();
}
assert(proto);
qDebug() << "Using protocol" << proto->name();
- Kleo::KeyGenerationJob *job = proto->keyGenerationJob();
+ QGpgME::KeyGenerationJob *job = proto->keyGenerationJob();
assert(job);
connect(job, SIGNAL(result(GpgME::KeyGenerationResult,QByteArray)),
diff --git a/src/tests/test_keylister.cpp b/src/tests/test_keylister.cpp
index fdc9dc6..561bac0 100644
--- a/src/tests/test_keylister.cpp
+++ b/src/tests/test_keylister.cpp
@@ -31,8 +31,8 @@
#include "test_keylister.h"
-#include "libkleo/keylistjob.h"
-#include "libkleo/cryptobackendfactory.h"
+#include <qgpgme/keylistjob.h>
+#include <qgpgme/qgpgmebackend.h>
#include <gpgme++/keylistresult.h>
#include <gpgme++/key.h>
@@ -123,7 +123,7 @@ void CertListView::slotResult(const GpgME::KeyListResult &result)
void CertListView::slotStart()
{
qDebug() << "CertListView::slotStart()";
- Kleo::KeyListJob *job = Kleo::CryptoBackendFactory::instance()->smime()->keyListJob(false);
+ QGpgME::KeyListJob *job = QGpgME::smime()->keyListJob(false);
assert(job);
QObject::connect(job, SIGNAL(nextKey(GpgME::Key)),
this, SLOT(slotAddKey(GpgME::Key)));
diff --git a/src/ui/cryptoconfigdialog.cpp b/src/ui/cryptoconfigdialog.cpp
index 343718a..bb34984 100644
--- a/src/ui/cryptoconfigdialog.cpp
+++ b/src/ui/cryptoconfigdialog.cpp
@@ -38,7 +38,7 @@
#include <KGuiItem>
#include <QVBoxLayout>
-Kleo::CryptoConfigDialog::CryptoConfigDialog(Kleo::CryptoConfig *config, QWidget *parent)
+Kleo::CryptoConfigDialog::CryptoConfigDialog(QGpgME::CryptoConfig *config, QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18n("Configure GnuPG Backend"));
diff --git a/src/ui/cryptoconfigdialog.h b/src/ui/cryptoconfigdialog.h
index 52485f6..e43197d 100644
--- a/src/ui/cryptoconfigdialog.h
+++ b/src/ui/cryptoconfigdialog.h
@@ -35,10 +35,15 @@
#include "kleo_export.h"
#include <QDialog>
class QDialogButtonBox;
+
+namespace QGpgME
+{
+class CryptoConfig;
+} // namespace QGpgME
+
namespace Kleo
{
-class CryptoConfig;
class CryptoConfigModule;
/**
@@ -48,7 +53,7 @@ class KLEO_EXPORT CryptoConfigDialog : public QDialog
{
Q_OBJECT
public:
- explicit CryptoConfigDialog(Kleo::CryptoConfig *config, QWidget *parent = Q_NULLPTR);
+ explicit CryptoConfigDialog(QGpgME::CryptoConfig *config, QWidget *parent = Q_NULLPTR);
protected Q_SLOTS:
void slotOk();
diff --git a/src/ui/cryptoconfigmodule.cpp b/src/ui/cryptoconfigmodule.cpp
index 351ccfe..0d57143 100644
--- a/src/ui/cryptoconfigmodule.cpp
+++ b/src/ui/cryptoconfigmodule.cpp
@@ -35,7 +35,7 @@
#include "kdhorizontalline.h"
#include "filenamerequester.h"
-#include "libkleo/cryptoconfig.h"
+#include <qgpgme/cryptoconfig.h>
#include <klineedit.h>
#include <KLocalizedString>
@@ -87,7 +87,7 @@ inline QIcon loadIcon(const QString &s)
return QIcon::fromTheme(ss.replace(QRegExp(QLatin1String("[^a-zA-Z0-9_]")), QStringLiteral("-")));
}
-static unsigned int num_components_with_options(const Kleo::CryptoConfig *config)
+static unsigned int num_components_with_options(const QGpgME::CryptoConfig *config)
{
if (!config) {
return 0;
@@ -95,14 +95,14 @@ static unsigned int num_components_with_options(const Kleo::CryptoConfig *config
const QStringList components = config->componentList();
unsigned int result = 0;
for (QStringList::const_iterator it = components.begin(); it != components.end(); ++it)
- if (const Kleo::CryptoConfigComponent *const comp = config->component(*it))
+ if (const QGpgME::CryptoConfigComponent *const comp = config->component(*it))
if (!comp->groupList().empty()) {
++result;
}
return result;
}
-static KPageView::FaceType determineJanusFace(const Kleo::CryptoConfig *config, Kleo::CryptoConfigModule::Layout layout, bool &ok)
+static KPageView::FaceType determineJanusFace(const QGpgME::CryptoConfig *config, Kleo::CryptoConfigModule::Layout layout, bool &ok)
{
ok = true;
if (num_components_with_options(config) < 2) {
@@ -115,13 +115,13 @@ static KPageView::FaceType determineJanusFace(const Kleo::CryptoConfig *config,
/* else */ KPageView::List;
}
-Kleo::CryptoConfigModule::CryptoConfigModule(Kleo::CryptoConfig *config, QWidget *parent)
+Kleo::CryptoConfigModule::CryptoConfigModule(QGpgME::CryptoConfig *config, QWidget *parent)
: KPageWidget(parent), mConfig(config)
{
init(IconListLayout);
}
-Kleo::CryptoConfigModule::CryptoConfigModule(Kleo::CryptoConfig *config, Layout layout, QWidget *parent)
+Kleo::CryptoConfigModule::CryptoConfigModule(QGpgME::CryptoConfig *config, Layout layout, QWidget *parent)
: KPageWidget(parent), mConfig(config)
{
init(layout);
@@ -133,7 +133,7 @@ void Kleo::CryptoConfigModule::init(Layout layout)
l->setMargin(0);
}
- Kleo::CryptoConfig *const config = mConfig;
+ QGpgME::CryptoConfig *const config = mConfig;
bool configOK = false;
const KPageView::FaceType type = determineJanusFace(config, layout, configOK);
@@ -162,7 +162,7 @@ void Kleo::CryptoConfigModule::init(Layout layout)
const QStringList components = config->componentList();
for (QStringList::const_iterator it = components.begin(); it != components.end(); ++it) {
//qCDebug(KLEO_UI_LOG) <<"Component" << (*it).toLocal8Bit() <<":";
- Kleo::CryptoConfigComponent *comp = config->component(*it);
+ QGpgME::CryptoConfigComponent *comp = config->component(*it);
Q_ASSERT(comp);
if (comp->groupList().empty()) {
continue;
@@ -268,7 +268,7 @@ void Kleo::CryptoConfigModule::cancel()
////
Kleo::CryptoConfigComponentGUI::CryptoConfigComponentGUI(
- CryptoConfigModule *module, Kleo::CryptoConfigComponent *component,
+ CryptoConfigModule *module, QGpgME::CryptoConfigComponent *component,
QWidget *parent)
: QWidget(parent),
mComponent(component)
@@ -278,7 +278,7 @@ Kleo::CryptoConfigComponentGUI::CryptoConfigComponentGUI(
if (groups.size() > 1) {
glay->setColumnMinimumWidth(0, KDHorizontalLine::indentHint());
for (QStringList::const_iterator it = groups.begin(), end = groups.end(); it != end; ++it) {
- Kleo::CryptoConfigGroup *group = mComponent->group(*it);
+ QGpgME::CryptoConfigGroup *group = mComponent->group(*it);
Q_ASSERT(group);
if (!group) {
continue;
@@ -326,16 +326,16 @@ void Kleo::CryptoConfigComponentGUI::defaults()
////
Kleo::CryptoConfigGroupGUI::CryptoConfigGroupGUI(
- CryptoConfigModule *module, Kleo::CryptoConfigGroup *group,
+ CryptoConfigModule *module, QGpgME::CryptoConfigGroup *group,
QGridLayout *glay, QWidget *widget)
: QObject(module), mGroup(group)
{
const int startRow = glay->rowCount();
const QStringList entries = mGroup->entryList();
for (QStringList::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) {
- Kleo::CryptoConfigEntry *entry = group->entry(*it);
+ QGpgME::CryptoConfigEntry *entry = group->entry(*it);
Q_ASSERT(entry);
- if (entry->level() > CryptoConfigEntry::Level_Advanced) {
+ if (entry->level() > QGpgME::CryptoConfigEntry::Level_Advanced) {
qCDebug(KLEO_UI_LOG) << "entry" << *it << "too advanced, skipping";
continue;
}
@@ -392,12 +392,12 @@ void Kleo::CryptoConfigGroupGUI::defaults()
////
-typedef CryptoConfigEntryGUI *(*constructor)(CryptoConfigModule *, Kleo::CryptoConfigEntry *, const QString &, QGridLayout *, QWidget *);
+typedef CryptoConfigEntryGUI *(*constructor)(CryptoConfigModule *, QGpgME::CryptoConfigEntry *, const QString &, QGridLayout *, QWidget *);
namespace
{
template <typename T_Widget>
-CryptoConfigEntryGUI *_create(CryptoConfigModule *m, Kleo::CryptoConfigEntry *e, const QString &n, QGridLayout *l, QWidget *p)
+CryptoConfigEntryGUI *_create(CryptoConfigModule *m, QGpgME::CryptoConfigEntry *e, const QString &n, QGridLayout *l, QWidget *p)
{
return new T_Widget(m, e, n, l, p);
}
@@ -412,7 +412,7 @@ static const struct WidgetsByEntryName {
};
static const unsigned int numWidgetsByEntryName = sizeof widgetsByEntryName / sizeof * widgetsByEntryName;
-static const constructor listWidgets[CryptoConfigEntry::NumArgType] = {
+static const constructor listWidgets[QGpgME::CryptoConfigEntry::NumArgType] = {
// None: A list of options with no arguments (e.g. -v -v -v) is shown as a spinbox
&_create<CryptoConfigEntrySpinBox>,
0, // String
@@ -425,7 +425,7 @@ static const constructor listWidgets[CryptoConfigEntry::NumArgType] = {
0, // DirPath
};
-static const constructor scalarWidgets[CryptoConfigEntry::NumArgType] = {
+static const constructor scalarWidgets[QGpgME::CryptoConfigEntry::NumArgType] = {
&_create<CryptoConfigEntryCheckBox>, // None
&_create<CryptoConfigEntryLineEdit>, // String
&_create<CryptoConfigEntrySpinBox>, // Int
@@ -436,7 +436,7 @@ static const constructor scalarWidgets[CryptoConfigEntry::NumArgType] = {
&_create<CryptoConfigEntryDirPath>, // DirPath
};
-CryptoConfigEntryGUI *Kleo::CryptoConfigEntryGUIFactory::createEntryGUI(CryptoConfigModule *module, Kleo::CryptoConfigEntry *entry, const QString &entryName, QGridLayout *glay, QWidget *widget)
+CryptoConfigEntryGUI *Kleo::CryptoConfigEntryGUIFactory::createEntryGUI(CryptoConfigModule *module, QGpgME::CryptoConfigEntry *entry, const QString &entryName, QGridLayout *glay, QWidget *widget)
{
assert(entry);
@@ -449,7 +449,7 @@ CryptoConfigEntryGUI *Kleo::CryptoConfigEntryGUIFactory::createEntryGUI(CryptoCo
// none found, so look up by type:
const unsigned int argType = entry->argType();
- assert(argType < CryptoConfigEntry::NumArgType);
+ assert(argType < QGpgME::CryptoConfigEntry::NumArgType);
if (entry->isList())
if (const constructor create = listWidgets[argType]) {
return create(module, entry, entryName, glay, widget);
@@ -469,7 +469,7 @@ CryptoConfigEntryGUI *Kleo::CryptoConfigEntryGUIFactory::createEntryGUI(CryptoCo
Kleo::CryptoConfigEntryGUI::CryptoConfigEntryGUI(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName)
: QObject(module), mEntry(entry), mName(entryName), mChanged(false)
{
@@ -504,7 +504,7 @@ void Kleo::CryptoConfigEntryGUI::resetToDefault()
Kleo::CryptoConfigEntryLineEdit::CryptoConfigEntryLineEdit(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry, const QString &entryName,
+ QGpgME::CryptoConfigEntry *entry, const QString &entryName,
QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName)
{
@@ -546,7 +546,7 @@ static const struct {
};
static const unsigned int numDebugLevels = sizeof debugLevels / sizeof * debugLevels;
-Kleo::CryptoConfigEntryDebugLevel::CryptoConfigEntryDebugLevel(CryptoConfigModule *module, Kleo::CryptoConfigEntry *entry,
+Kleo::CryptoConfigEntryDebugLevel::CryptoConfigEntryDebugLevel(CryptoConfigModule *module, QGpgME::CryptoConfigEntry *entry,
const QString &entryName, QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName),
mComboBox(new QComboBox(widget))
@@ -595,7 +595,7 @@ void Kleo::CryptoConfigEntryDebugLevel::doLoad()
Kleo::CryptoConfigEntryPath::CryptoConfigEntryPath(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry, const QString &entryName,
+ QGpgME::CryptoConfigEntry *entry, const QString &entryName,
QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName),
mFileNameRequester(0)
@@ -639,7 +639,7 @@ void Kleo::CryptoConfigEntryPath::doLoad()
Kleo::CryptoConfigEntryDirPath::CryptoConfigEntryDirPath(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry, const QString &entryName,
+ QGpgME::CryptoConfigEntry *entry, const QString &entryName,
QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName),
mFileNameRequester(0)
@@ -679,17 +679,17 @@ void Kleo::CryptoConfigEntryDirPath::doLoad()
Kleo::CryptoConfigEntrySpinBox::CryptoConfigEntrySpinBox(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry, const QString &entryName,
+ QGpgME::CryptoConfigEntry *entry, const QString &entryName,
QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName)
{
- if (entry->argType() == Kleo::CryptoConfigEntry::ArgType_None && entry->isList()) {
+ if (entry->argType() == QGpgME::CryptoConfigEntry::ArgType_None && entry->isList()) {
mKind = ListOfNone;
- } else if (entry->argType() == Kleo::CryptoConfigEntry::ArgType_UInt) {
+ } else if (entry->argType() == QGpgME::CryptoConfigEntry::ArgType_UInt) {
mKind = UInt;
} else {
- Q_ASSERT(entry->argType() == Kleo::CryptoConfigEntry::ArgType_Int);
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_Int);
mKind = Int;
}
@@ -748,7 +748,7 @@ void Kleo::CryptoConfigEntrySpinBox::doLoad()
Kleo::CryptoConfigEntryCheckBox::CryptoConfigEntryCheckBox(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry, const QString &entryName,
+ QGpgME::CryptoConfigEntry *entry, const QString &entryName,
QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName)
{
@@ -775,7 +775,7 @@ void Kleo::CryptoConfigEntryCheckBox::doLoad()
Kleo::CryptoConfigEntryLDAPURL::CryptoConfigEntryLDAPURL(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName)
@@ -865,7 +865,7 @@ void Kleo::CryptoConfigEntryLDAPURL::setURLList(const QList<QUrl> &urlList)
Kleo::CryptoConfigEntryKeyserver::CryptoConfigEntryKeyserver(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *glay, QWidget *widget)
: CryptoConfigEntryGUI(module, entry, entryName)
diff --git a/src/ui/cryptoconfigmodule.h b/src/ui/cryptoconfigmodule.h
index 67c74a8..d2622cc 100644
--- a/src/ui/cryptoconfigmodule.h
+++ b/src/ui/cryptoconfigmodule.h
@@ -36,12 +36,14 @@
#include <kpagedialog.h>
#include <QList>
-namespace Kleo
+namespace QGpgME
{
-
class CryptoConfig;
-class CryptoConfigComponentGUI;
+} // namespace QGpgME
+namespace Kleo
+{
+class CryptoConfigComponentGUI;
struct ParsedKeyserver {
QString url;
QVector< QPair<QString, QString> > options;
@@ -59,8 +61,8 @@ class KLEO_EXPORT CryptoConfigModule : public KPageWidget
Q_OBJECT
public:
enum Layout { TabbedLayout, IconListLayout, LinearizedLayout };
- explicit CryptoConfigModule(Kleo::CryptoConfig *config, QWidget *parent = Q_NULLPTR);
- explicit CryptoConfigModule(Kleo::CryptoConfig *config, Layout layout, QWidget *parent = Q_NULLPTR);
+ explicit CryptoConfigModule(QGpgME::CryptoConfig *config, QWidget *parent = Q_NULLPTR);
+ explicit CryptoConfigModule(QGpgME::CryptoConfig *config, Layout layout, QWidget *parent = Q_NULLPTR);
bool hasError() const;
@@ -76,7 +78,7 @@ private:
void init(Layout layout);
private:
- Kleo::CryptoConfig *mConfig;
+ QGpgME::CryptoConfig *mConfig;
QList<CryptoConfigComponentGUI *> mComponentGUIs;
};
diff --git a/src/ui/cryptoconfigmodule_p.h b/src/ui/cryptoconfigmodule_p.h
index bab40a3..f73f3d1 100644
--- a/src/ui/cryptoconfigmodule_p.h
+++ b/src/ui/cryptoconfigmodule_p.h
@@ -50,13 +50,16 @@ namespace Kleo
class FileNameRequester;
}
-namespace Kleo
+namespace QGpgME
{
-
class CryptoConfig;
class CryptoConfigComponent;
class CryptoConfigGroup;
class CryptoConfigEntry;
+} // namespace QGpgME
+
+namespace Kleo
+{
class CryptoConfigComponentGUI;
class CryptoConfigGroupGUI;
class CryptoConfigEntryGUI;
@@ -69,7 +72,7 @@ class CryptoConfigComponentGUI : public QWidget
Q_OBJECT
public:
- CryptoConfigComponentGUI(CryptoConfigModule *module, Kleo::CryptoConfigComponent *component,
+ CryptoConfigComponentGUI(CryptoConfigModule *module, QGpgME::CryptoConfigComponent *component,
QWidget *parent = Q_NULLPTR);
bool save();
@@ -77,7 +80,7 @@ public:
void defaults();
private:
- Kleo::CryptoConfigComponent *mComponent;
+ QGpgME::CryptoConfigComponent *mComponent;
QList<CryptoConfigGroupGUI *> mGroupGUIs;
};
@@ -89,7 +92,7 @@ class CryptoConfigGroupGUI : public QObject
Q_OBJECT
public:
- CryptoConfigGroupGUI(CryptoConfigModule *module, Kleo::CryptoConfigGroup *group,
+ CryptoConfigGroupGUI(CryptoConfigModule *module, QGpgME::CryptoConfigGroup *group,
QGridLayout *layout, QWidget *parent = Q_NULLPTR);
bool save();
@@ -97,7 +100,7 @@ public:
void defaults();
private:
- Kleo::CryptoConfigGroup *mGroup;
+ QGpgME::CryptoConfigGroup *mGroup;
QList<CryptoConfigEntryGUI *> mEntryGUIs;
};
@@ -110,7 +113,7 @@ class CryptoConfigEntryGUIFactory
public:
static CryptoConfigEntryGUI *createEntryGUI(
CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry, const QString &entryName,
+ QGpgME::CryptoConfigEntry *entry, const QString &entryName,
QGridLayout *layout, QWidget *widget);
};
@@ -122,7 +125,7 @@ class CryptoConfigEntryGUI : public QObject
Q_OBJECT
public:
CryptoConfigEntryGUI(CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName);
void load()
@@ -158,7 +161,7 @@ protected:
virtual void doSave() = 0;
virtual void doLoad() = 0;
- Kleo::CryptoConfigEntry *mEntry;
+ QGpgME::CryptoConfigEntry *mEntry;
QString mName;
bool mChanged;
};
@@ -172,7 +175,7 @@ class CryptoConfigEntryLineEdit : public CryptoConfigEntryGUI
public:
CryptoConfigEntryLineEdit(CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *layout,
QWidget *parent = Q_NULLPTR);
@@ -190,7 +193,7 @@ class CryptoConfigEntryDebugLevel : public CryptoConfigEntryGUI
{
Q_OBJECT
public:
- CryptoConfigEntryDebugLevel(CryptoConfigModule *module, Kleo::CryptoConfigEntry *entry,
+ CryptoConfigEntryDebugLevel(CryptoConfigModule *module, QGpgME::CryptoConfigEntry *entry,
const QString &entryName, QGridLayout *layout, QWidget *parent = Q_NULLPTR);
void doSave() Q_DECL_OVERRIDE;
@@ -208,7 +211,7 @@ class CryptoConfigEntryPath : public CryptoConfigEntryGUI
public:
CryptoConfigEntryPath(CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *layout,
QWidget *parent = Q_NULLPTR);
@@ -228,7 +231,7 @@ class CryptoConfigEntryDirPath : public CryptoConfigEntryGUI
public:
CryptoConfigEntryDirPath(CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *layout,
QWidget *parent = Q_NULLPTR);
@@ -248,7 +251,7 @@ class CryptoConfigEntrySpinBox : public CryptoConfigEntryGUI
public:
CryptoConfigEntrySpinBox(CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *layout,
QWidget *parent = Q_NULLPTR);
@@ -268,7 +271,7 @@ class CryptoConfigEntryCheckBox : public CryptoConfigEntryGUI
public:
CryptoConfigEntryCheckBox(CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *layout,
QWidget *parent = Q_NULLPTR);
@@ -287,7 +290,7 @@ class CryptoConfigEntryLDAPURL : public CryptoConfigEntryGUI
public:
CryptoConfigEntryLDAPURL(CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *layout,
QWidget *parent = Q_NULLPTR);
@@ -311,7 +314,7 @@ class CryptoConfigEntryKeyserver : public CryptoConfigEntryGUI
public:
CryptoConfigEntryKeyserver(CryptoConfigModule *module,
- Kleo::CryptoConfigEntry *entry,
+ QGpgME::CryptoConfigEntry *entry,
const QString &entryName,
QGridLayout *layout,
QWidget *parent = Q_NULLPTR);
diff --git a/src/ui/keyapprovaldialog.cpp b/src/ui/keyapprovaldialog.cpp
index 1d08bb0..d700b6c 100644
--- a/src/ui/keyapprovaldialog.cpp
+++ b/src/ui/keyapprovaldialog.cpp
@@ -38,7 +38,6 @@
#include "keyrequester.h"
-#include "libkleo/cryptobackend.h"
#include <qpushbutton.h>
#include <KLocalizedString>
#include <kseparator.h>
@@ -52,6 +51,7 @@
#include <QGridLayout>
#include <gpgme++/key.h>
+#include <qgpgme/qgpgmebackend.h>
#include <assert.h>
#include <QApplication>
diff --git a/src/ui/keyrequester.cpp b/src/ui/keyrequester.cpp
index c08e820..1c02e93 100644
--- a/src/ui/keyrequester.cpp
+++ b/src/ui/keyrequester.cpp
@@ -49,13 +49,13 @@
#include "keyselectiondialog.h"
-#include "libkleo/keylistjob.h"
#include "libkleo/dn.h"
-#include "libkleo/cryptobackendfactory.h"
// gpgme++
#include <gpgme++/key.h>
#include <gpgme++/keylistresult.h>
+#include <qgpgme/qgpgmebackend.h>
+#include <qgpgme/keylistjob.h>
// KDE
#include <KLocalizedString>
@@ -74,6 +74,8 @@
#include <assert.h>
+using namespace QGpgME;
+
Kleo::KeyRequester::KeyRequester(unsigned int allowedKeys, bool multipleKeys,
QWidget *parent)
: QWidget(parent),
@@ -415,10 +417,10 @@ void Kleo::KeyRequester::setAllowedKeys(unsigned int keyUsage)
mSMIMEBackend = 0;
if (mKeyUsage & KeySelectionDialog::OpenPGPKeys) {
- mOpenPGPBackend = Kleo::CryptoBackendFactory::instance()->openpgp();
+ mOpenPGPBackend = openpgp();
}
if (mKeyUsage & KeySelectionDialog::SMIMEKeys) {
- mSMIMEBackend = Kleo::CryptoBackendFactory::instance()->smime();
+ mSMIMEBackend = smime();
}
if (mOpenPGPBackend && !mSMIMEBackend) {
diff --git a/src/ui/keyrequester.h b/src/ui/keyrequester.h
index a94219b..e03b44f 100644
--- a/src/ui/keyrequester.h
+++ b/src/ui/keyrequester.h
@@ -49,7 +49,8 @@
#define __KLEO_UI_KEYREQUESTER_H__
#include "kleo_export.h"
-#include "libkleo/cryptobackend.h"
+
+#include <qgpgme/qgpgmebackend.h>
#include <QWidget>
#include <QLabel>
@@ -142,8 +143,8 @@ private Q_SLOTS:
void slotEraseButtonClicked();
private:
- const CryptoBackend::Protocol *mOpenPGPBackend;
- const CryptoBackend::Protocol *mSMIMEBackend;
+ const QGpgME::Protocol *mOpenPGPBackend;
+ const QGpgME::Protocol *mSMIMEBackend;
QLabel *mLabel;
QPushButton *mEraseButton;
QPushButton *mDialogButton;
diff --git a/src/ui/keyselectiondialog.cpp b/src/ui/keyselectiondialog.cpp
index 1625538..6805d5a 100644
--- a/src/ui/keyselectiondialog.cpp
+++ b/src/ui/keyselectiondialog.cpp
@@ -40,8 +40,6 @@
#include "progressdialog.h"
#include "libkleo/dn.h"
-#include "libkleo/keylistjob.h"
-#include "libkleo/cryptobackendfactory.h"
#include <QDebug>
#include "kleo_ui_debug.h"
@@ -49,6 +47,9 @@
#include <gpgme++/key.h>
#include <gpgme++/keylistresult.h>
+#include <qgpgme/keylistjob.h>
+#include <qgpgme/qgpgmebackend.h>
+
// KDE
#include <KLocalizedString>
#include <kwindowsystem.h>
@@ -425,10 +426,10 @@ void Kleo::KeySelectionDialog::init(bool rememberChoice, bool extendedSelection,
buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);
if (mKeyUsage & OpenPGPKeys) {
- mOpenPGPBackend = Kleo::CryptoBackendFactory::instance()->openpgp();
+ mOpenPGPBackend = QGpgME::openpgp();
}
if (mKeyUsage & SMIMEKeys) {
- mSMIMEBackend = Kleo::CryptoBackendFactory::instance()->smime();
+ mSMIMEBackend = QGpgME::smime();
}
mCheckSelectionTimer = new QTimer(this);
@@ -679,21 +680,21 @@ struct ExtractFingerprint {
};
}
-void Kleo::KeySelectionDialog::startKeyListJobForBackend(const CryptoBackend::Protocol *backend, const std::vector<GpgME::Key> &keys, bool validate)
+void Kleo::KeySelectionDialog::startKeyListJobForBackend(const QGpgME::Protocol *backend, const std::vector<GpgME::Key> &keys, bool validate)
{
assert(backend);
- KeyListJob *job = backend->keyListJob(false, false, validate); // local, w/o sigs, validation as givem
+ QGpgME::KeyListJob *job = backend->keyListJob(false, false, validate); // local, w/o sigs, validation as givem
if (!job) {
return;
}
- connect(job, &KeyListJob::result,
+ connect(job, &QGpgME::KeyListJob::result,
this, &KeySelectionDialog::slotKeyListResult);
if (validate)
- connect(job, &KeyListJob::nextKey,
+ connect(job, &QGpgME::KeyListJob::nextKey,
mKeyListView, &KeyListView::slotRefreshKey);
else
- connect(job, &KeyListJob::nextKey,
+ connect(job, &QGpgME::KeyListJob::nextKey,
mKeyListView, &KeyListView::slotAddKey);
QStringList fprs;
diff --git a/src/ui/keyselectiondialog.h b/src/ui/keyselectiondialog.h
index 5988c33..9efb909 100644
--- a/src/ui/keyselectiondialog.h
+++ b/src/ui/keyselectiondialog.h
@@ -38,9 +38,9 @@
#define __KLEO_UI_KEYSELECTIONDIALOG_H__
#include "kleo_export.h"
-#include "libkleo/cryptobackend.h"
#include <gpgme++/key.h>
+#include <qgpgme/qgpgmebackend.h>
#include <QDialog>
@@ -178,7 +178,7 @@ private:
void connectSignals();
void disconnectSignals();
- void startKeyListJobForBackend(const Kleo::CryptoBackend::Protocol *, const std::vector<GpgME::Key> &, bool);
+ void startKeyListJobForBackend(const QGpgME::Protocol *, const std::vector<GpgME::Key> &, bool);
void startValidatingKeyListing();
void init(bool, bool, const QString &, const QString &);
@@ -186,8 +186,8 @@ private:
private:
QVBoxLayout *mTopLayout;
Kleo::KeyListView *mKeyListView;
- const Kleo::CryptoBackend::Protocol *mOpenPGPBackend;
- const Kleo::CryptoBackend::Protocol *mSMIMEBackend;
+ const QGpgME::Protocol *mOpenPGPBackend;
+ const QGpgME::Protocol *mSMIMEBackend;
QCheckBox *mRememberCB;
std::vector<GpgME::Key> mSelectedKeys, mKeysToCheck;
unsigned int mKeyUsage;
diff --git a/src/ui/messagebox.cpp b/src/ui/messagebox.cpp
index 27d5193..e86cb22 100644
--- a/src/ui/messagebox.cpp
+++ b/src/ui/messagebox.cpp
@@ -35,10 +35,10 @@
#include <QDebug>
#include "kleo_ui_debug.h"
-#include "libkleo/job.h"
#include <gpgme++/signingresult.h>
#include <gpgme++/encryptionresult.h>
+#include <qgpgme/job.h>
#include <QFileDialog>
@@ -57,6 +57,7 @@
using namespace Kleo;
using namespace Kleo::Private;
using namespace GpgME;
+using namespace QGpgME;
// static
void MessageBox::auditLog(QWidget *parent, const Job *job, const QString &caption)
@@ -221,7 +222,7 @@ void MessageBox::error(QWidget *parent, const SigningResult &sresult, const Encr
}
// static
-bool MessageBox::showAuditLogButton(const Kleo::Job *job)
+bool MessageBox::showAuditLogButton(const QGpgME::Job *job)
{
if (!job) {
qCDebug(KLEO_UI_LOG) << "not showing audit log button (no job instance)";
diff --git a/src/ui/messagebox.h b/src/ui/messagebox.h
index 1a69050..af4749a 100644
--- a/src/ui/messagebox.h
+++ b/src/ui/messagebox.h
@@ -45,7 +45,7 @@ class SigningResult;
class EncryptionResult;
}
-namespace Kleo
+namespace QGpgME
{
class Job;
}
@@ -59,30 +59,30 @@ namespace Kleo
class KLEO_EXPORT MessageBox
{
public:
- static void information(QWidget *parent, const GpgME::SigningResult &result, const Kleo::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
- static void information(QWidget *parent, const GpgME::SigningResult &result, const Kleo::Job *job, KMessageBox::Options options = KMessageBox::Notify);
- static void error(QWidget *parent, const GpgME::SigningResult &result, const Kleo::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
- static void error(QWidget *parent, const GpgME::SigningResult &result, const Kleo::Job *job, KMessageBox::Options options = KMessageBox::Notify);
-
- static void information(QWidget *parent, const GpgME::EncryptionResult &result, const Kleo::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
- static void information(QWidget *parent, const GpgME::EncryptionResult &result, const Kleo::Job *job, KMessageBox::Options options = KMessageBox::Notify);
- static void error(QWidget *parent, const GpgME::EncryptionResult &result, const Kleo::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
- static void error(QWidget *parent, const GpgME::EncryptionResult &result, const Kleo::Job *job, KMessageBox::Options options = KMessageBox::Notify);
-
- static void information(QWidget *parent, const GpgME::SigningResult &sresult, const GpgME::EncryptionResult &eresult, const Kleo::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
- static void information(QWidget *parent, const GpgME::SigningResult &sresult, const GpgME::EncryptionResult &eresult, const Kleo::Job *job, KMessageBox::Options options = KMessageBox::Notify);
- static void error(QWidget *parent, const GpgME::SigningResult &sresult, const GpgME::EncryptionResult &eresult, const Kleo::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
- static void error(QWidget *parent, const GpgME::SigningResult &sresult, const GpgME::EncryptionResult &eresult, const Kleo::Job *job, KMessageBox::Options options = KMessageBox::Notify);
-
- static void auditLog(QWidget *parent, const Kleo::Job *job, const QString &caption);
- static void auditLog(QWidget *parent, const Kleo::Job *job);
+ static void information(QWidget *parent, const GpgME::SigningResult &result, const QGpgME::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
+ static void information(QWidget *parent, const GpgME::SigningResult &result, const QGpgME::Job *job, KMessageBox::Options options = KMessageBox::Notify);
+ static void error(QWidget *parent, const GpgME::SigningResult &result, const QGpgME::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
+ static void error(QWidget *parent, const GpgME::SigningResult &result, const QGpgME::Job *job, KMessageBox::Options options = KMessageBox::Notify);
+
+ static void information(QWidget *parent, const GpgME::EncryptionResult &result, const QGpgME::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
+ static void information(QWidget *parent, const GpgME::EncryptionResult &result, const QGpgME::Job *job, KMessageBox::Options options = KMessageBox::Notify);
+ static void error(QWidget *parent, const GpgME::EncryptionResult &result, const QGpgME::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
+ static void error(QWidget *parent, const GpgME::EncryptionResult &result, const QGpgME::Job *job, KMessageBox::Options options = KMessageBox::Notify);
+
+ static void information(QWidget *parent, const GpgME::SigningResult &sresult, const GpgME::EncryptionResult &eresult, const QGpgME::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
+ static void information(QWidget *parent, const GpgME::SigningResult &sresult, const GpgME::EncryptionResult &eresult, const QGpgME::Job *job, KMessageBox::Options options = KMessageBox::Notify);
+ static void error(QWidget *parent, const GpgME::SigningResult &sresult, const GpgME::EncryptionResult &eresult, const QGpgME::Job *job, const QString &caption, KMessageBox::Options options = KMessageBox::Notify);
+ static void error(QWidget *parent, const GpgME::SigningResult &sresult, const GpgME::EncryptionResult &eresult, const QGpgME::Job *job, KMessageBox::Options options = KMessageBox::Notify);
+
+ static void auditLog(QWidget *parent, const QGpgME::Job *job, const QString &caption);
+ static void auditLog(QWidget *parent, const QGpgME::Job *job);
static void auditLog(QWidget *parent, const QString &log, const QString &caption);
static void auditLog(QWidget *parent, const QString &log);
- static bool showAuditLogButton(const Kleo::Job *job);
+ static bool showAuditLogButton(const QGpgME::Job *job);
private:
- static void make(QWidget *parent, QMessageBox::Icon icon, const QString &text, const Kleo::Job *job, const QString &caption, KMessageBox::Options options);
+ static void make(QWidget *parent, QMessageBox::Icon icon, const QString &text, const QGpgME::Job *job, const QString &caption, KMessageBox::Options options);
};
}
diff --git a/src/ui/progressdialog.cpp b/src/ui/progressdialog.cpp
index f49a6e3..4dc89ea 100644
--- a/src/ui/progressdialog.cpp
+++ b/src/ui/progressdialog.cpp
@@ -38,7 +38,7 @@
#include "progressbar.h"
-#include "libkleo/job.h"
+#include <qgpgme/job.h>
#include <KLocalizedString>
@@ -46,7 +46,7 @@
#include <assert.h>
-Kleo::ProgressDialog::ProgressDialog(Job *job, const QString &baseText,
+Kleo::ProgressDialog::ProgressDialog(QGpgME::Job *job, const QString &baseText,
QWidget *creator, Qt::WindowFlags f)
: QProgressDialog(creator, f), mBaseText(baseText)
{
@@ -60,9 +60,9 @@ Kleo::ProgressDialog::ProgressDialog(Job *job, const QString &baseText,
setModal(false);
setRange(0, 0); // activate busy indicator
- connect(job, &Job::progress, this, &ProgressDialog::slotProgress);
- connect(job, &Job::done, this, &ProgressDialog::slotDone);
- connect(this, &QProgressDialog::canceled, job, &Job::slotCancel);
+ connect(job, &QGpgME::Job::progress, this, &ProgressDialog::slotProgress);
+ connect(job, &QGpgME::Job::done, this, &ProgressDialog::slotDone);
+ connect(this, &QProgressDialog::canceled, job, &QGpgME::Job::slotCancel);
QTimer::singleShot(minimumDuration(), this, &ProgressDialog::forceShow);
}
diff --git a/src/ui/progressdialog.h b/src/ui/progressdialog.h
index 0691624..7657dd7 100644
--- a/src/ui/progressdialog.h
+++ b/src/ui/progressdialog.h
@@ -39,11 +39,11 @@
#ifndef QT_NO_PROGRESSDIALOG
#include <QString>
+
+#include <qgpgme/job.h>
namespace Kleo
{
-class Job;
-
/**
@short A progress dialog for Kleo::Jobs
*/
@@ -51,7 +51,7 @@ class KLEO_EXPORT ProgressDialog : public QProgressDialog
{
Q_OBJECT
public:
- ProgressDialog(Job *job, const QString &baseText,
+ ProgressDialog(QGpgME::Job *job, const QString &baseText,
QWidget *widget = Q_NULLPTR, Qt::WindowFlags f = 0);
~ProgressDialog();