Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Add option to decrypt files in the same folder

In some setups it might be better to decrypt files temporarily
to the same folder as the encrypted file instead of the users
temporary directory.

E.g. Decrypting a very large file on a network share.

GnuPG-Bug-Id: T3602
parent 1edfcfe0
......@@ -234,9 +234,13 @@ void CryptoOperationsConfigWidget::setupGui()
"So that they can be opened with an editor or sent in a mail body. "
"This will increase file size by one third."));
mAutoDecryptVerifyCB = new QCheckBox(i18n("Automatically start operation based on input detection for decrypt/verify."));
mTmpDirCB = new QCheckBox(i18n("Create temporary decrypted files in the folder of the encrypted file."));
mTmpDirCB->setToolTip(i18nc("@info", "Set this option to avoid using the users temporary directory."));
fileGrpLay->addWidget(mPGPFileExtCB);
fileGrpLay->addWidget(mAutoDecryptVerifyCB);
fileGrpLay->addWidget(mASCIIArmorCB);
fileGrpLay->addWidget(mTmpDirCB);
QGridLayout *comboLay = new QGridLayout;
QLabel *chkLabel = new QLabel(i18n("Checksum program to use when creating checksum files:"));
......@@ -250,6 +254,7 @@ void CryptoOperationsConfigWidget::setupGui()
comboLay->addWidget(mArchiveDefinitionCB, 1, 1);
fileGrpLay->addLayout(comboLay);
fileGrp->setLayout(fileGrpLay);
baseLay->addWidget(fileGrp);
......@@ -273,6 +278,7 @@ void CryptoOperationsConfigWidget::setupGui()
connect(mPGPFileExtCB, &QCheckBox::toggled, this, &CryptoOperationsConfigWidget::changed);
connect(mAutoDecryptVerifyCB, &QCheckBox::toggled, this, &CryptoOperationsConfigWidget::changed);
connect(mASCIIArmorCB, &QCheckBox::toggled, this, &CryptoOperationsConfigWidget::changed);
connect(mTmpDirCB, &QCheckBox::toggled, this, &CryptoOperationsConfigWidget::changed);
}
CryptoOperationsConfigWidget::~CryptoOperationsConfigWidget() {}
......@@ -311,6 +317,7 @@ void CryptoOperationsConfigWidget::load()
mPGPFileExtCB->setChecked(filePrefs.usePGPFileExt());
mAutoDecryptVerifyCB->setChecked(filePrefs.autoDecryptVerify());
mASCIIArmorCB->setChecked(filePrefs.addASCIIArmor());
mTmpDirCB->setChecked(filePrefs.dontUseTmpDir());
const std::vector< std::shared_ptr<ChecksumDefinition> > cds = ChecksumDefinition::getChecksumDefinitions();
const std::shared_ptr<ChecksumDefinition> default_cd = ChecksumDefinition::getDefaultChecksumDefinition(cds);
......@@ -357,6 +364,7 @@ void CryptoOperationsConfigWidget::save()
filePrefs.setUsePGPFileExt(mPGPFileExtCB->isChecked());
filePrefs.setAutoDecryptVerify(mAutoDecryptVerifyCB->isChecked());
filePrefs.setAddASCIIArmor(mASCIIArmorCB->isChecked());
filePrefs.setDontUseTmpDir(mTmpDirCB->isChecked());
const int idx = mChecksumDefinitionCB->currentIndex();
if (idx >= 0) {
......
......@@ -69,7 +69,8 @@ private:
*mQuickSignCB,
*mPGPFileExtCB,
*mAutoDecryptVerifyCB,
*mASCIIArmorCB;
*mASCIIArmorCB,
*mTmpDirCB;
QComboBox *mChecksumDefinitionCB,
*mArchiveDefinitionCB;
};
......
......@@ -36,6 +36,8 @@
#include "autodecryptverifyfilescontroller.h"
#include "fileoperationspreferences.h"
#include <crypto/gui/decryptverifyoperationwidget.h>
#include <crypto/gui/decryptverifyfilesdialog.h>
#include <crypto/decryptverifytask.h>
......@@ -76,7 +78,10 @@ class AutoDecryptVerifyFilesController::Private
AutoDecryptVerifyFilesController *const q;
public:
explicit Private(AutoDecryptVerifyFilesController *qq);
~Private() { qCDebug(KLEOPATRA_LOG); }
~Private() {
qCDebug(KLEOPATRA_LOG);
delete m_workDir;
}
void slotDialogCanceled();
void schedule();
......@@ -107,13 +112,14 @@ public:
bool m_errorDetected;
DecryptVerifyOperation m_operation;
DecryptVerifyFilesDialog *m_dialog;
QTemporaryDir m_workDir;
QTemporaryDir *m_workDir;
};
AutoDecryptVerifyFilesController::Private::Private(AutoDecryptVerifyFilesController *qq) : q(qq),
m_errorDetected(false),
m_operation(DecryptVerify),
m_dialog(nullptr)
m_dialog(nullptr),
m_workDir(nullptr)
{
qRegisterMetaType<VerificationResult>();
}
......@@ -173,7 +179,8 @@ void AutoDecryptVerifyFilesController::Private::exec()
QTimer::singleShot(0, q, SLOT(schedule()));
if (m_dialog->exec() == QDialog::Accepted) {
const QDir workdir(m_workDir.path());
Q_ASSERT(m_workDir);
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);
......@@ -411,7 +418,19 @@ std::vector< std::shared_ptr<Task> > AutoDecryptVerifyFilesController::Private::
const auto ad = q->pick_archive_definition(cFile.protocol, archiveDefinitions, cFile.fileName);
const auto wd = QDir(m_workDir.path());
if (FileOperationsPreferences().dontUseTmpDir()) {
m_workDir = new QTemporaryDir(heuristicBaseDirectory(fileNames) + "/kleopatra-XXXXXX");
if (!m_workDir->isValid()) {
qCDebug(KLEOPATRA_LOG) << m_workDir->path() << "not a valid temporary directory.";
delete m_workDir;
m_workDir = new QTemporaryDir();
}
} else {
m_workDir = new QTemporaryDir();
}
qCDebug(KLEOPATRA_LOG) << "Using:" << m_workDir->path() << "as temporary directory.";
const auto wd = QDir(m_workDir->path());
const auto output =
ad ? ad->createOutputFromUnpackCommand(cFile.protocol, cFile.fileName, wd) :
......
......@@ -26,5 +26,10 @@
<whatsthis>Set this option to encode encrypted or signed files as base64 encoded text. So that they can be opened with an editor or sent in a mail body. This will increase file size by one third.</whatsthis>
<default>false</default>
</entry>
<entry name="DontUseTmpDir" key="dont-use-tmp-dir" type="Bool">
<label>Create temporary decrypted files in the folder of the encrypted file.</label>
<whatsthis>Set this option to avoid using the users temporary directory.</whatsthis>
<default>false</default>
</entry>
</group>
</kcfg>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment