Commit 448617fb authored by Andre Heinecke's avatar Andre Heinecke
Browse files

Fix sigencpage validation

Show warning again for opaque archive signatures and don't
show warning about own encryption key when encryption is not selected.
parent ab451eaf
......@@ -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();
......
......@@ -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;
......
......@@ -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();
......
Supports Markdown
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