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

qmgr: COM cleanup for IBackgroundCopyFile interface.

parent 175039e7
......@@ -202,8 +202,8 @@ HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBack
i = 0;
LIST_FOR_EACH_ENTRY(file, &job->files, BackgroundCopyFileImpl, entryFromJob)
{
file->lpVtbl->AddRef((IBackgroundCopyFile *) file);
This->files[i] = (IBackgroundCopyFile *) file;
IBackgroundCopyFile_AddRef(&file->IBackgroundCopyFile_iface);
This->files[i] = &file->IBackgroundCopyFile_iface;
++i;
}
LeaveCriticalSection(&job->cs);
......
......@@ -35,6 +35,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
static inline BackgroundCopyFileImpl *impl_from_IBackgroundCopyFile(IBackgroundCopyFile *iface)
{
return CONTAINING_RECORD(iface, BackgroundCopyFileImpl, IBackgroundCopyFile_iface);
}
static void BackgroundCopyFileDestructor(BackgroundCopyFileImpl *This)
{
IBackgroundCopyJob2_Release(&This->owner->IBackgroundCopyJob2_iface);
......@@ -43,38 +48,43 @@ static void BackgroundCopyFileDestructor(BackgroundCopyFileImpl *This)
HeapFree(GetProcessHeap(), 0, This);
}
static ULONG WINAPI BITS_IBackgroundCopyFile_AddRef(IBackgroundCopyFile* iface)
{
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
return InterlockedIncrement(&This->ref);
}
static HRESULT WINAPI BITS_IBackgroundCopyFile_QueryInterface(
IBackgroundCopyFile* iface,
REFIID riid,
void **ppvObject)
void **obj)
{
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IBackgroundCopyFile))
{
*ppvObject = &This->lpVtbl;
BITS_IBackgroundCopyFile_AddRef(iface);
*obj = iface;
IBackgroundCopyFile_AddRef(iface);
return S_OK;
}
*ppvObject = NULL;
*obj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI BITS_IBackgroundCopyFile_AddRef(IBackgroundCopyFile* iface)
{
BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
return ref;
}
static ULONG WINAPI BITS_IBackgroundCopyFile_Release(
IBackgroundCopyFile* iface)
{
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
if (ref == 0)
BackgroundCopyFileDestructor(This);
......@@ -86,7 +96,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyFile_GetRemoteName(
IBackgroundCopyFile* iface,
LPWSTR *pVal)
{
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface);
int n = (lstrlenW(This->info.RemoteName) + 1) * sizeof(WCHAR);
*pVal = CoTaskMemAlloc(n);
......@@ -101,7 +111,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyFile_GetLocalName(
IBackgroundCopyFile* iface,
LPWSTR *pVal)
{
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface);
int n = (lstrlenW(This->info.LocalName) + 1) * sizeof(WCHAR);
*pVal = CoTaskMemAlloc(n);
......@@ -116,7 +126,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyFile_GetProgress(
IBackgroundCopyFile* iface,
BG_FILE_PROGRESS *pVal)
{
BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface);
EnterCriticalSection(&This->owner->cs);
pVal->BytesTotal = This->fileProgress.BytesTotal;
......@@ -139,13 +149,12 @@ static const IBackgroundCopyFileVtbl BITS_IBackgroundCopyFile_Vtbl =
HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
LPCWSTR remoteName, LPCWSTR localName,
LPVOID *ppObj)
BackgroundCopyFileImpl **file)
{
BackgroundCopyFileImpl *This;
int n;
TRACE("(%s,%s,%p)\n", debugstr_w(remoteName),
debugstr_w(localName), ppObj);
TRACE("(%s, %s, %p)\n", debugstr_w(remoteName), debugstr_w(localName), file);
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
if (!This)
......@@ -170,7 +179,7 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
}
memcpy(This->info.LocalName, localName, n);
This->lpVtbl = &BITS_IBackgroundCopyFile_Vtbl;
This->IBackgroundCopyFile_iface.lpVtbl = &BITS_IBackgroundCopyFile_Vtbl;
This->ref = 1;
This->fileProgress.BytesTotal = BG_SIZE_UNKNOWN;
......@@ -179,7 +188,7 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
This->owner = owner;
IBackgroundCopyJob2_AddRef(&owner->IBackgroundCopyJob2_iface);
*ppObj = &This->lpVtbl;
*file = This;
return S_OK;
}
......@@ -236,7 +245,7 @@ static ULONG WINAPI DLBindStatusCallback_Release(IBindStatusCallback *iface)
if (ref == 0)
{
IBackgroundCopyFile_Release((IBackgroundCopyFile *) This->file);
IBackgroundCopyFile_Release(&This->file->IBackgroundCopyFile_iface);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -365,7 +374,7 @@ static DLBindStatusCallback *DLBindStatusCallbackConstructor(
return NULL;
This->IBindStatusCallback_iface.lpVtbl = &DLBindStatusCallback_Vtbl;
IBackgroundCopyFile_AddRef((IBackgroundCopyFile *) file);
IBackgroundCopyFile_AddRef(&file->IBackgroundCopyFile_iface);
This->file = file;
This->ref = 1;
return This;
......
......@@ -106,20 +106,18 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
LPCWSTR LocalName)
{
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
IBackgroundCopyFile *pFile;
BackgroundCopyFileImpl *file;
HRESULT res;
/* We should return E_INVALIDARG in these cases. */
FIXME("Check for valid filenames and supported protocols\n");
res = BackgroundCopyFileConstructor(This, RemoteUrl, LocalName, (LPVOID *) &pFile);
res = BackgroundCopyFileConstructor(This, RemoteUrl, LocalName, &file);
if (res != S_OK)
return res;
/* Add a reference to the file to file list */
IBackgroundCopyFile_AddRef(pFile);
file = (BackgroundCopyFileImpl *) pFile;
IBackgroundCopyFile_AddRef(&file->IBackgroundCopyFile_iface);
EnterCriticalSection(&This->cs);
list_add_head(&This->files, &file->entryFromJob);
This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN;
......
......@@ -49,7 +49,7 @@ typedef struct
/* Background copy file vtbl and related data */
typedef struct
{
const IBackgroundCopyFileVtbl *lpVtbl;
IBackgroundCopyFile IBackgroundCopyFile_iface;
LONG ref;
BG_FILE_INFO info;
BG_FILE_PROGRESS fileProgress;
......@@ -84,7 +84,7 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr,
IEnumBackgroundCopyJobs **enumjob) DECLSPEC_HIDDEN;
HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
LPCWSTR remoteName, LPCWSTR localName,
LPVOID *ppObj) DECLSPEC_HIDDEN;
BackgroundCopyFileImpl **file) DECLSPEC_HIDDEN;
HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl*, IEnumBackgroundCopyFiles**) DECLSPEC_HIDDEN;
DWORD WINAPI fileTransfer(void *param) DECLSPEC_HIDDEN;
void processJob(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