static HRESULT WINAPI DownloadBSC_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv) { DownloadBSC *This = STATUSCLB_THIS(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv); *ppv = STATUSCLB(This); }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) { TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv); *ppv = STATUSCLB(This); }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv); *ppv = SERVPROV(This); } if(*ppv) { IBindStatusCallback_AddRef((IUnknown*)*ppv); return S_OK; } TRACE("Unsupported riid = %s\n", debugstr_guid(riid)); return E_NOINTERFACE; }
static HRESULT WINAPI BSCServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv) { BindStatusCallback *This = SERVPROV_THIS(iface); HRESULT hres; if(IsEqualGUID(&IID_IHttpNegotiate, guidService)) { TRACE("(%p)->(IID_IHttpNegotiate %s %p)\n", This, debugstr_guid(riid), ppv); return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv); } if(IsEqualGUID(&IID_IHttpNegotiate2, guidService)) { TRACE("(%p)->(IID_IHttpNegotiate2 %s %p)\n", This, debugstr_guid(riid), ppv); return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv); } if(IsEqualGUID(&IID_IAuthenticate, guidService)) { TRACE("(%p)->(IID_IAuthenticate %s %p)\n", This, debugstr_guid(riid), ppv); return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv); } TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv); hres = IBindStatusCallback_QueryInterface(This->callback, riid, ppv); if(SUCCEEDED(hres)) return S_OK; if(This->serv_prov) { hres = IServiceProvider_QueryService(This->serv_prov, guidService, riid, ppv); if(SUCCEEDED(hres)) return S_OK; } return E_NOINTERFACE; }
static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv) { BindStatusCallback *This = STATUSCLB_THIS(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv); *ppv = STATUSCLB(This); }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) { TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv); *ppv = STATUSCLB(This); }else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid)) { TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv); *ppv = STATUSCLBEX(This); }else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid)) { TRACE("(%p)->(IID_IBindStatusCallbackHolder, %p)\n", This, ppv); *ppv = This; }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv); *ppv = SERVPROV(This); }else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) { TRACE("(%p)->(IID_IHttpNegotiate, %p)\n", This, ppv); *ppv = HTTPNEG2(This); }else if(IsEqualGUID(&IID_IHttpNegotiate2, riid)) { TRACE("(%p)->(IID_IHttpNegotiate2, %p)\n", This, ppv); *ppv = HTTPNEG2(This); }else if(IsEqualGUID(&IID_IAuthenticate, riid)) { TRACE("(%p)->(IID_IAuthenticate, %p)\n", This, ppv); *ppv = AUTHENTICATE(This); } if(*ppv) { IBindStatusCallback_AddRef((IUnknown*)*ppv); return S_OK; } TRACE("Unsupported riid = %s\n", debugstr_guid(riid)); return E_NOINTERFACE; }
/*********************************************************************** * RegisterBindStatusCallback (urlmon.@) * * Register a bind status callback. * * PARAMS * pbc [I] Binding context * pbsc [I] Callback to register * ppbscPrevious [O] Destination for previous callback * dwReserved [I] Reserved, must be 0. * * RETURNS * Success: S_OK. * Failure: E_INVALIDARG, if any argument is invalid, or * E_OUTOFMEMORY if memory allocation fails. */ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc, IBindStatusCallback **ppbscPrevious, DWORD dwReserved) { BindStatusCallback *holder; IBindStatusCallback *bsc, *prev = NULL; IUnknown *unk; HRESULT hres; TRACE("(%p %p %p %x)\n", pbc, pbsc, ppbscPrevious, dwReserved); if (!pbc || !pbsc) return E_INVALIDARG; hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk); if(SUCCEEDED(hres)) { hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&bsc); IUnknown_Release(unk); if(SUCCEEDED(hres)) { hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder); if(SUCCEEDED(hres)) { if(ppbscPrevious) { IBindStatusCallback_AddRef(holder->callback); *ppbscPrevious = holder->callback; } set_callback(holder, pbsc); IBindStatusCallback_Release(bsc); IBindStatusCallback_Release(STATUSCLB(holder)); return S_OK; }else { prev = bsc; } } IBindCtx_RevokeObjectParam(pbc, BSCBHolder); } hres = wrap_callback(pbsc, &bsc); if(SUCCEEDED(hres)) { hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)bsc); IBindStatusCallback_Release(bsc); } if(FAILED(hres)) { if(prev) IBindStatusCallback_Release(prev); return hres; } if(ppbscPrevious) *ppbscPrevious = prev; return S_OK; }
static HRESULT DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_name, IBindStatusCallback **ret_callback) { DownloadBSC *ret = heap_alloc(sizeof(*ret)); ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl; ret->lpServiceProviderVtbl = &ServiceProviderVtbl; ret->ref = 1; ret->file_name = heap_strdupW(file_name); ret->cache_file = NULL; if(callback) IBindStatusCallback_AddRef(callback); ret->callback = callback; *ret_callback = STATUSCLB(ret); return S_OK; }
static IBindStatusCallback *create_bsc(IBindStatusCallback *bsc) { BindStatusCallback *ret = heap_alloc_zero(sizeof(BindStatusCallback)); ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl; ret->lpServiceProviderVtbl = &BSCServiceProviderVtbl; ret->lpHttpNegotiate2Vtbl = &BSCHttpNegotiateVtbl; ret->lpAuthenticateVtbl = &BSCAuthenticateVtbl; ret->ref = 1; IBindStatusCallback_AddRef(bsc); ret->callback = bsc; IBindStatusCallback_QueryInterface(bsc, &IID_IServiceProvider, (void**)&ret->serv_prov); return STATUSCLB(ret); }
HRESULT wrap_callback(IBindStatusCallback *bsc, IBindStatusCallback **ret_iface) { BindStatusCallback *ret; ret = heap_alloc_zero(sizeof(BindStatusCallback)); if(!ret) return E_OUTOFMEMORY; ret->lpBindStatusCallbackExVtbl = &BindStatusCallbackExVtbl; ret->lpServiceProviderVtbl = &BSCServiceProviderVtbl; ret->lpHttpNegotiate2Vtbl = &BSCHttpNegotiateVtbl; ret->lpAuthenticateVtbl = &BSCAuthenticateVtbl; ret->ref = 1; set_callback(ret, bsc); *ret_iface = STATUSCLB(ret); return S_OK; }
/*********************************************************************** * RevokeBindStatusCallback (URLMON.@) * * Unregister a bind status callback. * * pbc [I] Binding context * pbsc [I] Callback to unregister * * RETURNS * Success: S_OK. * Failure: E_INVALIDARG, if any argument is invalid */ HRESULT WINAPI RevokeBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc) { BindStatusCallback *holder; IBindStatusCallback *callback; IUnknown *unk; BOOL dorevoke = FALSE; HRESULT hres; TRACE("(%p %p)\n", pbc, pbsc); if (!pbc || !pbsc) return E_INVALIDARG; hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk); if(FAILED(hres)) return S_OK; hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&callback); IUnknown_Release(unk); if(FAILED(hres)) return S_OK; hres = IBindStatusCallback_QueryInterface(callback, &IID_IBindStatusCallbackHolder, (void**)&holder); if(SUCCEEDED(hres)) { if(pbsc == holder->callback) dorevoke = TRUE; IBindStatusCallback_Release(STATUSCLB(holder)); }else if(pbsc == callback) { dorevoke = TRUE; } IBindStatusCallback_Release(callback); if(dorevoke) IBindCtx_RevokeObjectParam(pbc, BSCBHolder); return S_OK; }
static ULONG WINAPI DwlServiceProvider_Release(IServiceProvider *iface) { DownloadBSC *This = SERVPROV_THIS(iface); return IBindStatusCallback_Release(STATUSCLB(This)); }
static HRESULT WINAPI DwlServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv) { DownloadBSC *This = SERVPROV_THIS(iface); return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv); }
static ULONG WINAPI BSCAuthenticate_Release(IAuthenticate *iface) { BindStatusCallback *This = AUTHENTICATE_THIS(iface); return IBindStatusCallback_Release(STATUSCLB(This)); }
static ULONG WINAPI BSCHttpNegotiate_Release(IHttpNegotiate2 *iface) { BindStatusCallback *This = HTTPNEG2_THIS(iface); return IBindStatusCallback_Release(STATUSCLB(This)); }
static HRESULT WINAPI BSCHttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv) { BindStatusCallback *This = HTTPNEG2_THIS(iface); return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv); }
static ULONG WINAPI BSCServiceProvider_AddRef(IServiceProvider *iface) { BindStatusCallback *This = SERVPROV_THIS(iface); return IBindStatusCallback_AddRef(STATUSCLB(This)); }