qmgr: COM cleanup for the IEnumBackgroundCopyFiles iface.

This commit is contained in:
Michael Stefaniuc 2012-12-05 23:53:15 +01:00 committed by Alexandre Julliard
parent da71545319
commit 49e6d411b0
2 changed files with 44 additions and 50 deletions

View File

@ -23,6 +23,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
typedef struct
{
IEnumBackgroundCopyFiles IEnumBackgroundCopyFiles_iface;
LONG ref;
IBackgroundCopyFile **files;
ULONG numFiles;
ULONG indexFiles;
} EnumBackgroundCopyFilesImpl;
static void EnumBackgroundCopyFilesDestructor(EnumBackgroundCopyFilesImpl *This)
{
ULONG i;
@ -34,37 +43,39 @@ static void EnumBackgroundCopyFilesDestructor(EnumBackgroundCopyFilesImpl *This)
HeapFree(GetProcessHeap(), 0, This);
}
static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_AddRef(
IEnumBackgroundCopyFiles* iface)
static inline EnumBackgroundCopyFilesImpl *impl_from_IEnumBackgroundCopyFiles(IEnumBackgroundCopyFiles *iface)
{
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
return InterlockedIncrement(&This->ref);
return CONTAINING_RECORD(iface, EnumBackgroundCopyFilesImpl, IEnumBackgroundCopyFiles_iface);
}
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_QueryInterface(
IEnumBackgroundCopyFiles* iface,
REFIID riid,
void **ppvObject)
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_QueryInterface(IEnumBackgroundCopyFiles *iface,
REFIID riid, void **ppv)
{
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
TRACE("IID: %s\n", debugstr_guid(riid));
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IEnumBackgroundCopyFiles))
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumBackgroundCopyFiles))
{
*ppvObject = &This->lpVtbl;
BITS_IEnumBackgroundCopyFiles_AddRef(iface);
*ppv = iface;
IEnumBackgroundCopyFiles_AddRef(iface);
return S_OK;
}
*ppvObject = NULL;
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(
IEnumBackgroundCopyFiles* iface)
static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_AddRef(IEnumBackgroundCopyFiles *iface)
{
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(IEnumBackgroundCopyFiles *iface)
{
EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
@ -74,13 +85,10 @@ static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(
}
/* Return reference to one or more files in the file enumerator */
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(
IEnumBackgroundCopyFiles* iface,
ULONG celt,
IBackgroundCopyFile **rgelt,
ULONG *pceltFetched)
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(IEnumBackgroundCopyFiles *iface,
ULONG celt, IBackgroundCopyFile **rgelt, ULONG *pceltFetched)
{
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
ULONG fetched;
ULONG i;
IBackgroundCopyFile *file;
@ -115,11 +123,10 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(
}
/* Skip over one or more files in the file enumerator */
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(
IEnumBackgroundCopyFiles* iface,
ULONG celt)
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(IEnumBackgroundCopyFiles *iface,
ULONG celt)
{
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
if (celt > This->numFiles - This->indexFiles)
{
@ -131,27 +138,24 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(
return S_OK;
}
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Reset(
IEnumBackgroundCopyFiles* iface)
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Reset(IEnumBackgroundCopyFiles *iface)
{
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
This->indexFiles = 0;
return S_OK;
}
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Clone(
IEnumBackgroundCopyFiles* iface,
IEnumBackgroundCopyFiles **ppenum)
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Clone(IEnumBackgroundCopyFiles *iface,
IEnumBackgroundCopyFiles **ppenum)
{
FIXME("Not implemented\n");
return E_NOTIMPL;
}
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_GetCount(
IEnumBackgroundCopyFiles* iface,
ULONG *puCount)
static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_GetCount(IEnumBackgroundCopyFiles *iface,
ULONG *puCount)
{
EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
*puCount = This->numFiles;
return S_OK;
}
@ -181,7 +185,7 @@ HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, IBackgroundCopyJob2 *i
if (!This)
return E_OUTOFMEMORY;
This->lpVtbl = &BITS_IEnumBackgroundCopyFiles_Vtbl;
This->IEnumBackgroundCopyFiles_iface.lpVtbl = &BITS_IEnumBackgroundCopyFiles_Vtbl;
This->ref = 1;
/* Create array of files */
@ -210,6 +214,6 @@ HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, IBackgroundCopyJob2 *i
}
LeaveCriticalSection(&job->cs);
*ppObj = &This->lpVtbl;
*ppObj = &This->IEnumBackgroundCopyFiles_iface;
return S_OK;
}

View File

@ -46,16 +46,6 @@ typedef struct
struct list entryFromQmgr;
} BackgroundCopyJobImpl;
/* Enum background copy files vtbl and related data */
typedef struct
{
const IEnumBackgroundCopyFilesVtbl *lpVtbl;
LONG ref;
IBackgroundCopyFile **files;
ULONG numFiles;
ULONG indexFiles;
} EnumBackgroundCopyFilesImpl;
/* Background copy file vtbl and related data */
typedef struct
{