summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRagnar Thomsen <rthomsen6@gmail.com>2016-11-27 15:26:02 (GMT)
committerRagnar Thomsen <rthomsen6@gmail.com>2016-11-27 15:29:13 (GMT)
commita188149abf80140955ec66275bffe8d4e912b172 (patch)
tree47b086824537ae50a10e90b3c3c26a2ec4d0ce11
parent3d9e4dcd4832fe80ec6432ed9202efb5a6f0c239 (diff)
Improve ordering of encryption methods
The encryptions methods in CreateDialog were re-ordered so the strongest is at the top. This necessitated changing the EncryptionMethod field in the plugin json files from a map to an array, because QVariantMaps are always sorted by key. Differential Revision: D3520
-rw-r--r--kerfuffle/archiveformat.cpp12
-rw-r--r--kerfuffle/archiveformat.h6
-rw-r--r--kerfuffle/cliproperties.cpp4
-rw-r--r--kerfuffle/compressionoptionswidget.cpp2
-rw-r--r--plugins/cli7zplugin/kerfuffle_cli7z.json.cmake22
-rw-r--r--plugins/clirarplugin/kerfuffle_clirar.json.cmake20
-rw-r--r--plugins/clizipplugin/kerfuffle_clizip.json.cmake10
7 files changed, 41 insertions, 35 deletions
diff --git a/kerfuffle/archiveformat.cpp b/kerfuffle/archiveformat.cpp
index 7960d41..87090e3 100644
--- a/kerfuffle/archiveformat.cpp
+++ b/kerfuffle/archiveformat.cpp
@@ -45,7 +45,7 @@ ArchiveFormat::ArchiveFormat(const QMimeType& mimeType,
bool supportsMultiVolume,
const QVariantMap& compressionMethods,
const QString& defaultCompressionMethod,
- const QVariantMap &encryptionMethods,
+ const QStringList &encryptionMethods,
const QString &defaultEncryptionMethod) :
m_mimeType(mimeType),
m_encryptionType(encryptionType),
@@ -83,7 +83,13 @@ ArchiveFormat ArchiveFormat::fromMetadata(const QMimeType& mimeType, const KPlug
QVariantMap compressionMethods = formatProps[QStringLiteral("CompressionMethods")].toObject().toVariantMap();
QString defaultCompMethod = formatProps[QStringLiteral("CompressionMethodDefault")].toString();
- QVariantMap encryptionMethods = formatProps[QStringLiteral("EncryptionMethods")].toObject().toVariantMap();
+ // We use a QStringList instead of QVariantMap for encryption methods, to
+ // allow arbitrary ordering of the items.
+ QStringList encryptionMethods;
+ QJsonArray array = formatProps[QStringLiteral("EncryptionMethods")].toArray();
+ foreach (const QJsonValue &value, array) {
+ encryptionMethods.append(value.toString());
+ }
QString defaultEncMethod = formatProps[QStringLiteral("EncryptionMethodDefault")].toString();
Archive::EncryptionType encType = Archive::Unencrypted;
@@ -160,7 +166,7 @@ QString ArchiveFormat::defaultCompressionMethod() const
return m_defaultCompressionMethod;
}
-QVariantMap ArchiveFormat::encryptionMethods() const
+QStringList ArchiveFormat::encryptionMethods() const
{
return m_encryptionMethods;
}
diff --git a/kerfuffle/archiveformat.h b/kerfuffle/archiveformat.h
index 457fdd0..f04c449 100644
--- a/kerfuffle/archiveformat.h
+++ b/kerfuffle/archiveformat.h
@@ -47,7 +47,7 @@ public:
bool suppportsMultiVolume,
const QVariantMap& compressionMethods,
const QString& defaultCompressionMethod,
- const QVariantMap &encryptionMethods,
+ const QStringList &encryptionMethods,
const QString &defaultEncryptionMethod);
/**
@@ -73,7 +73,7 @@ public:
bool supportsMultiVolume() const;
QVariantMap compressionMethods() const;
QString defaultCompressionMethod() const;
- QVariantMap encryptionMethods() const;
+ QStringList encryptionMethods() const;
QString defaultEncryptionMethod() const;
private:
@@ -87,7 +87,7 @@ private:
bool m_supportsMultiVolume = false;
QVariantMap m_compressionMethods;
QString m_defaultCompressionMethod;
- QVariantMap m_encryptionMethods;
+ QStringList m_encryptionMethods;
QString m_defaultEncryptionMethod;
};
diff --git a/kerfuffle/cliproperties.cpp b/kerfuffle/cliproperties.cpp
index 726d754..6503b87 100644
--- a/kerfuffle/cliproperties.cpp
+++ b/kerfuffle/cliproperties.cpp
@@ -263,9 +263,9 @@ QString CliProperties::substituteEncryptionMethodSwitch(const QString &method) c
return QString();
}
- QString cliMethod = format.encryptionMethods().value(method).toString();
+ Q_ASSERT(format.encryptionMethods().contains(method));
- encMethodSwitch.replace(QLatin1String("$EncryptionMethod"), cliMethod);
+ encMethodSwitch.replace(QLatin1String("$EncryptionMethod"), method);
return encMethodSwitch;
}
diff --git a/kerfuffle/compressionoptionswidget.cpp b/kerfuffle/compressionoptionswidget.cpp
index 1b4f7a5..a7c137e 100644
--- a/kerfuffle/compressionoptionswidget.cpp
+++ b/kerfuffle/compressionoptionswidget.cpp
@@ -122,7 +122,7 @@ void CompressionOptionsWidget::updateWidgets()
collapsibleEncryption->setToolTip(QString());
encMethodComboBox->clear();
- encMethodComboBox->insertItems(0, archiveFormat.encryptionMethods().keys());
+ encMethodComboBox->insertItems(0, archiveFormat.encryptionMethods());
if (!m_opts.encryptionMethod().isEmpty() &&
encMethodComboBox->findText(m_opts.encryptionMethod()) > -1) {
diff --git a/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake b/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake
index f34a41f..2a69338 100644
--- a/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake
+++ b/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake
@@ -12,7 +12,7 @@
"Name[es]": "Complemento de archivo 7zip",
"Name[et]": "7zip arhiivi plugin",
"Name[fi]": "7zip-pakkaustuki",
- "Name[fr]": "Module externe d'archive « 7zip »",
+ "Name[fr]": "Module externe d'archive « 7zip »",
"Name[gl]": "Complemento de arquivo de 7zip",
"Name[he]": "תוסף ארכיוני 7zip",
"Name[it]": "Estensione per archivi 7zip",
@@ -61,9 +61,9 @@
"PPMd": "PPMd"
},
"EncryptionMethodDefault": "AES256",
- "EncryptionMethods": {
- "AES256": "AES256"
- },
+ "EncryptionMethods": [
+ "AES256"
+ ],
"HeaderEncryption": true,
"SupportsMultiVolume": true,
"SupportsTesting": true
@@ -83,13 +83,13 @@
},
"Encryption": true,
"EncryptionMethodDefault": "AES256",
- "EncryptionMethods": {
- "AES128": "AES128",
- "AES192": "AES192",
- "AES256": "AES256",
- "ZipCrypto": "ZipCrypto"
- },
+ "EncryptionMethods": [
+ "AES256",
+ "AES192",
+ "AES128",
+ "ZipCrypto"
+ ],
"SupportsMultiVolume": true,
"SupportsTesting": true
}
-} \ No newline at end of file
+}
diff --git a/plugins/clirarplugin/kerfuffle_clirar.json.cmake b/plugins/clirarplugin/kerfuffle_clirar.json.cmake
index 34ba891..4685bc3 100644
--- a/plugins/clirarplugin/kerfuffle_clirar.json.cmake
+++ b/plugins/clirarplugin/kerfuffle_clirar.json.cmake
@@ -12,7 +12,7 @@
"Name[es]": "Complemento de archivo RAR",
"Name[et]": "RAR-arhiivi plugin",
"Name[fi]": "RAR-pakkaustuki",
- "Name[fr]": "Module externe d'archive « RAR »",
+ "Name[fr]": "Module externe d'archive « RAR »",
"Name[gl]": "Complemento de arquivo RAR",
"Name[he]": "תוסף ארכיוני RAR",
"Name[it]": "Estensione per archivi RAR",
@@ -58,10 +58,10 @@
"RAR5": "5"
},
"EncryptionMethodDefault": "AES128",
- "EncryptionMethods": {
- "AES128": "AES128",
- "AES256": "AES256"
- },
+ "EncryptionMethods": [
+ "AES128",
+ "AES256"
+ ],
"HeaderEncryption": true,
"SupportsMultiVolume": true,
"SupportsTesting": true,
@@ -77,13 +77,13 @@
"RAR5": "5"
},
"EncryptionMethodDefault": "AES128",
- "EncryptionMethods": {
- "AES128": "AES128",
- "AES256": "AES256"
- },
+ "EncryptionMethods": [
+ "AES128",
+ "AES256"
+ ],
"HeaderEncryption": true,
"SupportsMultiVolume": true,
"SupportsTesting": true,
"SupportsWriteComment": true
}
-} \ No newline at end of file
+}
diff --git a/plugins/clizipplugin/kerfuffle_clizip.json.cmake b/plugins/clizipplugin/kerfuffle_clizip.json.cmake
index 50d65e7..8ddbf92 100644
--- a/plugins/clizipplugin/kerfuffle_clizip.json.cmake
+++ b/plugins/clizipplugin/kerfuffle_clizip.json.cmake
@@ -12,7 +12,7 @@
"Name[es]": "Complemento de archivo ZIP",
"Name[et]": "ZIP-arhiivi plugin",
"Name[fi]": "ZIP-pakkaustuki",
- "Name[fr]": "Module externe d'archive « zip »",
+ "Name[fr]": "Module externe d'archive « zip »",
"Name[gl]": "Complemento de arquivo ZIP",
"Name[he]": "תוסף ארכיוני ZIP",
"Name[it]": "Estensione per archivi ZIP",
@@ -67,9 +67,9 @@
},
"Encryption": true,
"EncryptionMethodDefault": "ZipCrypto",
- "EncryptionMethods": {
- "ZipCrypto": "ZipCrypto"
- },
+ "EncryptionMethods": [
+ "ZipCrypto"
+ ],
"SupportsTesting": true
}
-} \ No newline at end of file
+}