qmgr: COM cleanup for the IEnumBackgroundCopyJobs iface.

This commit is contained in:
Michael Stefaniuc 2012-12-04 23:24:45 +01:00 committed by Alexandre Julliard
parent 2f7885d990
commit efff59a2c8
2 changed files with 48 additions and 52 deletions

View File

@ -23,6 +23,20 @@
WINE_DEFAULT_DEBUG_CHANNEL(qmgr); WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
typedef struct
{
IEnumBackgroundCopyJobs IEnumBackgroundCopyJobs_iface;
LONG ref;
IBackgroundCopyJob **jobs;
ULONG numJobs;
ULONG indexJobs;
} EnumBackgroundCopyJobsImpl;
static inline EnumBackgroundCopyJobsImpl *impl_from_IEnumBackgroundCopyJobs(IEnumBackgroundCopyJobs *iface)
{
return CONTAINING_RECORD(iface, EnumBackgroundCopyJobsImpl, IEnumBackgroundCopyJobs_iface);
}
static void EnumBackgroundCopyJobsDestructor(EnumBackgroundCopyJobsImpl *This) static void EnumBackgroundCopyJobsDestructor(EnumBackgroundCopyJobsImpl *This)
{ {
ULONG i; ULONG i;
@ -34,52 +48,49 @@ static void EnumBackgroundCopyJobsDestructor(EnumBackgroundCopyJobsImpl *This)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_AddRef( static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_QueryInterface(IEnumBackgroundCopyJobs *iface,
IEnumBackgroundCopyJobs* iface) REFIID riid, void **ppv)
{ {
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface; TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv);
return InterlockedIncrement(&This->ref);
}
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_QueryInterface( if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumBackgroundCopyJobs))
IEnumBackgroundCopyJobs* iface,
REFIID riid,
void **ppvObject)
{
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface;
TRACE("IID: %s\n", debugstr_guid(riid));
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IEnumBackgroundCopyJobs))
{ {
*ppvObject = &This->lpVtbl; *ppv = iface;
BITS_IEnumBackgroundCopyJobs_AddRef(iface); IEnumBackgroundCopyJobs_AddRef(iface);
return S_OK; return S_OK;
} }
*ppvObject = NULL; *ppv = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_Release( static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_AddRef(IEnumBackgroundCopyJobs *iface)
IEnumBackgroundCopyJobs* iface)
{ {
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface; EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_Release(IEnumBackgroundCopyJobs *iface)
{
EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if (ref == 0) if (ref == 0)
EnumBackgroundCopyJobsDestructor(This); EnumBackgroundCopyJobsDestructor(This);
return ref; return ref;
} }
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Next( static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Next(IEnumBackgroundCopyJobs *iface, ULONG celt,
IEnumBackgroundCopyJobs* iface, IBackgroundCopyJob **rgelt, ULONG *pceltFetched)
ULONG celt,
IBackgroundCopyJob **rgelt,
ULONG *pceltFetched)
{ {
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface; EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface);
ULONG fetched; ULONG fetched;
ULONG i; ULONG i;
IBackgroundCopyJob *job; IBackgroundCopyJob *job;
@ -110,11 +121,9 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Next(
return fetched == celt ? S_OK : S_FALSE; return fetched == celt ? S_OK : S_FALSE;
} }
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Skip( static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Skip(IEnumBackgroundCopyJobs *iface, ULONG celt)
IEnumBackgroundCopyJobs* iface,
ULONG celt)
{ {
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface; EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface);
if (This->numJobs - This->indexJobs < celt) if (This->numJobs - This->indexJobs < celt)
{ {
@ -126,27 +135,24 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Skip(
return S_OK; return S_OK;
} }
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Reset( static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Reset(IEnumBackgroundCopyJobs *iface)
IEnumBackgroundCopyJobs* iface)
{ {
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface; EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface);
This->indexJobs = 0; This->indexJobs = 0;
return S_OK; return S_OK;
} }
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Clone( static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Clone(IEnumBackgroundCopyJobs *iface,
IEnumBackgroundCopyJobs* iface, IEnumBackgroundCopyJobs **ppenum)
IEnumBackgroundCopyJobs **ppenum)
{ {
FIXME("Not implemented\n"); FIXME("Not implemented\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_GetCount( static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_GetCount(IEnumBackgroundCopyJobs *iface,
IEnumBackgroundCopyJobs* iface,
ULONG *puCount) ULONG *puCount)
{ {
EnumBackgroundCopyJobsImpl *This = (EnumBackgroundCopyJobsImpl *) iface; EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface);
*puCount = This->numJobs; *puCount = This->numJobs;
return S_OK; return S_OK;
} }
@ -174,7 +180,7 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
if (!This) if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->lpVtbl = &BITS_IEnumBackgroundCopyJobs_Vtbl; This->IEnumBackgroundCopyJobs_iface.lpVtbl = &BITS_IEnumBackgroundCopyJobs_Vtbl;
This->ref = 1; This->ref = 1;
/* Create array of jobs */ /* Create array of jobs */
@ -206,6 +212,6 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop
} }
LeaveCriticalSection(&qmgr->cs); LeaveCriticalSection(&qmgr->cs);
*enumjob = (IEnumBackgroundCopyJobs *)&This->lpVtbl; *enumjob = &This->IEnumBackgroundCopyJobs_iface;
return S_OK; return S_OK;
} }

View File

@ -46,16 +46,6 @@ typedef struct
struct list entryFromQmgr; struct list entryFromQmgr;
} BackgroundCopyJobImpl; } BackgroundCopyJobImpl;
/* Enum background copy jobs vtbl and related data */
typedef struct
{
const IEnumBackgroundCopyJobsVtbl *lpVtbl;
LONG ref;
IBackgroundCopyJob **jobs;
ULONG numJobs;
ULONG indexJobs;
} EnumBackgroundCopyJobsImpl;
/* Enum background copy files vtbl and related data */ /* Enum background copy files vtbl and related data */
typedef struct typedef struct
{ {