Changeset View
Changeset View
Standalone View
Standalone View
kerfuffle/archiveformat.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 38 | ArchiveFormat::ArchiveFormat(const QMimeType& mimeType, | |||
---|---|---|---|---|---|
60 | m_encryptionMethods(encryptionMethods), | 60 | m_encryptionMethods(encryptionMethods), | ||
61 | m_defaultEncryptionMethod(defaultEncryptionMethod) | 61 | m_defaultEncryptionMethod(defaultEncryptionMethod) | ||
62 | { | 62 | { | ||
63 | } | 63 | } | ||
64 | 64 | | |||
65 | ArchiveFormat ArchiveFormat::fromMetadata(const QMimeType& mimeType, const KPluginMetaData& metadata) | 65 | ArchiveFormat ArchiveFormat::fromMetadata(const QMimeType& mimeType, const KPluginMetaData& metadata) | ||
66 | { | 66 | { | ||
67 | const QJsonObject json = metadata.rawData(); | 67 | const QJsonObject json = metadata.rawData(); | ||
68 | foreach (const QString& mime, metadata.mimeTypes()) { | 68 | const QStringList mimeTypes = metadata.mimeTypes(); | ||
69 | for (const QString& mime : mimeTypes) { | ||||
69 | if (mimeType.name() != mime) { | 70 | if (mimeType.name() != mime) { | ||
70 | continue; | 71 | continue; | ||
71 | } | 72 | } | ||
72 | 73 | | |||
73 | const QJsonObject formatProps = json[mime].toObject(); | 74 | const QJsonObject formatProps = json[mime].toObject(); | ||
74 | 75 | | |||
75 | int minCompLevel = formatProps[QStringLiteral("CompressionLevelMin")].toInt(); | 76 | int minCompLevel = formatProps[QStringLiteral("CompressionLevelMin")].toInt(); | ||
76 | int maxCompLevel = formatProps[QStringLiteral("CompressionLevelMax")].toInt(); | 77 | int maxCompLevel = formatProps[QStringLiteral("CompressionLevelMax")].toInt(); | ||
77 | int defaultCompLevel = formatProps[QStringLiteral("CompressionLevelDefault")].toInt(); | 78 | int defaultCompLevel = formatProps[QStringLiteral("CompressionLevelDefault")].toInt(); | ||
78 | 79 | | |||
79 | bool supportsWriteComment = formatProps[QStringLiteral("SupportsWriteComment")].toBool(); | 80 | bool supportsWriteComment = formatProps[QStringLiteral("SupportsWriteComment")].toBool(); | ||
80 | bool supportsTesting = formatProps[QStringLiteral("SupportsTesting")].toBool(); | 81 | bool supportsTesting = formatProps[QStringLiteral("SupportsTesting")].toBool(); | ||
81 | bool supportsMultiVolume = formatProps[QStringLiteral("SupportsMultiVolume")].toBool(); | 82 | bool supportsMultiVolume = formatProps[QStringLiteral("SupportsMultiVolume")].toBool(); | ||
82 | 83 | | |||
83 | QVariantMap compressionMethods = formatProps[QStringLiteral("CompressionMethods")].toObject().toVariantMap(); | 84 | QVariantMap compressionMethods = formatProps[QStringLiteral("CompressionMethods")].toObject().toVariantMap(); | ||
84 | QString defaultCompMethod = formatProps[QStringLiteral("CompressionMethodDefault")].toString(); | 85 | QString defaultCompMethod = formatProps[QStringLiteral("CompressionMethodDefault")].toString(); | ||
85 | 86 | | |||
86 | // We use a QStringList instead of QVariantMap for encryption methods, to | 87 | // We use a QStringList instead of QVariantMap for encryption methods, to | ||
87 | // allow arbitrary ordering of the items. | 88 | // allow arbitrary ordering of the items. | ||
88 | QStringList encryptionMethods; | 89 | QStringList encryptionMethods; | ||
89 | QJsonArray array = formatProps[QStringLiteral("EncryptionMethods")].toArray(); | 90 | const QJsonArray array = formatProps[QStringLiteral("EncryptionMethods")].toArray(); | ||
90 | foreach (const QJsonValue &value, array) { | 91 | for (const QJsonValue &value : array) { | ||
91 | encryptionMethods.append(value.toString()); | 92 | encryptionMethods.append(value.toString()); | ||
92 | } | 93 | } | ||
93 | QString defaultEncMethod = formatProps[QStringLiteral("EncryptionMethodDefault")].toString(); | 94 | QString defaultEncMethod = formatProps[QStringLiteral("EncryptionMethodDefault")].toString(); | ||
94 | 95 | | |||
95 | Archive::EncryptionType encType = Archive::Unencrypted; | 96 | Archive::EncryptionType encType = Archive::Unencrypted; | ||
96 | if (formatProps[QStringLiteral("HeaderEncryption")].toBool()) { | 97 | if (formatProps[QStringLiteral("HeaderEncryption")].toBool()) { | ||
97 | encType = Archive::HeaderEncrypted; | 98 | encType = Archive::HeaderEncrypted; | ||
98 | } else if (formatProps[QStringLiteral("Encryption")].toBool()) { | 99 | } else if (formatProps[QStringLiteral("Encryption")].toBool()) { | ||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |