diff --git a/kerfuffle/archiveformat.cpp b/kerfuffle/archiveformat.cpp index 7960d41f..87090e32 100644 --- a/kerfuffle/archiveformat.cpp +++ b/kerfuffle/archiveformat.cpp @@ -1,173 +1,179 @@ /* * Copyright (c) 2016 Elvis Angelaccio * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "archiveformat.h" #include "ark_debug.h" #include namespace Kerfuffle { ArchiveFormat::ArchiveFormat() { } ArchiveFormat::ArchiveFormat(const QMimeType& mimeType, Archive::EncryptionType encryptionType, int minCompLevel, int maxCompLevel, int defaultCompLevel, bool supportsWriteComment, bool supportsTesting, bool supportsMultiVolume, const QVariantMap& compressionMethods, const QString& defaultCompressionMethod, - const QVariantMap &encryptionMethods, + const QStringList &encryptionMethods, const QString &defaultEncryptionMethod) : m_mimeType(mimeType), m_encryptionType(encryptionType), m_minCompressionLevel(minCompLevel), m_maxCompressionLevel(maxCompLevel), m_defaultCompressionLevel(defaultCompLevel), m_supportsWriteComment(supportsWriteComment), m_supportsTesting(supportsTesting), m_supportsMultiVolume(supportsMultiVolume), m_compressionMethods(compressionMethods), m_defaultCompressionMethod(defaultCompressionMethod), m_encryptionMethods(encryptionMethods), m_defaultEncryptionMethod(defaultEncryptionMethod) { } ArchiveFormat ArchiveFormat::fromMetadata(const QMimeType& mimeType, const KPluginMetaData& metadata) { const QJsonObject json = metadata.rawData(); foreach (const QString& mime, metadata.mimeTypes()) { if (mimeType.name() != mime) { continue; } const QJsonObject formatProps = json[mime].toObject(); int minCompLevel = formatProps[QStringLiteral("CompressionLevelMin")].toInt(); int maxCompLevel = formatProps[QStringLiteral("CompressionLevelMax")].toInt(); int defaultCompLevel = formatProps[QStringLiteral("CompressionLevelDefault")].toInt(); bool supportsWriteComment = formatProps[QStringLiteral("SupportsWriteComment")].toBool(); bool supportsTesting = formatProps[QStringLiteral("SupportsTesting")].toBool(); bool supportsMultiVolume = formatProps[QStringLiteral("SupportsMultiVolume")].toBool(); 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; if (formatProps[QStringLiteral("HeaderEncryption")].toBool()) { encType = Archive::HeaderEncrypted; } else if (formatProps[QStringLiteral("Encryption")].toBool()) { encType = Archive::Encrypted; } return ArchiveFormat(mimeType, encType, minCompLevel, maxCompLevel, defaultCompLevel, supportsWriteComment, supportsTesting, supportsMultiVolume, compressionMethods, defaultCompMethod, encryptionMethods, defaultEncMethod); } return ArchiveFormat(); } bool ArchiveFormat::isValid() const { return m_mimeType.isValid(); } Archive::EncryptionType ArchiveFormat::encryptionType() const { return m_encryptionType; } int ArchiveFormat::minCompressionLevel() const { return m_minCompressionLevel; } int ArchiveFormat::maxCompressionLevel() const { return m_maxCompressionLevel; } int ArchiveFormat::defaultCompressionLevel() const { return m_defaultCompressionLevel; } bool ArchiveFormat::supportsWriteComment() const { return m_supportsWriteComment; } bool ArchiveFormat::supportsTesting() const { return m_supportsTesting; } bool ArchiveFormat::supportsMultiVolume() const { return m_supportsMultiVolume; } QVariantMap ArchiveFormat::compressionMethods() const { return m_compressionMethods; } QString ArchiveFormat::defaultCompressionMethod() const { return m_defaultCompressionMethod; } -QVariantMap ArchiveFormat::encryptionMethods() const +QStringList ArchiveFormat::encryptionMethods() const { return m_encryptionMethods; } QString ArchiveFormat::defaultEncryptionMethod() const { return m_defaultEncryptionMethod; } } diff --git a/kerfuffle/archiveformat.h b/kerfuffle/archiveformat.h index 457fdd05..f04c449d 100644 --- a/kerfuffle/archiveformat.h +++ b/kerfuffle/archiveformat.h @@ -1,96 +1,96 @@ /* * Copyright (c) 2016 Elvis Angelaccio * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ARCHIVEFORMAT_H #define ARCHIVEFORMAT_H #include "archive_kerfuffle.h" #include namespace Kerfuffle { class KERFUFFLE_EXPORT ArchiveFormat { public: explicit ArchiveFormat(); explicit ArchiveFormat(const QMimeType& mimeType, Kerfuffle::Archive::EncryptionType encryptionType, int minCompLevel, int maxCompLevel, int defaultCompLevel, bool supportsWriteComment, bool supportsTesting, bool suppportsMultiVolume, const QVariantMap& compressionMethods, const QString& defaultCompressionMethod, - const QVariantMap &encryptionMethods, + const QStringList &encryptionMethods, const QString &defaultEncryptionMethod); /** * @return The archive format of the given @p mimeType, according to the given @p metadata. */ static ArchiveFormat fromMetadata(const QMimeType& mimeType, const KPluginMetaData& metadata); /** * @return Whether the format is associated to a valid mimetype. */ bool isValid() const; /** * @return The encryption type supported by the archive format. */ Kerfuffle::Archive::EncryptionType encryptionType() const; int minCompressionLevel() const; int maxCompressionLevel() const; int defaultCompressionLevel() const; bool supportsWriteComment() const; bool supportsTesting() const; bool supportsMultiVolume() const; QVariantMap compressionMethods() const; QString defaultCompressionMethod() const; - QVariantMap encryptionMethods() const; + QStringList encryptionMethods() const; QString defaultEncryptionMethod() const; private: QMimeType m_mimeType; Kerfuffle::Archive::EncryptionType m_encryptionType = Kerfuffle::Archive::Unencrypted; int m_minCompressionLevel = -1; int m_maxCompressionLevel = 0; int m_defaultCompressionLevel = 0; bool m_supportsWriteComment = false; bool m_supportsTesting = false; bool m_supportsMultiVolume = false; QVariantMap m_compressionMethods; QString m_defaultCompressionMethod; - QVariantMap m_encryptionMethods; + QStringList m_encryptionMethods; QString m_defaultEncryptionMethod; }; } #endif // ARCHIVEFORMAT_H diff --git a/kerfuffle/cliproperties.cpp b/kerfuffle/cliproperties.cpp index 726d754b..6503b872 100644 --- a/kerfuffle/cliproperties.cpp +++ b/kerfuffle/cliproperties.cpp @@ -1,361 +1,361 @@ /* * ark -- archiver for the KDE project * * Copyright (C) 2016 Ragnar Thomsen * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "cliproperties.h" #include "ark_debug.h" #include "archiveformat.h" #include "pluginmanager.h" namespace Kerfuffle { CliProperties::CliProperties(QObject *parent, const KPluginMetaData &metaData, const QMimeType &archiveType) : QObject(parent) , m_mimeType(archiveType) , m_metaData(metaData) { } QStringList CliProperties::addArgs(const QString &archive, const QStringList &files, const QString &password, bool headerEncryption, int compressionLevel, const QString &compressionMethod, const QString &encryptionMethod, uint volumeSize) { if (!encryptionMethod.isEmpty()) { Q_ASSERT(!password.isEmpty()); } QStringList args; foreach (const QString &s, m_addSwitch) { args << s; } if (!password.isEmpty()) { args << substitutePasswordSwitch(password, headerEncryption); } if (compressionLevel > -1) { args << substituteCompressionLevelSwitch(compressionLevel); } if (!compressionMethod.isEmpty()) { args << substituteCompressionMethodSwitch(compressionMethod); } if (!encryptionMethod.isEmpty()) { args << substituteEncryptionMethodSwitch(encryptionMethod); } if (volumeSize > 0) { args << substituteMultiVolumeSwitch(volumeSize); } args << archive; args << files; args.removeAll(QString()); return args; } QStringList CliProperties::commentArgs(const QString &archive, const QString &commentfile) { QStringList args; foreach (const QString &s, substituteCommentSwitch(commentfile)) { args << s; } args << archive; args.removeAll(QString()); return args; } QStringList CliProperties::deleteArgs(const QString &archive, const QVector &files, const QString &password) { QStringList args; args << m_deleteSwitch; if (!password.isEmpty()) { args << substitutePasswordSwitch(password); } args << archive; foreach (const Archive::Entry *e, files) { args << e->fullPath(NoTrailingSlash); } args.removeAll(QString()); return args; } QStringList CliProperties::extractArgs(const QString &archive, const QStringList &files, bool preservePaths, const QString &password) { QStringList args; if (preservePaths && !m_extractSwitch.isEmpty()) { args << m_extractSwitch; } else if (!preservePaths && !m_extractSwitchNoPreserve.isEmpty()) { args << m_extractSwitchNoPreserve; } if (!password.isEmpty()) { args << substitutePasswordSwitch(password); } args << archive; args << files; args.removeAll(QString()); return args; } QStringList CliProperties::listArgs(const QString &archive, const QString &password) { QStringList args; foreach (const QString &s, m_listSwitch) { args << s; } if (!password.isEmpty()) { args << substitutePasswordSwitch(password); } args << archive; args.removeAll(QString()); return args; } QStringList CliProperties::moveArgs(const QString &archive, const QVector &entries, Archive::Entry *destination, const QString &password) { QStringList args; args << m_moveSwitch; if (!password.isEmpty()) { args << substitutePasswordSwitch(password); } args << archive; if (entries.count() > 1) { foreach (const Archive::Entry *file, entries) { args << file->fullPath(NoTrailingSlash) << destination->fullPath() + file->name(); } } else { args << entries.at(0)->fullPath(NoTrailingSlash) << destination->fullPath(NoTrailingSlash); } args.removeAll(QString()); return args; } QStringList CliProperties::testArgs(const QString &archive, const QString &password) { QStringList args; foreach (const QString &s, m_testSwitch) { args << s; } if (!password.isEmpty()) { args << substitutePasswordSwitch(password); } args << archive; args.removeAll(QString()); return args; } QStringList CliProperties::substituteCommentSwitch(const QString &commentfile) const { Q_ASSERT(!commentfile.isEmpty()); Q_ASSERT(ArchiveFormat::fromMetadata(m_mimeType, m_metaData).supportsWriteComment()); QStringList commentSwitches = m_commentSwitch; Q_ASSERT(!commentSwitches.isEmpty()); QMutableListIterator i(commentSwitches); while (i.hasNext()) { i.next(); i.value().replace(QLatin1String("$CommentFile"), commentfile); } return commentSwitches; } QStringList CliProperties::substitutePasswordSwitch(const QString &password, bool headerEnc) const { if (password.isEmpty()) { return QStringList(); } Archive::EncryptionType encryptionType = ArchiveFormat::fromMetadata(m_mimeType, m_metaData).encryptionType(); Q_ASSERT(encryptionType != Archive::EncryptionType::Unencrypted); QStringList passwordSwitch; if (headerEnc) { passwordSwitch = m_passwordSwitchHeaderEnc; } else { passwordSwitch = m_passwordSwitch; } Q_ASSERT(!passwordSwitch.isEmpty()); QMutableListIterator i(passwordSwitch); while (i.hasNext()) { i.next(); i.value().replace(QLatin1String("$Password"), password); } return passwordSwitch; } QString CliProperties::substituteCompressionLevelSwitch(int level) const { if (level < 0 || level > 9) { return QString(); } Q_ASSERT(ArchiveFormat::fromMetadata(m_mimeType, m_metaData).maxCompressionLevel() != -1); QString compLevelSwitch = m_compressionLevelSwitch; Q_ASSERT(!compLevelSwitch.isEmpty()); compLevelSwitch.replace(QLatin1String("$CompressionLevel"), QString::number(level)); return compLevelSwitch; } QString CliProperties::substituteCompressionMethodSwitch(const QString &method) const { if (method.isEmpty()) { return QString(); } Q_ASSERT(!ArchiveFormat::fromMetadata(m_mimeType, m_metaData).compressionMethods().isEmpty()); QString compMethodSwitch = m_compressionMethodSwitch[m_mimeType.name()].toString(); Q_ASSERT(!compMethodSwitch.isEmpty()); QString cliMethod = ArchiveFormat::fromMetadata(m_mimeType, m_metaData).compressionMethods().value(method).toString(); compMethodSwitch.replace(QLatin1String("$CompressionMethod"), cliMethod); return compMethodSwitch; } QString CliProperties::substituteEncryptionMethodSwitch(const QString &method) const { if (method.isEmpty()) { return QString(); } const ArchiveFormat format = ArchiveFormat::fromMetadata(m_mimeType, m_metaData); Q_ASSERT(!format.encryptionMethods().isEmpty()); QString encMethodSwitch = m_encryptionMethodSwitch[m_mimeType.name()].toString(); if (encMethodSwitch.isEmpty()) { 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; } QString CliProperties::substituteMultiVolumeSwitch(uint volumeSize) const { // The maximum value we allow in the QDoubleSpinBox is 1000MB. Converted to // KB this is 1024000. if (volumeSize <= 0 || volumeSize > 1024000) { return QString(); } Q_ASSERT(ArchiveFormat::fromMetadata(m_mimeType, m_metaData).supportsMultiVolume()); QString multiVolumeSwitch = m_multiVolumeSwitch; Q_ASSERT(!multiVolumeSwitch.isEmpty()); multiVolumeSwitch.replace(QLatin1String("$VolumeSize"), QString::number(volumeSize)); return multiVolumeSwitch; } bool CliProperties::isPasswordPrompt(const QString &line) { foreach(const QString &rx, m_passwordPromptPatterns) { if (QRegularExpression(rx).match(line).hasMatch()) { return true; } } return false; } bool CliProperties::isWrongPasswordMsg(const QString &line) { foreach(const QString &rx, m_wrongPasswordPatterns) { if (QRegularExpression(rx).match(line).hasMatch()) { return true; } } return false; } bool CliProperties::isTestPassedMsg(const QString &line) { foreach(const QString &rx, m_testPassedPatterns) { if (QRegularExpression(rx).match(line).hasMatch()) { return true; } } return false; } bool CliProperties::isfileExistsMsg(const QString &line) { foreach(const QString &rx, m_fileExistsPatterns) { if (QRegularExpression(rx).match(line).hasMatch()) { return true; } } return false; } bool CliProperties::isFileExistsFileName(const QString &line) { foreach(const QString &rx, m_fileExistsFileName) { if (QRegularExpression(rx).match(line).hasMatch()) { return true; } } return false; } bool CliProperties::isCorruptArchiveMsg(const QString &line) { foreach(const QString &rx, m_corruptArchivePatterns) { if (QRegularExpression(rx).match(line).hasMatch()) { return true; } } return false; } bool CliProperties::isDiskFullMsg(const QString &line) { foreach(const QString &rx, m_diskFullPatterns) { if (QRegularExpression(rx).match(line).hasMatch()) { return true; } } return false; } } diff --git a/kerfuffle/compressionoptionswidget.cpp b/kerfuffle/compressionoptionswidget.cpp index 1b4f7a5e..a7c137e0 100644 --- a/kerfuffle/compressionoptionswidget.cpp +++ b/kerfuffle/compressionoptionswidget.cpp @@ -1,301 +1,301 @@ /* * ark -- archiver for the KDE project * * Copyright (C) 2016 Ragnar Thomsen * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "compressionoptionswidget.h" #include "ark_debug.h" #include "archiveformat.h" #include "pluginmanager.h" #include "settings.h" #include #include #include namespace Kerfuffle { CompressionOptionsWidget::CompressionOptionsWidget(QWidget *parent, const CompressionOptions &opts) : QWidget(parent) , m_opts(opts) { setupUi(this); KColorScheme colorScheme(QPalette::Active, KColorScheme::View); pwdWidget->setBackgroundWarningColor(colorScheme.background(KColorScheme::NegativeBackground).color()); pwdWidget->setPasswordStrengthMeterVisible(false); connect(multiVolumeCheckbox, &QCheckBox::stateChanged, this, &CompressionOptionsWidget::slotMultiVolumeChecked); connect(compMethodComboBox, &QComboBox::currentTextChanged, this, &CompressionOptionsWidget::slotCompMethodChanged); connect(encMethodComboBox, &QComboBox::currentTextChanged, this, &CompressionOptionsWidget::slotEncryptionMethodChanged); if (m_opts.isVolumeSizeSet()) { multiVolumeCheckbox->setChecked(true); // Convert from kilobytes. volumeSizeSpinbox->setValue(static_cast(m_opts.volumeSize()) / 1024); } warningMsgWidget->setWordWrap(true); } CompressionOptions CompressionOptionsWidget::commpressionOptions() const { CompressionOptions opts; opts.setCompressionLevel(compLevelSlider->value()); if (multiVolumeCheckbox->isChecked()) { opts.setVolumeSize(volumeSize()); } if (!compMethodComboBox->currentText().isEmpty()) { opts.setCompressionMethod(compMethodComboBox->currentText()); } return opts; } int CompressionOptionsWidget::compressionLevel() const { if (compLevelSlider->isEnabled()) { return compLevelSlider->value(); } else { return -1; } } QString CompressionOptionsWidget::compressionMethod() const { return compMethodComboBox->currentText(); } ulong CompressionOptionsWidget::volumeSize() const { if (collapsibleMultiVolume->isEnabled() && multiVolumeCheckbox->isChecked()) { // Convert to kilobytes. return volumeSizeSpinbox->value() * 1024; } else { return 0; } } void CompressionOptionsWidget::setEncryptionVisible(bool visible) { collapsibleEncryption->setVisible(visible); } QString CompressionOptionsWidget::password() const { return pwdWidget->password(); } void CompressionOptionsWidget::updateWidgets() { const KPluginMetaData metadata = PluginManager().preferredPluginFor(m_mimetype)->metaData(); const ArchiveFormat archiveFormat = ArchiveFormat::fromMetadata(m_mimetype, metadata); Q_ASSERT(archiveFormat.isValid()); if (archiveFormat.encryptionType() != Archive::Unencrypted) { collapsibleEncryption->setEnabled(true); 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) { encMethodComboBox->setCurrentText(m_opts.encryptionMethod()); } else { encMethodComboBox->setCurrentText(archiveFormat.defaultEncryptionMethod()); } if (!archiveFormat.encryptionMethods().isEmpty()) { lblEncMethod->setEnabled(true); encMethodComboBox->setEnabled(true); } pwdWidget->setEnabled(true); if (archiveFormat.encryptionType() == Archive::HeaderEncrypted) { encryptHeaderCheckBox->setEnabled(true); encryptHeaderCheckBox->setToolTip(QString()); } else { encryptHeaderCheckBox->setEnabled(false); // Show the tooltip only if the encryption is still enabled. // This is needed because if the new filter is e.g. tar, the whole encryption group gets disabled. if (collapsibleEncryption->isEnabled() && collapsibleEncryption->isExpanded()) { encryptHeaderCheckBox->setToolTip(i18n("Protection of the list of files is not possible with the %1 format.", m_mimetype.comment())); } else { encryptHeaderCheckBox->setToolTip(QString()); } } } else { collapsibleEncryption->setEnabled(false); collapsibleEncryption->setToolTip(i18n("Protection of the archive with password is not possible with the %1 format.", m_mimetype.comment())); lblEncMethod->setEnabled(false); encMethodComboBox->setEnabled(false); encMethodComboBox->clear(); pwdWidget->setEnabled(false); encryptHeaderCheckBox->setToolTip(QString()); } collapsibleCompression->setEnabled(true); if (archiveFormat.maxCompressionLevel() == 0) { compLevelSlider->setEnabled(false); lblCompLevel1->setEnabled(false); lblCompLevel2->setEnabled(false); lblCompLevel3->setEnabled(false); compLevelSlider->setToolTip(i18n("It is not possible to set compression level for the %1 format.", m_mimetype.comment())); } else { compLevelSlider->setEnabled(true); lblCompLevel1->setEnabled(true); lblCompLevel2->setEnabled(true); lblCompLevel3->setEnabled(true); compLevelSlider->setToolTip(QString()); compLevelSlider->setMinimum(archiveFormat.minCompressionLevel()); compLevelSlider->setMaximum(archiveFormat.maxCompressionLevel()); if (m_opts.isCompressionLevelSet()) { compLevelSlider->setValue(m_opts.compressionLevel()); } else { compLevelSlider->setValue(archiveFormat.defaultCompressionLevel()); } } if (archiveFormat.compressionMethods().isEmpty()) { lblCompMethod->setEnabled(false); compMethodComboBox->setEnabled(false); compMethodComboBox->setToolTip(i18n("It is not possible to set compression method for the %1 format.", m_mimetype.comment())); compMethodComboBox->clear(); } else { lblCompMethod->setEnabled(true); compMethodComboBox->setEnabled(true); compMethodComboBox->setToolTip(QString()); compMethodComboBox->clear(); compMethodComboBox->insertItems(0, archiveFormat.compressionMethods().keys()); if (!m_opts.compressionMethod().isEmpty() && compMethodComboBox->findText(m_opts.compressionMethod()) > -1) { compMethodComboBox->setCurrentText(m_opts.compressionMethod()); } else { compMethodComboBox->setCurrentText(archiveFormat.defaultCompressionMethod()); } } collapsibleCompression->setEnabled(compLevelSlider->isEnabled() || compMethodComboBox->isEnabled()); if (archiveFormat.supportsMultiVolume()) { collapsibleMultiVolume->setEnabled(true); collapsibleMultiVolume->setToolTip(QString()); } else { collapsibleMultiVolume->setEnabled(false); collapsibleMultiVolume->setToolTip(i18n("The %1 format does not support multi-volume archives.", m_mimetype.comment())); } } void CompressionOptionsWidget::setMimeType(const QMimeType &mimeType) { m_mimetype = mimeType; updateWidgets(); } bool CompressionOptionsWidget::isEncryptionAvailable() const { return collapsibleEncryption->isEnabled(); } bool CompressionOptionsWidget::isEncryptionEnabled() const { return isEncryptionAvailable() && collapsibleEncryption->isExpanded(); } bool CompressionOptionsWidget::isHeaderEncryptionAvailable() const { return isEncryptionEnabled() && encryptHeaderCheckBox->isEnabled(); } bool CompressionOptionsWidget::isHeaderEncryptionEnabled() const { return isHeaderEncryptionAvailable() && encryptHeaderCheckBox->isChecked(); } KNewPasswordWidget::PasswordStatus CompressionOptionsWidget::passwordStatus() const { return pwdWidget->passwordStatus(); } QString CompressionOptionsWidget::encryptionMethod() const { if (encMethodComboBox->isEnabled() && encMethodComboBox->count() > 1 && !password().isEmpty()) { return encMethodComboBox->currentText(); } return QString(); } void CompressionOptionsWidget::slotMultiVolumeChecked(int state) { if (state == Qt::Checked) { lblVolumeSize->setEnabled(true); volumeSizeSpinbox->setEnabled(true); } else { lblVolumeSize->setEnabled(false); volumeSizeSpinbox->setEnabled(false); } } void CompressionOptionsWidget::slotCompMethodChanged(const QString &value) { // This hack is needed for the RAR format because the available encryption // method is dependent on the selected compression method. Rar uses AES128 // for RAR4 format and AES256 for RAR5 format. if (m_mimetype == QMimeDatabase().mimeTypeForName(QStringLiteral("application/vnd.rar")) || m_mimetype == QMimeDatabase().mimeTypeForName(QStringLiteral("application/x-rar"))) { encMethodComboBox->clear(); if (value == QLatin1String("RAR4")) { encMethodComboBox->insertItem(0, QStringLiteral("AES128")); } else { encMethodComboBox->insertItem(0, QStringLiteral("AES256")); } } } void CompressionOptionsWidget::slotEncryptionMethodChanged(const QString &value) { if (value.isEmpty() || m_mimetype != QMimeDatabase().mimeTypeForName(QStringLiteral("application/zip"))) { warningMsgWidget->hide(); return; } // AES encryption is not supported by unzip, warn the users if they are creating a zip. warningMsgWidget->setVisible(value != QLatin1String("ZipCrypto") && ArkSettings::showEncryptionWarning()); } } diff --git a/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake b/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake index f34a41f0..2a69338f 100644 --- a/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake +++ b/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake @@ -1,95 +1,95 @@ { "KPlugin": { "Id": "kerfuffle_cli7z", "MimeTypes": [ "@SUPPORTED_MIMETYPES@" ], "Name": "7zip archive plugin", "Name[ca@valencia]": "Connector per arxius 7zip", "Name[ca]": "Connector per arxius 7zip", "Name[cs]": "Modul pro archiv 7zip", "Name[de]": "7zip-Archiv-Modul", "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", "Name[nb]": "Programtillegg for 7zip-arkiv", "Name[nl]": "7zip-archiefplug-in", "Name[nn]": "7zip-arkivtillegg", "Name[pl]": "Wtyczka archiwów 7zip", "Name[pt]": "'Plugin' de pacotes 7zip", "Name[pt_BR]": "Plugin de arquivos 7zip", "Name[ru]": "Поддержка архивов 7zip", "Name[sk]": "Modul 7zip archívu", "Name[sl]": "Vstavek za arhive 7zip", "Name[sr@ijekavian]": "Прикључак 7зип архива", "Name[sr@ijekavianlatin]": "Priključak 7zip arhiva", "Name[sr@latin]": "Priključak 7zip arhiva", "Name[sr]": "Прикључак 7зип архива", "Name[sv]": "Insticksprogram för 7zip-arkiv", "Name[uk]": "Додаток для архівів 7zip", "Name[x-test]": "xx7zip archive pluginxx", "Name[zh_CN]": "7zip 归档插件", "Name[zh_TW]": "7zip 壓縮檔外掛程式", "ServiceTypes": [ "Kerfuffle/Plugin" ], "Version": "@KDE_APPLICATIONS_VERSION@" }, "X-KDE-Kerfuffle-ReadOnlyExecutables": [ "7z" ], "X-KDE-Kerfuffle-ReadWrite": true, "X-KDE-Kerfuffle-ReadWriteExecutables": [ "7z" ], "X-KDE-Priority": 180, "application/x-7z-compressed": { "CompressionLevelDefault": 5, "CompressionLevelMax": 9, "CompressionLevelMin": 0, "CompressionMethodDefault": "LZMA2", "CompressionMethods": { "BZip2": "BZip2", "Copy": "Copy", "Deflate": "Deflate", "LZMA": "LZMA", "LZMA2": "LZMA2", "PPMd": "PPMd" }, "EncryptionMethodDefault": "AES256", - "EncryptionMethods": { - "AES256": "AES256" - }, + "EncryptionMethods": [ + "AES256" + ], "HeaderEncryption": true, "SupportsMultiVolume": true, "SupportsTesting": true }, "application/zip": { "CompressionLevelDefault": 5, "CompressionLevelMax": 9, "CompressionLevelMin": 0, "CompressionMethodDefault": "Deflate", "CompressionMethods": { "BZip2": "BZip2", "Copy": "Copy", "Deflate": "Deflate", "Deflate64": "Deflate64", "LZMA": "LZMA", "PPMd": "PPMd" }, "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 34ba8916..4685bc39 100644 --- a/plugins/clirarplugin/kerfuffle_clirar.json.cmake +++ b/plugins/clirarplugin/kerfuffle_clirar.json.cmake @@ -1,89 +1,89 @@ { "KPlugin": { "Id": "kerfuffle_clirar", "MimeTypes": [ "@SUPPORTED_MIMETYPES@" ], "Name": "RAR archive plugin", "Name[ca@valencia]": "Connector per arxius RAR", "Name[ca]": "Connector per arxius RAR", "Name[cs]": "Modul pro archiv RAR", "Name[de]": "RAR-Archiv-Modul", "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", "Name[ja]": "RAR アーカイブ用プラグイン", "Name[nb]": "Programtillegg for RAR-arkiv", "Name[nl]": "RAR-archiefplug-in", "Name[nn]": "RAR-arkivtillegg", "Name[pl]": "Wtyczka archiwów RAR", "Name[pt]": "'Plugin' de pacotes RAR", "Name[pt_BR]": "Plugin de arquivos RAR", "Name[ru]": "Поддержка архивов RAR", "Name[sk]": "Modul RAR archívu", "Name[sl]": "Vstavek za arhive RAR", "Name[sr@ijekavian]": "Прикључак РАР архива", "Name[sr@ijekavianlatin]": "Priključak RAR arhiva", "Name[sr@latin]": "Priključak RAR arhiva", "Name[sr]": "Прикључак РАР архива", "Name[sv]": "Insticksprogram för RAR-arkiv", "Name[uk]": "Додаток для архівів RAR", "Name[x-test]": "xxRAR archive pluginxx", "Name[zh_CN]": "RAR 归档插件", "Name[zh_TW]": "RAR 壓縮檔外掛程式", "ServiceTypes": [ "Kerfuffle/Plugin" ], "Version": "@KDE_APPLICATIONS_VERSION@" }, "X-KDE-Kerfuffle-ReadOnlyExecutables": [ "unrar" ], "X-KDE-Kerfuffle-ReadWrite": true, "X-KDE-Kerfuffle-ReadWriteExecutables": [ "rar" ], "X-KDE-Priority": 120, "application/vnd.rar": { "CompressionLevelDefault": 3, "CompressionLevelMax": 5, "CompressionLevelMin": 0, "CompressionMethodDefault": "RAR4", "CompressionMethods": { "RAR4": "4", "RAR5": "5" }, "EncryptionMethodDefault": "AES128", - "EncryptionMethods": { - "AES128": "AES128", - "AES256": "AES256" - }, + "EncryptionMethods": [ + "AES128", + "AES256" + ], "HeaderEncryption": true, "SupportsMultiVolume": true, "SupportsTesting": true, "SupportsWriteComment": true }, "application/x-rar": { "CompressionLevelDefault": 3, "CompressionLevelMax": 5, "CompressionLevelMin": 0, "CompressionMethodDefault": "RAR4", "CompressionMethods": { "RAR4": "4", "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 50d65e75..8ddbf924 100644 --- a/plugins/clizipplugin/kerfuffle_clizip.json.cmake +++ b/plugins/clizipplugin/kerfuffle_clizip.json.cmake @@ -1,75 +1,75 @@ { "KPlugin": { "Id": "kerfuffle_clizip", "MimeTypes": [ "@SUPPORTED_MIMETYPES@" ], "Name": "ZIP archive plugin", "Name[ca@valencia]": "Connector per arxius ZIP", "Name[ca]": "Connector per arxius ZIP", "Name[cs]": "Modul pro archiv ZIP", "Name[de]": "ZIP-Archiv-Modul", "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", "Name[nb]": "Programtillegg for ZIP-arkiv", "Name[nl]": "ZIP-archiefplug-in", "Name[nn]": "ZIP-arkivtillegg", "Name[pl]": "Wtyczka archiwów ZIP", "Name[pt]": "'Plugin' de pacotes ZIP", "Name[pt_BR]": "Plugin de arquivos ZIP", "Name[ru]": "Поддержка архивов ZIP", "Name[sk]": "Modul ZIP archívu", "Name[sl]": "Vstavek za arhive ZIP", "Name[sr@ijekavian]": "Прикључак ЗИП архива", "Name[sr@ijekavianlatin]": "Priključak ZIP arhiva", "Name[sr@latin]": "Priključak ZIP arhiva", "Name[sr]": "Прикључак ЗИП архива", "Name[sv]": "Insticksprogram för ZIP-arkiv", "Name[uk]": "Додаток для архівів ZIP", "Name[x-test]": "xxZIP archive pluginxx", "Name[zh_CN]": "ZIP 归档插件", "Name[zh_TW]": "ZIP 壓縮檔外掛程式", "ServiceTypes": [ "Kerfuffle/Plugin" ], "Version": "@KDE_APPLICATIONS_VERSION@" }, "X-KDE-Kerfuffle-ReadOnlyExecutables": [ "zipinfo", "unzip" ], "X-KDE-Kerfuffle-ReadWrite": true, "X-KDE-Kerfuffle-ReadWriteExecutables": [ "zip" ], "X-KDE-Priority": 160, "application/x-java-archive": { "CompressionLevelDefault": 6, "CompressionLevelMax": 9, "CompressionLevelMin": 0, "Encryption": true, "SupportsTesting": true }, "application/zip": { "CompressionLevelDefault": 6, "CompressionLevelMax": 9, "CompressionLevelMin": 0, "CompressionMethodDefault": "Deflate", "CompressionMethods": { "BZip2": "bzip2", "Deflate": "deflate", "Store": "store" }, "Encryption": true, "EncryptionMethodDefault": "ZipCrypto", - "EncryptionMethods": { - "ZipCrypto": "ZipCrypto" - }, + "EncryptionMethods": [ + "ZipCrypto" + ], "SupportsTesting": true } -} \ No newline at end of file +}