ManaPlus
|
#include <download.h>
Public Member Functions | |
Download (void *const ptr, const std::string &url, const DownloadUpdate updateFunction, const bool ignoreError, const bool isUpload, const bool isXml) | |
~Download () | |
void | addHeader (const std::string &header) |
void | noCache () |
void | setFile (const std::string &filename, const int64_t adler32) |
void | setWriteFunction (WriteFunction write) |
bool | start () |
void | cancel () |
void | addMirror (const std::string &str) |
const char * | getError () const |
void | setIgnoreError (const bool n) |
Static Public Member Functions | |
static size_t | writeFunction (void *ptr, size_t size, size_t nmemb, void *stream) |
static void | prepareForm (curl_httppost **form, const std::string &fileName) |
static unsigned long | fadler32 (FILE *const file) |
static void | addProxy (CURL *const curl) |
static void | secureCurl (CURL *const curl) |
static void | addHeaders (CURL *const curl) |
static void | addCommonFlags (CURL *const curl) |
static unsigned long | adlerBuffer (const char *const buffer, int size) |
static std::string | getUploadResponse () |
Static Private Member Functions | |
static int | downloadThread (void *ptr) |
static int | downloadProgress (void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) |
Private Attributes | |
void * | mPtr |
std::string | mUrl |
struct { | |
unsigned cancel: 1 | |
unsigned memoryWrite: 1 | |
unsigned checkAdler: 1 | |
} | mOptions |
std::string | mFileName |
std::queue< std::string > | mUrlQueue |
WriteFunction | mWriteFunction |
unsigned long | mAdler |
DownloadUpdate | mUpdateFunction |
SDL_Thread * | mThread |
CURL * | mCurl |
curl_slist * | mHeaders |
curl_httppost * | mFormPost |
char * | mError |
bool | mIgnoreError |
bool | mUpload |
bool | mIsXml |
Static Private Attributes | |
static std::string | mUploadResponse |
Definition at line 48 of file download.h.
Net::Download::Download | ( | void *const | ptr, |
const std::string & | url, | ||
const DownloadUpdate | updateFunction, | ||
const bool | ignoreError, | ||
const bool | isUpload, | ||
const bool | isXml | ||
) |
Definition at line 57 of file download.cpp.
References mError, mOptions, mUpload, mUrl, mUrlQueue, Settings::serverName, settings, and Actions::url().
Net::Download::~Download | ( | ) |
Definition at line 101 of file download.cpp.
References mError, mFormPost, mHeaders, mThread, and SDL::WaitThread().
|
static |
Definition at line 613 of file download.cpp.
References Logger::getFile(), and logger.
Referenced by WhoIsOnline::downloadThread(), and downloadThread().
void Net::Download::addHeader | ( | const std::string & | header | ) |
|
static |
Definition at line 608 of file download.cpp.
Referenced by WhoIsOnline::downloadThread(), and downloadThread().
|
inline |
Definition at line 88 of file download.h.
References mUrlQueue.
Referenced by UpdaterWindow::download(), and ServerDialog::downloadServerList().
|
static |
Definition at line 509 of file download.cpp.
References config, Configuration::getIntValue(), and Configuration::getStringValue().
Referenced by WhoIsOnline::downloadThread(), and downloadThread().
|
static |
Definition at line 147 of file download.cpp.
References FUNC_BLOCK, and EmoteDB::size().
Referenced by UpdaterWindow::getFileHash().
void Net::Download::cancel | ( | ) |
Cancels the download. Returns immediately, the cancelled status will be noted in the next avialable update call.
|
staticprivate |
Definition at line 223 of file download.cpp.
References cancel, DownloadStatus::Cancelled, CAST_SIZE, DownloadStatus::Idle, mOptions, mPtr, mUpdateFunction, and mUpload.
Referenced by downloadThread().
|
staticprivate |
Definition at line 246 of file download.cpp.
References addCommonFlags(), addHeaders(), addProxy(), cancel, checkAdler, DownloadStatus::Complete, downloadProgress(), DownloadStatus::Error, fadler32(), isTerminate, Logger::log_r(), logger, mAdler, mCurl, memoryWrite, mError, mFileName, mFormPost, mHeaders, mIsXml, mOptions, mPtr, mUpdateFunction, mUpload, mUploadResponse, mUrl, mUrlQueue, mWriteFunction, PRAGMA45(), prepareForm(), VirtFs::remove(), Files::renameFile(), secureCurl(), settings, DownloadStatus::Starting, Settings::userAgent, XML::Document::validateXml(), and writeFunction().
Referenced by start().
|
static |
Calculates the Alder-32 checksum for the given file.
Definition at line 123 of file download.cpp.
References CAST_SIZE, and VirtFs::read().
Referenced by downloadThread(), and UpdaterWindow::validateFile().
char * Net::Download::getError | ( | ) | const |
Definition at line 218 of file download.cpp.
References mError.
Referenced by ServerDialog::downloadUpdate(), and UpdaterWindow::logic().
|
inlinestatic |
Definition at line 114 of file download.h.
References mUploadResponse.
Referenced by Actions::uploadUpdate().
void Net::Download::noCache | ( | ) |
Convience method for adding no-cache headers.
Definition at line 160 of file download.cpp.
References addHeader().
Referenced by UpdaterWindow::download().
|
static |
|
static |
Definition at line 574 of file download.cpp.
Referenced by WhoIsOnline::downloadThread(), and downloadThread().
void Net::Download::setFile | ( | const std::string & | filename, |
const int64_t | adler32 | ||
) |
Definition at line 166 of file download.cpp.
References mAdler, mFileName, and mOptions.
Referenced by UpdaterWindow::download(), ServerDialog::downloadServerList(), and Actions::uploadFile().
|
inline |
void Net::Download::setWriteFunction | ( | WriteFunction | write | ) |
Definition at line 182 of file download.cpp.
References mOptions, mWriteFunction, and VirtFs::write().
Referenced by UpdaterWindow::download().
bool Net::Download::start | ( | ) |
Starts the download thread.
Definition at line 188 of file download.cpp.
References SDL::createThread(), DOWNLOAD_ERROR_MESSAGE_THREAD, downloadThread(), Logger::log(), Logger::log1(), logger, mError, mIgnoreError, mPtr, mThread, mUpdateFunction, mUpload, mUrl, and DownloadStatus::ThreadError.
Referenced by UpdaterWindow::download(), ServerDialog::downloadServerList(), and Actions::uploadFile().
|
static |
Definition at line 643 of file download.cpp.
References mUploadResponse, and EmoteDB::size().
Referenced by downloadThread().
void Net::Download::cancel |
Definition at line 127 of file download.h.
Referenced by UpdaterWindow::action(), ServerDialog::close(), ServerDialog::connectToSelectedServer(), UpdaterWindow::download(), downloadProgress(), ServerDialog::downloadServerList(), downloadThread(), ServerDialog::~ServerDialog(), and UpdaterWindow::~UpdaterWindow().
unsigned Net::Download::checkAdler |
Definition at line 129 of file download.h.
Referenced by downloadThread().
|
private |
Definition at line 134 of file download.h.
Referenced by downloadThread(), and setFile().
|
private |
Definition at line 137 of file download.h.
Referenced by downloadThread().
unsigned Net::Download::memoryWrite |
Definition at line 128 of file download.h.
Referenced by downloadThread().
|
private |
Definition at line 140 of file download.h.
Referenced by Download(), downloadThread(), getError(), start(), and ~Download().
|
private |
Definition at line 131 of file download.h.
Referenced by downloadThread(), and setFile().
|
private |
Definition at line 139 of file download.h.
Referenced by downloadThread(), and ~Download().
|
private |
Definition at line 138 of file download.h.
Referenced by addHeader(), downloadThread(), and ~Download().
|
private |
Definition at line 141 of file download.h.
Referenced by setIgnoreError(), and start().
|
private |
Definition at line 143 of file download.h.
Referenced by downloadThread().
struct { ... } Net::Download::mOptions |
Referenced by Download(), downloadProgress(), downloadThread(), setFile(), and setWriteFunction().
|
private |
Definition at line 123 of file download.h.
Referenced by downloadProgress(), downloadThread(), and start().
|
private |
Definition at line 136 of file download.h.
Referenced by start(), and ~Download().
|
private |
Definition at line 135 of file download.h.
Referenced by downloadProgress(), downloadThread(), and start().
|
private |
Definition at line 142 of file download.h.
Referenced by Download(), downloadProgress(), downloadThread(), and start().
|
staticprivate |
Definition at line 122 of file download.h.
Referenced by downloadThread(), getUploadResponse(), and writeFunction().
|
private |
Definition at line 124 of file download.h.
Referenced by Download(), downloadThread(), and start().
|
private |
Definition at line 132 of file download.h.
Referenced by addMirror(), Download(), and downloadThread().
|
private |
Definition at line 133 of file download.h.
Referenced by downloadThread(), and setWriteFunction().