Commit a7449dbf authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

qmgr: COM cleanup of IBackgroundCopyJob2 interface.

parent 62b4f31d
...@@ -167,14 +167,13 @@ static const IEnumBackgroundCopyFilesVtbl BITS_IEnumBackgroundCopyFiles_Vtbl = ...@@ -167,14 +167,13 @@ static const IEnumBackgroundCopyFilesVtbl BITS_IEnumBackgroundCopyFiles_Vtbl =
BITS_IEnumBackgroundCopyFiles_GetCount BITS_IEnumBackgroundCopyFiles_GetCount
}; };
HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, IBackgroundCopyJob2 *iCopyJob) HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBackgroundCopyFiles **enum_files)
{ {
EnumBackgroundCopyFilesImpl *This; EnumBackgroundCopyFilesImpl *This;
BackgroundCopyFileImpl *file; BackgroundCopyFileImpl *file;
BackgroundCopyJobImpl *job = (BackgroundCopyJobImpl *) iCopyJob;
ULONG i; ULONG i;
TRACE("%p, %p)\n", ppObj, job); TRACE("%p, %p)\n", job, enum_files);
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
if (!This) if (!This)
...@@ -209,6 +208,6 @@ HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, IBackgroundCopyJob2 *i ...@@ -209,6 +208,6 @@ HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, IBackgroundCopyJob2 *i
} }
LeaveCriticalSection(&job->cs); LeaveCriticalSection(&job->cs);
*ppObj = &This->IEnumBackgroundCopyFiles_iface; *enum_files = &This->IEnumBackgroundCopyFiles_iface;
return S_OK; return S_OK;
} }
...@@ -200,9 +200,9 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop ...@@ -200,9 +200,9 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop
i = 0; i = 0;
LIST_FOR_EACH_ENTRY(job, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr) LIST_FOR_EACH_ENTRY(job, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr)
{ {
IBackgroundCopyJob *iJob = (IBackgroundCopyJob *) job; IBackgroundCopyJob *job_iface = (IBackgroundCopyJob*)&job->IBackgroundCopyJob2_iface;
IBackgroundCopyJob_AddRef(iJob); IBackgroundCopyJob_AddRef(job_iface);
This->jobs[i++] = iJob; This->jobs[i++] = job_iface;
} }
LeaveCriticalSection(&qmgr->cs); LeaveCriticalSection(&qmgr->cs);
......
...@@ -37,7 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(qmgr); ...@@ -37,7 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
static void BackgroundCopyFileDestructor(BackgroundCopyFileImpl *This) static void BackgroundCopyFileDestructor(BackgroundCopyFileImpl *This)
{ {
IBackgroundCopyJob_Release((IBackgroundCopyJob *) This->owner); IBackgroundCopyJob2_Release(&This->owner->IBackgroundCopyJob2_iface);
HeapFree(GetProcessHeap(), 0, This->info.LocalName); HeapFree(GetProcessHeap(), 0, This->info.LocalName);
HeapFree(GetProcessHeap(), 0, This->info.RemoteName); HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
...@@ -177,7 +177,7 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner, ...@@ -177,7 +177,7 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
This->fileProgress.BytesTransferred = 0; This->fileProgress.BytesTransferred = 0;
This->fileProgress.Completed = FALSE; This->fileProgress.Completed = FALSE;
This->owner = owner; This->owner = owner;
IBackgroundCopyJob_AddRef((IBackgroundCopyJob *) owner); IBackgroundCopyJob2_AddRef(&owner->IBackgroundCopyJob2_iface);
*ppObj = &This->lpVtbl; *ppObj = &This->lpVtbl;
return S_OK; return S_OK;
......
...@@ -36,36 +36,46 @@ static void BackgroundCopyJobDestructor(BackgroundCopyJobImpl *This) ...@@ -36,36 +36,46 @@ static void BackgroundCopyJobDestructor(BackgroundCopyJobImpl *This)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
static ULONG WINAPI BITS_IBackgroundCopyJob_AddRef(IBackgroundCopyJob2 *iface) static inline BackgroundCopyJobImpl *impl_from_IBackgroundCopyJob2(IBackgroundCopyJob2 *iface)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; return CONTAINING_RECORD(iface, BackgroundCopyJobImpl, IBackgroundCopyJob2_iface);
return InterlockedIncrement(&This->ref);
} }
static HRESULT WINAPI BITS_IBackgroundCopyJob_QueryInterface( static HRESULT WINAPI BITS_IBackgroundCopyJob_QueryInterface(
IBackgroundCopyJob2 *iface, REFIID riid, LPVOID *ppvObject) IBackgroundCopyJob2 *iface, REFIID riid, void **obj)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
TRACE("IID: %s\n", debugstr_guid(riid));
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
if (IsEqualGUID(riid, &IID_IUnknown) if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IBackgroundCopyJob) || IsEqualGUID(riid, &IID_IBackgroundCopyJob)
|| IsEqualGUID(riid, &IID_IBackgroundCopyJob2)) || IsEqualGUID(riid, &IID_IBackgroundCopyJob2))
{ {
*ppvObject = &This->lpVtbl; *obj = iface;
BITS_IBackgroundCopyJob_AddRef(iface); IBackgroundCopyJob2_AddRef(iface);
return S_OK; return S_OK;
} }
*ppvObject = NULL; *obj = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI BITS_IBackgroundCopyJob_AddRef(IBackgroundCopyJob2 *iface)
{
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
return ref;
}
static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface) static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
if (ref == 0) if (ref == 0)
BackgroundCopyJobDestructor(This); BackgroundCopyJobDestructor(This);
...@@ -95,7 +105,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile( ...@@ -95,7 +105,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
LPCWSTR RemoteUrl, LPCWSTR RemoteUrl,
LPCWSTR LocalName) LPCWSTR LocalName)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
IBackgroundCopyFile *pFile; IBackgroundCopyFile *pFile;
BackgroundCopyFileImpl *file; BackgroundCopyFileImpl *file;
HRESULT res; HRESULT res;
...@@ -121,10 +131,11 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile( ...@@ -121,10 +131,11 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles( static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles(
IBackgroundCopyJob2 *iface, IBackgroundCopyJob2 *iface,
IEnumBackgroundCopyFiles **ppEnum) IEnumBackgroundCopyFiles **enum_files)
{ {
TRACE("\n"); BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
return EnumBackgroundCopyFilesConstructor((LPVOID *) ppEnum, iface); TRACE("(%p)->(%p)\n", This, enum_files);
return EnumBackgroundCopyFilesConstructor(This, enum_files);
} }
static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend( static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend(
...@@ -137,7 +148,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend( ...@@ -137,7 +148,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend(
static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume( static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume(
IBackgroundCopyJob2 *iface) IBackgroundCopyJob2 *iface)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
HRESULT rv = S_OK; HRESULT rv = S_OK;
EnterCriticalSection(&globalMgr.cs); EnterCriticalSection(&globalMgr.cs);
...@@ -171,7 +182,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel( ...@@ -171,7 +182,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel(
static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete( static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete(
IBackgroundCopyJob2 *iface) IBackgroundCopyJob2 *iface)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
HRESULT rv = S_OK; HRESULT rv = S_OK;
EnterCriticalSection(&This->cs); EnterCriticalSection(&This->cs);
...@@ -214,7 +225,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetId( ...@@ -214,7 +225,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetId(
IBackgroundCopyJob2 *iface, IBackgroundCopyJob2 *iface,
GUID *pVal) GUID *pVal)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
*pVal = This->jobId; *pVal = This->jobId;
return S_OK; return S_OK;
} }
...@@ -223,7 +234,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType( ...@@ -223,7 +234,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType(
IBackgroundCopyJob2 *iface, IBackgroundCopyJob2 *iface,
BG_JOB_TYPE *pVal) BG_JOB_TYPE *pVal)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
if (!pVal) if (!pVal)
return E_INVALIDARG; return E_INVALIDARG;
...@@ -236,7 +247,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress( ...@@ -236,7 +247,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress(
IBackgroundCopyJob2 *iface, IBackgroundCopyJob2 *iface,
BG_JOB_PROGRESS *pVal) BG_JOB_PROGRESS *pVal)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
if (!pVal) if (!pVal)
return E_INVALIDARG; return E_INVALIDARG;
...@@ -263,7 +274,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState( ...@@ -263,7 +274,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState(
IBackgroundCopyJob2 *iface, IBackgroundCopyJob2 *iface,
BG_JOB_STATE *pVal) BG_JOB_STATE *pVal)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
if (!pVal) if (!pVal)
return E_INVALIDARG; return E_INVALIDARG;
...@@ -301,7 +312,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName( ...@@ -301,7 +312,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName(
IBackgroundCopyJob2 *iface, IBackgroundCopyJob2 *iface,
LPWSTR *pVal) LPWSTR *pVal)
{ {
BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface; BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
int n; int n;
if (!pVal) if (!pVal)
...@@ -563,20 +574,19 @@ static const IBackgroundCopyJob2Vtbl BITS_IBackgroundCopyJob_Vtbl = ...@@ -563,20 +574,19 @@ static const IBackgroundCopyJob2Vtbl BITS_IBackgroundCopyJob_Vtbl =
BITS_IBackgroundCopyJob_RemoveCredentials BITS_IBackgroundCopyJob_RemoveCredentials
}; };
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID *job_id, BackgroundCopyJobImpl **job)
GUID *pJobId, LPVOID *ppObj)
{ {
HRESULT hr; HRESULT hr;
BackgroundCopyJobImpl *This; BackgroundCopyJobImpl *This;
int n; int n;
TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, ppObj); TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job);
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_IBackgroundCopyJob_Vtbl; This->IBackgroundCopyJob2_iface.lpVtbl = &BITS_IBackgroundCopyJob_Vtbl;
InitializeCriticalSection(&This->cs); InitializeCriticalSection(&This->cs);
This->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BackgroundCopyJobImpl.cs"); This->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BackgroundCopyJobImpl.cs");
...@@ -603,7 +613,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, ...@@ -603,7 +613,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return hr; return hr;
} }
*pJobId = This->jobId; *job_id = This->jobId;
list_init(&This->files); list_init(&This->files);
This->jobProgress.BytesTotal = 0; This->jobProgress.BytesTotal = 0;
...@@ -613,7 +623,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, ...@@ -613,7 +623,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
This->state = BG_JOB_STATE_SUSPENDED; This->state = BG_JOB_STATE_SUSPENDED;
*ppObj = &This->lpVtbl; *job = This;
return S_OK; return S_OK;
} }
......
...@@ -60,14 +60,13 @@ static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob(IBackgroundCopyManag ...@@ -60,14 +60,13 @@ static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob(IBackgroundCopyManag
HRESULT hres; HRESULT hres;
TRACE("\n"); TRACE("\n");
hres = BackgroundCopyJobConstructor(DisplayName, Type, pJobId, hres = BackgroundCopyJobConstructor(DisplayName, Type, pJobId, &job);
(LPVOID *) ppJob);
if (FAILED(hres)) if (FAILED(hres))
return hres; return hres;
/* Add a reference to the job to job list */ /* Add a reference to the job to job list */
*ppJob = (IBackgroundCopyJob*)&job->IBackgroundCopyJob2_iface;
IBackgroundCopyJob_AddRef(*ppJob); IBackgroundCopyJob_AddRef(*ppJob);
job = (BackgroundCopyJobImpl *) *ppJob;
EnterCriticalSection(&globalMgr.cs); EnterCriticalSection(&globalMgr.cs);
list_add_head(&globalMgr.jobs, &job->entryFromQmgr); list_add_head(&globalMgr.jobs, &job->entryFromQmgr);
LeaveCriticalSection(&globalMgr.cs); LeaveCriticalSection(&globalMgr.cs);
...@@ -141,7 +140,7 @@ DWORD WINAPI fileTransfer(void *param) ...@@ -141,7 +140,7 @@ DWORD WINAPI fileTransfer(void *param)
LIST_FOR_EACH_ENTRY_SAFE(job, jobCur, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr) LIST_FOR_EACH_ENTRY_SAFE(job, jobCur, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr)
{ {
list_remove(&job->entryFromQmgr); list_remove(&job->entryFromQmgr);
IBackgroundCopyJob_Release((IBackgroundCopyJob *) job); IBackgroundCopyJob2_Release(&job->IBackgroundCopyJob2_iface);
} }
return 0; return 0;
} }
...@@ -156,7 +155,7 @@ DWORD WINAPI fileTransfer(void *param) ...@@ -156,7 +155,7 @@ DWORD WINAPI fileTransfer(void *param)
if (job->state == BG_JOB_STATE_ACKNOWLEDGED || job->state == BG_JOB_STATE_CANCELLED) if (job->state == BG_JOB_STATE_ACKNOWLEDGED || job->state == BG_JOB_STATE_CANCELLED)
{ {
list_remove(&job->entryFromQmgr); list_remove(&job->entryFromQmgr);
IBackgroundCopyJob_Release((IBackgroundCopyJob *) job); IBackgroundCopyJob2_Release(&job->IBackgroundCopyJob2_iface);
} }
else if (job->state == BG_JOB_STATE_QUEUED) else if (job->state == BG_JOB_STATE_QUEUED)
{ {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
/* Background copy job vtbl and related data */ /* Background copy job vtbl and related data */
typedef struct typedef struct
{ {
const IBackgroundCopyJob2Vtbl *lpVtbl; IBackgroundCopyJob2 IBackgroundCopyJob2_iface;
LONG ref; LONG ref;
LPWSTR displayName; LPWSTR displayName;
BG_JOB_TYPE type; BG_JOB_TYPE type;
...@@ -79,14 +79,13 @@ extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN; ...@@ -79,14 +79,13 @@ extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN;
HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
GUID *pJobId, LPVOID *ppObj) DECLSPEC_HIDDEN; GUID *pJobId, BackgroundCopyJobImpl **job) DECLSPEC_HIDDEN;
HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr,
IEnumBackgroundCopyJobs **enumjob) DECLSPEC_HIDDEN; IEnumBackgroundCopyJobs **enumjob) DECLSPEC_HIDDEN;
HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner, HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
LPCWSTR remoteName, LPCWSTR localName, LPCWSTR remoteName, LPCWSTR localName,
LPVOID *ppObj) DECLSPEC_HIDDEN; LPVOID *ppObj) DECLSPEC_HIDDEN;
HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl*, IEnumBackgroundCopyFiles**) DECLSPEC_HIDDEN;
IBackgroundCopyJob2 *copyJob) DECLSPEC_HIDDEN;
DWORD WINAPI fileTransfer(void *param) DECLSPEC_HIDDEN; DWORD WINAPI fileTransfer(void *param) DECLSPEC_HIDDEN;
void processJob(BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN; void processJob(BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN; BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
......
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