Jacek Caban : urlmon: Use default binding callback if no callback is provided.
Alexandre Julliard
julliard at winehq.org
Thu Oct 7 11:24:24 CDT 2010
Module: wine
Branch: master
Commit: a3aa115ac3bbbc3c1d2156448d5e11057cbb25dc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a3aa115ac3bbbc3c1d2156448d5e11057cbb25dc
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Oct 6 21:36:18 2010 +0200
urlmon: Use default binding callback if no callback is provided.
---
dlls/urlmon/bindctx.c | 2 +-
dlls/urlmon/binding.c | 10 +++++-----
dlls/urlmon/download.c | 42 +++++++++++++++++++++++++++++++-----------
dlls/urlmon/urlmon_main.h | 2 ++
4 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/dlls/urlmon/bindctx.c b/dlls/urlmon/bindctx.c
index 67391a4..b08eb80 100644
--- a/dlls/urlmon/bindctx.c
+++ b/dlls/urlmon/bindctx.c
@@ -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;
diff --git a/dlls/urlmon/binding.c b/dlls/urlmon/binding.c
index 8bfaf76..b7f742d 100644
--- a/dlls/urlmon/binding.c
+++ b/dlls/urlmon/binding.c
@@ -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)
diff --git a/dlls/urlmon/download.c b/dlls/urlmon/download.c
index fee9606..cc49849 100644
--- a/dlls/urlmon/download.c
+++ b/dlls/urlmon/download.c
@@ -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))
diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h
index 62e461d..7391982 100644
--- a/dlls/urlmon/urlmon_main.h
+++ b/dlls/urlmon/urlmon_main.h
@@ -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;
More information about the wine-cvs
mailing list