summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-09-05 15:14:14 (GMT)
committerAndre Heinecke <aheinecke@intevation.de>2016-09-05 15:14:14 (GMT)
commit2f7c88639578c2dd11e298f911a0ed7604338755 (patch)
tree6bcb6bc0e824c401ef2779a39317c99ee44f4e22
parentdbb1f8b0216db246039bedbe11009b9d2637bc85 (diff)
Fix encrypt / sign of single directory
This also unifies the "archive forced" logic in a single place and removes some kdtools complication.
-rw-r--r--src/crypto/signencryptfilescontroller.cpp36
1 files changed, 11 insertions, 25 deletions
diff --git a/src/crypto/signencryptfilescontroller.cpp b/src/crypto/signencryptfilescontroller.cpp
index daeea1f..e234bd0 100644
--- a/src/crypto/signencryptfilescontroller.cpp
+++ b/src/crypto/signencryptfilescontroller.cpp
@@ -50,7 +50,6 @@
#include "fileoperationspreferences.h"
-#include <Libkleo/Stl_Util>
#include <Libkleo/Exception>
#include <Libkleo/Classify>
@@ -72,23 +71,6 @@ using namespace boost;
using namespace GpgME;
using namespace KMime::Types;
-namespace
-{
-
-struct is_dir : std::unary_function<QString, bool> {
- bool operator()(const QString &file) const
- {
- return QFileInfo(file).isDir();
- }
-};
-
-}
-
-static bool contains_dir(const QStringList &files)
-{
- return kdtools::any(files, is_dir());
-}
-
class SignEncryptFilesController::Private
{
friend class ::Kleo::Crypto::SignEncryptFilesController;
@@ -305,17 +287,19 @@ static boost::shared_ptr<ArchiveDefinition> getDefaultAd()
return ad;
}
-static QMap <int, QString> buildOutputNames(const QStringList &files)
+static QMap <int, QString> buildOutputNames(const QStringList &files, const bool archive)
{
QMap <int, QString> nameMap;
// Build the default names for the wizard.
QString baseNameCms;
QString baseNamePgp;
- if (files.size() > 1) {
+ const QFileInfo firstFile(files.first());
+ if (archive) {
QString baseName;
- baseName = QDir(heuristicBaseDirectory(files)).absoluteFilePath(
- i18nc("base name of an archive file, e.g. archive.zip or archive.tar.gz", "archive"));
+ baseName = QDir(heuristicBaseDirectory(files)).absoluteFilePath(files.size() > 1 ?
+ i18nc("base name of an archive file, e.g. archive.zip or archive.tar.gz", "archive") :
+ firstFile.baseName());
const auto ad = getDefaultAd();
baseNamePgp = baseName + QStringLiteral(".") + ad->extensions(GpgME::OpenPGP).first() + QStringLiteral(".");
@@ -338,11 +322,13 @@ void SignEncryptFilesController::setFiles(const QStringList &files)
{
kleo_assert(!files.empty());
d->files = files;
- if (contains_dir(files) || files.size() > 1) {
+ bool archive = false;
+ if (files.size() > 1 || QFileInfo(files.first()).isDir()) {
setOperationMode((operationMode() & ~ArchiveMask) | ArchiveForced);
+ archive = true;
}
d->ensureWizardCreated();
- d->wizard->setOutputNames(buildOutputNames(files));
+ d->wizard->setOutputNames(buildOutputNames(files, archive));
}
void SignEncryptFilesController::Private::slotWizardCanceled()
@@ -515,7 +501,7 @@ void SignEncryptFilesController::Private::slotWizardOperationPrepared()
kleo_assert(wizard);
kleo_assert(!files.empty());
- const bool archive = files.size() > 1;
+ const bool archive = (operation & ArchiveMask) == ArchiveForced;
const QVector<Key> recipients = wizard->resolvedRecipients();
const QVector<Key> signers = wizard->resolvedSigners();