From 654ba0eca0a4bdc45c89cec63c20f71d2d529f5f Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 26 Apr 2014 18:04:41 +0000 Subject: [PATCH] [QMGR] * Sync with Wine 1.7.17. CORE-8080 svn path=/trunk/; revision=62998 --- reactos/dll/win32/qmgr/enum_files.c | 55 ++-- reactos/dll/win32/qmgr/enum_jobs.c | 57 ++-- reactos/dll/win32/qmgr/factory.c | 2 +- reactos/dll/win32/qmgr/file.c | 84 +++-- reactos/dll/win32/qmgr/job.c | 446 +++++++++++++++++--------- reactos/dll/win32/qmgr/qmgr.c | 80 +++-- reactos/dll/win32/qmgr/qmgr.h | 21 +- reactos/dll/win32/qmgr/qmgr_local.idl | 3 + reactos/dll/win32/qmgr/qmgr_main.c | 35 -- reactos/media/doc/README.WINE | 2 +- 10 files changed, 471 insertions(+), 314 deletions(-) diff --git a/reactos/dll/win32/qmgr/enum_files.c b/reactos/dll/win32/qmgr/enum_files.c index 8b01fd301de..c7648a7db9a 100644 --- a/reactos/dll/win32/qmgr/enum_files.c +++ b/reactos/dll/win32/qmgr/enum_files.c @@ -34,10 +34,12 @@ static inline EnumBackgroundCopyFilesImpl *impl_from_IEnumBackgroundCopyFiles(IE return CONTAINING_RECORD(iface, EnumBackgroundCopyFilesImpl, IEnumBackgroundCopyFiles_iface); } -static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_QueryInterface(IEnumBackgroundCopyFiles *iface, +static HRESULT WINAPI EnumBackgroundCopyFiles_QueryInterface(IEnumBackgroundCopyFiles *iface, REFIID riid, void **ppv) { - TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv); + EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface); + + TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv); if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumBackgroundCopyFiles)) { @@ -50,21 +52,23 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_QueryInterface(IEnumBackgrou return E_NOINTERFACE; } -static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_AddRef(IEnumBackgroundCopyFiles *iface) +static ULONG WINAPI EnumBackgroundCopyFiles_AddRef(IEnumBackgroundCopyFiles *iface) { EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface); ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p) ref=%d\n", This, ref); + TRACE("(%p)->(%d)\n", This, ref); return ref; } -static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(IEnumBackgroundCopyFiles *iface) +static ULONG WINAPI EnumBackgroundCopyFiles_Release(IEnumBackgroundCopyFiles *iface) { EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface); ULONG ref = InterlockedDecrement(&This->ref); ULONG i; + TRACE("(%p)->(%d)\n", This, ref); + if (ref == 0) { for(i = 0; i < This->numFiles; i++) @@ -77,7 +81,7 @@ static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(IEnumBackgroundCopyFil } /* Return reference to one or more files in the file enumerator */ -static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(IEnumBackgroundCopyFiles *iface, +static HRESULT WINAPI EnumBackgroundCopyFiles_Next(IEnumBackgroundCopyFiles *iface, ULONG celt, IBackgroundCopyFile **rgelt, ULONG *pceltFetched) { EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface); @@ -85,6 +89,8 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(IEnumBackgroundCopyFile ULONG i; IBackgroundCopyFile *file; + TRACE("(%p)->(%d %p %p)\n", This, celt, rgelt, pceltFetched); + /* Despite documented behavior, Windows (tested on XP) is not verifying that the caller set pceltFetched to zero. No check here. */ @@ -115,11 +121,13 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(IEnumBackgroundCopyFile } /* Skip over one or more files in the file enumerator */ -static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(IEnumBackgroundCopyFiles *iface, +static HRESULT WINAPI EnumBackgroundCopyFiles_Skip(IEnumBackgroundCopyFiles *iface, ULONG celt) { EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface); + TRACE("(%p)->(%d)\n", This, celt); + if (celt > This->numFiles - This->indexFiles) { This->indexFiles = This->numFiles; @@ -130,38 +138,43 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(IEnumBackgroundCopyFile return S_OK; } -static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Reset(IEnumBackgroundCopyFiles *iface) +static HRESULT WINAPI EnumBackgroundCopyFiles_Reset(IEnumBackgroundCopyFiles *iface) { EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface); + + TRACE("(%p)\n", This); + This->indexFiles = 0; return S_OK; } -static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Clone(IEnumBackgroundCopyFiles *iface, +static HRESULT WINAPI EnumBackgroundCopyFiles_Clone(IEnumBackgroundCopyFiles *iface, IEnumBackgroundCopyFiles **ppenum) { - FIXME("Not implemented\n"); + EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface); + FIXME("(%p)->(%p): stub\n", This, ppenum); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_GetCount(IEnumBackgroundCopyFiles *iface, +static HRESULT WINAPI EnumBackgroundCopyFiles_GetCount(IEnumBackgroundCopyFiles *iface, ULONG *puCount) { EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface); + TRACE("(%p)->(%p)\n", This, puCount); *puCount = This->numFiles; return S_OK; } -static const IEnumBackgroundCopyFilesVtbl BITS_IEnumBackgroundCopyFiles_Vtbl = +static const IEnumBackgroundCopyFilesVtbl EnumBackgroundCopyFilesVtbl = { - BITS_IEnumBackgroundCopyFiles_QueryInterface, - BITS_IEnumBackgroundCopyFiles_AddRef, - BITS_IEnumBackgroundCopyFiles_Release, - BITS_IEnumBackgroundCopyFiles_Next, - BITS_IEnumBackgroundCopyFiles_Skip, - BITS_IEnumBackgroundCopyFiles_Reset, - BITS_IEnumBackgroundCopyFiles_Clone, - BITS_IEnumBackgroundCopyFiles_GetCount + EnumBackgroundCopyFiles_QueryInterface, + EnumBackgroundCopyFiles_AddRef, + EnumBackgroundCopyFiles_Release, + EnumBackgroundCopyFiles_Next, + EnumBackgroundCopyFiles_Skip, + EnumBackgroundCopyFiles_Reset, + EnumBackgroundCopyFiles_Clone, + EnumBackgroundCopyFiles_GetCount }; HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBackgroundCopyFiles **enum_files) @@ -176,7 +189,7 @@ HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl *job, IEnumBack if (!This) return E_OUTOFMEMORY; - This->IEnumBackgroundCopyFiles_iface.lpVtbl = &BITS_IEnumBackgroundCopyFiles_Vtbl; + This->IEnumBackgroundCopyFiles_iface.lpVtbl = &EnumBackgroundCopyFilesVtbl; This->ref = 1; /* Create array of files */ diff --git a/reactos/dll/win32/qmgr/enum_jobs.c b/reactos/dll/win32/qmgr/enum_jobs.c index 6af19be5b97..5dd5d3b083d 100644 --- a/reactos/dll/win32/qmgr/enum_jobs.c +++ b/reactos/dll/win32/qmgr/enum_jobs.c @@ -34,10 +34,12 @@ static inline EnumBackgroundCopyJobsImpl *impl_from_IEnumBackgroundCopyJobs(IEnu return CONTAINING_RECORD(iface, EnumBackgroundCopyJobsImpl, IEnumBackgroundCopyJobs_iface); } -static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_QueryInterface(IEnumBackgroundCopyJobs *iface, +static HRESULT WINAPI EnumBackgroundCopyJobs_QueryInterface(IEnumBackgroundCopyJobs *iface, REFIID riid, void **ppv) { - TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv); + EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface); + + TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv); if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumBackgroundCopyJobs)) { @@ -50,23 +52,23 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_QueryInterface(IEnumBackgroun return E_NOINTERFACE; } -static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_AddRef(IEnumBackgroundCopyJobs *iface) +static ULONG WINAPI EnumBackgroundCopyJobs_AddRef(IEnumBackgroundCopyJobs *iface) { EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface); ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p) ref=%d\n", This, ref); + TRACE("(%p)->(%d)\n", This, ref); return ref; } -static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_Release(IEnumBackgroundCopyJobs *iface) +static ULONG WINAPI EnumBackgroundCopyJobs_Release(IEnumBackgroundCopyJobs *iface) { EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface); ULONG ref = InterlockedDecrement(&This->ref); ULONG i; - TRACE("(%p) ref=%d\n", This, ref); + TRACE("(%p)->(%d)\n", This, ref); if (ref == 0) { for(i = 0; i < This->numJobs; i++) @@ -78,7 +80,7 @@ static ULONG WINAPI BITS_IEnumBackgroundCopyJobs_Release(IEnumBackgroundCopyJobs return ref; } -static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Next(IEnumBackgroundCopyJobs *iface, ULONG celt, +static HRESULT WINAPI EnumBackgroundCopyJobs_Next(IEnumBackgroundCopyJobs *iface, ULONG celt, IBackgroundCopyJob **rgelt, ULONG *pceltFetched) { EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface); @@ -86,6 +88,8 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Next(IEnumBackgroundCopyJobs ULONG i; IBackgroundCopyJob *job; + TRACE("(%p)->(%d %p %p)\n", This, celt, rgelt, pceltFetched); + fetched = min(celt, This->numJobs - This->indexJobs); if (pceltFetched) *pceltFetched = fetched; @@ -112,10 +116,12 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Next(IEnumBackgroundCopyJobs return fetched == celt ? S_OK : S_FALSE; } -static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Skip(IEnumBackgroundCopyJobs *iface, ULONG celt) +static HRESULT WINAPI EnumBackgroundCopyJobs_Skip(IEnumBackgroundCopyJobs *iface, ULONG celt) { EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface); + TRACE("(%p)->(%d)\n", This, celt); + if (This->numJobs - This->indexJobs < celt) { This->indexJobs = This->numJobs; @@ -126,38 +132,45 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Skip(IEnumBackgroundCopyJobs return S_OK; } -static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Reset(IEnumBackgroundCopyJobs *iface) +static HRESULT WINAPI EnumBackgroundCopyJobs_Reset(IEnumBackgroundCopyJobs *iface) { EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface); + + TRACE("(%p)\n", This); + This->indexJobs = 0; return S_OK; } -static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_Clone(IEnumBackgroundCopyJobs *iface, +static HRESULT WINAPI EnumBackgroundCopyJobs_Clone(IEnumBackgroundCopyJobs *iface, IEnumBackgroundCopyJobs **ppenum) { - FIXME("Not implemented\n"); + EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface); + FIXME("(%p)->(%p): stub\n", This, ppenum); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IEnumBackgroundCopyJobs_GetCount(IEnumBackgroundCopyJobs *iface, +static HRESULT WINAPI EnumBackgroundCopyJobs_GetCount(IEnumBackgroundCopyJobs *iface, ULONG *puCount) { EnumBackgroundCopyJobsImpl *This = impl_from_IEnumBackgroundCopyJobs(iface); + + TRACE("(%p)->(%p)\n", This, puCount); + *puCount = This->numJobs; return S_OK; } -static const IEnumBackgroundCopyJobsVtbl BITS_IEnumBackgroundCopyJobs_Vtbl = +static const IEnumBackgroundCopyJobsVtbl EnumBackgroundCopyJobsVtbl = { - BITS_IEnumBackgroundCopyJobs_QueryInterface, - BITS_IEnumBackgroundCopyJobs_AddRef, - BITS_IEnumBackgroundCopyJobs_Release, - BITS_IEnumBackgroundCopyJobs_Next, - BITS_IEnumBackgroundCopyJobs_Skip, - BITS_IEnumBackgroundCopyJobs_Reset, - BITS_IEnumBackgroundCopyJobs_Clone, - BITS_IEnumBackgroundCopyJobs_GetCount + EnumBackgroundCopyJobs_QueryInterface, + EnumBackgroundCopyJobs_AddRef, + EnumBackgroundCopyJobs_Release, + EnumBackgroundCopyJobs_Next, + EnumBackgroundCopyJobs_Skip, + EnumBackgroundCopyJobs_Reset, + EnumBackgroundCopyJobs_Clone, + EnumBackgroundCopyJobs_GetCount }; HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCopyJobs **enumjob) @@ -171,7 +184,7 @@ HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCop This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); if (!This) return E_OUTOFMEMORY; - This->IEnumBackgroundCopyJobs_iface.lpVtbl = &BITS_IEnumBackgroundCopyJobs_Vtbl; + This->IEnumBackgroundCopyJobs_iface.lpVtbl = &EnumBackgroundCopyJobsVtbl; This->ref = 1; /* Create array of jobs */ diff --git a/reactos/dll/win32/qmgr/factory.c b/reactos/dll/win32/qmgr/factory.c index 7a069f3e92e..69e6d98d6c3 100644 --- a/reactos/dll/win32/qmgr/factory.c +++ b/reactos/dll/win32/qmgr/factory.c @@ -57,7 +57,7 @@ BITS_IClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter, REF if (pUnkOuter) return CLASS_E_NOAGGREGATION; - res = BackgroundCopyManagerConstructor(pUnkOuter, (LPVOID*) &punk); + res = BackgroundCopyManagerConstructor((LPVOID*) &punk); if (FAILED(res)) return res; diff --git a/reactos/dll/win32/qmgr/file.c b/reactos/dll/win32/qmgr/file.c index 6ba493ae142..1aee9b8700b 100644 --- a/reactos/dll/win32/qmgr/file.c +++ b/reactos/dll/win32/qmgr/file.c @@ -28,7 +28,7 @@ static inline BackgroundCopyFileImpl *impl_from_IBackgroundCopyFile(IBackgroundC return CONTAINING_RECORD(iface, BackgroundCopyFileImpl, IBackgroundCopyFile_iface); } -static HRESULT WINAPI BITS_IBackgroundCopyFile_QueryInterface( +static HRESULT WINAPI BackgroundCopyFile_QueryInterface( IBackgroundCopyFile* iface, REFIID riid, void **obj) @@ -49,7 +49,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyFile_QueryInterface( return E_NOINTERFACE; } -static ULONG WINAPI BITS_IBackgroundCopyFile_AddRef(IBackgroundCopyFile* iface) +static ULONG WINAPI BackgroundCopyFile_AddRef(IBackgroundCopyFile* iface) { BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface); ULONG ref = InterlockedIncrement(&This->ref); @@ -57,7 +57,7 @@ static ULONG WINAPI BITS_IBackgroundCopyFile_AddRef(IBackgroundCopyFile* iface) return ref; } -static ULONG WINAPI BITS_IBackgroundCopyFile_Release( +static ULONG WINAPI BackgroundCopyFile_Release( IBackgroundCopyFile* iface) { BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface); @@ -77,42 +77,36 @@ static ULONG WINAPI BITS_IBackgroundCopyFile_Release( } /* Get the remote name of a background copy file */ -static HRESULT WINAPI BITS_IBackgroundCopyFile_GetRemoteName( +static HRESULT WINAPI BackgroundCopyFile_GetRemoteName( IBackgroundCopyFile* iface, LPWSTR *pVal) { BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface); - int n = (lstrlenW(This->info.RemoteName) + 1) * sizeof(WCHAR); - *pVal = CoTaskMemAlloc(n); - if (!*pVal) - return E_OUTOFMEMORY; + TRACE("(%p)->(%p)\n", This, pVal); - memcpy(*pVal, This->info.RemoteName, n); - return S_OK; + return return_strval(This->info.RemoteName, pVal); } -static HRESULT WINAPI BITS_IBackgroundCopyFile_GetLocalName( +static HRESULT WINAPI BackgroundCopyFile_GetLocalName( IBackgroundCopyFile* iface, LPWSTR *pVal) { BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface); - int n = (lstrlenW(This->info.LocalName) + 1) * sizeof(WCHAR); - *pVal = CoTaskMemAlloc(n); - if (!*pVal) - return E_OUTOFMEMORY; + TRACE("(%p)->(%p)\n", This, pVal); - memcpy(*pVal, This->info.LocalName, n); - return S_OK; + return return_strval(This->info.LocalName, pVal); } -static HRESULT WINAPI BITS_IBackgroundCopyFile_GetProgress( +static HRESULT WINAPI BackgroundCopyFile_GetProgress( IBackgroundCopyFile* iface, BG_FILE_PROGRESS *pVal) { BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface); + TRACE("(%p)->(%p)\n", This, pVal); + EnterCriticalSection(&This->owner->cs); pVal->BytesTotal = This->fileProgress.BytesTotal; pVal->BytesTransferred = This->fileProgress.BytesTransferred; @@ -122,14 +116,14 @@ static HRESULT WINAPI BITS_IBackgroundCopyFile_GetProgress( return S_OK; } -static const IBackgroundCopyFileVtbl BITS_IBackgroundCopyFile_Vtbl = +static const IBackgroundCopyFileVtbl BackgroundCopyFileVtbl = { - BITS_IBackgroundCopyFile_QueryInterface, - BITS_IBackgroundCopyFile_AddRef, - BITS_IBackgroundCopyFile_Release, - BITS_IBackgroundCopyFile_GetRemoteName, - BITS_IBackgroundCopyFile_GetLocalName, - BITS_IBackgroundCopyFile_GetProgress + BackgroundCopyFile_QueryInterface, + BackgroundCopyFile_AddRef, + BackgroundCopyFile_Release, + BackgroundCopyFile_GetRemoteName, + BackgroundCopyFile_GetLocalName, + BackgroundCopyFile_GetProgress }; HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner, @@ -164,7 +158,7 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner, } memcpy(This->info.LocalName, localName, n); - This->IBackgroundCopyFile_iface.lpVtbl = &BITS_IBackgroundCopyFile_Vtbl; + This->IBackgroundCopyFile_iface.lpVtbl = &BackgroundCopyFileVtbl; This->ref = 1; This->fileProgress.BytesTotal = BG_SIZE_UNKNOWN; @@ -217,6 +211,25 @@ static inline DLBindStatusCallback *impl_from_IBindStatusCallback(IBindStatusCal return CONTAINING_RECORD(iface, DLBindStatusCallback, IBindStatusCallback_iface); } +static HRESULT WINAPI DLBindStatusCallback_QueryInterface( + IBindStatusCallback *iface, + REFIID riid, + void **ppvObject) +{ + DLBindStatusCallback *This = impl_from_IBindStatusCallback(iface); + + if (IsEqualGUID(riid, &IID_IUnknown) + || IsEqualGUID(riid, &IID_IBindStatusCallback)) + { + *ppvObject = &This->IBindStatusCallback_iface; + IBindStatusCallback_AddRef(iface); + return S_OK; + } + + *ppvObject = NULL; + return E_NOINTERFACE; +} + static ULONG WINAPI DLBindStatusCallback_AddRef(IBindStatusCallback *iface) { DLBindStatusCallback *This = impl_from_IBindStatusCallback(iface); @@ -237,25 +250,6 @@ static ULONG WINAPI DLBindStatusCallback_Release(IBindStatusCallback *iface) return ref; } -static HRESULT WINAPI DLBindStatusCallback_QueryInterface( - IBindStatusCallback *iface, - REFIID riid, - void **ppvObject) -{ - DLBindStatusCallback *This = impl_from_IBindStatusCallback(iface); - - if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IBindStatusCallback)) - { - *ppvObject = &This->IBindStatusCallback_iface; - DLBindStatusCallback_AddRef(iface); - return S_OK; - } - - *ppvObject = NULL; - return E_NOINTERFACE; -} - static HRESULT WINAPI DLBindStatusCallback_GetBindInfo( IBindStatusCallback *iface, DWORD *grfBINDF, diff --git a/reactos/dll/win32/qmgr/job.c b/reactos/dll/win32/qmgr/job.c index c4a2325e7ce..911def76657 100644 --- a/reactos/dll/win32/qmgr/job.c +++ b/reactos/dll/win32/qmgr/job.c @@ -20,12 +20,17 @@ #include "qmgr.h" +static inline BOOL is_job_done(const BackgroundCopyJobImpl *job) +{ + return job->state == BG_JOB_STATE_CANCELLED || job->state == BG_JOB_STATE_ACKNOWLEDGED; +} + static inline BackgroundCopyJobImpl *impl_from_IBackgroundCopyJob2(IBackgroundCopyJob2 *iface) { return CONTAINING_RECORD(iface, BackgroundCopyJobImpl, IBackgroundCopyJob2_iface); } -static HRESULT WINAPI BITS_IBackgroundCopyJob_QueryInterface( +static HRESULT WINAPI BackgroundCopyJob_QueryInterface( IBackgroundCopyJob2 *iface, REFIID riid, void **obj) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); @@ -45,7 +50,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_QueryInterface( return E_NOINTERFACE; } -static ULONG WINAPI BITS_IBackgroundCopyJob_AddRef(IBackgroundCopyJob2 *iface) +static ULONG WINAPI BackgroundCopyJob_AddRef(IBackgroundCopyJob2 *iface) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); ULONG ref = InterlockedIncrement(&This->ref); @@ -53,7 +58,7 @@ static ULONG WINAPI BITS_IBackgroundCopyJob_AddRef(IBackgroundCopyJob2 *iface) return ref; } -static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface) +static ULONG WINAPI BackgroundCopyJob_Release(IBackgroundCopyJob2 *iface) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); ULONG ref = InterlockedDecrement(&This->ref); @@ -64,7 +69,10 @@ static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface) { This->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->cs); + if (This->callback) + IBackgroundCopyCallback2_Release(This->callback); HeapFree(GetProcessHeap(), 0, This->displayName); + HeapFree(GetProcessHeap(), 0, This->description); HeapFree(GetProcessHeap(), 0, This); } @@ -73,50 +81,56 @@ static ULONG WINAPI BITS_IBackgroundCopyJob_Release(IBackgroundCopyJob2 *iface) /*** IBackgroundCopyJob methods ***/ -static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFileSet( +static HRESULT WINAPI BackgroundCopyJob_AddFileSet( IBackgroundCopyJob2 *iface, ULONG cFileCount, BG_FILE_INFO *pFileSet) { + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + HRESULT hr = S_OK; ULONG i; + + TRACE("(%p)->(%d %p)\n", This, cFileCount, pFileSet); + + EnterCriticalSection(&This->cs); + for (i = 0; i < cFileCount; ++i) { - HRESULT hr = IBackgroundCopyJob2_AddFile(iface, pFileSet[i].RemoteName, - pFileSet[i].LocalName); - if (FAILED(hr)) - return hr; + BackgroundCopyFileImpl *file; + + /* We should return E_INVALIDARG in these cases. */ + FIXME("Check for valid filenames and supported protocols\n"); + + hr = BackgroundCopyFileConstructor(This, pFileSet[i].RemoteName, pFileSet[i].LocalName, &file); + if (hr != S_OK) break; + + /* Add a reference to the file to file list */ + list_add_head(&This->files, &file->entryFromJob); + This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN; + ++This->jobProgress.FilesTotal; } - return S_OK; + + LeaveCriticalSection(&This->cs); + + return hr; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile( +static HRESULT WINAPI BackgroundCopyJob_AddFile( IBackgroundCopyJob2 *iface, LPCWSTR RemoteUrl, LPCWSTR LocalName) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); - BackgroundCopyFileImpl *file; - HRESULT res; - - /* We should return E_INVALIDARG in these cases. */ - FIXME("Check for valid filenames and supported protocols\n"); + BG_FILE_INFO file; - res = BackgroundCopyFileConstructor(This, RemoteUrl, LocalName, &file); - if (res != S_OK) - return res; - - /* Add a reference to the file to file list */ - IBackgroundCopyFile_AddRef(&file->IBackgroundCopyFile_iface); - EnterCriticalSection(&This->cs); - list_add_head(&This->files, &file->entryFromJob); - This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN; - ++This->jobProgress.FilesTotal; - LeaveCriticalSection(&This->cs); + TRACE("(%p)->(%s %s)\n", This, debugstr_w(RemoteUrl), debugstr_w(LocalName)); - return S_OK; + file.RemoteName = (LPWSTR)RemoteUrl; + file.LocalName = (LPWSTR)LocalName; + return IBackgroundCopyJob2_AddFileSet(iface, 1, &file); } -static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles( +static HRESULT WINAPI BackgroundCopyJob_EnumFiles( IBackgroundCopyJob2 *iface, IEnumBackgroundCopyFiles **enum_files) { @@ -125,22 +139,24 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles( return EnumBackgroundCopyFilesConstructor(This, enum_files); } -static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend( +static HRESULT WINAPI BackgroundCopyJob_Suspend( IBackgroundCopyJob2 *iface) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p): stub\n", This); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume( +static HRESULT WINAPI BackgroundCopyJob_Resume( IBackgroundCopyJob2 *iface) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); HRESULT rv = S_OK; + TRACE("(%p)\n", This); + EnterCriticalSection(&globalMgr.cs); - if (This->state == BG_JOB_STATE_CANCELLED - || This->state == BG_JOB_STATE_ACKNOWLEDGED) + if (is_job_done(This)) { rv = BG_E_INVALID_STATE; } @@ -159,23 +175,25 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume( return rv; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel( +static HRESULT WINAPI BackgroundCopyJob_Cancel( IBackgroundCopyJob2 *iface) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p): stub\n", This); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete( +static HRESULT WINAPI BackgroundCopyJob_Complete( IBackgroundCopyJob2 *iface) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); HRESULT rv = S_OK; + TRACE("(%p)\n", This); + EnterCriticalSection(&This->cs); - if (This->state == BG_JOB_STATE_CANCELLED - || This->state == BG_JOB_STATE_ACKNOWLEDGED) + if (is_job_done(This)) { rv = BG_E_INVALID_STATE; } @@ -208,21 +226,24 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Complete( return rv; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetId( +static HRESULT WINAPI BackgroundCopyJob_GetId( IBackgroundCopyJob2 *iface, GUID *pVal) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + TRACE("(%p)->(%p)\n", This, pVal); *pVal = This->jobId; return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType( +static HRESULT WINAPI BackgroundCopyJob_GetType( IBackgroundCopyJob2 *iface, BG_JOB_TYPE *pVal) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + TRACE("(%p)->(%p)\n", This, pVal); + if (!pVal) return E_INVALIDARG; @@ -230,12 +251,14 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetType( return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress( +static HRESULT WINAPI BackgroundCopyJob_GetProgress( IBackgroundCopyJob2 *iface, BG_JOB_PROGRESS *pVal) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + TRACE("(%p)->(%p)\n", This, pVal); + if (!pVal) return E_INVALIDARG; @@ -249,20 +272,23 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProgress( return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetTimes( +static HRESULT WINAPI BackgroundCopyJob_GetTimes( IBackgroundCopyJob2 *iface, BG_JOB_TIMES *pVal) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, pVal); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState( +static HRESULT WINAPI BackgroundCopyJob_GetState( IBackgroundCopyJob2 *iface, BG_JOB_STATE *pVal) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + TRACE("(%p)->(%p)\n", This, pVal); + if (!pVal) return E_INVALIDARG; @@ -271,113 +297,191 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState( return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetError( +static HRESULT WINAPI BackgroundCopyJob_GetError( IBackgroundCopyJob2 *iface, IBackgroundCopyError **ppError) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, ppError); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetOwner( +static HRESULT WINAPI BackgroundCopyJob_GetOwner( IBackgroundCopyJob2 *iface, LPWSTR *pVal) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, pVal); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDisplayName( +static HRESULT WINAPI BackgroundCopyJob_SetDisplayName( IBackgroundCopyJob2 *iface, LPCWSTR Val) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%s): stub\n", This, debugstr_w(Val)); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDisplayName( +static HRESULT WINAPI BackgroundCopyJob_GetDisplayName( IBackgroundCopyJob2 *iface, LPWSTR *pVal) { BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); - int n; - if (!pVal) - return E_INVALIDARG; + TRACE("(%p)->(%p)\n", This, pVal); - n = (lstrlenW(This->displayName) + 1) * sizeof **pVal; - *pVal = CoTaskMemAlloc(n); - if (*pVal == NULL) - return E_OUTOFMEMORY; - memcpy(*pVal, This->displayName, n); - return S_OK; + return return_strval(This->displayName, pVal); } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetDescription( +static HRESULT WINAPI BackgroundCopyJob_SetDescription( IBackgroundCopyJob2 *iface, LPCWSTR Val) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + static const int max_description_len = 1024; + HRESULT hr = S_OK; + int len; + + TRACE("(%p)->(%s)\n", This, debugstr_w(Val)); + + if (!Val) return E_INVALIDARG; + + len = strlenW(Val); + if (len > max_description_len) return BG_E_STRING_TOO_LONG; + + EnterCriticalSection(&This->cs); + + if (is_job_done(This)) + { + hr = BG_E_INVALID_STATE; + } + else + { + HeapFree(GetProcessHeap(), 0, This->description); + if ((This->description = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)))) + strcpyW(This->description, Val); + else + hr = E_OUTOFMEMORY; + } + + LeaveCriticalSection(&This->cs); + + return hr; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetDescription( +static HRESULT WINAPI BackgroundCopyJob_GetDescription( IBackgroundCopyJob2 *iface, LPWSTR *pVal) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + + TRACE("(%p)->(%p)\n", This, pVal); + + return return_strval(This->description, pVal); } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetPriority( +static HRESULT WINAPI BackgroundCopyJob_SetPriority( IBackgroundCopyJob2 *iface, BG_JOB_PRIORITY Val) { - FIXME("(%p,0x%08x) stub\n", iface, Val); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%d): stub\n", This, Val); return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetPriority( +static HRESULT WINAPI BackgroundCopyJob_GetPriority( IBackgroundCopyJob2 *iface, BG_JOB_PRIORITY *pVal) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, pVal); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyFlags( +static HRESULT WINAPI BackgroundCopyJob_SetNotifyFlags( IBackgroundCopyJob2 *iface, ULONG Val) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + static const ULONG valid_flags = BG_NOTIFY_JOB_TRANSFERRED | + BG_NOTIFY_JOB_ERROR | + BG_NOTIFY_DISABLE | + BG_NOTIFY_JOB_MODIFICATION | + BG_NOTIFY_FILE_TRANSFERRED; + + TRACE("(%p)->(0x%x)\n", This, Val); + + if (is_job_done(This)) return BG_E_INVALID_STATE; + if (Val & ~valid_flags) return E_NOTIMPL; + This->notify_flags = Val; + return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyFlags( +static HRESULT WINAPI BackgroundCopyJob_GetNotifyFlags( IBackgroundCopyJob2 *iface, ULONG *pVal) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + + TRACE("(%p)->(%p)\n", This, pVal); + + if (!pVal) return E_INVALIDARG; + + *pVal = This->notify_flags; + + return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyInterface( +static HRESULT WINAPI BackgroundCopyJob_SetNotifyInterface( IBackgroundCopyJob2 *iface, IUnknown *Val) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + HRESULT hr = S_OK; + + TRACE("(%p)->(%p)\n", This, Val); + + if (is_job_done(This)) return BG_E_INVALID_STATE; + + if (This->callback) + { + IBackgroundCopyCallback2_Release(This->callback); + This->callback = NULL; + This->callback2 = FALSE; + } + + if (Val) + { + hr = IUnknown_QueryInterface(Val, &IID_IBackgroundCopyCallback2, (void**)&This->callback); + if (FAILED(hr)) + hr = IUnknown_QueryInterface(Val, &IID_IBackgroundCopyCallback, (void**)&This->callback); + else + This->callback2 = TRUE; + } + + return hr; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyInterface( +static HRESULT WINAPI BackgroundCopyJob_GetNotifyInterface( IBackgroundCopyJob2 *iface, IUnknown **pVal) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + + TRACE("(%p)->(%p)\n", This, pVal); + + if (!pVal) return E_INVALIDARG; + + *pVal = (IUnknown*)This->callback; + if (*pVal) + IUnknown_AddRef(*pVal); + + return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay( +static HRESULT WINAPI BackgroundCopyJob_SetMinimumRetryDelay( IBackgroundCopyJob2 *iface, ULONG Seconds) { @@ -385,180 +489,195 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay( return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetMinimumRetryDelay( +static HRESULT WINAPI BackgroundCopyJob_GetMinimumRetryDelay( IBackgroundCopyJob2 *iface, ULONG *Seconds) { - FIXME("%p\n", Seconds); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, Seconds); *Seconds = 30; return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNoProgressTimeout( +static HRESULT WINAPI BackgroundCopyJob_SetNoProgressTimeout( IBackgroundCopyJob2 *iface, ULONG Seconds) { - FIXME("%u\n", Seconds); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%d): stub\n", This, Seconds); return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNoProgressTimeout( +static HRESULT WINAPI BackgroundCopyJob_GetNoProgressTimeout( IBackgroundCopyJob2 *iface, ULONG *Seconds) { - FIXME("%p\n", Seconds); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, Seconds); *Seconds = 900; return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetErrorCount( +static HRESULT WINAPI BackgroundCopyJob_GetErrorCount( IBackgroundCopyJob2 *iface, ULONG *Errors) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, Errors); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetProxySettings( +static HRESULT WINAPI BackgroundCopyJob_SetProxySettings( IBackgroundCopyJob2 *iface, BG_JOB_PROXY_USAGE ProxyUsage, const WCHAR *ProxyList, const WCHAR *ProxyBypassList) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%d %s %s): stub\n", This, ProxyUsage, debugstr_w(ProxyList), debugstr_w(ProxyBypassList)); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetProxySettings( +static HRESULT WINAPI BackgroundCopyJob_GetProxySettings( IBackgroundCopyJob2 *iface, BG_JOB_PROXY_USAGE *pProxyUsage, LPWSTR *pProxyList, LPWSTR *pProxyBypassList) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p %p %p): stub\n", This, pProxyUsage, pProxyList, pProxyBypassList); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_TakeOwnership( +static HRESULT WINAPI BackgroundCopyJob_TakeOwnership( IBackgroundCopyJob2 *iface) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p): stub\n", This); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNotifyCmdLine( +static HRESULT WINAPI BackgroundCopyJob_SetNotifyCmdLine( IBackgroundCopyJob2 *iface, LPCWSTR prog, LPCWSTR params) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%s %s): stub\n", This, debugstr_w(prog), debugstr_w(params)); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNotifyCmdLine( +static HRESULT WINAPI BackgroundCopyJob_GetNotifyCmdLine( IBackgroundCopyJob2 *iface, LPWSTR *prog, LPWSTR *params) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p %p): stub\n", This, prog, params); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetReplyProgress( +static HRESULT WINAPI BackgroundCopyJob_GetReplyProgress( IBackgroundCopyJob2 *iface, BG_JOB_REPLY_PROGRESS *progress) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, progress); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetReplyData( +static HRESULT WINAPI BackgroundCopyJob_GetReplyData( IBackgroundCopyJob2 *iface, byte **pBuffer, UINT64 *pLength) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p %p): stub\n", This, pBuffer, pLength); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetReplyFileName( +static HRESULT WINAPI BackgroundCopyJob_SetReplyFileName( IBackgroundCopyJob2 *iface, LPCWSTR filename) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%s): stub\n", This, debugstr_w(filename)); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_GetReplyFileName( +static HRESULT WINAPI BackgroundCopyJob_GetReplyFileName( IBackgroundCopyJob2 *iface, LPWSTR *pFilename) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, pFilename); return E_NOTIMPL; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_SetCredentials( +static HRESULT WINAPI BackgroundCopyJob_SetCredentials( IBackgroundCopyJob2 *iface, BG_AUTH_CREDENTIALS *cred) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%p): stub\n", This, cred); return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyJob_RemoveCredentials( +static HRESULT WINAPI BackgroundCopyJob_RemoveCredentials( IBackgroundCopyJob2 *iface, BG_AUTH_TARGET target, BG_AUTH_SCHEME scheme) { - FIXME("Not implemented\n"); + BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface); + FIXME("(%p)->(%d %d): stub\n", This, target, scheme); return S_OK; } -static const IBackgroundCopyJob2Vtbl BITS_IBackgroundCopyJob_Vtbl = -{ - BITS_IBackgroundCopyJob_QueryInterface, - BITS_IBackgroundCopyJob_AddRef, - BITS_IBackgroundCopyJob_Release, - BITS_IBackgroundCopyJob_AddFileSet, - BITS_IBackgroundCopyJob_AddFile, - BITS_IBackgroundCopyJob_EnumFiles, - BITS_IBackgroundCopyJob_Suspend, - BITS_IBackgroundCopyJob_Resume, - BITS_IBackgroundCopyJob_Cancel, - BITS_IBackgroundCopyJob_Complete, - BITS_IBackgroundCopyJob_GetId, - BITS_IBackgroundCopyJob_GetType, - BITS_IBackgroundCopyJob_GetProgress, - BITS_IBackgroundCopyJob_GetTimes, - BITS_IBackgroundCopyJob_GetState, - BITS_IBackgroundCopyJob_GetError, - BITS_IBackgroundCopyJob_GetOwner, - BITS_IBackgroundCopyJob_SetDisplayName, - BITS_IBackgroundCopyJob_GetDisplayName, - BITS_IBackgroundCopyJob_SetDescription, - BITS_IBackgroundCopyJob_GetDescription, - BITS_IBackgroundCopyJob_SetPriority, - BITS_IBackgroundCopyJob_GetPriority, - BITS_IBackgroundCopyJob_SetNotifyFlags, - BITS_IBackgroundCopyJob_GetNotifyFlags, - BITS_IBackgroundCopyJob_SetNotifyInterface, - BITS_IBackgroundCopyJob_GetNotifyInterface, - BITS_IBackgroundCopyJob_SetMinimumRetryDelay, - BITS_IBackgroundCopyJob_GetMinimumRetryDelay, - BITS_IBackgroundCopyJob_SetNoProgressTimeout, - BITS_IBackgroundCopyJob_GetNoProgressTimeout, - BITS_IBackgroundCopyJob_GetErrorCount, - BITS_IBackgroundCopyJob_SetProxySettings, - BITS_IBackgroundCopyJob_GetProxySettings, - BITS_IBackgroundCopyJob_TakeOwnership, - BITS_IBackgroundCopyJob_SetNotifyCmdLine, - BITS_IBackgroundCopyJob_GetNotifyCmdLine, - BITS_IBackgroundCopyJob_GetReplyProgress, - BITS_IBackgroundCopyJob_GetReplyData, - BITS_IBackgroundCopyJob_SetReplyFileName, - BITS_IBackgroundCopyJob_GetReplyFileName, - BITS_IBackgroundCopyJob_SetCredentials, - BITS_IBackgroundCopyJob_RemoveCredentials +static const IBackgroundCopyJob2Vtbl BackgroundCopyJobVtbl = +{ + BackgroundCopyJob_QueryInterface, + BackgroundCopyJob_AddRef, + BackgroundCopyJob_Release, + BackgroundCopyJob_AddFileSet, + BackgroundCopyJob_AddFile, + BackgroundCopyJob_EnumFiles, + BackgroundCopyJob_Suspend, + BackgroundCopyJob_Resume, + BackgroundCopyJob_Cancel, + BackgroundCopyJob_Complete, + BackgroundCopyJob_GetId, + BackgroundCopyJob_GetType, + BackgroundCopyJob_GetProgress, + BackgroundCopyJob_GetTimes, + BackgroundCopyJob_GetState, + BackgroundCopyJob_GetError, + BackgroundCopyJob_GetOwner, + BackgroundCopyJob_SetDisplayName, + BackgroundCopyJob_GetDisplayName, + BackgroundCopyJob_SetDescription, + BackgroundCopyJob_GetDescription, + BackgroundCopyJob_SetPriority, + BackgroundCopyJob_GetPriority, + BackgroundCopyJob_SetNotifyFlags, + BackgroundCopyJob_GetNotifyFlags, + BackgroundCopyJob_SetNotifyInterface, + BackgroundCopyJob_GetNotifyInterface, + BackgroundCopyJob_SetMinimumRetryDelay, + BackgroundCopyJob_GetMinimumRetryDelay, + BackgroundCopyJob_SetNoProgressTimeout, + BackgroundCopyJob_GetNoProgressTimeout, + BackgroundCopyJob_GetErrorCount, + BackgroundCopyJob_SetProxySettings, + BackgroundCopyJob_GetProxySettings, + BackgroundCopyJob_TakeOwnership, + BackgroundCopyJob_SetNotifyCmdLine, + BackgroundCopyJob_GetNotifyCmdLine, + BackgroundCopyJob_GetReplyProgress, + BackgroundCopyJob_GetReplyData, + BackgroundCopyJob_SetReplyFileName, + BackgroundCopyJob_GetReplyFileName, + BackgroundCopyJob_SetCredentials, + BackgroundCopyJob_RemoveCredentials }; HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID *job_id, BackgroundCopyJobImpl **job) @@ -573,14 +692,14 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID if (!This) return E_OUTOFMEMORY; - This->IBackgroundCopyJob2_iface.lpVtbl = &BITS_IBackgroundCopyJob_Vtbl; + This->IBackgroundCopyJob2_iface.lpVtbl = &BackgroundCopyJobVtbl; InitializeCriticalSection(&This->cs); This->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BackgroundCopyJobImpl.cs"); This->ref = 1; This->type = type; - n = (lstrlenW(displayName) + 1) * sizeof *displayName; + n = (strlenW(displayName) + 1) * sizeof *displayName; This->displayName = HeapAlloc(GetProcessHeap(), 0, n); if (!This->displayName) { @@ -609,8 +728,15 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID This->jobProgress.FilesTransferred = 0; This->state = BG_JOB_STATE_SUSPENDED; + This->description = NULL; + This->notify_flags = BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_TRANSFERRED; + This->callback = NULL; + This->callback2 = FALSE; *job = This; + + TRACE("created job %s:%p\n", debugstr_guid(&This->jobId), This); + return S_OK; } diff --git a/reactos/dll/win32/qmgr/qmgr.c b/reactos/dll/win32/qmgr/qmgr.c index 28a90d7f658..69c5c3ae96a 100644 --- a/reactos/dll/win32/qmgr/qmgr.c +++ b/reactos/dll/win32/qmgr/qmgr.c @@ -22,10 +22,10 @@ BackgroundCopyManagerImpl globalMgr; -static HRESULT WINAPI BITS_IBackgroundCopyManager_QueryInterface(IBackgroundCopyManager *iface, +static HRESULT WINAPI BackgroundCopyManager_QueryInterface(IBackgroundCopyManager *iface, REFIID riid, void **ppv) { - TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv); + TRACE("(%s, %p)\n", debugstr_guid(riid), ppv); if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IBackgroundCopyManager)) { @@ -38,24 +38,25 @@ static HRESULT WINAPI BITS_IBackgroundCopyManager_QueryInterface(IBackgroundCopy return E_NOINTERFACE; } -static ULONG WINAPI BITS_IBackgroundCopyManager_AddRef(IBackgroundCopyManager *iface) +static ULONG WINAPI BackgroundCopyManager_AddRef(IBackgroundCopyManager *iface) { return 2; } -static ULONG WINAPI BITS_IBackgroundCopyManager_Release(IBackgroundCopyManager *iface) +static ULONG WINAPI BackgroundCopyManager_Release(IBackgroundCopyManager *iface) { return 1; } /*** IBackgroundCopyManager interface methods ***/ -static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob(IBackgroundCopyManager *iface, +static HRESULT WINAPI BackgroundCopyManager_CreateJob(IBackgroundCopyManager *iface, LPCWSTR DisplayName, BG_JOB_TYPE Type, GUID *pJobId, IBackgroundCopyJob **ppJob) { BackgroundCopyJobImpl *job; HRESULT hres; - TRACE("\n"); + + TRACE("(%s %d %p %p)\n", debugstr_w(DisplayName), Type, pJobId, ppJob); hres = BackgroundCopyJobConstructor(DisplayName, Type, pJobId, &job); if (FAILED(hres)) @@ -70,50 +71,73 @@ static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob(IBackgroundCopyManag return S_OK; } -static HRESULT WINAPI BITS_IBackgroundCopyManager_GetJob(IBackgroundCopyManager *iface, - REFGUID jobID, IBackgroundCopyJob **ppJob) +static HRESULT WINAPI BackgroundCopyManager_GetJob(IBackgroundCopyManager *iface, + REFGUID jobID, IBackgroundCopyJob **job) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + BackgroundCopyManagerImpl *qmgr = &globalMgr; + HRESULT hr = BG_E_NOT_FOUND; + BackgroundCopyJobImpl *cur; + + TRACE("(%s %p)\n", debugstr_guid(jobID), job); + + if (!job || !jobID) return E_INVALIDARG; + + *job = NULL; + + EnterCriticalSection(&qmgr->cs); + + LIST_FOR_EACH_ENTRY(cur, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr) + { + if (IsEqualGUID(&cur->jobId, jobID)) + { + *job = (IBackgroundCopyJob*)&cur->IBackgroundCopyJob2_iface; + IBackgroundCopyJob2_AddRef(&cur->IBackgroundCopyJob2_iface); + hr = S_OK; + break; + } + } + + LeaveCriticalSection(&qmgr->cs); + + return hr; } -static HRESULT WINAPI BITS_IBackgroundCopyManager_EnumJobs(IBackgroundCopyManager *iface, - DWORD dwFlags, IEnumBackgroundCopyJobs **ppEnum) +static HRESULT WINAPI BackgroundCopyManager_EnumJobs(IBackgroundCopyManager *iface, + DWORD flags, IEnumBackgroundCopyJobs **ppEnum) { - TRACE("\n"); + TRACE("(0x%x %p)\n", flags, ppEnum); return enum_copy_job_create(&globalMgr, ppEnum); } -static HRESULT WINAPI BITS_IBackgroundCopyManager_GetErrorDescription(IBackgroundCopyManager *iface, - HRESULT hResult, DWORD LanguageId, LPWSTR *pErrorDescription) +static HRESULT WINAPI BackgroundCopyManager_GetErrorDescription(IBackgroundCopyManager *iface, + HRESULT hr, DWORD langid, LPWSTR *error_description) { - FIXME("Not implemented\n"); + FIXME("(0x%08x 0x%x %p): stub\n", hr, langid, error_description); return E_NOTIMPL; } - -static const IBackgroundCopyManagerVtbl BITS_IBackgroundCopyManager_Vtbl = +static const IBackgroundCopyManagerVtbl BackgroundCopyManagerVtbl = { - BITS_IBackgroundCopyManager_QueryInterface, - BITS_IBackgroundCopyManager_AddRef, - BITS_IBackgroundCopyManager_Release, - BITS_IBackgroundCopyManager_CreateJob, - BITS_IBackgroundCopyManager_GetJob, - BITS_IBackgroundCopyManager_EnumJobs, - BITS_IBackgroundCopyManager_GetErrorDescription + BackgroundCopyManager_QueryInterface, + BackgroundCopyManager_AddRef, + BackgroundCopyManager_Release, + BackgroundCopyManager_CreateJob, + BackgroundCopyManager_GetJob, + BackgroundCopyManager_EnumJobs, + BackgroundCopyManager_GetErrorDescription }; BackgroundCopyManagerImpl globalMgr = { - { &BITS_IBackgroundCopyManager_Vtbl }, + { &BackgroundCopyManagerVtbl }, { NULL, -1, 0, 0, 0, 0 }, NULL, LIST_INIT(globalMgr.jobs) }; /* Constructor for instances of background copy manager */ -HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj) +HRESULT BackgroundCopyManagerConstructor(LPVOID *ppObj) { - TRACE("(%p,%p)\n", pUnkOuter, ppObj); + TRACE("(%p)\n", ppObj); *ppObj = &globalMgr; return S_OK; } diff --git a/reactos/dll/win32/qmgr/qmgr.h b/reactos/dll/win32/qmgr/qmgr.h index c93bcc2ba3e..ae8668502e8 100644 --- a/reactos/dll/win32/qmgr/qmgr.h +++ b/reactos/dll/win32/qmgr/qmgr.h @@ -34,9 +34,11 @@ #include #include #include +#include #include #include +#include WINE_DEFAULT_DEBUG_CHANNEL(qmgr); @@ -46,11 +48,15 @@ typedef struct IBackgroundCopyJob2 IBackgroundCopyJob2_iface; LONG ref; LPWSTR displayName; + LPWSTR description; BG_JOB_TYPE type; GUID jobId; struct list files; BG_JOB_PROGRESS jobProgress; BG_JOB_STATE state; + ULONG notify_flags; + IBackgroundCopyCallback2 *callback; + BOOL callback2; /* IBackgroundCopyCallback2 is supported in addition to IBackgroundCopyCallback */ /* Protects file list, and progress */ CRITICAL_SECTION cs; struct list entryFromQmgr; @@ -87,7 +93,7 @@ extern HANDLE stop_event DECLSPEC_HIDDEN; extern ClassFactoryImpl BITS_ClassFactory DECLSPEC_HIDDEN; extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN; -HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; +HRESULT BackgroundCopyManagerConstructor(LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID *pJobId, BackgroundCopyJobImpl **job) DECLSPEC_HIDDEN; HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr, @@ -109,6 +115,19 @@ qmgr_strdup(const char *s) return d ? memcpy(d, s, n) : NULL; } +static inline HRESULT return_strval(const WCHAR *str, WCHAR **ret) +{ + int len; + + if (!ret) return E_INVALIDARG; + + len = strlenW(str); + *ret = CoTaskMemAlloc((len+1)*sizeof(WCHAR)); + if (!*ret) return E_OUTOFMEMORY; + strcpyW(*ret, str); + return S_OK; +} + static inline BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE fromState, BG_JOB_STATE toState) diff --git a/reactos/dll/win32/qmgr/qmgr_local.idl b/reactos/dll/win32/qmgr/qmgr_local.idl index 8e1341d010f..edbe71eacde 100644 --- a/reactos/dll/win32/qmgr/qmgr_local.idl +++ b/reactos/dll/win32/qmgr/qmgr_local.idl @@ -16,7 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#pragma makedep ident + #include "bits.idl" #define DO_NO_IMPORTS #include "bits1_5.idl" +#include "bits3_0.idl" diff --git a/reactos/dll/win32/qmgr/qmgr_main.c b/reactos/dll/win32/qmgr/qmgr_main.c index 267bd1f827c..31ff89050f7 100644 --- a/reactos/dll/win32/qmgr/qmgr_main.c +++ b/reactos/dll/win32/qmgr/qmgr_main.c @@ -98,35 +98,6 @@ static void cleanup_register_strtable(STRTABLEA *strtable) } } -static HRESULT register_service(BOOL do_register) -{ - static const WCHAR name[] = { 'B','I','T','S', 0 }; - static const WCHAR path[] = { 's','v','c','h','o','s','t','.','e','x','e', - ' ','-','k',' ','n','e','t','s','v','c','s', 0 }; - SC_HANDLE scm, service; - - scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (!scm) - return SELFREG_E_CLASS; - - if (do_register) - service = CreateServiceW(scm, name, name, SERVICE_ALL_ACCESS, - SERVICE_WIN32_OWN_PROCESS, - SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, - path, NULL, NULL, NULL, NULL, NULL); - else - service = OpenServiceW(scm, name, DELETE); - - - CloseServiceHandle(scm); - if (service) - { - if (!do_register) DeleteService(service); - CloseServiceHandle(service); - } - return S_OK; -} - /* Use an INF file to register or unregister the DLL */ static HRESULT register_server(BOOL do_register) { @@ -138,12 +109,6 @@ static HRESULT register_server(BOOL do_register) TRACE("(%x)\n", do_register); - hr = register_service(do_register); - if (FAILED(hr)) { - ERR("register_service failed: %d\n", GetLastError()); - return hr; - } - hAdvpack = LoadLibraryW(wszAdvpack); pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall"); diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index be089a15e8d..a09cbaa9f36 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -159,7 +159,7 @@ reactos/dll/win32/powrprof # Forked at Wine-1.0rc5 reactos/dll/win32/printui # Synced to Wine-1.7.1 reactos/dll/win32/propsys # Synced to Wine-1.7.17 reactos/dll/win32/pstorec # Synced to Wine-1.7.1 -reactos/dll/win32/qmgr # Synced to Wine-1.7.1 +reactos/dll/win32/qmgr # Synced to Wine-1.7.17 reactos/dll/win32/qmgrprxy # Synced to Wine-1.7.1 reactos/dll/win32/query # Synced to Wine-1.7.1 reactos/dll/win32/rasapi32 # Synced to Wine-1.7.1 -- 2.17.1