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)
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;
......
......@@ -1369,12 +1369,12 @@ static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback)
HRESULT hres;
hres = IBindCtx_GetObjectParam(pbc, bscb_holderW, &unk);
if(SUCCEEDED(hres)) {
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)callback);
IUnknown_Release(unk);
}
if(FAILED(hres))
return create_default_callback(callback);
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)
......
......@@ -171,14 +171,16 @@ static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface,
TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
if(This->cache_file) {
BOOL b;
b = CopyFileW(This->cache_file, This->file_name, FALSE);
if(!b)
FIXME("CopyFile failed: %u\n", GetLastError());
}else {
FIXME("No cache file\n");
if(This->file_name) {
if(This->cache_file) {
BOOL b;
b = CopyFileW(This->cache_file, This->file_name, FALSE);
if(!b)
FIXME("CopyFile failed: %u\n", GetLastError());
}else {
FIXME("No cache file\n");
}
}
if(This->callback)
......@@ -301,7 +303,7 @@ static const IServiceProviderVtbl ServiceProviderVtbl = {
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));
......@@ -315,7 +317,22 @@ static IBindStatusCallback *DownloadBSC_Create(IBindStatusCallback *callback, LP
IBindStatusCallback_AddRef(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
if(pCaller)
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);
IBindStatusCallback_Release(callback);
if(FAILED(hres))
......
......@@ -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);
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink, IInternetBindInfo *bind_info);
IWinInetInfo *get_wininet_info(IInternetProtocol*);
HRESULT create_default_callback(IBindStatusCallback**);
HRESULT wrap_callback(IBindStatusCallback*,IBindStatusCallback**);
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