summaryrefslogtreecommitdiff
path: root/src/gui/updatewindow.h
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-10-13 09:00:01 -0600
committerJared Adams <jaxad0127@gmail.com>2009-10-13 09:00:01 -0600
commit0aed5e4eb3af56ba0bf9ceb0343c262a7427b6ba (patch)
treee63bc37eb35cd10bc012d4d54fe7d76a81a5edc1 /src/gui/updatewindow.h
parent5987d6ff5e737d72193089418a3bf31f9f5a5c8f (diff)
downloadmana-0aed5e4eb3af56ba0bf9ceb0343c262a7427b6ba.tar.gz
mana-0aed5e4eb3af56ba0bf9ceb0343c262a7427b6ba.tar.bz2
mana-0aed5e4eb3af56ba0bf9ceb0343c262a7427b6ba.tar.xz
mana-0aed5e4eb3af56ba0bf9ceb0343c262a7427b6ba.zip
Add an asynchronous download class
And use it to download news, updates, and the server list.
Diffstat (limited to 'src/gui/updatewindow.h')
-rw-r--r--src/gui/updatewindow.h35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index 65a934dc..6e738fca 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updatewindow.h
@@ -24,6 +24,8 @@
#include "gui/widgets/window.h"
+#include "net/download.h"
+
#include "utils/mutex.h"
#include <guichan/actionlistener.hpp>
@@ -36,8 +38,6 @@ class Button;
class ProgressBar;
class ScrollArea;
-struct SDL_Thread;
-
/**
* Update progress window GUI
*
@@ -92,23 +92,18 @@ private:
void download();
/**
- * The thread function that download the files.
+ * A download callback for progress updates.
*/
- static int downloadThread(void *ptr);
-
- /**
- * A libcurl callback for progress updates.
- */
- static int updateProgress(void *ptr,
- double dt, double dn, double ut, double un);
+ static int updateProgress(void *ptr, DownloadStatus status,
+ size_t dt, size_t dn);
/**
* A libcurl callback for writing to memory.
*/
static size_t memoryWrite(void *ptr, size_t size, size_t nmemb,
- FILE *stream);
+ void *stream);
- enum DownloadStatus
+ enum UpdateDownloadStatus
{
UPDATE_ERROR,
UPDATE_IDLE,
@@ -118,11 +113,8 @@ private:
UPDATE_RESOURCES
};
- /** A thread that use libcurl to download updates. */
- SDL_Thread *mThread;
-
/** Status of the current download. */
- DownloadStatus mDownloadStatus;
+ UpdateDownloadStatus mDownloadStatus;
/** Host where we get the updated files. */
std::string mUpdateHost;
@@ -136,8 +128,11 @@ private:
/** The new label caption to be set in the logic method. */
std::string mNewLabelCaption;
- /** The mutex used to guard access to mNewLabelCaption. */
- Mutex mLabelMutex;
+ /** The new progress value to be set in the logic method. */
+ float mDownloadProgress;
+
+ /** The mutex used to guard access to mNewLabelCaption and mDownloadProgress. */
+ Mutex mDownloadMutex;
/** The Adler32 checksum of the file currently downloading. */
unsigned long mCurrentChecksum;
@@ -157,8 +152,8 @@ private:
/** Buffer for files downloaded to memory. */
char *mMemoryBuffer;
- /** Buffer to handler human readable error provided by curl. */
- char *mCurlError;
+ /** Download handle. */
+ Net::Download *mDownload;
/** List of files to download. */
std::vector<std::string> mLines;