summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-08-05 11:08:00 (GMT)
committerAndre Heinecke <aheinecke@intevation.de>2016-08-05 11:08:00 (GMT)
commit448617fbfe0a612d141533d43dcaf3b26753d61b (patch)
tree052f5851174469eff872ccc3d504a83ff377c546
parentab451eafcf37b31da8f5bd883631f1d7f3344177 (diff)
Fix sigencpage validation
Show warning again for opaque archive signatures and don't show warning about own encryption key when encryption is not selected.
-rw-r--r--src/crypto/gui/signencryptfileswizard.cpp54
-rw-r--r--src/crypto/gui/signencryptfileswizard.h2
-rw-r--r--src/crypto/signencryptfilescontroller.cpp8
3 files changed, 38 insertions, 26 deletions
diff --git a/src/crypto/gui/signencryptfileswizard.cpp b/src/crypto/gui/signencryptfileswizard.cpp
index 3857b9d..b2c3466 100644
--- a/src/crypto/gui/signencryptfileswizard.cpp
+++ b/src/crypto/gui/signencryptfileswizard.cpp
@@ -65,27 +65,6 @@ enum Page {
NumPages
};
-/*
-FIXME: Either show this warning or fix detached signatures for archives.
- bool validatePage() Q_DECL_OVERRIDE {
- if (isSignOnlySelected() && isArchiveRequested())
- return KMessageBox::warningContinueCancel(this,
- xi18nc("@info",
- "<para>Archiving in combination with sign-only currently requires what are known as opaque signatures - "
- "unlike detached ones, these embed the content in the signature.</para>"
- "<para>This format is rather unusual. You might want to archive the files separately, "
- "and then sign the archive as one file with Kleopatra.</para>"
- "<para>Future versions of Kleopatra are expected to also support detached signatures in this case.</para>"),
- i18nc("@title:window", "Unusual Signature Warning"),
- KStandardGuiItem::cont(), KStandardGuiItem::cancel(),
- QStringLiteral("signencryptfileswizard-archive+sign-only-warning"))
- == KMessageBox::Continue;
- else {
- return true;
- }
- }
-*/
-
class SigEncPage: public QWizardPage
{
Q_OBJECT
@@ -94,7 +73,8 @@ public:
explicit SigEncPage(QWidget *parent = Q_NULLPTR)
: QWizardPage(parent),
mWidget(new SignEncryptWidget),
- mOutLayout(new QVBoxLayout)
+ mOutLayout(new QVBoxLayout),
+ mArchive(false)
{
setTitle(i18nc("@title", "Sign / Encrypt Files"));
auto vLay = new QVBoxLayout(this);
@@ -132,8 +112,32 @@ public:
setCommitPage(true);
}
+ void setArchiveForced(bool archive)
+ {
+ mArchive = archive;
+ }
+
bool validatePage() Q_DECL_OVERRIDE
{
+ bool sign = !mWidget->signKey().isNull();
+ bool encrypt = !mWidget->selfKey().isNull() || !mWidget->recipients().empty();
+
+ if (sign && !encrypt && mArchive) {
+ return KMessageBox::warningContinueCancel(this,
+ xi18nc("@info",
+ "<para>Archiving in combination with sign-only currently requires what are known as opaque signatures - "
+ "unlike detached ones, these embed the content in the signature.</para>"
+ "<para>This format is rather unusual. You might want to archive the files separately, "
+ "and then sign the archive as one file with Kleopatra.</para>"
+ "<para>Future versions of Kleopatra are expected to also support detached signatures in this case.</para>"),
+ i18nc("@title:window", "Unusual Signature Warning"),
+ KStandardGuiItem::cont(), KStandardGuiItem::cancel(),
+ QStringLiteral("signencryptfileswizard-archive+sign-only-warning"))
+ == KMessageBox::Continue;
+ } else if (sign && !encrypt) {
+ return true;
+ }
+
if (!mWidget->selfKey().isNull()) {
return true;
}
@@ -277,6 +281,7 @@ private:
QMap <int, QWidget *> mRequester;
QVBoxLayout *mOutLayout;
QWidget *mPlaceholderWidget;
+ bool mArchive;
};
class ResultPage : public NewResultPage
@@ -352,6 +357,11 @@ void SignEncryptFilesWizard::setEncryptionUserMutable(bool mut)
mEncryptionUserMutable = mut;
}
+void SignEncryptFilesWizard::setArchiveForced(bool archive)
+{
+ mSigEncPage->setArchiveForced(archive);
+}
+
QVector<Key> SignEncryptFilesWizard::resolvedRecipients() const
{
return mSigEncPage->recipients();
diff --git a/src/crypto/gui/signencryptfileswizard.h b/src/crypto/gui/signencryptfileswizard.h
index 4468b24..7a97c2c 100644
--- a/src/crypto/gui/signencryptfileswizard.h
+++ b/src/crypto/gui/signencryptfileswizard.h
@@ -88,6 +88,8 @@ public:
void setEncryptionPreset(bool preset);
void setEncryptionUserMutable(bool mut);
+ void setArchiveForced(bool archive);
+
void setOutputNames(const QMap<int, QString> &nameMap) const;
QMap<int, QString> outputNames() const;
diff --git a/src/crypto/signencryptfilescontroller.cpp b/src/crypto/signencryptfilescontroller.cpp
index d0e3e58..60827a5 100644
--- a/src/crypto/signencryptfilescontroller.cpp
+++ b/src/crypto/signencryptfilescontroller.cpp
@@ -225,9 +225,6 @@ void SignEncryptFilesController::Private::assertValidOperation(unsigned int op)
void SignEncryptFilesController::setOperationMode(unsigned int mode)
{
Private::assertValidOperation(mode);
- if (contains_dir(d->files)) {
- mode = (mode & ~ArchiveMask) | ArchiveForced;
- }
d->operation = mode;
d->updateWizardMode();
}
@@ -240,6 +237,7 @@ void SignEncryptFilesController::Private::updateWizardMode()
wizard->setWindowTitle(titleForOperation(operation));
const unsigned int signOp = (operation & SignMask);
const unsigned int encrOp = (operation & EncryptMask);
+ const unsigned int archOp = (operation & ArchiveMask);
if (signOp == SignDisallowed) {
wizard->setSigningUserMutable(false);
@@ -264,6 +262,8 @@ void SignEncryptFilesController::Private::updateWizardMode()
wizard->setEncryptionPreset(true);
}
}
+
+ wizard->setArchiveForced(archOp == ArchiveForced);
}
unsigned int SignEncryptFilesController::operationMode() const
@@ -332,7 +332,7 @@ void SignEncryptFilesController::setFiles(const QStringList &files)
{
kleo_assert(!files.empty());
d->files = files;
- if (contains_dir(files)) {
+ if (contains_dir(files) || files.size() > 1) {
setOperationMode((operationMode() & ~ArchiveMask) | ArchiveForced);
}
d->ensureWizardCreated();