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

urlmon: Use default binding callback if no callback is provided.

parent 428c1bba
...@@ -477,7 +477,7 @@ static void set_callback(BindStatusCallback *This, IBindStatusCallback *bsc) ...@@ -477,7 +477,7 @@ static void set_callback(BindStatusCallback *This, IBindStatusCallback *bsc)
This->serv_prov = hres == S_OK ? serv_prov : NULL; This->serv_prov = hres == S_OK ? serv_prov : NULL;
} }
static HRESULT wrap_callback(IBindStatusCallback *bsc, IBindStatusCallback **ret_iface) HRESULT wrap_callback(IBindStatusCallback *bsc, IBindStatusCallback **ret_iface)
{ {
BindStatusCallback *ret; BindStatusCallback *ret;
......
...@@ -1369,12 +1369,12 @@ static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback) ...@@ -1369,12 +1369,12 @@ static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback)
HRESULT hres; HRESULT hres;
hres = IBindCtx_GetObjectParam(pbc, bscb_holderW, &unk); hres = IBindCtx_GetObjectParam(pbc, bscb_holderW, &unk);
if(SUCCEEDED(hres)) { if(FAILED(hres))
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)callback); return create_default_callback(callback);
IUnknown_Release(unk);
}
return SUCCEEDED(hres) ? S_OK : INET_E_DATA_NOT_AVAILABLE; hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)callback);
IUnknown_Release(unk);
return hres;
} }
static BOOL is_urlmon_protocol(LPCWSTR url) static BOOL is_urlmon_protocol(LPCWSTR url)
......
...@@ -171,14 +171,16 @@ static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface, ...@@ -171,14 +171,16 @@ static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface,
TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError)); TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
if(This->cache_file) { if(This->file_name) {
BOOL b; if(This->cache_file) {
BOOL b;
b = CopyFileW(This->cache_file, This->file_name, FALSE);
if(!b) b = CopyFileW(This->cache_file, This->file_name, FALSE);
FIXME("CopyFile failed: %u\n", GetLastError()); if(!b)
}else { FIXME("CopyFile failed: %u\n", GetLastError());
FIXME("No cache file\n"); }else {
FIXME("No cache file\n");
}
} }
if(This->callback) if(This->callback)
...@@ -301,7 +303,7 @@ static const IServiceProviderVtbl ServiceProviderVtbl = { ...@@ -301,7 +303,7 @@ static const IServiceProviderVtbl ServiceProviderVtbl = {
DwlServiceProvider_QueryService DwlServiceProvider_QueryService
}; };
static IBindStatusCallback *DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_name) static HRESULT DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_name, IBindStatusCallback **ret_callback)
{ {
DownloadBSC *ret = heap_alloc(sizeof(*ret)); DownloadBSC *ret = heap_alloc(sizeof(*ret));
...@@ -315,7 +317,22 @@ static IBindStatusCallback *DownloadBSC_Create(IBindStatusCallback *callback, LP ...@@ -315,7 +317,22 @@ static IBindStatusCallback *DownloadBSC_Create(IBindStatusCallback *callback, LP
IBindStatusCallback_AddRef(callback); IBindStatusCallback_AddRef(callback);
ret->callback = callback; ret->callback = callback;
return STATUSCLB(ret); *ret_callback = STATUSCLB(ret);
return S_OK;
}
HRESULT create_default_callback(IBindStatusCallback **ret)
{
IBindStatusCallback *callback;
HRESULT hres;
hres = DownloadBSC_Create(NULL, NULL, &callback);
if(FAILED(hres))
return hres;
hres = wrap_callback(callback, ret);
IBindStatusCallback_Release(callback);
return hres;
} }
/*********************************************************************** /***********************************************************************
...@@ -348,7 +365,10 @@ HRESULT WINAPI URLDownloadToFileW(LPUNKNOWN pCaller, LPCWSTR szURL, LPCWSTR szFi ...@@ -348,7 +365,10 @@ HRESULT WINAPI URLDownloadToFileW(LPUNKNOWN pCaller, LPCWSTR szURL, LPCWSTR szFi
if(pCaller) if(pCaller)
FIXME("pCaller not supported\n"); FIXME("pCaller not supported\n");
callback = DownloadBSC_Create(lpfnCB, szFileName); hres = DownloadBSC_Create(lpfnCB, szFileName, &callback);
if(FAILED(hres))
return hres;
hres = CreateAsyncBindCtx(0, callback, NULL, &bindctx); hres = CreateAsyncBindCtx(0, callback, NULL, &bindctx);
IBindStatusCallback_Release(callback); IBindStatusCallback_Release(callback);
if(FAILED(hres)) if(FAILED(hres))
......
...@@ -80,6 +80,8 @@ HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, v ...@@ -80,6 +80,8 @@ HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, v
HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol); HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol);
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink, IInternetBindInfo *bind_info); void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink, IInternetBindInfo *bind_info);
IWinInetInfo *get_wininet_info(IInternetProtocol*); IWinInetInfo *get_wininet_info(IInternetProtocol*);
HRESULT create_default_callback(IBindStatusCallback**);
HRESULT wrap_callback(IBindStatusCallback*,IBindStatusCallback**);
typedef struct ProtocolVtbl ProtocolVtbl; typedef struct ProtocolVtbl ProtocolVtbl;
......
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