diff options
| author | JosJuice <josjuice@gmail.com> | 2019-08-23 13:20:09 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2019-08-24 16:37:19 +0200 |
| commit | 22933d85020b0b1f4ff285fbfdfca940f52fe1c3 (patch) | |
| tree | 137070ef9f8ccbaa1ca85bb6b056159624c2cf69 /Source/Core/DolphinQt/Config/VerifyWidget.cpp | |
| parent | 88522b7a26bf189dc8122a1b951f2a76eec77c86 (diff) | |
VolumeVerifier: Add datfile parsing
Diffstat (limited to 'Source/Core/DolphinQt/Config/VerifyWidget.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/Config/VerifyWidget.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/Source/Core/DolphinQt/Config/VerifyWidget.cpp b/Source/Core/DolphinQt/Config/VerifyWidget.cpp index 488343fc76..f688c38932 100644 --- a/Source/Core/DolphinQt/Config/VerifyWidget.cpp +++ b/Source/Core/DolphinQt/Config/VerifyWidget.cpp @@ -29,6 +29,7 @@ VerifyWidget::VerifyWidget(std::shared_ptr<DiscIO::Volume> volume) : m_volume(st layout->addWidget(m_problems); layout->addWidget(m_summary_text); layout->addLayout(m_hash_layout); + layout->addLayout(m_redump_layout); layout->addWidget(m_verify_button); layout->setStretchFactor(m_problems, 5); @@ -55,8 +56,21 @@ void VerifyWidget::CreateWidgets() std::tie(m_md5_checkbox, m_md5_line_edit) = AddHashLine(m_hash_layout, tr("MD5:")); std::tie(m_sha1_checkbox, m_sha1_line_edit) = AddHashLine(m_hash_layout, tr("SHA-1:")); + m_redump_layout = new QFormLayout; + if (DiscIO::IsDisc(m_volume->GetVolumeType())) + { + std::tie(m_redump_checkbox, m_redump_line_edit) = + AddHashLine(m_redump_layout, tr("Redump.org Status:")); + } + else + { + m_redump_checkbox = nullptr; + m_redump_line_edit = nullptr; + } + // Extend line edits to their maximum possible widths (needed on macOS) m_hash_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); + m_redump_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); m_verify_button = new QPushButton(tr("Verify Integrity"), this); } @@ -80,6 +94,9 @@ std::pair<QCheckBox*, QLineEdit*> VerifyWidget::AddHashLine(QFormLayout* layout, void VerifyWidget::ConnectWidgets() { connect(m_verify_button, &QPushButton::clicked, this, &VerifyWidget::Verify); + + connect(m_md5_checkbox, &QCheckBox::stateChanged, this, &VerifyWidget::UpdateRedumpEnabled); + connect(m_sha1_checkbox, &QCheckBox::stateChanged, this, &VerifyWidget::UpdateRedumpEnabled); } static void SetHash(QLineEdit* line_edit, const std::vector<u8>& hash) @@ -89,10 +106,25 @@ static void SetHash(QLineEdit* line_edit, const std::vector<u8>& hash) line_edit->setText(QString::fromLatin1(byte_array.toHex())); } +bool VerifyWidget::CanVerifyRedump() const +{ + // We don't allow Redump verification with CRC32 only since generating a collision is too easy + return m_md5_checkbox->isChecked() || m_sha1_checkbox->isChecked(); +} + +void VerifyWidget::UpdateRedumpEnabled() +{ + if (m_redump_checkbox) + m_redump_checkbox->setEnabled(CanVerifyRedump()); +} + void VerifyWidget::Verify() { + const bool redump_verification = + CanVerifyRedump() && m_redump_checkbox && m_redump_checkbox->isChecked(); + DiscIO::VolumeVerifier verifier( - *m_volume, + *m_volume, redump_verification, {m_crc32_checkbox->isChecked(), m_md5_checkbox->isChecked(), m_sha1_checkbox->isChecked()}); // We have to divide the number of processed bytes with something so it won't make ints overflow @@ -147,6 +179,9 @@ void VerifyWidget::Verify() SetHash(m_crc32_line_edit, result.hashes.crc32); SetHash(m_md5_line_edit, result.hashes.md5); SetHash(m_sha1_line_edit, result.hashes.sha1); + + if (m_redump_line_edit) + m_redump_line_edit->setText(QString::fromStdString(result.redump.message)); } void VerifyWidget::SetProblemCellText(int row, int column, QString text) |
