qmgr: Use an iface instead of a vtbl pointer in DLBindStatusCallback.

This commit is contained in:
Michael Stefaniuc 2010-12-04 22:16:22 +01:00 committed by Alexandre Julliard
parent be5bb18502
commit 21c1cbf308
1 changed files with 17 additions and 11 deletions

View File

@ -213,20 +213,25 @@ static DWORD CALLBACK copyProgressCallback(LARGE_INTEGER totalSize,
typedef struct typedef struct
{ {
const IBindStatusCallbackVtbl *lpVtbl; IBindStatusCallback IBindStatusCallback_iface;
BackgroundCopyFileImpl *file; BackgroundCopyFileImpl *file;
LONG ref; LONG ref;
} DLBindStatusCallback; } DLBindStatusCallback;
static inline DLBindStatusCallback *impl_from_IBindStatusCallback(IBindStatusCallback *iface)
{
return CONTAINING_RECORD(iface, DLBindStatusCallback, IBindStatusCallback_iface);
}
static ULONG WINAPI DLBindStatusCallback_AddRef(IBindStatusCallback *iface) static ULONG WINAPI DLBindStatusCallback_AddRef(IBindStatusCallback *iface)
{ {
DLBindStatusCallback *This = (DLBindStatusCallback *) iface; DLBindStatusCallback *This = impl_from_IBindStatusCallback(iface);
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI DLBindStatusCallback_Release(IBindStatusCallback *iface) static ULONG WINAPI DLBindStatusCallback_Release(IBindStatusCallback *iface)
{ {
DLBindStatusCallback *This = (DLBindStatusCallback *) iface; DLBindStatusCallback *This = impl_from_IBindStatusCallback(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0)
@ -243,12 +248,12 @@ static HRESULT WINAPI DLBindStatusCallback_QueryInterface(
REFIID riid, REFIID riid,
void **ppvObject) void **ppvObject)
{ {
DLBindStatusCallback *This = (DLBindStatusCallback *) iface; DLBindStatusCallback *This = impl_from_IBindStatusCallback(iface);
if (IsEqualGUID(riid, &IID_IUnknown) if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IBindStatusCallback)) || IsEqualGUID(riid, &IID_IBindStatusCallback))
{ {
*ppvObject = &This->lpVtbl; *ppvObject = &This->IBindStatusCallback_iface;
DLBindStatusCallback_AddRef(iface); DLBindStatusCallback_AddRef(iface);
return S_OK; return S_OK;
} }
@ -304,7 +309,7 @@ static HRESULT WINAPI DLBindStatusCallback_OnProgress(
ULONG statusCode, ULONG statusCode,
LPCWSTR statusText) LPCWSTR statusText)
{ {
DLBindStatusCallback *This = (DLBindStatusCallback *) iface; DLBindStatusCallback *This = impl_from_IBindStatusCallback(iface);
BackgroundCopyFileImpl *file = This->file; BackgroundCopyFileImpl *file = This->file;
BackgroundCopyJobImpl *job = file->owner; BackgroundCopyJobImpl *job = file->owner;
ULONG64 diff; ULONG64 diff;
@ -359,7 +364,7 @@ static DLBindStatusCallback *DLBindStatusCallbackConstructor(
if (!This) if (!This)
return NULL; return NULL;
This->lpVtbl = &DLBindStatusCallback_Vtbl; This->IBindStatusCallback_iface.lpVtbl = &DLBindStatusCallback_Vtbl;
IBackgroundCopyFile_AddRef((IBackgroundCopyFile *) file); IBackgroundCopyFile_AddRef((IBackgroundCopyFile *) file);
This->file = file; This->file = file;
This->ref = 1; This->ref = 1;
@ -369,7 +374,7 @@ static DLBindStatusCallback *DLBindStatusCallbackConstructor(
BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job)
{ {
static const WCHAR prefix[] = {'B','I','T', 0}; static const WCHAR prefix[] = {'B','I','T', 0};
IBindStatusCallback *callbackObj; DLBindStatusCallback *callbackObj;
WCHAR tmpDir[MAX_PATH]; WCHAR tmpDir[MAX_PATH];
WCHAR tmpName[MAX_PATH]; WCHAR tmpName[MAX_PATH];
HRESULT hr; HRESULT hr;
@ -390,7 +395,7 @@ BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job)
return FALSE; return FALSE;
} }
callbackObj = (IBindStatusCallback *) DLBindStatusCallbackConstructor(file); callbackObj = DLBindStatusCallbackConstructor(file);
if (!callbackObj) if (!callbackObj)
{ {
ERR("Out of memory\n"); ERR("Out of memory\n");
@ -412,8 +417,9 @@ BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job)
transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSFERRING); transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSFERRING);
DeleteUrlCacheEntryW(file->info.RemoteName); DeleteUrlCacheEntryW(file->info.RemoteName);
hr = URLDownloadToFileW(NULL, file->info.RemoteName, tmpName, 0, callbackObj); hr = URLDownloadToFileW(NULL, file->info.RemoteName, tmpName, 0,
IBindStatusCallback_Release(callbackObj); &callbackObj->IBindStatusCallback_iface);
IBindStatusCallback_Release(&callbackObj->IBindStatusCallback_iface);
if (hr == INET_E_DOWNLOAD_FAILURE) if (hr == INET_E_DOWNLOAD_FAILURE)
{ {
TRACE("URLDownload failed, trying local file copy\n"); TRACE("URLDownload failed, trying local file copy\n");