Commit b74af4aa authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

urlmon: Use ifaces instead of vtbl pointers in DownloadBSC.

parent d98e2103
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon); WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
typedef struct { typedef struct {
const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl; IBindStatusCallback IBindStatusCallback_iface;
const IServiceProviderVtbl *lpServiceProviderVtbl; IServiceProvider IServiceProvider_iface;
LONG ref; LONG ref;
...@@ -32,27 +32,32 @@ typedef struct { ...@@ -32,27 +32,32 @@ typedef struct {
LPWSTR cache_file; LPWSTR cache_file;
} DownloadBSC; } DownloadBSC;
#define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl) static inline DownloadBSC *impl_from_IBindStatusCallback(IBindStatusCallback *iface)
#define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl) {
return CONTAINING_RECORD(iface, DownloadBSC, IBindStatusCallback_iface);
}
#define STATUSCLB_THIS(iface) DEFINE_THIS(DownloadBSC, BindStatusCallback, iface) static inline DownloadBSC *impl_from_IServiceProvider(IServiceProvider *iface)
{
return CONTAINING_RECORD(iface, DownloadBSC, IServiceProvider_iface);
}
static HRESULT WINAPI DownloadBSC_QueryInterface(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_QueryInterface(IBindStatusCallback *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
*ppv = NULL; *ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) { if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv); TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
*ppv = STATUSCLB(This); *ppv = &This->IBindStatusCallback_iface;
}else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) { }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv); TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
*ppv = STATUSCLB(This); *ppv = &This->IBindStatusCallback_iface;
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) { }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv); TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
*ppv = SERVPROV(This); *ppv = &This->IServiceProvider_iface;
} }
if(*ppv) { if(*ppv) {
...@@ -66,7 +71,7 @@ static HRESULT WINAPI DownloadBSC_QueryInterface(IBindStatusCallback *iface, ...@@ -66,7 +71,7 @@ static HRESULT WINAPI DownloadBSC_QueryInterface(IBindStatusCallback *iface,
static ULONG WINAPI DownloadBSC_AddRef(IBindStatusCallback *iface) static ULONG WINAPI DownloadBSC_AddRef(IBindStatusCallback *iface)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
LONG ref = InterlockedIncrement(&This->ref); LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref = %d\n", This, ref); TRACE("(%p) ref = %d\n", This, ref);
...@@ -76,7 +81,7 @@ static ULONG WINAPI DownloadBSC_AddRef(IBindStatusCallback *iface) ...@@ -76,7 +81,7 @@ static ULONG WINAPI DownloadBSC_AddRef(IBindStatusCallback *iface)
static ULONG WINAPI DownloadBSC_Release(IBindStatusCallback *iface) static ULONG WINAPI DownloadBSC_Release(IBindStatusCallback *iface)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
LONG ref = InterlockedDecrement(&This->ref); LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref = %d\n", This, ref); TRACE("(%p) ref = %d\n", This, ref);
...@@ -95,7 +100,7 @@ static ULONG WINAPI DownloadBSC_Release(IBindStatusCallback *iface) ...@@ -95,7 +100,7 @@ static ULONG WINAPI DownloadBSC_Release(IBindStatusCallback *iface)
static HRESULT WINAPI DownloadBSC_OnStartBinding(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_OnStartBinding(IBindStatusCallback *iface,
DWORD dwReserved, IBinding *pbind) DWORD dwReserved, IBinding *pbind)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind); TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind);
...@@ -107,14 +112,14 @@ static HRESULT WINAPI DownloadBSC_OnStartBinding(IBindStatusCallback *iface, ...@@ -107,14 +112,14 @@ static HRESULT WINAPI DownloadBSC_OnStartBinding(IBindStatusCallback *iface,
static HRESULT WINAPI DownloadBSC_GetPriority(IBindStatusCallback *iface, LONG *pnPriority) static HRESULT WINAPI DownloadBSC_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
FIXME("(%p)->(%p)\n", This, pnPriority); FIXME("(%p)->(%p)\n", This, pnPriority);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI DownloadBSC_OnLowResource(IBindStatusCallback *iface, DWORD reserved) static HRESULT WINAPI DownloadBSC_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
FIXME("(%p)->(%d)\n", This, reserved); FIXME("(%p)->(%d)\n", This, reserved);
return E_NOTIMPL; return E_NOTIMPL;
} }
...@@ -133,7 +138,7 @@ static HRESULT on_progress(DownloadBSC *This, ULONG progress, ULONG progress_max ...@@ -133,7 +138,7 @@ static HRESULT on_progress(DownloadBSC *This, ULONG progress, ULONG progress_max
static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText) ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
HRESULT hres = S_OK; HRESULT hres = S_OK;
TRACE("%p)->(%u %u %u %s)\n", This, ulProgress, ulProgressMax, ulStatusCode, TRACE("%p)->(%u %u %u %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
...@@ -167,7 +172,7 @@ static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG u ...@@ -167,7 +172,7 @@ static HRESULT WINAPI DownloadBSC_OnProgress(IBindStatusCallback *iface, ULONG u
static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface,
HRESULT hresult, LPCWSTR szError) HRESULT hresult, LPCWSTR szError)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError)); TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
...@@ -192,7 +197,7 @@ static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface, ...@@ -192,7 +197,7 @@ static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface,
static HRESULT WINAPI DownloadBSC_GetBindInfo(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_GetBindInfo(IBindStatusCallback *iface,
DWORD *grfBINDF, BINDINFO *pbindinfo) DWORD *grfBINDF, BINDINFO *pbindinfo)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
DWORD bindf = 0; DWORD bindf = 0;
TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo); TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
...@@ -216,7 +221,7 @@ static HRESULT WINAPI DownloadBSC_GetBindInfo(IBindStatusCallback *iface, ...@@ -216,7 +221,7 @@ static HRESULT WINAPI DownloadBSC_GetBindInfo(IBindStatusCallback *iface,
static HRESULT WINAPI DownloadBSC_OnDataAvailable(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_OnDataAvailable(IBindStatusCallback *iface,
DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed) DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed); TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
...@@ -226,13 +231,11 @@ static HRESULT WINAPI DownloadBSC_OnDataAvailable(IBindStatusCallback *iface, ...@@ -226,13 +231,11 @@ static HRESULT WINAPI DownloadBSC_OnDataAvailable(IBindStatusCallback *iface,
static HRESULT WINAPI DownloadBSC_OnObjectAvailable(IBindStatusCallback *iface, static HRESULT WINAPI DownloadBSC_OnObjectAvailable(IBindStatusCallback *iface,
REFIID riid, IUnknown *punk) REFIID riid, IUnknown *punk)
{ {
DownloadBSC *This = STATUSCLB_THIS(iface); DownloadBSC *This = impl_from_IBindStatusCallback(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk); FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
return E_NOTIMPL; return E_NOTIMPL;
} }
#undef STATUSCLB_THIS
static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = { static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
DownloadBSC_QueryInterface, DownloadBSC_QueryInterface,
DownloadBSC_AddRef, DownloadBSC_AddRef,
...@@ -247,31 +250,29 @@ static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = { ...@@ -247,31 +250,29 @@ static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
DownloadBSC_OnObjectAvailable DownloadBSC_OnObjectAvailable
}; };
#define SERVPROV_THIS(iface) DEFINE_THIS(DownloadBSC, ServiceProvider, iface)
static HRESULT WINAPI DwlServiceProvider_QueryInterface(IServiceProvider *iface, static HRESULT WINAPI DwlServiceProvider_QueryInterface(IServiceProvider *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
DownloadBSC *This = SERVPROV_THIS(iface); DownloadBSC *This = impl_from_IServiceProvider(iface);
return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv); return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
} }
static ULONG WINAPI DwlServiceProvider_AddRef(IServiceProvider *iface) static ULONG WINAPI DwlServiceProvider_AddRef(IServiceProvider *iface)
{ {
DownloadBSC *This = SERVPROV_THIS(iface); DownloadBSC *This = impl_from_IServiceProvider(iface);
return IBindStatusCallback_AddRef(STATUSCLB(This)); return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
} }
static ULONG WINAPI DwlServiceProvider_Release(IServiceProvider *iface) static ULONG WINAPI DwlServiceProvider_Release(IServiceProvider *iface)
{ {
DownloadBSC *This = SERVPROV_THIS(iface); DownloadBSC *This = impl_from_IServiceProvider(iface);
return IBindStatusCallback_Release(STATUSCLB(This)); return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
} }
static HRESULT WINAPI DwlServiceProvider_QueryService(IServiceProvider *iface, static HRESULT WINAPI DwlServiceProvider_QueryService(IServiceProvider *iface,
REFGUID guidService, REFIID riid, void **ppv) REFGUID guidService, REFIID riid, void **ppv)
{ {
DownloadBSC *This = SERVPROV_THIS(iface); DownloadBSC *This = impl_from_IServiceProvider(iface);
IServiceProvider *serv_prov; IServiceProvider *serv_prov;
HRESULT hres; HRESULT hres;
...@@ -294,8 +295,6 @@ static HRESULT WINAPI DwlServiceProvider_QueryService(IServiceProvider *iface, ...@@ -294,8 +295,6 @@ static HRESULT WINAPI DwlServiceProvider_QueryService(IServiceProvider *iface,
return E_NOINTERFACE; return E_NOINTERFACE;
} }
#undef SERVPROV_THIS
static const IServiceProviderVtbl ServiceProviderVtbl = { static const IServiceProviderVtbl ServiceProviderVtbl = {
DwlServiceProvider_QueryInterface, DwlServiceProvider_QueryInterface,
DwlServiceProvider_AddRef, DwlServiceProvider_AddRef,
...@@ -307,8 +306,8 @@ static HRESULT DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_na ...@@ -307,8 +306,8 @@ static HRESULT DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_na
{ {
DownloadBSC *ret = heap_alloc(sizeof(*ret)); DownloadBSC *ret = heap_alloc(sizeof(*ret));
ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl; ret->IBindStatusCallback_iface.lpVtbl = &BindStatusCallbackVtbl;
ret->lpServiceProviderVtbl = &ServiceProviderVtbl; ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
ret->ref = 1; ret->ref = 1;
ret->file_name = heap_strdupW(file_name); ret->file_name = heap_strdupW(file_name);
ret->cache_file = NULL; ret->cache_file = NULL;
...@@ -317,7 +316,7 @@ static HRESULT DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_na ...@@ -317,7 +316,7 @@ static HRESULT DownloadBSC_Create(IBindStatusCallback *callback, LPCWSTR file_na
IBindStatusCallback_AddRef(callback); IBindStatusCallback_AddRef(callback);
ret->callback = callback; ret->callback = callback;
*ret_callback = STATUSCLB(ret); *ret_callback = &ret->IBindStatusCallback_iface;
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