diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-09-04 20:05:48 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-09-04 20:05:48 +0300 |
commit | 62ec17f6e489ec50f17219444468aeb8969dc961 (patch) | |
tree | 350d7edb5c26c282a4e1906544536d68831228ac /src/gui/updaterwindow.cpp | |
parent | 71d924d7dcdac067f02a317e9353ee067dbd0bde (diff) | |
parent | fd484fc70fca32ff9065b91c175089b65aa3fd26 (diff) | |
download | manaverse-stripped1.1.9.4.tar.gz manaverse-stripped1.1.9.4.tar.bz2 manaverse-stripped1.1.9.4.tar.xz manaverse-stripped1.1.9.4.zip |
Merge branch 'master' into strippedstripped1.1.9.4
Conflicts:
data/fonts/mplus-1p-bold.ttf
data/fonts/mplus-1p-regular.ttf
src/guichan/basiccontainer.cpp
src/guichan/include/guichan/basiccontainer.hpp
src/guichan/widgets/window.cpp
Diffstat (limited to 'src/gui/updaterwindow.cpp')
-rw-r--r-- | src/gui/updaterwindow.cpp | 76 |
1 files changed, 67 insertions, 9 deletions
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 7534b12a9..4ba1c9179 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -54,6 +54,8 @@ const std::string xmlUpdateFile = "resources.xml"; const std::string txtUpdateFile = "resources2.txt"; +const std::string updateServer2 + = "http://download.evolonline.org/manaplus/updates/"; std::vector<updateFile> loadXMLFile(const std::string &fileName); std::vector<updateFile> loadTxtFile(const std::string &fileName); @@ -137,6 +139,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), + mUpdatesDirReal(updatesDir), mCurrentFile("news.txt"), mDownloadProgress(0.0f), mCurrentChecksum(0), @@ -147,6 +150,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mMemoryBuffer(NULL), mDownload(NULL), mUpdateIndex(0), + mUpdateIndexOffset(0), mLoadUpdates(applyUpdates), mUpdateType(updateType) { @@ -181,6 +185,9 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, setVisible(true); mCancelButton->requestFocus(); + mUpdateServerPath = mUpdateHost; + removeProtocol(mUpdateServerPath); + // Try to download the updates list download(); } @@ -539,8 +546,9 @@ void UpdaterWindow::logic() mProgressBar->setProgress(mDownloadProgress); if (mUpdateFiles.size() && mUpdateIndex <= mUpdateFiles.size()) { - mProgressBar->setText(strprintf("%d/%d", - mUpdateIndex + 1, (int)mUpdateFiles.size() + 1)); + mProgressBar->setText(strprintf("%d/%d", mUpdateIndex + + mUpdateIndexOffset + 1, (int)mUpdateFiles.size() + + (int)mTempUpdateFiles.size() + 1)); } else { @@ -582,13 +590,12 @@ void UpdaterWindow::logic() // Parse current memory buffer as news and dispose of the data loadPatch(); -/* - mCurrentFile = "news.txt"; - mStoreInMemory = true; - mDownloadStatus = UPDATE_NEWS; - download(); // download() changes mDownloadComplete to false -*/ - mDownloadStatus = UPDATE_COMPLETE; + mUpdateHost = updateServer2 + mUpdateServerPath; + mUpdatesDir += "/fix"; + mCurrentFile = xmlUpdateFile; + mStoreInMemory = false; + mDownloadStatus = UPDATE_LIST2; + download(); } break; @@ -681,7 +688,58 @@ void UpdaterWindow::logic() } } break; + case UPDATE_LIST2: + if (mDownloadComplete) + { + if (mCurrentFile == xmlUpdateFile) + { + mTempUpdateFiles = loadXMLFile( + mUpdatesDir + "/" + xmlUpdateFile); + } + mUpdateIndexOffset = mUpdateIndex; + mUpdateIndex = 0; + mStoreInMemory = false; + mDownloadStatus = UPDATE_RESOURCES2; + download(); + } + break; + case UPDATE_RESOURCES2: + if (mDownloadComplete) + { + if (mUpdateIndex < mTempUpdateFiles.size()) + { + updateFile thisFile = mTempUpdateFiles[mUpdateIndex]; + mCurrentFile = thisFile.name; + std::string checksum; + checksum = thisFile.hash; + std::stringstream ss(checksum); + ss >> std::hex >> mCurrentChecksum; + + std::ifstream temp( + (mUpdatesDir + "/" + mCurrentFile).c_str()); + + if (!temp.is_open() || !validateFile(mUpdatesDir + "/" + + mCurrentFile, mCurrentChecksum)) + { + temp.close(); + download(); + } + else + { + temp.close(); + logger->log("%s already here", mCurrentFile.c_str()); + } + mUpdateIndex++; + } + else + { + mUpdatesDir = mUpdatesDirReal; + mDownloadStatus = UPDATE_COMPLETE; + } + } + break; case UPDATE_COMPLETE: + mUpdatesDir = mUpdatesDirReal; enable(); setLabel(_("Completed")); break; |