summaryrefslogtreecommitdiff
path: root/src/gui/updatewindow.cpp
diff options
context:
space:
mode:
authorCedric Borgese <cedric.borgese@gmail.com>2005-07-22 17:27:59 +0000
committerCedric Borgese <cedric.borgese@gmail.com>2005-07-22 17:27:59 +0000
commit5731ddbf5ef5fa1556a7c5f84c0c71865a15499b (patch)
tree967cfacdf62a8930be9691152746b6f0e6b35a6e /src/gui/updatewindow.cpp
parent4333effa0e80c996c91e4014cf449c30a32120b7 (diff)
downloadmana-5731ddbf5ef5fa1556a7c5f84c0c71865a15499b.tar.gz
mana-5731ddbf5ef5fa1556a7c5f84c0c71865a15499b.tar.bz2
mana-5731ddbf5ef5fa1556a7c5f84c0c71865a15499b.tar.xz
mana-5731ddbf5ef5fa1556a7c5f84c0c71865a15499b.zip
Merge between moi1392's branch and head
Diffstat (limited to 'src/gui/updatewindow.cpp')
-rw-r--r--src/gui/updatewindow.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 14a0afa6..29ea8e8a 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -35,19 +35,21 @@
#include <SDL_mutex.h>
-UpdaterWindow::UpdaterWindow(const std::string& updateHost):
+UpdaterWindow::UpdaterWindow():
Window("Updating...")
{
m_thread = NULL;
m_mutex = NULL;
m_downloadStatus = UPDATE_NEWS;
- m_updateHost = updateHost;
+ m_updateHost = "";
m_currentFile = "news.txt";
m_downloadComplete = true;
m_basePath = "";
m_storeInMemory = true;
m_downloadedBytes = 0;
m_memoryBuffer = NULL;
+ m_curlError = new char[CURL_ERROR_SIZE];
+ m_curlError[0] = 0;
int h = 300;
int w = 320;
@@ -83,6 +85,7 @@ UpdaterWindow::UpdaterWindow(const std::string& updateHost):
UpdaterWindow::~UpdaterWindow()
{
+ delete m_curlError;
delete label;
delete progressBar;
delete cancelButton;
@@ -218,24 +221,29 @@ int UpdaterWindow::downloadThread(void *ptr)
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, UpdaterWindow::memoryWrite);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, ptr);
}
- else {
+ else
+ {
outFilename = uw->m_basePath + "/data/download.temp";
outfile = fopen(outFilename.c_str(), "wb");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
}
+ curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, uw->m_curlError);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, UpdaterWindow::updateProgress);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, ptr);
- res = curl_easy_perform(curl);
+ if ((res = curl_easy_perform(curl)) != 0)
+ {
+ uw->m_downloadStatus = UPDATE_ERROR;
+ std::cerr << "curl error " << res << " : " << uw->m_curlError << std::endl;
+ }
curl_easy_cleanup(curl);
uw->m_downloadComplete = true;
- if (res != 0) {
- uw->m_downloadStatus = UPDATE_ERROR;
- }
- else if (!uw->m_storeInMemory) {
+
+ if (!uw->m_storeInMemory)
+ {
fclose(outfile);
// If the download was successful give the file the proper name
// else it will be deleted later
@@ -304,6 +312,7 @@ void UpdaterWindow::updateData()
addRow("##1 The update process is incomplete.");
addRow("##1 It is strongly recommended that");
addRow("##1 you try again later");
+ addRow(m_curlError);
m_downloadStatus = UPDATE_COMPLETE;
break;
case UPDATE_NEWS: