Module: wine Branch: master Commit: 111e6929ac9067694efd55c710c7609e1d988522 URL: http://source.winehq.org/git/wine.git/?a=commit;h=111e6929ac9067694efd55c710...
Author: Roy Shea roy@cs.hmc.edu Date: Fri Feb 22 15:06:17 2008 -0800
qmgr: Implement IBackgroundCopyManager_CreateJob with test.
---
dlls/qmgr/job.c | 40 ++++++++++++++++++++++++++++++++++++++++ dlls/qmgr/qmgr.c | 5 +++-- dlls/qmgr/qmgr.h | 5 +++++ dlls/qmgr/tests/qmgr.c | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c index ef7dd53..1a554de 100644 --- a/dlls/qmgr/job.c +++ b/dlls/qmgr/job.c @@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
static void BackgroundCopyJobDestructor(BackgroundCopyJobImpl *This) { + HeapFree(GetProcessHeap(), 0, This->displayName); HeapFree(GetProcessHeap(), 0, This); }
@@ -361,3 +362,42 @@ static const IBackgroundCopyJobVtbl BITS_IBackgroundCopyJob_Vtbl = BITS_IBackgroundCopyJob_GetProxySettings, BITS_IBackgroundCopyJob_TakeOwnership, }; + +HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, + GUID *pJobId, LPVOID *ppObj) +{ + HRESULT hr; + BackgroundCopyJobImpl *This; + int n; + + TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, ppObj); + + This = HeapAlloc(GetProcessHeap(), 0, sizeof *This); + if (!This) + return E_OUTOFMEMORY; + + This->lpVtbl = &BITS_IBackgroundCopyJob_Vtbl; + This->ref = 1; + This->type = type; + + n = (lstrlenW(displayName) + 1) * sizeof *displayName; + This->displayName = HeapAlloc(GetProcessHeap(), 0, n); + if (!This->displayName) + { + HeapFree(GetProcessHeap(), 0, This); + return E_OUTOFMEMORY; + } + memcpy(This->displayName, displayName, n); + + hr = CoCreateGuid(&This->jobId); + if (FAILED(hr)) + { + HeapFree(GetProcessHeap(), 0, This->displayName); + HeapFree(GetProcessHeap(), 0, This); + return hr; + } + memcpy(pJobId, &This->jobId, sizeof(GUID)); + + *ppObj = &This->lpVtbl; + return S_OK; +} diff --git a/dlls/qmgr/qmgr.c b/dlls/qmgr/qmgr.c index b257a16..e274159 100644 --- a/dlls/qmgr/qmgr.c +++ b/dlls/qmgr/qmgr.c @@ -91,8 +91,9 @@ static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob( GUID *pJobId, IBackgroundCopyJob **ppJob) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + TRACE("\n"); + return BackgroundCopyJobConstructor(DisplayName, Type, pJobId, + (LPVOID *) ppJob); }
static HRESULT WINAPI BITS_IBackgroundCopyManager_GetJob( diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h index 1118e2b..178fda1 100644 --- a/dlls/qmgr/qmgr.h +++ b/dlls/qmgr/qmgr.h @@ -34,6 +34,9 @@ typedef struct { const IBackgroundCopyJobVtbl *lpVtbl; LONG ref; + LPWSTR displayName; + BG_JOB_TYPE type; + GUID jobId; } BackgroundCopyJobImpl;
/* Background copy manager vtbl and related data */ @@ -51,6 +54,8 @@ typedef struct extern ClassFactoryImpl BITS_ClassFactory;
HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj); +HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, + GUID *pJobId, LPVOID *ppObj);
/* Little helper functions */ static inline char * diff --git a/dlls/qmgr/tests/qmgr.c b/dlls/qmgr/tests/qmgr.c index 0051751..e36ff36 100644 --- a/dlls/qmgr/tests/qmgr.c +++ b/dlls/qmgr/tests/qmgr.c @@ -48,9 +48,46 @@ test_CreateInstance(void)
}
+static void test_CreateJob(void) +{ + /* Job information */ + static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0}; + IBackgroundCopyJob* job = NULL; + GUID tmpId; + HRESULT hres; + ULONG res; + IBackgroundCopyManager* manager = NULL; + + /* Setup */ + hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, + CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager, + (void **) &manager); + if(hres != S_OK) + { + skip("Unable to create bits instance required for test.\n"); + return; + } + + /* Create bits job */ + hres = IBackgroundCopyManager_CreateJob(manager, copyNameW, + BG_JOB_TYPE_DOWNLOAD, &tmpId, + &job); + ok(hres == S_OK, "CreateJob failed: %08x\n", hres); + if(hres != S_OK) + skip("Unable to create bits job.\n"); + else + { + res = IBackgroundCopyJob_Release(job); + ok(res == 0, "Bad ref count on release: %u\n", res); + } + + IBackgroundCopyManager_Release(manager); +} + START_TEST(qmgr) { CoInitialize(NULL); test_CreateInstance(); + test_CreateJob(); CoUninitialize(); }