From 24da769a6d39f063e00d0d8646efee66534599f5 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 6 Dec 2010 18:29:34 +0100 Subject: [PATCH] Use a more efficient method to update the progress model when new jobs are added + slightly improve auto updater. --- LameXP.vcproj | 2 +- res/tools/wupdate.exe | Bin 294239 -> 294295 bytes src/Config.h | 2 +- src/Dialog_Update.cpp | 80 ++++++++++++++++++++++++++++------ src/Model_Progress.cpp | 7 ++- src/Thread_Initialization.cpp | 2 +- 6 files changed, 74 insertions(+), 19 deletions(-) diff --git a/LameXP.vcproj b/LameXP.vcproj index d3a2b443..d959f717 100644 --- a/LameXP.vcproj +++ b/LameXP.vcproj @@ -130,7 +130,7 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" OmitFramePointers="true" - AdditionalIncludeDirectories=""$(QTDIR)\include";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"C:\Program Files\Microsoft SDKs\Windows\v7.1"" + AdditionalIncludeDirectories=""$(QTDIR)\include";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui"" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;QT_LARGEFILE_SUPPORT;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_NO_DEBUG" MinimalRebuild="false" BasicRuntimeChecks="0" diff --git a/res/tools/wupdate.exe b/res/tools/wupdate.exe index 18e443c464bdd12dac5b027d94ccd6431f029643..32e517d3bfb37dd5e979a0a9744396e423b89910 100644 GIT binary patch delta 2221 zcmV;e2vYao`Vp7=5rDJ-6uJqlN&oee?u!+mM;;`>1x^!N+zJ1#kb!dv988xe)nB+GU9k6&HZQ8${a zl6=9mw_Y`zTzYIleY7jTMjJHx8VJ4vhW(&A!VH&4FxxG)LRxG2TuYo7n1Gfyh>Sl0 zGXpD@Jb#S7K{m1&wI44ULE`-<8{ekHcd1(z5|FPK%Ig1zvb`LV0DC*=yV-qn9()5- z1!~|86HSOP<oO@9k~-ZLdryQ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|^tM-KHYP_Z~rxL{i0H+VH)xVLC{4>oO0mSHxYT=y%#?Zk z23?_4Ss7^TqUBtFW%mfr3JmIX6_Y!Ia4TcRgUU*nV8Ce1&$!k!pA#iWs8^U_Ks$N- zxhzh3F01X7Ab3g8%X-dByZo?ZBgKp8%4Us-X)*6Ss${k;d3 zBdFNAg)SLM5ZZk<|CfX8E6 zxPZb|^Ys6rkW lQ?g6{`tzIK?-rNuaReQQxWWO4xWWRrxWWV5x&+@`r7tfuFTwx- diff --git a/src/Config.h b/src/Config.h index 457dcb0d..b36838c7 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 124 +#define VER_LAMEXP_BUILD 127 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Dialog_Update.cpp b/src/Dialog_Update.cpp index 949064e5..99ff0657 100644 --- a/src/Dialog_Update.cpp +++ b/src/Dialog_Update.cpp @@ -45,7 +45,7 @@ static const char *section_id = "LameXP"; static const char *mirror_url_postfix = "update_beta.ver"; -static const char *mirrors[] = +static const char *update_mirrors[] = { "http://mulder.dummwiedeutsch.de/", "http://mulder.brhack.net/", @@ -55,6 +55,19 @@ static const char *mirrors[] = NULL }; +static const char *known_hosts[] = +{ + "http://www.example.com/", + "http://www.google.com/", + "http://www.wikipedia.org/", + "http://www.msn.com/", + "http://www.yahoo.com/", + NULL +}; + +static const int MIN_CONNSCORE = 2; +static char *USER_AGENT_STR = "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101101 IceCat/3.6.12 (like Firefox/3.6.12)"; + /////////////////////////////////////////////////////////////////////////////// class UpdateInfo @@ -123,7 +136,6 @@ void UpdateDialog::showEvent(QShowEvent *event) { QDialog::showEvent(event); - statusLabel->setText("Checking for new updates online, please wait..."); labelVersionInstalled->setText(QString("Build %1 (%2)").arg(QString::number(lamexp_version_build()), lamexp_version_date().toString(Qt::ISODate))); labelVersionLatest->setText("(Unknown)"); @@ -136,11 +148,11 @@ void UpdateDialog::showEvent(QShowEvent *event) logButton->hide(); infoLabel->hide(); - for(int i = 0; mirrors[i]; i++) - { - progressBar->setMaximum(i+2); - } + int counter = 2; + for(int i = 0; known_hosts[i]; i++) counter++; + for(int i = 0; update_mirrors[i]; i++) counter++; + progressBar->setMaximum(counter); progressBar->setValue(0); } @@ -160,6 +172,8 @@ void UpdateDialog::updateInit(void) void UpdateDialog::checkForUpdates(void) { bool success = false; + int connectionScore = 0; + m_updateInfo = new UpdateInfo; progressBar->setValue(0); @@ -172,20 +186,59 @@ void UpdateDialog::checkForUpdates(void) QApplication::processEvents(); QApplication::setOverrideCursor(Qt::WaitCursor); + statusLabel->setText("Testing your internet connection, please wait..."); + m_logFile->clear(); + m_logFile->append("Checking internet connection..."); + + for(int i = 0; known_hosts[i]; i++) + { + progressBar->setValue(progressBar->value() + 1); + if(connectionScore < MIN_CONNSCORE) + { + m_logFile->append(QStringList() << "" << "Testing host:" << known_hosts[i] << ""); + QString outFile = QString("%1/%2.htm").arg(QDir::tempPath(), QUuid::createUuid().toString()); + if(getFile(known_hosts[i], outFile)) + { + connectionScore++; + } + QFile::remove(outFile); + } + } + + if(connectionScore < MIN_CONNSCORE) + { + if(!retryButton->isVisible()) retryButton->show(); + if(!logButton->isVisible()) logButton->show(); + closeButton->setEnabled(true); + retryButton->setEnabled(true); + logButton->setEnabled(true); + statusLabel->setText("Connectivity test faild. Please check your internet connection!"); + progressBar->setValue(progressBar->maximum()); + LAMEXP_DELETE(m_updateInfo); + if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); + QApplication::restoreOverrideCursor(); + progressBar->setValue(progressBar->maximum()); + return; + } + + statusLabel->setText("Checking for new updates online, please wait..."); m_logFile->append("Checking for updates online..."); - for(int i = 0; mirrors[i]; i++) + for(int i = 0; update_mirrors[i]; i++) { - progressBar->setValue(i+1); - if(tryUpdateMirror(m_updateInfo, mirrors[i])) + progressBar->setValue(progressBar->value() + 1); + if(!success) { - success = true; - break; + if(tryUpdateMirror(m_updateInfo, update_mirrors[i])) + { + success = true; + } } } QApplication::restoreOverrideCursor(); + progressBar->setValue(progressBar->maximum()); if(!success) { @@ -194,7 +247,7 @@ void UpdateDialog::checkForUpdates(void) closeButton->setEnabled(true); retryButton->setEnabled(true); logButton->setEnabled(true); - statusLabel->setText("Failed to fetch update information. Check your internet connection!"); + statusLabel->setText("Failed to fetch update information from server. Try again later!"); progressBar->setValue(progressBar->maximum()); LAMEXP_DELETE(m_updateInfo); if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); @@ -226,7 +279,6 @@ void UpdateDialog::checkForUpdates(void) closeButton->setEnabled(true); if(retryButton->isVisible()) retryButton->hide(); if(logButton->isVisible()) logButton->hide(); - progressBar->setValue(progressBar->maximum()); m_success = true; } @@ -293,7 +345,7 @@ bool UpdateDialog::getFile(const QString &url, const QString &outFile) connect(&process, SIGNAL(finished(int,QProcess::ExitStatus)), &loop, SLOT(quit())); connect(&process, SIGNAL(readyRead()), &loop, SLOT(quit())); - process.start(m_binaryWGet, QStringList() << "-O" << output.absoluteFilePath() << url); + process.start(m_binaryWGet, QStringList() << "-U" << USER_AGENT_STR << "-O" << output.absoluteFilePath() << url); if(!process.waitForStarted()) { diff --git a/src/Model_Progress.cpp b/src/Model_Progress.cpp index 17996185..669c9fd9 100644 --- a/src/Model_Progress.cpp +++ b/src/Model_Progress.cpp @@ -126,13 +126,16 @@ void ProgressModel::addJob(const QUuid &jobId, const QString &jobName, const QSt return; } - beginResetModel(); + int newIndex = m_jobList.count(); + beginInsertRows(QModelIndex(), newIndex, newIndex); + m_jobList.append(jobId); m_jobName.insert(jobId, jobName); m_jobStatus.insert(jobId, jobInitialStatus); m_jobState.insert(jobId, jobInitialState); m_jobLogFile.insert(jobId, QStringList()); - endResetModel(); + + endInsertRows(); } void ProgressModel::updateJob(const QUuid &jobId, const QString &newStatus, int newState) diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 6da387a5..a0249a33 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -62,7 +62,7 @@ static const struct lamexp_tool_t g_lamexp_tools[] = {"7dcf6517aa90ed15737ee8ea50ea00a6dece2d27", "valdec.exe"}, {"8159f4e824b3e343ece95ba6dbb5e16da9c4866e", "volumax.exe"}, {"62e2805d1b2eb2a4d86a5ca6e6ea58010d05d2a7", "wget.exe"}, - {"acc9cdb9a0adf9760125f53f04ade6bb45422dc8", "wupdate.exe"}, + {"022bf035f0ba9b69569e419106dda304df0d5001", "wupdate.exe"}, {"4d018ac7f6a42abd53faacfae5055c2a3c176430", "wvunpack.exe"}, {NULL, NULL} };