Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34135170
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
50 KB
Subscribers
None
View Options
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index af59d47d1..462b94f90 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,300 +1,302 @@
add_subdirectory(icons)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if (NOT DISABLE_KWATCHGNUPG)
add_subdirectory(kwatchgnupg)
endif()
add_subdirectory(libkleopatraclient)
add_subdirectory(conf)
add_subdirectory(kconf_update)
if(WIN32)
set(_kleopatra_extra_uiserver_SRCS uiserver/uiserver_win.cpp)
set(_kleopatra_extra_SRCS utils/gnupg-registry.c selftest/registrycheck.cpp)
else()
set(_kleopatra_extra_uiserver_SRCS uiserver/uiserver_unix.cpp)
set(_kleopatra_extra_SRCS)
endif()
set(_kleopatra_uiserver_SRCS
uiserver/sessiondata.cpp
uiserver/uiserver.cpp
${_kleopatra_extra_uiserver_SRCS}
uiserver/assuanserverconnection.cpp
uiserver/echocommand.cpp
uiserver/decryptverifycommandemailbase.cpp
uiserver/decryptverifycommandfilesbase.cpp
uiserver/signcommand.cpp
uiserver/signencryptfilescommand.cpp
uiserver/prepencryptcommand.cpp
uiserver/prepsigncommand.cpp
uiserver/encryptcommand.cpp
uiserver/selectcertificatecommand.cpp
uiserver/importfilescommand.cpp
uiserver/createchecksumscommand.cpp
uiserver/verifychecksumscommand.cpp
selftest/uiservercheck.cpp
)
if(ASSUAN2_FOUND)
set(_kleopatra_uiserver_extra_libs ${ASSUAN2_LIBRARIES})
else()
if(WIN32)
set(_kleopatra_uiserver_extra_libs ${ASSUAN_VANILLA_LIBRARIES})
else()
set(_kleopatra_uiserver_extra_libs ${ASSUAN_PTHREAD_LIBRARIES})
endif()
endif()
if(HAVE_GPG_ERR_SOURCE_KLEO)
add_definitions(-DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_KLEO)
else()
add_definitions(-DGPG_ERR_SOURCE_DEFAULT=GPG_ERR_SOURCE_USER_1)
endif()
ki18n_wrap_ui(_kleopatra_uiserver_SRCS crypto/gui/signingcertificateselectionwidget.ui)
set(_kleopatra_SRCS
utils/gnupg-helper.cpp
utils/filesystemwatcher.cpp
utils/filedialog.cpp
utils/kdpipeiodevice.cpp
utils/kdlogtextwidget.cpp
utils/kdsignalblocker.cpp
utils/headerview.cpp
utils/scrollarea.cpp
utils/dragqueen.cpp
utils/multivalidator.cpp
utils/systemtrayicon.cpp
utils/hex.cpp
utils/path-helper.cpp
utils/input.cpp
utils/output.cpp
utils/formatting.cpp
utils/validation.cpp
utils/wsastarter.cpp
utils/classify.cpp
utils/iodevicelogger.cpp
utils/log.cpp
utils/action_data.cpp
utils/types.cpp
utils/archivedefinition.cpp
utils/auditlog.cpp
utils/clipboardmenu.cpp
utils/kuniqueservice.cpp
selftest/selftest.cpp
selftest/enginecheck.cpp
selftest/gpgconfcheck.cpp
selftest/gpgagentcheck.cpp
selftest/libkleopatrarccheck.cpp
${_kleopatra_extra_SRCS}
models/keycache.cpp
models/keylistmodel.cpp
models/keylistsortfilterproxymodel.cpp
models/subkeylistmodel.cpp
models/useridlistmodel.cpp
view/keylistcontroller.cpp
view/keytreeview.cpp
view/searchbar.cpp
view/tabwidget.cpp
view/keycacheoverlay.cpp
dialogs/certificateselectiondialog.cpp
dialogs/expirydialog.cpp
dialogs/lookupcertificatesdialog.cpp
dialogs/ownertrustdialog.cpp
dialogs/selftestdialog.cpp
dialogs/certifycertificatedialog.cpp
dialogs/exportsecretkeydialog.cpp
dialogs/adduseriddialog.cpp
dialogs/certificatedetailsdialog.cpp
dialogs/exportcertificatesdialog.cpp
dialogs/deletecertificatesdialog.cpp
dialogs/setinitialpindialog.cpp
crypto/controller.cpp
crypto/certificateresolver.cpp
crypto/sender.cpp
crypto/recipient.cpp
crypto/task.cpp
crypto/taskcollection.cpp
crypto/decryptverifytask.cpp
crypto/decryptverifyemailcontroller.cpp
crypto/decryptverifyfilescontroller.cpp
+ crypto/autodecryptverifyfilescontroller.cpp
crypto/encryptemailtask.cpp
crypto/encryptemailcontroller.cpp
crypto/newsignencryptemailcontroller.cpp
crypto/signencryptfilestask.cpp
crypto/signencryptfilescontroller.cpp
crypto/signemailtask.cpp
crypto/signemailcontroller.cpp
crypto/createchecksumscontroller.cpp
crypto/verifychecksumscontroller.cpp
crypto/gui/wizard.cpp
crypto/gui/wizardpage.cpp
crypto/gui/signingcertificateselectionwidget.cpp
crypto/gui/signingcertificateselectiondialog.cpp
crypto/gui/resultitemwidget.cpp
crypto/gui/resultlistwidget.cpp
crypto/gui/resultpage.cpp
crypto/gui/newresultpage.cpp
crypto/gui/signencryptfileswizard.cpp
crypto/gui/signencryptemailconflictdialog.cpp
crypto/gui/decryptverifyoperationwidget.cpp
crypto/gui/decryptverifyfileswizard.cpp
+ crypto/gui/decryptverifyfilesdialog.cpp
crypto/gui/objectspage.cpp
crypto/gui/resolverecipientspage.cpp
crypto/gui/signerresolvepage.cpp
crypto/gui/encryptemailwizard.cpp
crypto/gui/signemailwizard.cpp
crypto/gui/signencryptwizard.cpp
crypto/gui/verifychecksumsdialog.cpp
commands/command.cpp
commands/gnupgprocesscommand.cpp
commands/detailscommand.cpp
commands/exportcertificatecommand.cpp
commands/importcertificatescommand.cpp
commands/importcertificatefromfilecommand.cpp
commands/importcertificatefromclipboardcommand.cpp
commands/lookupcertificatescommand.cpp
commands/reloadkeyscommand.cpp
commands/refreshx509certscommand.cpp
commands/refreshopenpgpcertscommand.cpp
commands/deletecertificatescommand.cpp
commands/decryptverifyfilescommand.cpp
commands/signencryptfilescommand.cpp
commands/signencryptfoldercommand.cpp
commands/encryptclipboardcommand.cpp
commands/signclipboardcommand.cpp
commands/decryptverifyclipboardcommand.cpp
commands/clearcrlcachecommand.cpp
commands/dumpcrlcachecommand.cpp
commands/dumpcertificatecommand.cpp
commands/importcrlcommand.cpp
commands/changeexpirycommand.cpp
commands/changeownertrustcommand.cpp
commands/changeroottrustcommand.cpp
commands/changepassphrasecommand.cpp
commands/certifycertificatecommand.cpp
commands/selftestcommand.cpp
commands/exportsecretkeycommand.cpp
commands/exportopenpgpcertstoservercommand.cpp
commands/adduseridcommand.cpp
commands/newcertificatecommand.cpp
commands/setinitialpincommand.cpp
commands/learncardkeyscommand.cpp
commands/checksumcreatefilescommand.cpp
commands/checksumverifyfilescommand.cpp
commands/exportpaperkeycommand.cpp
${_kleopatra_uiserver_files}
conf/configuredialog.cpp
newcertificatewizard/listwidget.cpp
newcertificatewizard/newcertificatewizard.cpp
smartcard/readerstatus.cpp
aboutdata.cpp
systrayicon.cpp
kleopatraapplication.cpp
mainwindow.cpp
main.cpp
)
if(HAVE_KCMUTILS)
set (_kleopatra_extra_libs KF5::KCMUtils)
else()
set (_kleopatra_SRCS conf/kleopageconfigdialog.cpp ${_kleopatra_SRCS})
endif()
ecm_qt_declare_logging_category(_kleopatra_SRCS HEADER kleopatra_debug.h IDENTIFIER KLEOPATRA_LOG CATEGORY_NAME log_kleopatra)
if(KLEO_MODEL_TEST)
add_definitions(-DKLEO_MODEL_TEST)
set(_kleopatra_SRCS ${_kleopatra_SRCS} models/modeltest.cpp)
endif()
ki18n_wrap_ui(_kleopatra_SRCS
dialogs/certificationoptionswidget.ui
dialogs/expirydialog.ui
dialogs/lookupcertificatesdialog.ui
dialogs/ownertrustdialog.ui
dialogs/selectchecklevelwidget.ui
dialogs/selftestdialog.ui
dialogs/exportsecretkeydialog.ui
dialogs/adduseriddialog.ui
dialogs/certificatedetailsdialog.ui
dialogs/setinitialpindialog.ui
newcertificatewizard/listwidget.ui
newcertificatewizard/chooseprotocolpage.ui
newcertificatewizard/enterdetailspage.ui
newcertificatewizard/overviewpage.ui
newcertificatewizard/keycreationpage.ui
newcertificatewizard/resultpage.ui
newcertificatewizard/advancedsettingsdialog.ui
)
kconfig_add_kcfg_files(_kleopatra_SRCS
kcfg/tooltippreferences.kcfgc
kcfg/emailoperationspreferences.kcfgc
kcfg/fileoperationspreferences.kcfgc
kcfg/smimevalidationpreferences.kcfgc
)
file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/*-apps-kleopatra.png")
ecm_add_app_icon(_kleopatra_SRCS ICONS ${ICONS_SRCS})
qt5_add_resources(_kleopatra_SRCS kleopatra.qrc)
add_executable(kleopatra_bin ${_kleopatra_SRCS} ${_kleopatra_uiserver_SRCS})
set_target_properties(kleopatra_bin PROPERTIES OUTPUT_NAME kleopatra)
target_link_libraries(kleopatra_bin
${_kleopatra_extra_libs}
KF5::Libkleo
KF5::Mime
KF5::I18n
KF5::XmlGui
KF5::IconThemes
KF5::WindowSystem
KF5::CoreAddons
Qt5::Network
Qt5::PrintSupport # Printing secret keys
${_kleopatra_uiserver_extra_libs}
${_kleopatra_dbusaddons_libs}
kleopatraclientcore
)
install(TARGETS kleopatra_bin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(
PROGRAMS data/org.kde.kleopatra.desktop data/kleopatra_import.desktop
DESTINATION ${KDE_INSTALL_APPDIR}
)
install(FILES data/org.kde.kleopatra.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
install(
FILES data/kleopatra_signencryptfiles.desktop
data/kleopatra_signencryptfolders.desktop
data/kleopatra_decryptverifyfiles.desktop
data/kleopatra_decryptverifyfolders.desktop
DESTINATION ${KDE_INSTALL_KSERVICES5DIR}
)
diff --git a/src/commands/decryptverifyfilescommand.cpp b/src/commands/decryptverifyfilescommand.cpp
index 56d38f497..a4c118ccf 100644
--- a/src/commands/decryptverifyfilescommand.cpp
+++ b/src/commands/decryptverifyfilescommand.cpp
@@ -1,206 +1,218 @@
/* -*- mode: c++; c-basic-offset:4 -*-
commands/decryptverifyfilescommand.cpp
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Kleopatra 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.
Kleopatra 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-kleopatra.h>
#include "decryptverifyfilescommand.h"
+#include "fileoperationspreferences.h"
#include "command_p.h"
-#include <crypto/decryptverifyfilescontroller.h>
+#include "crypto/decryptverifyfilescontroller.h"
+#include "crypto/autodecryptverifyfilescontroller.h"
#include <utils/filedialog.h>
#include <Libkleo/Stl_Util>
#include <KLocalizedString>
#include "kleopatra_debug.h"
#include <QStringList>
#include <exception>
using namespace Kleo;
using namespace Kleo::Commands;
using namespace Kleo::Crypto;
using namespace boost;
class DecryptVerifyFilesCommand::Private : public Command::Private
{
friend class ::Kleo::Commands::DecryptVerifyFilesCommand;
DecryptVerifyFilesCommand *q_func() const
{
return static_cast<DecryptVerifyFilesCommand *>(q);
}
public:
- explicit Private(DecryptVerifyFilesCommand *qq, KeyListController *c);
+ explicit Private(DecryptVerifyFilesCommand *qq, KeyListController *c,
+ bool forceManualMode=false);
~Private();
QStringList selectFiles() const;
void init();
private:
void slotControllerDone()
{
finished();
}
void slotControllerError(int, const QString &msg)
{
KMessageBox::error(parentWidgetOrView(), msg, i18n("Decrypt/Verify Failed"));
finished();
}
private:
QStringList files;
shared_ptr<const ExecutionContext> shared_qq;
- DecryptVerifyFilesController controller;
+ DecryptVerifyFilesController *mController;
};
DecryptVerifyFilesCommand::Private *DecryptVerifyFilesCommand::d_func()
{
return static_cast<Private *>(d.get());
}
const DecryptVerifyFilesCommand::Private *DecryptVerifyFilesCommand::d_func() const
{
return static_cast<const Private *>(d.get());
}
#define d d_func()
#define q q_func()
-DecryptVerifyFilesCommand::Private::Private(DecryptVerifyFilesCommand *qq, KeyListController *c)
+DecryptVerifyFilesCommand::Private::Private(DecryptVerifyFilesCommand *qq, KeyListController *c, bool forceManualMode)
: Command::Private(qq, c),
files(),
- shared_qq(qq, kdtools::nodelete()),
- controller()
-{
+ shared_qq(qq, kdtools::nodelete())
+{
+ FileOperationsPreferences prefs;
+ if (!forceManualMode &&
+ GpgME::hasFeature(0, GpgME::BinaryAndFineGrainedIdentify) &&
+ prefs.autoDecryptVerify()) {
+ mController = new AutoDecryptVerifyFilesController();
+ } else {
+ mController = new DecryptVerifyFilesController();
+ }
+
}
DecryptVerifyFilesCommand::Private::~Private()
{
qCDebug(KLEOPATRA_LOG);
+ delete mController;
}
DecryptVerifyFilesCommand::DecryptVerifyFilesCommand(KeyListController *c)
: Command(new Private(this, c))
{
d->init();
}
DecryptVerifyFilesCommand::DecryptVerifyFilesCommand(QAbstractItemView *v, KeyListController *c)
: Command(v, new Private(this, c))
{
d->init();
}
-DecryptVerifyFilesCommand::DecryptVerifyFilesCommand(const QStringList &files, KeyListController *c)
- : Command(new Private(this, c))
+DecryptVerifyFilesCommand::DecryptVerifyFilesCommand(const QStringList &files, KeyListController *c, bool forceManualMode)
+ : Command(new Private(this, c, forceManualMode))
{
d->init();
d->files = files;
}
DecryptVerifyFilesCommand::DecryptVerifyFilesCommand(const QStringList &files, QAbstractItemView *v, KeyListController *c)
: Command(v, new Private(this, c))
{
d->init();
d->files = files;
}
void DecryptVerifyFilesCommand::Private::init()
{
- controller.setExecutionContext(shared_qq);
- connect(&controller, SIGNAL(done()), q, SLOT(slotControllerDone()));
- connect(&controller, SIGNAL(error(int,QString)), q, SLOT(slotControllerError(int,QString)));
+ mController->setExecutionContext(shared_qq);
+ connect(mController, SIGNAL(done()), q, SLOT(slotControllerDone()));
+ connect(mController, SIGNAL(error(int,QString)), q, SLOT(slotControllerError(int,QString)));
}
DecryptVerifyFilesCommand::~DecryptVerifyFilesCommand()
{
qCDebug(KLEOPATRA_LOG);
}
void DecryptVerifyFilesCommand::setFiles(const QStringList &files)
{
d->files = files;
}
void DecryptVerifyFilesCommand::setOperation(DecryptVerifyOperation op)
{
try {
- d->controller.setOperation(op);
+ d->mController->setOperation(op);
} catch (...) {}
}
DecryptVerifyOperation DecryptVerifyFilesCommand::operation() const
{
- return d->controller.operation();
+ return d->mController->operation();
}
void DecryptVerifyFilesCommand::doStart()
{
try {
if (d->files.empty()) {
d->files = d->selectFiles();
}
if (d->files.empty()) {
d->finished();
return;
}
- d->controller.setFiles(d->files);
- d->controller.start();
+ d->mController->setFiles(d->files);
+ d->mController->start();
} catch (const std::exception &e) {
d->information(i18n("An error occurred: %1",
QString::fromLocal8Bit(e.what())),
i18n("Decrypt/Verify Files Error"));
d->finished();
}
}
void DecryptVerifyFilesCommand::doCancel()
{
qCDebug(KLEOPATRA_LOG);
- d->controller.cancel();
+ d->mController->cancel();
}
QStringList DecryptVerifyFilesCommand::Private::selectFiles() const
{
return FileDialog::getOpenFileNames(parentWidgetOrView(), i18n("Select One or More Files to Decrypt and/or Verify"), QStringLiteral("enc"));
}
#undef d
#undef q
#include "moc_decryptverifyfilescommand.cpp"
diff --git a/src/commands/decryptverifyfilescommand.h b/src/commands/decryptverifyfilescommand.h
index 5c4eae290..060b3b49e 100644
--- a/src/commands/decryptverifyfilescommand.h
+++ b/src/commands/decryptverifyfilescommand.h
@@ -1,77 +1,77 @@
/* -*- mode: c++; c-basic-offset:4 -*-
commands/decryptverifyfilescommand.h
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Kleopatra 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.
Kleopatra 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 __KLEOPATRA_COMMMANDS_DECRYPTVERIFYFILESCOMMAND_H__
#define __KLEOPATRA_COMMMANDS_DECRYPTVERIFYFILESCOMMAND_H__
-#include <commands/command.h>
+#include "commands/command.h"
-#include <utils/types.h>
+#include "utils/types.h"
class QStringList;
namespace Kleo
{
namespace Commands
{
class DecryptVerifyFilesCommand : public Command
{
Q_OBJECT
public:
explicit DecryptVerifyFilesCommand(QAbstractItemView *view, KeyListController *parent);
explicit DecryptVerifyFilesCommand(KeyListController *parent);
explicit DecryptVerifyFilesCommand(const QStringList &files, QAbstractItemView *view, KeyListController *parent);
- explicit DecryptVerifyFilesCommand(const QStringList &files, KeyListController *parent);
+ explicit DecryptVerifyFilesCommand(const QStringList &files, KeyListController *parent, bool forceManualMode = false);
~DecryptVerifyFilesCommand();
void setFiles(const QStringList &files);
void setOperation(DecryptVerifyOperation operation);
DecryptVerifyOperation operation() const;
private:
void doStart() Q_DECL_OVERRIDE;
void doCancel() Q_DECL_OVERRIDE;
private:
class Private;
inline Private *d_func();
inline const Private *d_func() const;
Q_PRIVATE_SLOT(d_func(), void slotControllerDone())
Q_PRIVATE_SLOT(d_func(), void slotControllerError(int, QString))
};
}
}
#endif // __KLEOPATRA_COMMMANDS_DECRYPTVERIFYFILESCOMMAND_H__
diff --git a/src/crypto/autodecryptverifyfilescontroller.cpp b/src/crypto/autodecryptverifyfilescontroller.cpp
new file mode 100644
index 000000000..95d69c728
--- /dev/null
+++ b/src/crypto/autodecryptverifyfilescontroller.cpp
@@ -0,0 +1,384 @@
+/* -*- mode: c++; c-basic-offset:4 -*-
+ autodecryptverifyfilescontroller.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2008 Klarälvdalens Datakonsult AB
+ 2016 Intevation GmbH
+
+ Kleopatra 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.
+
+ Kleopatra 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-kleopatra.h>
+
+#include "autodecryptverifyfilescontroller.h"
+
+#include <crypto/gui/decryptverifyoperationwidget.h>
+#include <crypto/gui/decryptverifyfilesdialog.h>
+#include <crypto/decryptverifytask.h>
+#include <crypto/taskcollection.h>
+
+#include "commands/decryptverifyfilescommand.h"
+
+#include <utils/classify.h>
+#include <utils/gnupg-helper.h>
+#include <utils/path-helper.h>
+#include <utils/input.h>
+#include <utils/output.h>
+#include <utils/kleo_assert.h>
+#include <utils/archivedefinition.h>
+
+#include <KLocalizedString>
+#include <KMessageBox>
+#include "kleopatra_debug.h"
+
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+#include <QPointer>
+#include <QTimer>
+#include <QFileDialog>
+#include <QTemporaryDir>
+
+#include <boost/shared_ptr.hpp>
+
+#include <memory>
+#include <vector>
+
+using namespace boost;
+using namespace GpgME;
+using namespace Kleo;
+using namespace Kleo::Crypto;
+using namespace Kleo::Crypto::Gui;
+
+class AutoDecryptVerifyFilesController::Private
+{
+ AutoDecryptVerifyFilesController *const q;
+public:
+ explicit Private(AutoDecryptVerifyFilesController *qq);
+ ~Private() { qCDebug(KLEOPATRA_LOG); }
+
+ void slotDialogCanceled();
+ void schedule();
+
+ void exec();
+ std::vector<shared_ptr<Task> > buildTasks(const QStringList &, QStringList &);
+
+ void reportError(int err, const QString &details)
+ {
+ q->setLastError(err, details);
+ q->emitDoneOrError();
+ }
+ void cancelAllTasks();
+
+ QStringList m_passedFiles, m_filesAfterPreparation;
+ std::vector<shared_ptr<const DecryptVerifyResult> > m_results;
+ std::vector<shared_ptr<Task> > m_runnableTasks, m_completedTasks;
+ shared_ptr<Task> m_runningTask;
+ bool m_errorDetected;
+ DecryptVerifyOperation m_operation;
+ DecryptVerifyFilesDialog *m_dialog;
+ QTemporaryDir m_workDir;
+};
+
+AutoDecryptVerifyFilesController::Private::Private(AutoDecryptVerifyFilesController *qq) : q(qq),
+ m_errorDetected(false),
+ m_operation(DecryptVerify),
+ m_dialog(Q_NULLPTR)
+{
+ qRegisterMetaType<VerificationResult>();
+}
+
+void AutoDecryptVerifyFilesController::Private::slotDialogCanceled()
+{
+ qCDebug(KLEOPATRA_LOG);
+}
+
+void AutoDecryptVerifyFilesController::Private::schedule()
+{
+ if (!m_runningTask && !m_runnableTasks.empty()) {
+ const shared_ptr<Task> t = m_runnableTasks.back();
+ m_runnableTasks.pop_back();
+ t->start();
+ m_runningTask = t;
+ }
+ if (!m_runningTask) {
+ kleo_assert(m_runnableTasks.empty());
+ Q_FOREACH (const shared_ptr<const DecryptVerifyResult> &i, m_results) {
+ Q_EMIT q->verificationResult(i->verificationResult());
+ }
+ }
+}
+
+void AutoDecryptVerifyFilesController::Private::exec()
+{
+ Q_ASSERT(!m_dialog);
+
+ QStringList undetected;
+ std::vector<shared_ptr<Task> > tasks = buildTasks(m_passedFiles, undetected);
+
+ if (!undetected.isEmpty()) {
+ // Since GpgME 1.7.0 Classification is supposed to be reliable
+ // so we really can't do anything with this data.
+ reportError(makeGnuPGError(GPG_ERR_GENERAL),
+ xi18n("Failed to find encrypted or signed data in one or more files.<nl/>"
+ "You can manually select what to do with the files now.<nl/>"
+ "If they contain signed or encrypted data please report a bug (see Help->Report Bug)."));
+ auto cmd = new Commands::DecryptVerifyFilesCommand(undetected, Q_NULLPTR, true);
+ cmd->start();
+ }
+ if (tasks.empty()) {
+ q->emitDoneOrError();
+ return;
+ }
+ Q_ASSERT(m_runnableTasks.empty());
+ m_runnableTasks.swap(tasks);
+
+ shared_ptr<TaskCollection> coll(new TaskCollection);
+ Q_FOREACH (const shared_ptr<Task> &i, m_runnableTasks) {
+ q->connectTask(i);
+ }
+ coll->setTasks(m_runnableTasks);
+ m_dialog = new DecryptVerifyFilesDialog(coll);
+ m_dialog->setOutputLocation(heuristicBaseDirectory(m_passedFiles));
+
+ QTimer::singleShot(0, q, SLOT(schedule()));
+ if (m_dialog->exec() == QDialog::Accepted) {
+ const QDir workdir(m_workDir.path());
+ const QDir outDir(m_dialog->outputLocation());
+ bool overWriteAll = false;
+ qCDebug(KLEOPATRA_LOG) << workdir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+ Q_FOREACH (const QFileInfo &fi, workdir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot)) {
+ const auto inpath = fi.absoluteFilePath();
+ const auto outpath = outDir.absoluteFilePath(fi.fileName());
+ qCDebug(KLEOPATRA_LOG) << "Moving " << inpath << " to " << outpath;
+ const QFileInfo ofi(outpath);
+ if (ofi.exists()) {
+ int sel = KMessageBox::No;
+ if (!overWriteAll) {
+ sel = KMessageBox::questionYesNoCancel(m_dialog, i18n("The file <b>%1</b> already exists.\n"
+ "Overwrite?", outpath),
+ i18n("Overwrite Existing File?"),
+ KStandardGuiItem::overwrite(),
+ KGuiItem(i18n("Overwrite All")),
+ KStandardGuiItem::cancel());
+ }
+ if (sel == KMessageBox::Cancel) {
+ qCDebug(KLEOPATRA_LOG) << "Overwriting canceled for: " << outpath;
+ continue;
+ }
+ if (sel == KMessageBox::No) { //Overwrite All
+ overWriteAll = true;
+ }
+ if (!QFile::remove(outpath)) {
+ reportError(makeGnuPGError(GPG_ERR_GENERAL),
+ xi18n("Failed to delete <filename>%1</filename>.",
+ outpath));
+ continue;
+ }
+ }
+ if (!QFile::rename(inpath, outpath)) {
+ reportError(makeGnuPGError(GPG_ERR_GENERAL),
+ xi18n("Failed to move <filename>%1</filename> to <filename>%2</filename>.",
+ inpath, outpath));
+ }
+ }
+ }
+ q->emitDoneOrError();
+ return;
+}
+
+std::vector< shared_ptr<Task> > AutoDecryptVerifyFilesController::Private::buildTasks(const QStringList &fileNames, QStringList &undetected)
+{
+ std::vector<shared_ptr<Task> > tasks;
+ Q_FOREACH (const QString &fName, fileNames) {
+ const auto classification = classify(fName);
+ const auto proto = findProtocol(classification);
+
+ QFileInfo fi(fName);
+ qCDebug(KLEOPATRA_LOG) << "classified" << fName << "as" << printableClassification(classification);
+
+ if (!fi.isReadable()) {
+ reportError(makeGnuPGError(GPG_ERR_ASS_NO_INPUT),
+ xi18n("Cannot open <filename>%1</filename> for reading.", fName));
+ } else if (mayBeAnyCertStoreType(classification)) {
+ // Trying to verify a certificate. Possible because extensions are often similar
+ // for PGP Keys.
+ reportError(makeGnuPGError(GPG_ERR_ASS_NO_INPUT),
+ xi18n("The file <filename>%1</filename> contains certificates and can't be decrypted or verified.", fName));
+ qCDebug(KLEOPATRA_LOG) << "reported error";
+ } else if (isDetachedSignature(classification)) {
+ // Detached signature, try to find data or ask the user.
+ QString signedDataFileName = findSignedData(fName);
+ if (signedDataFileName.isEmpty()) {
+ signedDataFileName = QFileDialog::getOpenFileName(Q_NULLPTR, xi18n("Select the file to verify with \"%1\"", fi.fileName()),
+ fi.dir().dirName());
+ }
+ if (signedDataFileName.isEmpty()) {
+ qCDebug(KLEOPATRA_LOG) << "No signed data selected. Verify abortet.";
+ continue;
+ }
+ qCDebug(KLEOPATRA_LOG) << "Detached verify: " << fName << " Data: " << signedDataFileName;
+ shared_ptr<VerifyDetachedTask> t(new VerifyDetachedTask);
+ t->setInput(Input::createFromFile(fName));
+ t->setSignedData(Input::createFromFile(signedDataFileName));
+ t->setProtocol(proto);
+ tasks.push_back(t);
+ } else if (!mayBeAnyMessageType(classification)) {
+ // Not a Message? Maybe there is a signature for this file?
+ const auto signatures = findSignatures(fName);
+ if (!signatures.empty()) {
+ Q_FOREACH (const QString &sig, signatures) {
+ qCDebug(KLEOPATRA_LOG) << "Guessing: " << sig << " is a signature for: " << fName;
+ shared_ptr<VerifyDetachedTask> t(new VerifyDetachedTask);
+ t->setInput(Input::createFromFile(sig));
+ t->setSignedData(Input::createFromFile(fName));
+ t->setProtocol(proto);
+ tasks.push_back(t);
+ }
+ } else {
+ undetected << fName;
+ qCDebug(KLEOPATRA_LOG) << "Failed detection for: " << fName << " adding to undetected.";
+ }
+ } else {
+ // Any Message type so we have input and output.
+ const auto input = Input::createFromFile(fName);
+ const auto archiveDefinitions = ArchiveDefinition::getArchiveDefinitions();
+
+ const auto ad = q->pick_archive_definition(proto, archiveDefinitions, fName);
+
+ const auto wd = QDir(m_workDir.path());
+
+ const auto output =
+ ad ? ad->createOutputFromUnpackCommand(proto, fName, wd) :
+ /*else*/ Output::createFromFile(wd.absoluteFilePath(outputFileName(fi.fileName())), false);
+
+ if (isOpaqueSignature(classification)) {
+ qCDebug(KLEOPATRA_LOG) << "creating a VerifyOpaqueTask";
+ shared_ptr<VerifyOpaqueTask> t(new VerifyOpaqueTask);
+ t->setInput(input);
+ t->setOutput(output);
+ t->setProtocol(proto);
+ tasks.push_back(t);
+ } else {
+ // Any message. That is not an opaque signature needs to be
+ // decrypted. Verify we always do because we can't know if
+ // an encrypted message is also signed.
+ qCDebug(KLEOPATRA_LOG) << "creating a DecryptVerifyTask";
+ shared_ptr<DecryptVerifyTask> t(new DecryptVerifyTask);
+ t->setInput(input);
+ t->setOutput(output);
+ t->setProtocol(proto);
+ tasks.push_back(t);
+ }
+ }
+ }
+
+ return tasks;
+}
+
+void AutoDecryptVerifyFilesController::setFiles(const QStringList &files)
+{
+ d->m_passedFiles = files;
+}
+
+AutoDecryptVerifyFilesController::AutoDecryptVerifyFilesController(QObject *parent) :
+ DecryptVerifyFilesController(parent), d(new Private(this))
+{
+}
+
+AutoDecryptVerifyFilesController::AutoDecryptVerifyFilesController(const shared_ptr<const ExecutionContext> &ctx, QObject *parent) :
+ DecryptVerifyFilesController(ctx, parent), d(new Private(this))
+{
+}
+
+AutoDecryptVerifyFilesController::~AutoDecryptVerifyFilesController()
+{
+ qCDebug(KLEOPATRA_LOG);
+}
+
+void AutoDecryptVerifyFilesController::start()
+{
+ d->exec();
+}
+
+void AutoDecryptVerifyFilesController::setOperation(DecryptVerifyOperation op)
+{
+ d->m_operation = op;
+}
+
+DecryptVerifyOperation AutoDecryptVerifyFilesController::operation() const
+{
+ return d->m_operation;
+}
+
+void AutoDecryptVerifyFilesController::Private::cancelAllTasks()
+{
+
+ // we just kill all runnable tasks - this will not result in
+ // signal emissions.
+ m_runnableTasks.clear();
+
+ // a cancel() will result in a call to
+ if (m_runningTask) {
+ m_runningTask->cancel();
+ }
+}
+
+void AutoDecryptVerifyFilesController::cancel()
+{
+ qCDebug(KLEOPATRA_LOG);
+ try {
+ d->m_errorDetected = true;
+ if (d->m_dialog) {
+ d->m_dialog->close();
+ }
+ d->cancelAllTasks();
+ } catch (const std::exception &e) {
+ qCDebug(KLEOPATRA_LOG) << "Caught exception: " << e.what();
+ }
+}
+
+void AutoDecryptVerifyFilesController::doTaskDone(const Task *task, const shared_ptr<const Task::Result> &result)
+{
+ assert(task);
+ assert(task == d->m_runningTask.get());
+ Q_UNUSED(task);
+
+ // We could just delete the tasks here, but we can't use
+ // Qt::QueuedConnection here (we need sender()) and other slots
+ // might not yet have executed. Therefore, we push completed tasks
+ // into a burial container
+
+ d->m_completedTasks.push_back(d->m_runningTask);
+ d->m_runningTask.reset();
+
+ if (const shared_ptr<const DecryptVerifyResult> &dvr = boost::dynamic_pointer_cast<const DecryptVerifyResult>(result)) {
+ d->m_results.push_back(dvr);
+ }
+
+ QTimer::singleShot(0, this, SLOT(schedule()));
+}
+#include "moc_autodecryptverifyfilescontroller.cpp"
diff --git a/src/commands/decryptverifyfilescommand.h b/src/crypto/autodecryptverifyfilescontroller.h
similarity index 55%
copy from src/commands/decryptverifyfilescommand.h
copy to src/crypto/autodecryptverifyfilescontroller.h
index 5c4eae290..76332fc41 100644
--- a/src/commands/decryptverifyfilescommand.h
+++ b/src/crypto/autodecryptverifyfilescontroller.h
@@ -1,77 +1,87 @@
/* -*- mode: c++; c-basic-offset:4 -*-
- commands/decryptverifyfilescommand.h
+ autodecryptverifyfilescontroller.h
This file is part of Kleopatra, the KDE keymanager
Copyright (c) 2008 Klarälvdalens Datakonsult AB
+ 2016 Intevation GmbH
Kleopatra 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.
Kleopatra 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 __KLEOPATRA_COMMMANDS_DECRYPTVERIFYFILESCOMMAND_H__
-#define __KLEOPATRA_COMMMANDS_DECRYPTVERIFYFILESCOMMAND_H__
+#ifndef __KLEOPATRA_CRYPTO_AUTODECRYPTVERIFYFILESCONTROLLER_H__
+#define __KLEOPATRA_CRYPTO_AUTODECRYPTVERIFYFILESCONTROLLER_H__
-#include <commands/command.h>
+#include "crypto/decryptverifyfilescontroller.h"
#include <utils/types.h>
-class QStringList;
+#include <QMetaType>
+
+#include<boost/shared_ptr.hpp>
+
+#include <vector>
+
+namespace GpgME
+{
+class VerificationResult;
+}
namespace Kleo
{
-namespace Commands
+namespace Crypto
{
-class DecryptVerifyFilesCommand : public Command
+class AutoDecryptVerifyFilesController : public DecryptVerifyFilesController
{
Q_OBJECT
public:
- explicit DecryptVerifyFilesCommand(QAbstractItemView *view, KeyListController *parent);
- explicit DecryptVerifyFilesCommand(KeyListController *parent);
- explicit DecryptVerifyFilesCommand(const QStringList &files, QAbstractItemView *view, KeyListController *parent);
- explicit DecryptVerifyFilesCommand(const QStringList &files, KeyListController *parent);
- ~DecryptVerifyFilesCommand();
+ explicit AutoDecryptVerifyFilesController(QObject *parent = Q_NULLPTR);
+ explicit AutoDecryptVerifyFilesController(const boost::shared_ptr<const ExecutionContext> &ctx, QObject *parent = Q_NULLPTR);
+
+ ~AutoDecryptVerifyFilesController();
- void setFiles(const QStringList &files);
+ void setFiles(const QStringList &files) Q_DECL_OVERRIDE;
+ void setOperation(DecryptVerifyOperation op) Q_DECL_OVERRIDE;
+ DecryptVerifyOperation operation() const Q_DECL_OVERRIDE;
+ void start() Q_DECL_OVERRIDE;
- void setOperation(DecryptVerifyOperation operation);
- DecryptVerifyOperation operation() const;
+public Q_SLOTS:
+ void cancel() Q_DECL_OVERRIDE;
private:
- void doStart() Q_DECL_OVERRIDE;
- void doCancel() Q_DECL_OVERRIDE;
+ void doTaskDone(const Task *task, const boost::shared_ptr<const Task::Result> &) Q_DECL_OVERRIDE;
private:
class Private;
- inline Private *d_func();
- inline const Private *d_func() const;
- Q_PRIVATE_SLOT(d_func(), void slotControllerDone())
- Q_PRIVATE_SLOT(d_func(), void slotControllerError(int, QString))
+ kdtools::pimpl_ptr<Private> d;
+ Q_PRIVATE_SLOT(d, void slotDialogCanceled())
+ Q_PRIVATE_SLOT(d, void schedule())
};
}
}
-#endif // __KLEOPATRA_COMMMANDS_DECRYPTVERIFYFILESCOMMAND_H__
+#endif // __KLEOPATRA_CRYPTO_AUTODECRYPTVERIFYFILESCONTROLLER_H__
diff --git a/src/crypto/gui/decryptverifyfilesdialog.cpp b/src/crypto/gui/decryptverifyfilesdialog.cpp
new file mode 100644
index 000000000..2262deac5
--- /dev/null
+++ b/src/crypto/gui/decryptverifyfilesdialog.cpp
@@ -0,0 +1,220 @@
+/* crypto/gui/decryptverifyfilesdialog.cpp
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2007 Klarälvdalens Datakonsult AB
+ Copyright (c) 2016 Intevation GmbH
+
+ Kleopatra 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.
+
+ Kleopatra 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 "decryptverifyfilesdialog.h"
+
+#include "kleopatra_debug.h"
+
+#include "crypto/taskcollection.h"
+#include "crypto/decryptverifytask.h"
+#include "crypto/gui/resultpage.h"
+#include "crypto/gui/resultlistwidget.h"
+
+#include <Libkleo/FileNameRequester>
+
+#include <QVBoxLayout>
+#include <QProgressBar>
+#include <QLabel>
+#include <QDialogButtonBox>
+#include <QPushButton>
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+#include <KLocalizedString>
+#include <KMessageBox>
+
+using namespace Kleo;
+using namespace Kleo::Crypto;
+using namespace Kleo::Crypto::Gui;
+
+DecryptVerifyFilesDialog::DecryptVerifyFilesDialog(const boost::shared_ptr<TaskCollection> &coll, QWidget *parent)
+ : QDialog(parent), m_tasks(coll), m_buttonBox(new QDialogButtonBox)
+{
+ auto vLay = new QVBoxLayout(this);
+ auto labels = new QWidget;
+ auto outputLayout = new QHBoxLayout;
+
+ m_outputLocationFNR = new FileNameRequester;
+ auto outLabel = new QLabel(i18n("&Output folder:"));
+ outLabel->setBuddy(m_outputLocationFNR);
+ outputLayout->addWidget(outLabel);
+ outputLayout->addWidget(m_outputLocationFNR);
+ m_outputLocationFNR->setFilter(QDir::Dirs);
+
+ vLay->addLayout(outputLayout);
+
+ m_progressLabelLayout = new QVBoxLayout(labels);
+ vLay->addWidget(labels);
+ m_progressBar = new QProgressBar;
+ vLay->addWidget(m_progressBar);
+ m_resultList = new ResultListWidget;
+ vLay->addWidget(m_resultList);
+
+ resize(QSize(640, 480));
+
+ m_tasks = coll;
+ assert(m_tasks);
+ m_resultList->setTaskCollection(coll);
+ connect(m_tasks.get(), &TaskCollection::progress, this, &DecryptVerifyFilesDialog::progress);
+ connect(m_tasks.get(), &TaskCollection::done, this, &DecryptVerifyFilesDialog::allDone);
+ connect(m_tasks.get(), &TaskCollection::result, this, &DecryptVerifyFilesDialog::result);
+ connect(m_tasks.get(), &TaskCollection::started, this, &DecryptVerifyFilesDialog::started);
+
+ connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
+ connect(m_buttonBox, &QDialogButtonBox::clicked, this, &DecryptVerifyFilesDialog::btnClicked);
+
+ layout()->addWidget(m_buttonBox);
+
+ bool hasOutputs = false;
+ Q_FOREACH (const boost::shared_ptr<Task> t, coll->tasks()) {
+ if (!qobject_cast<VerifyDetachedTask *>(t.get())) {
+ hasOutputs = true;
+ break;
+ }
+ }
+ if (hasOutputs) {
+ setWindowTitle(i18n("Decrypt/Verify Files"));
+ m_okButton = QDialogButtonBox::SaveAll;
+ m_buttonBox->addButton(QDialogButtonBox::Discard);
+ connect(m_buttonBox, &QDialogButtonBox::accepted, this, &DecryptVerifyFilesDialog::checkAccept);
+ } else {
+ outLabel->setVisible(false);
+ m_outputLocationFNR->setVisible(false);
+ setWindowTitle(i18n("Verify Files"));
+ m_okButton = QDialogButtonBox::Ok;
+ m_buttonBox->addButton(QDialogButtonBox::Close);
+ connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accepted);
+ }
+ m_buttonBox->addButton(m_okButton);
+ m_buttonBox->button(m_okButton)->setEnabled(false);
+}
+
+void DecryptVerifyFilesDialog::allDone()
+{
+ qCDebug(KLEOPATRA_LOG) << "All done";
+ Q_ASSERT(m_tasks);
+ m_progressBar->setRange(0, 100);
+ m_progressBar->setValue(100);
+ m_tasks.reset();
+ Q_FOREACH (const QString &i, m_progressLabelByTag.keys()) {
+ if (!i.isEmpty()) {
+ m_progressLabelByTag.value(i)->setText(i18n("%1: All operations completed.", i));
+ } else {
+ m_progressLabelByTag.value(i)->setText(i18n("All operations completed."));
+ }
+ }
+ m_buttonBox->button(m_okButton)->setEnabled(true);
+}
+
+void DecryptVerifyFilesDialog::started(const boost::shared_ptr<Task> &task)
+{
+ Q_ASSERT(task);
+ const auto tag = task->tag();
+ auto label = labelForTag(tag);
+ Q_ASSERT(label);
+ if (tag.isEmpty()) {
+ label->setText(i18nc("number, operation description", "Operation %1: %2", m_tasks->numberOfCompletedTasks() + 1, task->label()));
+ } else {
+ label->setText(i18nc("tag( \"OpenPGP\" or \"CMS\"), operation description", "%1: %2", tag, task->label()));
+ }
+}
+
+QLabel *DecryptVerifyFilesDialog::labelForTag(const QString &tag)
+{
+ if (QLabel *const label = m_progressLabelByTag.value(tag)) {
+ return label;
+ }
+ auto label = new QLabel;
+ label->setTextFormat(Qt::RichText);
+ label->setWordWrap(true);
+ m_progressLabelLayout->addWidget(label);
+ m_progressLabelByTag.insert(tag, label);
+ return label;
+}
+
+void DecryptVerifyFilesDialog::progress(const QString &msg, int progress, int total)
+{
+ Q_UNUSED(msg);
+ assert(progress >= 0);
+ assert(total >= 0);
+ m_progressBar->setRange(0, total);
+ m_progressBar->setValue(progress);
+}
+
+void DecryptVerifyFilesDialog::setOutputLocation(const QString &dir)
+{
+ m_outputLocationFNR->setFileName(dir);
+}
+
+QString DecryptVerifyFilesDialog::outputLocation() const
+{
+ return m_outputLocationFNR->fileName();
+}
+
+void DecryptVerifyFilesDialog::btnClicked(QAbstractButton *btn)
+{
+ if (m_buttonBox->buttonRole(btn) == QDialogButtonBox::DestructiveRole) {
+ close();
+ }
+}
+
+void DecryptVerifyFilesDialog::checkAccept() {
+ const auto outLoc = outputLocation();
+ if (outLoc.isEmpty()) {
+ KMessageBox::information(this, i18n("Please select an output folder."),
+ i18n("No output folder."));
+ return;
+ }
+ const QFileInfo fi(outLoc);
+
+ if (fi.exists() && fi.isDir() && fi.isWritable()) {
+ accept();
+ return;
+ }
+
+ if (!fi.exists()) {
+ qCDebug(KLEOPATRA_LOG) << "Output dir does not exist. Trying to create.";
+ const QDir dir(outLoc);
+ if (!dir.mkdir(outLoc)) {
+ KMessageBox::information(this, i18n("Please select a different output folder."),
+ i18n("Failed to create output folder."));
+ return;
+ } else {
+ accept();
+ return;
+ }
+ }
+
+ KMessageBox::information(this, i18n("Please select a different output folder."),
+ i18n("Invalid output folder."));
+}
diff --git a/src/crypto/gui/decryptverifyfilesdialog.h b/src/crypto/gui/decryptverifyfilesdialog.h
new file mode 100644
index 000000000..fd557fd58
--- /dev/null
+++ b/src/crypto/gui/decryptverifyfilesdialog.h
@@ -0,0 +1,95 @@
+/* crypto/gui/decryptverifyfilesdialog.h
+
+ This file is part of Kleopatra, the KDE keymanager
+ Copyright (c) 2007 Klarälvdalens Datakonsult AB
+ Copyright (c) 2016 Intevation GmbH
+
+ Kleopatra 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.
+
+ Kleopatra 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 CRYPTO_GUI_DECRYPTVERIFYFILESDIALOG_H
+#define CRYPTO_GUI_DECRYPTVERIFYFILESDIALOG_H
+
+#include <boost/shared_ptr.hpp>
+
+#include <QDialog>
+#include <QString>
+#include <QDialogButtonBox>
+
+#include "crypto/task.h"
+
+class QVBoxLayout;
+class QProgressBar;
+template <typename K, typename U> class QHash;
+class QLabel;
+
+namespace Kleo
+{
+class FileNameRequester;
+namespace Crypto
+{
+class TaskCollection;
+
+namespace Gui
+{
+class ResultListWidget;
+
+class DecryptVerifyFilesDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ explicit DecryptVerifyFilesDialog(const boost::shared_ptr<TaskCollection> &coll,
+ QWidget *parent = Q_NULLPTR);
+
+ void setOutputLocation(const QString &dir);
+ QString outputLocation() const;
+
+protected Q_SLOTS:
+ void progress(const QString &msg, int progress, int total);
+ void started(const boost::shared_ptr<Task> &result);
+ void allDone();
+ void btnClicked(QAbstractButton *btn);
+ void checkAccept();
+
+protected:
+ QLabel *labelForTag(const QString &tag);
+
+private:
+ boost::shared_ptr<TaskCollection> m_tasks;
+ QProgressBar *m_progressBar;
+ QHash<QString, QLabel *> m_progressLabelByTag;
+ QVBoxLayout *m_progressLabelLayout;
+ int m_lastErrorItemIndex;
+ ResultListWidget *m_resultList;
+ FileNameRequester *m_outputLocationFNR;
+ QDialogButtonBox::StandardButton m_okButton;
+ QDialogButtonBox *m_buttonBox;
+};
+
+} // namespace Gui
+} //namespace Crypto;
+} // namespace Kleo
+
+#endif // CRYPTO_GUI_DECRYPTVERIFYFILESDIALOG_H
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Dec 8, 11:06 AM (7 h, 49 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f6/68/992400ff94562e28a5a2e106df73
Attached To
rKLEOPATRA Kleopatra
Event Timeline
Log In to Comment