Commit 8012d4ae authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Moved extracting callback from IBindCtx to separated function.

parent 54639c5d
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon); WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 }; static WCHAR bscb_holderW[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
extern IID IID_IBindStatusCallbackHolder; extern IID IID_IBindStatusCallbackHolder;
...@@ -51,6 +51,44 @@ static void *get_callback_iface(BindStatusCallback *This, REFIID riid) ...@@ -51,6 +51,44 @@ static void *get_callback_iface(BindStatusCallback *This, REFIID riid)
return SUCCEEDED(hres) ? ret : NULL; return SUCCEEDED(hres) ? ret : NULL;
} }
static IBindStatusCallback *bsch_from_bctx(IBindCtx *bctx)
{
IBindStatusCallback *bsc;
IUnknown *unk;
HRESULT hres;
hres = IBindCtx_GetObjectParam(bctx, bscb_holderW, &unk);
if(FAILED(hres))
return NULL;
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&bsc);
IUnknown_Release(unk);
return SUCCEEDED(hres) ? bsc : NULL;
}
static IBindStatusCallback *bsc_from_bctx(IBindCtx *bctx)
{
BindStatusCallback *holder;
IBindStatusCallback *bsc;
HRESULT hres;
bsc = bsch_from_bctx(bctx);
if(!bsc)
return NULL;
hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder);
if(FAILED(hres))
return bsc;
if(holder->callback) {
IBindStatusCallback_Release(bsc);
bsc = holder->callback;
}
IBindStatusCallbackEx_Release(&holder->IBindStatusCallbackEx_iface);
return bsc;
}
static inline BindStatusCallback *impl_from_IBindStatusCallbackEx(IBindStatusCallbackEx *iface) static inline BindStatusCallback *impl_from_IBindStatusCallbackEx(IBindStatusCallbackEx *iface)
{ {
return CONTAINING_RECORD(iface, BindStatusCallback, IBindStatusCallbackEx_iface); return CONTAINING_RECORD(iface, BindStatusCallback, IBindStatusCallbackEx_iface);
...@@ -516,7 +554,6 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb ...@@ -516,7 +554,6 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb
{ {
BindStatusCallback *holder; BindStatusCallback *holder;
IBindStatusCallback *bsc, *prev = NULL; IBindStatusCallback *bsc, *prev = NULL;
IUnknown *unk;
HRESULT hres; HRESULT hres;
TRACE("(%p %p %p %x)\n", pbc, pbsc, ppbscPrevious, dwReserved); TRACE("(%p %p %p %x)\n", pbc, pbsc, ppbscPrevious, dwReserved);
...@@ -524,11 +561,8 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb ...@@ -524,11 +561,8 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb
if (!pbc || !pbsc) if (!pbc || !pbsc)
return E_INVALIDARG; return E_INVALIDARG;
hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk); bsc = bsch_from_bctx(pbc);
if(SUCCEEDED(hres)) { if(bsc) {
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&bsc);
IUnknown_Release(unk);
if(SUCCEEDED(hres)) {
hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder); hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
if(ppbscPrevious) { if(ppbscPrevious) {
...@@ -544,14 +578,13 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb ...@@ -544,14 +578,13 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb
}else { }else {
prev = bsc; prev = bsc;
} }
}
IBindCtx_RevokeObjectParam(pbc, BSCBHolder); IBindCtx_RevokeObjectParam(pbc, bscb_holderW);
} }
hres = wrap_callback(pbsc, &bsc); hres = wrap_callback(pbsc, &bsc);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)bsc); hres = IBindCtx_RegisterObjectParam(pbc, bscb_holderW, (IUnknown*)bsc);
IBindStatusCallback_Release(bsc); IBindStatusCallback_Release(bsc);
} }
if(FAILED(hres)) { if(FAILED(hres)) {
...@@ -579,39 +612,21 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb ...@@ -579,39 +612,21 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb
*/ */
HRESULT WINAPI RevokeBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc) HRESULT WINAPI RevokeBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc)
{ {
BindStatusCallback *holder;
IBindStatusCallback *callback; IBindStatusCallback *callback;
IUnknown *unk;
BOOL dorevoke = FALSE;
HRESULT hres;
TRACE("(%p %p)\n", pbc, pbsc); TRACE("(%p %p)\n", pbc, pbsc);
if (!pbc || !pbsc) if (!pbc || !pbsc)
return E_INVALIDARG; return E_INVALIDARG;
hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk); callback = bsc_from_bctx(pbc);
if(FAILED(hres)) if(!callback)
return S_OK; return S_OK;
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&callback); if(callback == pbsc)
IUnknown_Release(unk); IBindCtx_RevokeObjectParam(pbc, bscb_holderW);
if(FAILED(hres))
return S_OK;
hres = IBindStatusCallback_QueryInterface(callback, &IID_IBindStatusCallbackHolder, (void**)&holder);
if(SUCCEEDED(hres)) {
if(pbsc == holder->callback)
dorevoke = TRUE;
IBindStatusCallbackEx_Release(&holder->IBindStatusCallbackEx_iface);
}else if(pbsc == callback) {
dorevoke = TRUE;
}
IBindStatusCallback_Release(callback); IBindStatusCallback_Release(callback);
if(dorevoke)
IBindCtx_RevokeObjectParam(pbc, BSCBHolder);
return S_OK; return S_OK;
} }
......
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