diff options
author | Cedric Borgese <cedric.borgese@gmail.com> | 2005-07-19 16:57:05 +0000 |
---|---|---|
committer | Cedric Borgese <cedric.borgese@gmail.com> | 2005-07-19 16:57:05 +0000 |
commit | 025a25afacc724ea41d0856822f748925c763054 (patch) | |
tree | a83976e97db7adba5f298def4bf7f58c39e67ed6 /src/gui/updatewindow.h | |
parent | f3c21ab9c33ef60362eff046b97b886f3f2bd26f (diff) | |
download | mana-client-025a25afacc724ea41d0856822f748925c763054.tar.gz mana-client-025a25afacc724ea41d0856822f748925c763054.tar.bz2 mana-client-025a25afacc724ea41d0856822f748925c763054.tar.xz mana-client-025a25afacc724ea41d0856822f748925c763054.zip |
Rewrite UpdaterWindow in a more object oriented style.
Diffstat (limited to 'src/gui/updatewindow.h')
-rw-r--r-- | src/gui/updatewindow.h | 115 |
1 files changed, 95 insertions, 20 deletions
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h index 062dc191..e48a1063 100644 --- a/src/gui/updatewindow.h +++ b/src/gui/updatewindow.h @@ -31,15 +31,6 @@ #include "browserbox.h" #include "scrollarea.h" -enum { - UPDATE_ERROR, - UPDATE_IDLE, - UPDATE_LIST, - UPDATE_COMPLETE, - UPDATE_NEWS, - UPDATE_RESOURCES -}; - /** * Update progress window GUI * @@ -47,21 +38,11 @@ enum { */ class UpdaterWindow : public Window, public gcn::ActionListener { - protected: - std::string labelText; /**< Text for caption label */ - - gcn::Label *label; /**< Progress bar caption */ - Button *cancelButton; /**< Button to stop the update process */ - Button *playButton; /**< Button to start playing */ - ProgressBar *progressBar; /**< Update progress bar */ - BrowserBox* browserBox; /**< Box to display news */ - ScrollArea *scrollArea; /**< Used to scroll news box */ - public: /** * Constructor */ - UpdaterWindow(); + UpdaterWindow(const std::string& updateHost = "themanaworld.org/files"); /** * Destructor @@ -95,7 +76,101 @@ class UpdaterWindow : public Window, public gcn::ActionListener */ void addRow(const std::string &row); + void updateData(); + int updateState; + + protected: + + void download(); + + /* + * The tread function that download the files + */ + static int downloadThread(void *ptr); + + /* + * A libcurl callback + */ + static int updateProgress(void *ptr, double dt, double dn, double ut, double un); + + /* + * A libcurl callback + */ + static size_t memoryWrite(void *ptr, size_t size, size_t nmemb, FILE *stream); + + enum DownloadStatus + { + UPDATE_ERROR, + UPDATE_IDLE, + UPDATE_LIST, + UPDATE_COMPLETE, + UPDATE_NEWS, + UPDATE_RESOURCES + }; + + /* + * A thread that use libcurl to download updates + */ + class SDL_Thread *m_thread; + + /* + * A mutex to protect shared data betwed the threads + */ + class SDL_mutex *m_mutex; + + + /* + * Status of the current download + */ + DownloadStatus m_downloadStatus; + + /* + * host where we get the updated files + */ + std::string m_updateHost; + + /* + * the file currently downloading + */ + std::string m_currentFile; + + /* + * Absolute path to locally save downloaded files + */ + std::string m_basePath; + + /* + * A flag to know if we must write the downloaded file + * in m_memoryBuffer instead of a regular file + */ + bool m_storeInMemory; + + /* + * flag that show if current download is complete + */ + bool m_downloadComplete; + + /* + * byte count currently downloaded in m_memoryBuffer + */ + int m_downloadedBytes; + + /* + * buffer where to put downloaded file which are + * not stored in file system + */ + char *m_memoryBuffer; + + std::string labelText; /**< Text for caption label */ + + gcn::Label *label; /**< Progress bar caption */ + Button *cancelButton; /**< Button to stop the update process */ + Button *playButton; /**< Button to start playing */ + ProgressBar *progressBar; /**< Update progress bar */ + BrowserBox* browserBox; /**< Box to display news */ + ScrollArea *scrollArea; /**< Used to scroll news box */ + }; void updateData(); |