HRESULT download_to_cache(IUri *uri, stop_cache_binding_proc_t proc, void *ctx, IBindStatusCallback *callback) { DownloadBSC *dwl_bsc; IBindCtx *bindctx; IMoniker *mon; IUnknown *unk; HRESULT hres; hres = DownloadBSC_Create(callback, NULL, &dwl_bsc); if(FAILED(hres)) return hres; dwl_bsc->onstop_proc = proc; dwl_bsc->ctx = ctx; dwl_bsc->bindf = BINDF_ASYNCHRONOUS; hres = CreateAsyncBindCtx(0, &dwl_bsc->IBindStatusCallback_iface, NULL, &bindctx); IBindStatusCallback_Release(&dwl_bsc->IBindStatusCallback_iface); if(FAILED(hres)) return hres; hres = CreateURLMonikerEx2(NULL, uri, &mon, 0); if(FAILED(hres)) { IBindCtx_Release(bindctx); return hres; } hres = IMoniker_BindToStorage(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); IMoniker_Release(mon); IBindCtx_Release(bindctx); if(SUCCEEDED(hres) && unk) IUnknown_Release(unk); return hres; }
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; }
/*********************************************************************** * URLDownloadToFileW (URLMON.@) * * Downloads URL szURL to file szFileName and call lpfnCB callback to * report progress. * * PARAMS * pCaller [I] controlling IUnknown interface. * szURL [I] URL of the file to download * szFileName [I] file name to store the content of the URL * dwReserved [I] reserved - set to 0 * lpfnCB [I] callback for progress report * * RETURNS * S_OK on success */ HRESULT WINAPI URLDownloadToFileW(LPUNKNOWN pCaller, LPCWSTR szURL, LPCWSTR szFileName, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB) { IBindStatusCallback *callback; IUnknown *unk; IMoniker *mon; IBindCtx *bindctx; HRESULT hres; TRACE("(%p %s %s %d %p)\n", pCaller, debugstr_w(szURL), debugstr_w(szFileName), dwReserved, lpfnCB); if(pCaller) FIXME("pCaller not supported\n"); hres = DownloadBSC_Create(lpfnCB, szFileName, &callback); if(FAILED(hres)) return hres; hres = CreateAsyncBindCtx(0, callback, NULL, &bindctx); IBindStatusCallback_Release(callback); if(FAILED(hres)) return hres; hres = CreateURLMoniker(NULL, szURL, &mon); if(FAILED(hres)) { IBindCtx_Release(bindctx); return hres; } hres = IMoniker_BindToStorage(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); IMoniker_Release(mon); IBindCtx_Release(bindctx); if(unk) IUnknown_Release(unk); return hres == MK_S_ASYNCHRONOUS ? S_OK : hres; }