Use a more efficient method to update the progress model when new jobs are added + slightly improve auto updater.

This commit is contained in:
LoRd_MuldeR 2010-12-06 18:29:34 +01:00
parent c2f132007f
commit 24da769a6d
6 changed files with 74 additions and 19 deletions

View File

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

Binary file not shown.

View File

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

View File

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

View File

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

View File

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