2 #include "IDataLoader.h" 6 #include "util/mutex.h" 16 class IProcessorWorkerData;
36 virtual void SetEstimatedSizeInBytes(
int nSize);
39 virtual int GetEstimatedSizeInBytes();
42 const char* GetFileName();
45 void SetUrl(
const char* url);
48 virtual HRESULT Decompress(
void** ppData,
int* pcBytes );
50 virtual HRESULT Destroy();
53 virtual HRESULT Load();
58 int m_nEstimatedSizeInBytes;
87 static const DWORD DEFAULT_TIME_OUT = 15000;
95 virtual HRESULT LockDeviceObject();
96 virtual HRESULT UnLockDeviceObject();
97 virtual HRESULT Destroy();
98 virtual HRESULT Process(
void* pData,
int cBytes );
99 virtual HRESULT CopyToResource();
100 virtual void SetResourceError();
112 URL_REQUEST_HTTP_AUTO,
113 URL_REQUEST_HTTP_GET,
114 URL_REQUEST_HTTP_POST,
115 URL_REQUEST_HTTP_GETFILE,
116 URL_REQUEST_HTTP_HEADERS_ONLY,
123 URL_REQUEST_UNSTARTED,
124 URL_REQUEST_INCOMPLETE,
125 URL_REQUEST_COMPLETED,
130 void SetUrl(
const char* url);
133 void SetHeadersOnly();
139 void SetScriptCallback(
const char* sCallback);
144 void SetSaveToFile(
const char* filename);
147 void AppendHTTPHeader(
const char* text);
150 CURLFORMcode AppendFormParam(
const char* name,
const char*
value);
159 CURLFORMcode AppendFormParam(
const char* name,
const char* type,
const char* file,
const char* data,
int datalen,
bool bCacheData =
false);
162 void SetCurlEasyOpt(CURL*
handle);
168 static size_t CUrl_write_data_callback(
void *buffer,
size_t size,
size_t nmemb,
void *stream);
169 static size_t CUrl_write_header_callback(
void *buffer,
size_t size,
size_t nmemb,
void *stream);
170 static int CUrl_progress_callback(
void *clientp,
double dltotal,
double dlnow,
double ultotal,
double ulnow);
171 static size_t CUrl_read_email_payload(
void *ptr,
size_t size,
size_t nmemb,
void *userp);
173 size_t write_data_callback(
void *buffer,
size_t size,
size_t nmemb);
174 size_t write_header_callback(
void *buffer,
size_t size,
size_t nmemb);
175 int progress_callback(
double dltotal,
double dlnow,
double ultotal,
double ulnow);
178 void SetTimeOut(
int nMilliSeconds);
183 void SetForbidReuse(
bool bForbidReuse);
191 void SetCallBack(URL_LOADER_CALLBACK pFuncCallback=NULL,
CUrlProcessorUserData* pUserData=NULL,
bool bDeleteUserData=
false);
196 bool IsTimedOut(DWORD nCurrentTime);
204 void SafeDeleteUserData();
210 inline vector<char>&
GetData() {
return m_data;}
219 int GetBytesReceived();
222 void AddBytesReceived(
int nBytesReceived);
224 bool IsEnableProgressUpdate()
const;
226 void SetEnableProgressUpdate(
bool val);
228 const char* CopyRequestData(
const char* pData,
int nLength);
234 bool IsSyncCallbackMode()
const;
235 void SetSyncCallbackMode(
bool val);
237 int InvokeCallbackScript(
const char* sCode,
int nLength);
291 int m_nBytesReceived;
295 vector<char> m_header;
296 std::string m_sResponseData;
297 std::string m_sResponseHeader;
299 std::string m_sRequestData;
301 CURLcode m_returnCode;
bool m_bForbidReuse
whether to reuse connection.
Definition: UrlLoaders.h:285
int m_nUserDataType
default to 0.
Definition: UrlLoaders.h:266
CUrlProcessorUserData * m_pUserData
optional user data to be send along with the m_pfuncCallBack
Definition: UrlLoaders.h:268
CParaFile * m_pFile
the file to which to save the content to.
Definition: UrlLoaders.h:261
DWORD m_nTimeOutTime
for how long the request is considered timed out.
Definition: UrlLoaders.h:283
define this to enable debugging of NPL code in visual studio
Definition: INPL.h:9
NPL object proxy.
Definition: NPLTable.h:73
struct curl_httppost * m_pFormPost
CURLOPT_HTTPPOST.
Definition: UrlLoaders.h:244
URLREQUEST_STATUS m_nStatus
the current status of the request.
Definition: UrlLoaders.h:273
for read function
Definition: UrlLoaders.h:72
Definition: handle.hpp:33
string m_sSaveToFileName
the file name to save the response data to
Definition: UrlLoaders.h:259
one should derive from this class with virtual destructor.
Definition: UrlLoaders.h:62
different physics engine has different winding order.
Definition: EventBinding.h:32
string m_url
CURLOPT_URL.
Definition: UrlLoaders.h:240
std::unique_ptr< NPL::NPLObjectProxy > m_options
all lib curl options
Definition: UrlLoaders.h:308
URLREQUEST_STATUS
url request status
Definition: UrlLoaders.h:120
interface of processor worker data
Definition: IDataLoader.h:44
DWORD m_nLastProgressTime
we send progress data at fixed 1 second interval, even when there are many or zero data...
Definition: UrlLoaders.h:278
bool m_bIsSyncCallbackMode
we will invoke callback immediately using NPL.call instead of NPL.activate.
Definition: UrlLoaders.h:289
int m_nPriority
task priority
Definition: UrlLoaders.h:250
std::string m_sNPLStateName
the NPL runtime state name in which the NPL call back will be invoked.
Definition: UrlLoaders.h:254
IDataProcessor is an interface that the AsyncLoader class uses to process and copy data into locked r...
Definition: IDataLoader.h:76
struct curl_slist * m_pHttpHeaders
http headers to send
Definition: UrlLoaders.h:242
CUrlProcessorUserData * GetUserData()
get user data.
Definition: UrlLoaders.h:207
vector< char > & GetHeader()
get request header.
Definition: UrlLoaders.h:213
Definition: enum_maker.hpp:46
bool m_bEnableProgressUpdate
whether to send progress update via callback
Definition: UrlLoaders.h:287
it presents a real or virtual file in ParaEngine.
Definition: ParaFile.h:31
IDataLoader is an interface that the AsyncLoader class uses to load data from disk.
Definition: IDataLoader.h:14
virtual bool IsDeviceObject()
default to true.
Definition: UrlLoaders.h:107
DWORD m_nStartTime
The time that this request is started or received any response.
Definition: UrlLoaders.h:276
CUrlProcessor implementation of IDataProcessor.
Definition: UrlLoaders.h:83
URLREQUEST_TYPE m_type
The type of the url request task.
Definition: UrlLoaders.h:271
virtual bool IsDeviceObject()
default to true.
Definition: UrlLoaders.h:55
URLREQUEST_TYPE
type of the url request task
Definition: UrlLoaders.h:110
CTextureLoader implementation of IDataLoader it will first search locally.
Definition: UrlLoaders.h:23
vector< char > & GetData()
get request data.
Definition: UrlLoaders.h:210
std::string m_sNPLCallback
the NPL function to call when task is finished.
Definition: UrlLoaders.h:252
URL_LOADER_CALLBACK m_pfuncCallBack
the C++ function to call when task is finished.
Definition: UrlLoaders.h:257