2014-10-29 12:37:38 +00:00
|
|
|
#ifndef ENGINE_CLIENT_FETCHER_H
|
|
|
|
#define ENGINE_CLIENT_FETCHER_H
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include "curl/curl.h"
|
|
|
|
#include "curl/easy.h"
|
|
|
|
#include <engine/fetcher.h>
|
|
|
|
|
|
|
|
class CFetcher : public IFetcher
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
CURL *m_pHandle;
|
|
|
|
|
2015-02-27 21:06:19 +00:00
|
|
|
void *m_pThHandle;
|
|
|
|
|
2017-08-30 21:14:00 +00:00
|
|
|
bool m_Running;
|
2014-10-29 12:37:38 +00:00
|
|
|
LOCK m_Lock;
|
2017-08-30 21:14:00 +00:00
|
|
|
SEMAPHORE m_Queued;
|
2014-10-29 12:37:38 +00:00
|
|
|
CFetchTask *m_pFirst;
|
|
|
|
CFetchTask *m_pLast;
|
|
|
|
class IStorage *m_pStorage;
|
|
|
|
public:
|
|
|
|
CFetcher();
|
|
|
|
virtual bool Init();
|
|
|
|
~CFetcher();
|
|
|
|
|
2015-03-14 19:01:18 +00:00
|
|
|
virtual void QueueAdd(CFetchTask *pTask, const char *pUrl, const char *pDest, int StorageType = -2, void *pUser = 0, COMPFUNC pfnCompCb = 0, PROGFUNC pfnProgCb = 0);
|
2015-02-12 17:58:54 +00:00
|
|
|
virtual void Escape(char *pBud, size_t size, const char *pStr);
|
2014-10-29 12:37:38 +00:00
|
|
|
static void FetcherThread(void *pUser);
|
2015-03-13 19:17:23 +00:00
|
|
|
void FetchFile(CFetchTask *pTask);
|
2017-08-30 19:01:19 +00:00
|
|
|
static size_t WriteToFile(char *pData, size_t size, size_t nmemb, void *pFile);
|
2014-10-29 12:37:38 +00:00
|
|
|
static int ProgressCallback(void *pUser, double DlTotal, double DlCurr, double UlTotal, double UlCurr);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|