Simplified file verification code quite a bit.

This commit is contained in:
LoRd_MuldeR 2014-04-21 16:39:54 +02:00
parent 10e5b33b06
commit d5095d74f8
7 changed files with 36 additions and 78 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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("<nobr>Sorry, the x265 encoder is <b>not</b> currently available on this computer!<br>Please see the Readme file on how to obtain and install x265...</nobr>"));
ui->cbxEncoderType->setCurrentIndex(OptionsModel::EncType_X264);
return;
}
//Check 64-Bit support
if((ui->cbxEncoderArch->currentIndex() == OptionsModel::EncArch_x64) && (!m_sysinfo->hasX64Support()))
{

View File

@ -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

View File

@ -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<QString, QString> 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);
}

View File

@ -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; }