Commit 9a9a8510 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Add support for application/vnd.rar, fixes opening RAR with shared-mime-info 1.7

shared-mime-info 1.7 introduced the official IANA mimetype
`application/vnd.rar` and degraded `application/x-rar` to alias.

For now we need to register both mimetypes. Once distributions start
shipping shared-mime-info 1.7, we can drop the alias.

For this reason, we cannot have a reliable test case in mimetypetest.
Also, in `PluginLoader::sortByComment()` we need to check whether
mimetypes are valid, because `application/vnd.rar` might not be in
`QMimeDatabase()`.

BUG: 368786
FIXED-IN: 16.08.2

Closes T3729
parent 7dbd6e9d
......@@ -79,8 +79,8 @@ void AddDialogTest::testBasicWidgets_data()
qDebug() << "7z format not available, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-rar"))) {
QTest::newRow("rar") << QStringLiteral("application/x-rar") << true << 2 << 5;
if (writeMimeTypes.contains(QStringLiteral("application/vnd.rar"))) {
QTest::newRow("rar") << QStringLiteral("application/vnd.rar") << true << 2 << 5;
} else {
qDebug() << "rar format not available, skipping test.";
}
......
......@@ -153,7 +153,7 @@ void AddToArchiveTest::testCompressHere_data()
qDebug() << "7z/zip executable not found in path. Skipping compress-here-(ZIP) tests.";
}
if (!PluginManager().preferredWritePluginsFor(QMimeDatabase().mimeTypeForName(QStringLiteral("application/x-rar"))).isEmpty()) {
if (!PluginManager().preferredWritePluginsFor(QMimeDatabase().mimeTypeForName(QStringLiteral("application/vnd.rar"))).isEmpty()) {
QTest::newRow("compress here (as RAR) - dir with files")
<< QStringLiteral("rar")
<< QStringList {QFINDTESTDATA("data/testdir")}
......
......@@ -78,8 +78,8 @@ void CreateDialogTest::testBasicWidgets_data()
qDebug() << "7z format not available in CreateDialog, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-rar"))) {
QTest::newRow("rar") << QStringLiteral("application/x-rar");
if (writeMimeTypes.contains(QStringLiteral("application/vnd.rar"))) {
QTest::newRow("rar") << QStringLiteral("application/vnd.rar");
} else {
qDebug() << "rar format not available in CreateDialog, skipping test.";
}
......@@ -133,8 +133,8 @@ void CreateDialogTest::testEncryption_data()
qDebug() << "7z format not available in CreateDialog, skipping test.";
}
if (m_pluginManager.supportedWriteMimeTypes().contains(QStringLiteral("application/x-rar"))) {
QTest::newRow("rar") << QStringLiteral("application/x-rar") << true << true;
if (m_pluginManager.supportedWriteMimeTypes().contains(QStringLiteral("application/vnd.rar"))) {
QTest::newRow("rar") << QStringLiteral("application/vnd.rar") << true << true;
} else {
qDebug() << "rar format not available in CreateDialog, skipping test.";
}
......
......@@ -199,7 +199,9 @@ QStringList PluginManager::sortByComment(const QSet<QString> &mimeTypes)
// Initialize the QMap to sort by comment.
foreach (const QString &mimeType, mimeTypes) {
QMimeType mime(QMimeDatabase().mimeTypeForName(mimeType));
map[mime.comment().toLower()] = mime.name();
if (mime.isValid()) {
map[mime.comment().toLower()] = mime.name();
}
}
// Convert to sorted QStringList.
......
########### next target ###############
set(SUPPORTED_CLIRAR_MIMETYPES "application/x-rar;")
# TODO: drop application/x-rar alias once distributions ship shared-mime-info 1.7
set(SUPPORTED_CLIRAR_MIMETYPES "application/vnd.rar;application/x-rar;")
set(kerfuffle_clirar_SRCS cliplugin.cpp)
......@@ -9,7 +10,11 @@ ecm_qt_declare_logging_category(kerfuffle_clirar_SRCS
IDENTIFIER ARK
CATEGORY_NAME ark.clirar)
set(SUPPORTED_MIMETYPES "application/x-rar")
# NOTE: the first double-quotes of the first mime and the last
# double-quotes of the last mime must NOT be escaped.
set(SUPPORTED_MIMETYPES
"application/vnd.rar\",
\"application/x-rar")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/kerfuffle_clirar.json.cmake
......
......@@ -45,6 +45,15 @@
"rar"
],
"X-KDE-Priority": 120,
"application/vnd.rar": {
"CompressionLevelDefault": 3,
"CompressionLevelMax": 5,
"CompressionLevelMin": 0,
"SupportsWriteComment": true,
"SupportsTesting": true,
"HeaderEncryption": true,
"SupportsMultiVolume": true
},
"application/x-rar": {
"CompressionLevelDefault": 3,
"CompressionLevelMax": 5,
......
########### next target ###############
set(SUPPORTED_CLIUNARCHIVER_MIMETYPES "application/x-rar;")
# TODO: drop application/x-rar alias once distributions ship shared-mime-info 1.7
set(SUPPORTED_CLIUNARCHIVER_MIMETYPES "application/vnd.rar;application/x-rar;")
set(kerfuffle_cliunarchiver_SRCS cliplugin.cpp)
......@@ -9,7 +10,11 @@ ecm_qt_declare_logging_category(kerfuffle_cliunarchiver_SRCS
IDENTIFIER ARK
CATEGORY_NAME ark.cliunarchiver)
set(SUPPORTED_MIMETYPES "application/x-rar")
# NOTE: the first double-quotes of the first mime and the last
# double-quotes of the last mime must NOT be escaped.
set(SUPPORTED_MIMETYPES
"application/vnd.rar\",
\"application/x-rar")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/kerfuffle_cliunarchiver.json.cmake
......
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