Commit c2ffe977 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Move HttpProtocol::Continue implementation to generic Protocol object.

parent 4c129514
......@@ -53,6 +53,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
#define FLAG_LAST_DATA_REPORTED 0x0010
#define FLAG_RESULT_REPORTED 0x0020
static inline HRESULT report_progress(Protocol *protocol, ULONG status_code, LPCWSTR status_text)
{
return IInternetProtocolSink_ReportProgress(protocol->protocol_sink, status_code, status_text);
}
static inline HRESULT report_result(Protocol *protocol, HRESULT hres)
{
if (!(protocol->flags & FLAG_RESULT_REPORTED) && protocol->protocol_sink) {
......@@ -95,6 +100,69 @@ static void all_data_read(Protocol *protocol)
report_result(protocol, S_OK);
}
HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data)
{
HRESULT hres;
if (!data) {
WARN("Expected pProtocolData to be non-NULL\n");
return S_OK;
}
if(!protocol->request) {
WARN("Expected request to be non-NULL\n");
return S_OK;
}
if(!protocol->protocol_sink) {
WARN("Expected IInternetProtocolSink pointer to be non-NULL\n");
return S_OK;
}
if(data->pData == (LPVOID)BINDSTATUS_DOWNLOADINGDATA) {
hres = protocol->vtbl->start_downloading(protocol);
if(FAILED(hres)) {
protocol_close_connection(protocol);
report_result(protocol, hres);
return S_OK;
}
if(protocol->bindf & BINDF_NEEDFILE) {
WCHAR cache_file[MAX_PATH];
DWORD buflen = sizeof(cache_file);
if(InternetQueryOptionW(protocol->request, INTERNET_OPTION_DATAFILE_NAME,
cache_file, &buflen)) {
report_progress(protocol, BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_file);
}else {
FIXME("Could not get cache file\n");
}
}
protocol->flags |= FLAG_FIRST_CONTINUE_COMPLETE;
}
if(data->pData >= (LPVOID)BINDSTATUS_DOWNLOADINGDATA) {
BOOL res;
/* InternetQueryDataAvailable may immediately fork and perform its asynchronous
* read, so clear the flag _before_ calling so it does not incorrectly get cleared
* after the status callback is called */
protocol->flags &= ~FLAG_REQUEST_COMPLETE;
res = InternetQueryDataAvailable(protocol->request, &protocol->available_bytes, 0, 0);
if(res) {
protocol->flags |= FLAG_REQUEST_COMPLETE;
report_data(protocol);
}else if(GetLastError() != ERROR_IO_PENDING) {
protocol->flags |= FLAG_REQUEST_COMPLETE;
WARN("InternetQueryDataAvailable failed: %d\n", GetLastError());
report_result(protocol, INET_E_DATA_NOT_AVAILABLE);
}
}
return S_OK;
}
HRESULT protocol_read(Protocol *protocol, void *buf, ULONG size, ULONG *read_ret)
{
ULONG read = 0;
......
......@@ -103,9 +103,11 @@ typedef struct {
} Protocol;
struct ProtocolVtbl {
HRESULT (*start_downloading)(Protocol*);
void (*close_connection)(Protocol*);
};
HRESULT protocol_continue(Protocol*,PROTOCOLDATA*);
HRESULT protocol_read(Protocol*,void*,ULONG,ULONG*);
HRESULT protocol_lock_request(Protocol*);
HRESULT protocol_unlock_request(Protocol*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment