From d5095d74f84e105b66f7f7d58816f3bc0599a737 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 21 Apr 2014 16:39:54 +0200 Subject: [PATCH] Simplified file verification code quite a bit. --- src/encoder_x265.cpp | 2 +- src/model_sysinfo.h | 1 - src/version.h | 2 +- src/win_addJob.cpp | 8 ------- src/win_main.cpp | 54 ++++++++++---------------------------------- src/win_updater.cpp | 38 +++++++++++-------------------- src/win_updater.h | 9 ++++++++ 7 files changed, 36 insertions(+), 78 deletions(-) diff --git a/src/encoder_x265.cpp b/src/encoder_x265.cpp index 3113193..6e896ea 100644 --- a/src/encoder_x265.cpp +++ b/src/encoder_x265.cpp @@ -33,7 +33,7 @@ //x265 version info static const unsigned int VERSION_X265_MINIMUM_VER = 9; -static const unsigned int VERSION_X265_MINIMUM_REV = 68; +static const unsigned int VERSION_X265_MINIMUM_REV = 70; // ------------------------------------------------------------ // Helper Macros diff --git a/src/model_sysinfo.h b/src/model_sysinfo.h index 7ad9558..ac76e2e 100644 --- a/src/model_sysinfo.h +++ b/src/model_sysinfo.h @@ -71,7 +71,6 @@ public: SYSINFO_MAKE_FLAG(SSE, 0x00000004) SYSINFO_MAKE_FLAG(AVS, 0x00000008) SYSINFO_MAKE_FLAG(VPS, 0x00000010) - SYSINFO_MAKE_FLAG(256, 0x00000020) SYSINFO_MAKE_PATH(VPS) SYSINFO_MAKE_PATH(App) diff --git a/src/version.h b/src/version.h index 98ff590..5735110 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 3 #define VER_X264_PATCH 7 -#define VER_X264_BUILD 850 +#define VER_X264_BUILD 851 #define VER_X264_PORTABLE_EDITION (0) diff --git a/src/win_addJob.cpp b/src/win_addJob.cpp index 9f5f38b..1d043a2 100644 --- a/src/win_addJob.cpp +++ b/src/win_addJob.cpp @@ -479,14 +479,6 @@ void AddJobDialog::modeIndexChanged(int index) void AddJobDialog::accept(void) { - //Check x265 support - if((ui->cbxEncoderType->currentIndex() == OptionsModel::EncType_X265) && (!m_sysinfo->has256Support())) - { - QMessageBox::warning(this, tr("x265 unsupported"), tr("Sorry, the x265 encoder is not currently available on this computer!
Please see the Readme file on how to obtain and install x265...
")); - ui->cbxEncoderType->setCurrentIndex(OptionsModel::EncType_X264); - return; - } - //Check 64-Bit support if((ui->cbxEncoderArch->currentIndex() == OptionsModel::EncArch_x64) && (!m_sysinfo->hasX64Support())) { diff --git a/src/win_main.cpp b/src/win_main.cpp index 05bfea1..1d73f41 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -766,12 +766,22 @@ void MainWindow::init(void) QStringList binFiles; for(OptionsModel::EncArch arch = OptionsModel::EncArch_x32; arch <= OptionsModel::EncArch_x64; NEXT(arch)) { - for(OptionsModel::EncVariant varnt = OptionsModel::EncVariant_LoBit; varnt <= OptionsModel::EncVariant_HiBit; NEXT(varnt)) + for(OptionsModel::EncType encdr = OptionsModel::EncType_X264; encdr <= OptionsModel::EncType_X265; NEXT(encdr)) { - binFiles << ENC_BINARY(m_sysinfo, OptionsModel::EncType_X264, arch, varnt); + for(OptionsModel::EncVariant varnt = OptionsModel::EncVariant_LoBit; varnt <= OptionsModel::EncVariant_HiBit; NEXT(varnt)) + { + binFiles << ENC_BINARY(m_sysinfo, encdr, arch, varnt); + } } binFiles << AVS_BINARY(m_sysinfo, arch == OptionsModel::EncArch_x64); } + for(size_t i = 0; UpdaterDialog::BINARIES[i].name; i++) + { + if(UpdaterDialog::BINARIES[i].exec) + { + binFiles << QString("%1/toolset/common/%2").arg(m_sysinfo->getAppPath(), QString::fromLatin1(UpdaterDialog::BINARIES[i].name)); + } + } qDebug("[Validating binaries]"); for(QStringList::ConstIterator iter = binFiles.constBegin(); iter != binFiles.constEnd(); iter++) @@ -799,46 +809,6 @@ void MainWindow::init(void) } } qDebug(" "); - - //--------------------------------------- - // Check x265 binaries - //--------------------------------------- - - binFiles.clear(); - for(OptionsModel::EncArch arch = OptionsModel::EncArch_x32; arch <= OptionsModel::EncArch_x64; NEXT(arch)) - { - for(OptionsModel::EncVariant varnt = OptionsModel::EncVariant_LoBit; varnt <= OptionsModel::EncVariant_HiBit; NEXT(varnt)) - { - binFiles << ENC_BINARY(m_sysinfo, OptionsModel::EncType_X265, arch, varnt); - } - } - - qDebug("[Checking for x265 support]"); - bool bHaveX265 = true; - for(QStringList::ConstIterator iter = binFiles.constBegin(); iter != binFiles.constEnd(); iter++) - { - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - QFile *file = new QFile(*iter); - qDebug("%s", file->fileName().toLatin1().constData()); - if(file->open(QIODevice::ReadOnly)) - { - if(x264_is_executable(file->fileName())) - { - m_toolsList << file; - continue; - } - X264_DELETE(file); - } - bHaveX265 = false; - qWarning("x265 binaries not found or incomplete -> disable x265 support!"); - break; - } - if(bHaveX265) - { - qDebug("x265 support is officially enabled now!"); - m_sysinfo->set256Support(true); - } - qDebug(" "); //--------------------------------------- // Check for portable mode diff --git a/src/win_updater.cpp b/src/win_updater.cpp index 945cc38..2b130f6 100644 --- a/src/win_updater.cpp +++ b/src/win_updater.cpp @@ -40,15 +40,18 @@ /////////////////////////////////////////////////////////////////////////////// +const UpdaterDialog::binary_t UpdaterDialog::BINARIES[] = +{ + { "wget.exe", "7b522345239bcb95b5b0f7f50a883ba5957894a1feb769763e38ed789a8a0f63fead0155f54b9ffd0f1cdc5dfd855d207a6e7a8e4fd192589a8838ce646c504e", 1 }, + { "gpgv.exe", "b42b7ef5650cd78d92773f03d4eefc90d9ba6ffe6af19d389851e32b5ab1c58c91c3dfceb2cbe0d0d13774ee2cf100c20f0add7f33463229999da5aaa861f064", 1 }, + { "gpgv.gpg", "58e0f0e462bbd0b5aa4f638801c1097da7da4b3eb38c8c88ad1db23705c0f11e174b083fa55fe76bd3ba196341c967833a6f3427d6f63ad8565900745535d8fa", 0 }, + { "wupd.exe", "e8ee5fb11e4964c0091311a41b46e2ea49cf675755ee830c38a26027c81aecc78842c25facc0ac6b797586e4c4b22ac116dd1735b0b11b67c13e4a17fb1e5f5e", 1 }, + { NULL, NULL, 0 } +}; + #define UPDATE_TEXT(N, TEXT) ui->label_phase##N->setText((TEXT)) #define UPDATE_ICON(N, ICON) ui->icon_phase##N->setPixmap(QIcon(":/buttons/" ICON ".png").pixmap(16, 16)) -/* -ui->labelLoadingLeft->setVisible((FLAG)); \ -ui->labelLoadingCenter->setVisible((FLAG)); \ -ui->labelLoadingRight->setVisible((FLAG)); \ -*/ - #define SHOW_ANIMATION(FLAG) do \ { \ ui->frameAnimation->setVisible((FLAG)); \ @@ -453,21 +456,6 @@ void UpdaterDialog::installUpdate(void) bool UpdaterDialog::checkBinaries(QString &wgetBin, QString &gpgvBin) { qDebug("[File Verification]"); - - static struct - { - const char* name; - const char* hash; - } - FILE_INFO[] = - { - { "wget.exe", "7b522345239bcb95b5b0f7f50a883ba5957894a1feb769763e38ed789a8a0f63fead0155f54b9ffd0f1cdc5dfd855d207a6e7a8e4fd192589a8838ce646c504e" }, - { "gpgv.exe", "b42b7ef5650cd78d92773f03d4eefc90d9ba6ffe6af19d389851e32b5ab1c58c91c3dfceb2cbe0d0d13774ee2cf100c20f0add7f33463229999da5aaa861f064" }, - { "gpgv.gpg", "58e0f0e462bbd0b5aa4f638801c1097da7da4b3eb38c8c88ad1db23705c0f11e174b083fa55fe76bd3ba196341c967833a6f3427d6f63ad8565900745535d8fa" }, - { "wupd.exe", "e8ee5fb11e4964c0091311a41b46e2ea49cf675755ee830c38a26027c81aecc78842c25facc0ac6b797586e4c4b22ac116dd1735b0b11b67c13e4a17fb1e5f5e" }, - { NULL, NULL } - }; - QMap binaries; m_keysFile.clear(); @@ -477,12 +465,12 @@ bool UpdaterDialog::checkBinaries(QString &wgetBin, QString &gpgvBin) bool okay = true; - for(size_t i = 0; FILE_INFO[i].name; i++) + for(size_t i = 0; BINARIES[i].name; i++) { - const QString binPath = QString("%1/toolset/common/%2").arg(m_sysinfo->getAppPath(), QString::fromLatin1(FILE_INFO[i].name)); - if(okay = okay && checkFileHash(binPath, FILE_INFO[i].hash)) + const QString binPath = QString("%1/toolset/common/%2").arg(m_sysinfo->getAppPath(), QString::fromLatin1(BINARIES[i].name)); + if(okay = okay && checkFileHash(binPath, BINARIES[i].hash)) { - binaries.insert(FILE_INFO[i].name, binPath); + binaries.insert(BINARIES[i].name, binPath); } QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); } diff --git a/src/win_updater.h b/src/win_updater.h index 1668695..58332e5 100644 --- a/src/win_updater.h +++ b/src/win_updater.h @@ -40,7 +40,16 @@ public: UpdaterDialog(QWidget *parent, const SysinfoModel *sysinfo, const char *const updateUrl); ~UpdaterDialog(void); + typedef struct + { + const char* name; + const char* hash; + const bool exec; + } + binary_t; + static const int READY_TO_INSTALL_UPDATE = 42; + static const binary_t BINARIES[]; inline bool getSuccess(void) { return m_success; }