reactos/base/applications/rapps/include/asyncinet.h
He Yang e506581454
[RAPPS] snapshot url support (#2925)
* [RAPPS] add snapshot url support
* [RAPPS] fix snapshot prev window won't update if size not changed
* [RAPPS] fix crash after cancel download
* [RAPPS] show broken-img if failed to create file / make network request
* [RAPPS] create a snapshots folder if it does not exist
* [RAPPS] add a helper function to perform callback
* [RAPPS] check bIsCancelled when handling ERROR_INVALID_HANDLE
* [RAPPS] remove W suffix for AsyncInetDownload
* [RAPPS] add assert for unknown event
* [RAPPS] Improve AsyncInetDownload error handling
* [RAPPS] move DisplayFailed to private, fix crash when cancelling
* [RAPPS] check for ERROR_INTERNET_OPERATION_CANCELLED
* [RAPPS] improve error logging
* [RAPPS] remove \r in error logging
* [RAPPS] rewrite AsyncInet
2020-09-06 17:09:19 +02:00

67 lines
1.6 KiB
C

#ifndef ASYNC_INET
#define ASYNC_INET
enum ASYNC_EVENT
{
ASYNCINET_DATA, // wParam is the Data retrieved from the internet, lParam is the length of Data
ASYNCINET_COMPLETE, // wParam and lParam are not used.
// when receiving this, AsyncInet will be free soon and should not used anymore
ASYNCINET_CANCELLED, // wParam and lParam are not used.
// when receiving this, AsyncInet will be free soon and should not used anymore
ASYNCINET_ERROR // wParam is not used. lParam specify the error code (if there is one).
// when receiving this, AsyncInet will be free soon and should not used anymore
};
typedef struct __AsyncInet ASYNCINET, * pASYNCINET;
typedef int
(*ASYNCINET_CALLBACK)(
pASYNCINET AsyncInet,
ASYNC_EVENT Event,
WPARAM wParam,
LPARAM lParam,
VOID* Extension
);
typedef struct __AsyncInet
{
HINTERNET hInternet;
HINTERNET hInetFile;
HANDLE hEventHandleCreated;
UINT ReferenceCnt;
CRITICAL_SECTION CriticalSection;
HANDLE hEventHandleClose;
BOOL bIsOpenUrlComplete;
BOOL bCancelled;
BYTE ReadBuffer[4096];
DWORD BytesRead;
ASYNCINET_CALLBACK Callback;
VOID* Extension;
} ASYNCINET, * pASYNCINET;
pASYNCINET AsyncInetDownload(LPCWSTR lpszAgent,
DWORD dwAccessType,
LPCWSTR lpszProxy,
LPCWSTR lpszProxyBypass,
LPCWSTR lpszUrl,
BOOL bAllowCache,
ASYNCINET_CALLBACK Callback,
VOID* Extension
);
BOOL AsyncInetCancel(pASYNCINET AsyncInet);
VOID AsyncInetRelease(pASYNCINET AsyncInet);
#endif