summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-05 17:23:21 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-06 13:06:50 +0300
commit05cec243c28f50bd5ee7a167067501f7bd8db3ff (patch)
treeb3b4e97b873ebf5e082ee1092a4c33a1ebdd72b8 /src/gui
parent25bed1bb7f7dbfa3caa0f239c63dbabd3b0bd50d (diff)
downloadmv-05cec243c28f50bd5ee7a167067501f7bd8db3ff.tar.gz
mv-05cec243c28f50bd5ee7a167067501f7bd8db3ff.tar.bz2
mv-05cec243c28f50bd5ee7a167067501f7bd8db3ff.tar.xz
mv-05cec243c28f50bd5ee7a167067501f7bd8db3ff.zip
Validate xml downloads, and if failed, use another mirror.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/serverdialog.cpp2
-rw-r--r--src/gui/windows/updaterwindow.cpp20
-rw-r--r--src/gui/windows/updaterwindow.h2
3 files changed, 19 insertions, 5 deletions
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 653d62567..015c94f00 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -522,7 +522,7 @@ void ServerDialog::downloadServerList()
}
mDownload = new Net::Download(this, listFile,
- &downloadUpdate, false, false);
+ &downloadUpdate, false, false, true);
mDownload->setFile(std::string(mDir).append("/").append(
branding.getStringValue("onlineServerFile")));
mDownload->start();
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 842176793..dab1a6ebc 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -193,7 +193,8 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost,
mStoreInMemory(true),
mDownloadComplete(true),
mUserCancel(false),
- mLoadUpdates(applyUpdates)
+ mLoadUpdates(applyUpdates),
+ mValidateXml(false)
{
setWindowName("UpdaterWindow");
setResizable(true);
@@ -532,13 +533,16 @@ void UpdaterWindow::download()
{
mDownload = new Net::Download(this,
"http://manaplus.org/update/" + mCurrentFile,
- &updateProgress, true, false);
+ &updateProgress,
+ true, false, mValidateXml);
mDownload->addMirror("http://www.manaplus.org/update/" + mCurrentFile);
}
else
{
- mDownload = new Net::Download(this, std::string(mUpdateHost).append(
- "/").append(mCurrentFile), &updateProgress, false, false);
+ mDownload = new Net::Download(this,
+ std::string(mUpdateHost).append("/").append(mCurrentFile),
+ &updateProgress,
+ false, false, mValidateXml);
const std::vector<std::string> &mirrors = client->getMirrors();
FOR_EACH (std::vector<std::string>::const_iterator, it, mirrors)
@@ -788,6 +792,7 @@ void UpdaterWindow::logic()
// Parse current memory buffer as news and dispose of the data
loadNews();
+ mValidateXml = true;
mCurrentFile = xmlUpdateFile;
mStoreInMemory = false;
mDownloadStatus = UPDATE_LIST;
@@ -803,6 +808,7 @@ void UpdaterWindow::logic()
mUpdateHost = updateServer2 + mUpdateServerPath;
mUpdatesDir.append("/fix");
mCurrentFile = xmlUpdateFile;
+ mValidateXml = true;
mStoreInMemory = false;
mDownloadStatus = UPDATE_LIST2;
download();
@@ -827,6 +833,7 @@ void UpdaterWindow::logic()
// If the resources.xml file fails,
// fall back onto a older version
mCurrentFile = txtUpdateFile;
+ mValidateXml = false;
mStoreInMemory = false;
mDownloadStatus = UPDATE_LIST;
download();
@@ -835,6 +842,7 @@ void UpdaterWindow::logic()
}
else if (mCurrentFile == txtUpdateFile)
{
+ mValidateXml = true;
mUpdateFiles = loadTxtFile(std::string(mUpdatesDir).append(
"/").append(txtUpdateFile));
}
@@ -863,6 +871,7 @@ void UpdaterWindow::logic()
std::ifstream temp((std::string(mUpdatesDir).append(
"/").append(mCurrentFile)).c_str());
+ mValidateXml = false;
if (!temp.is_open() || !validateFile(std::string(
mUpdatesDir).append("/").append(mCurrentFile),
mCurrentChecksum))
@@ -883,6 +892,7 @@ void UpdaterWindow::logic()
mCurrentFile = "latest.txt";
mStoreInMemory = true;
mDownloadStatus = UPDATE_PATCH;
+ mValidateXml = false;
download(); // download() changes
// mDownloadComplete to false
}
@@ -898,6 +908,7 @@ void UpdaterWindow::logic()
}
mUpdateIndexOffset = mUpdateIndex;
mUpdateIndex = 0;
+ mValidateXml = true;
mStoreInMemory = false;
mDownloadStatus = UPDATE_RESOURCES2;
download();
@@ -906,6 +917,7 @@ void UpdaterWindow::logic()
case UPDATE_RESOURCES2:
if (mDownloadComplete)
{
+ mValidateXml = false;
if (mUpdateIndex < mTempUpdateFiles.size())
{
const UpdateFile thisFile = mTempUpdateFiles[mUpdateIndex];
diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h
index 4874ba8ba..d73da1e3e 100644
--- a/src/gui/windows/updaterwindow.h
+++ b/src/gui/windows/updaterwindow.h
@@ -268,6 +268,8 @@ private:
/** Tells ~UpdaterWindow() if it should load updates */
bool mLoadUpdates;
+
+ bool mValidateXml;
};
#endif // GUI_WINDOWS_UPDATERWINDOW_H