From 4121ac12243ba94e6a320df9d450976dc06678e1 Mon Sep 17 00:00:00 2001 From: David Hedberg Date: Mon, 3 Jan 2011 03:47:38 +0100 Subject: [PATCH] urlmon: Add new on_error function to protocol vtbl. --- dlls/urlmon/ftp.c | 8 +++++++- dlls/urlmon/gopher.c | 8 +++++++- dlls/urlmon/http.c | 8 +++++++- dlls/urlmon/protocol.c | 40 +++++++++++++++++++++++---------------- dlls/urlmon/urlmon_main.h | 2 ++ 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/dlls/urlmon/ftp.c b/dlls/urlmon/ftp.c index deb611bc901..854f169ef2d 100644 --- a/dlls/urlmon/ftp.c +++ b/dlls/urlmon/ftp.c @@ -99,13 +99,19 @@ static void FtpProtocol_close_connection(Protocol *prot) { } +static void FtpProtocol_on_error(Protocol *prot, DWORD error) +{ + FIXME("(%p) %d - stub\n", prot, error); +} + #undef ASYNCPROTOCOL_THIS static const ProtocolVtbl AsyncProtocolVtbl = { FtpProtocol_open_request, FtpProtocol_end_request, FtpProtocol_start_downloading, - FtpProtocol_close_connection + FtpProtocol_close_connection, + FtpProtocol_on_error }; static HRESULT WINAPI FtpProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) diff --git a/dlls/urlmon/gopher.c b/dlls/urlmon/gopher.c index da241e9358e..596488216e4 100644 --- a/dlls/urlmon/gopher.c +++ b/dlls/urlmon/gopher.c @@ -70,13 +70,19 @@ static void GopherProtocol_close_connection(Protocol *prot) { } +static void GopherProtocol_on_error(Protocol *prot, DWORD error) +{ + FIXME("(%p) %d - stub\n", prot, error); +} + #undef ASYNCPROTOCOL_THIS static const ProtocolVtbl AsyncProtocolVtbl = { GopherProtocol_open_request, GopherProtocol_end_request, GopherProtocol_start_downloading, - GopherProtocol_close_connection + GopherProtocol_close_connection, + GopherProtocol_on_error }; #define PROTOCOL_THIS(iface) DEFINE_THIS(GopherProtocol, IInternetProtocol, iface) diff --git a/dlls/urlmon/http.c b/dlls/urlmon/http.c index cfa2fc6585d..a62323b35fa 100644 --- a/dlls/urlmon/http.c +++ b/dlls/urlmon/http.c @@ -388,13 +388,19 @@ static void HttpProtocol_close_connection(Protocol *prot) } } +static void HttpProtocol_on_error(Protocol *prot, DWORD error) +{ + FIXME("(%p) %d - stub\n", prot, error); +} + #undef ASYNCPROTOCOL_THIS static const ProtocolVtbl AsyncProtocolVtbl = { HttpProtocol_open_request, HttpProtocol_end_request, HttpProtocol_start_downloading, - HttpProtocol_close_connection + HttpProtocol_close_connection, + HttpProtocol_on_error }; static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) diff --git a/dlls/urlmon/protocol.c b/dlls/urlmon/protocol.c index 2ca16297780..1b8b5e3e13b 100644 --- a/dlls/urlmon/protocol.c +++ b/dlls/urlmon/protocol.c @@ -76,25 +76,27 @@ static void request_complete(Protocol *protocol, INTERNET_ASYNC_RESULT *ar) TRACE("(%p)->(%p)\n", protocol, ar); - if(!ar->dwResult) { - WARN("request failed: %d\n", ar->dwError); - return; - } - - protocol->flags |= FLAG_REQUEST_COMPLETE; - - if(!protocol->request) { - TRACE("setting request handle %p\n", (HINTERNET)ar->dwResult); - protocol->request = (HINTERNET)ar->dwResult; - } - /* PROTOCOLDATA same as native */ memset(&data, 0, sizeof(data)); data.dwState = 0xf1000000; - if(protocol->flags & FLAG_FIRST_CONTINUE_COMPLETE) - data.pData = (LPVOID)BINDSTATUS_ENDDOWNLOADCOMPONENTS; - else - data.pData = (LPVOID)BINDSTATUS_DOWNLOADINGDATA; + + if(ar->dwResult) { + protocol->flags |= FLAG_REQUEST_COMPLETE; + + if(!protocol->request) { + TRACE("setting request handle %p\n", (HINTERNET)ar->dwResult); + protocol->request = (HINTERNET)ar->dwResult; + } + + if(protocol->flags & FLAG_FIRST_CONTINUE_COMPLETE) + data.pData = (LPVOID)BINDSTATUS_ENDDOWNLOADCOMPONENTS; + else + data.pData = (LPVOID)BINDSTATUS_DOWNLOADINGDATA; + + }else { + protocol->flags |= FLAG_ERROR; + data.pData = (LPVOID)ar->dwError; + } if (protocol->bindf & BINDF_FROMURLMON) IInternetProtocolSink_Switch(protocol->protocol_sink, &data); @@ -301,6 +303,12 @@ HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data) return S_OK; } + if(protocol->flags & FLAG_ERROR) { + protocol->flags &= ~FLAG_ERROR; + protocol->vtbl->on_error(protocol, (DWORD)data->pData); + return S_OK; + } + if(protocol->post_stream) return write_post_stream(protocol); diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index dc6d3fc8753..719c2ebdb8f 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -113,6 +113,7 @@ struct ProtocolVtbl { HRESULT (*end_request)(Protocol*); HRESULT (*start_downloading)(Protocol*); void (*close_connection)(Protocol*); + void (*on_error)(Protocol*,DWORD); }; /* Flags are needed for, among other things, return HRESULTs from the Read function @@ -144,6 +145,7 @@ struct ProtocolVtbl { #define FLAG_ALL_DATA_READ 0x0008 #define FLAG_LAST_DATA_REPORTED 0x0010 #define FLAG_RESULT_REPORTED 0x0020 +#define FLAG_ERROR 0x0040 HRESULT protocol_start(Protocol*,IInternetProtocol*,IUri*,IInternetProtocolSink*,IInternetBindInfo*); HRESULT protocol_continue(Protocol*,PROTOCOLDATA*);