Module: wine Branch: master Commit: be8bac15fd43756aeaac883c145c17645729dc90 URL: http://source.winehq.org/git/wine.git/?a=commit;h=be8bac15fd43756aeaac883c14...
Author: Roy Shea roy@cs.hmc.edu Date: Tue Feb 26 17:51:20 2008 -0800
qmgr: Implement IBackgroundCopyJob_AddFile.
---
dlls/qmgr/job.c | 27 +++++++++++++- dlls/qmgr/qmgr.h | 6 +++ dlls/qmgr/tests/Makefile.in | 2 +- dlls/qmgr/tests/job.c | 79 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 3 deletions(-)
diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c index b14783c..3db3c79 100644 --- a/dlls/qmgr/job.c +++ b/dlls/qmgr/job.c @@ -80,8 +80,25 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile( LPCWSTR RemoteUrl, LPCWSTR LocalName) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) 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(RemoteUrl, LocalName, (LPVOID *) &pFile); + if (res != S_OK) + return res; + + /* Add a reference to the file to file list */ + IBackgroundCopyFile_AddRef(pFile); + file = (BackgroundCopyFileImpl *) pFile; + list_add_head(&This->files, &file->entryFromJob); + ++This->jobProgress.FilesTotal; + + return S_OK; }
static HRESULT WINAPI BITS_IBackgroundCopyJob_EnumFiles( @@ -414,6 +431,12 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, } memcpy(pJobId, &This->jobId, sizeof(GUID));
+ list_init(&This->files); + This->jobProgress.BytesTotal = BG_SIZE_UNKNOWN; + This->jobProgress.BytesTransferred = 0; + This->jobProgress.FilesTotal = 0; + This->jobProgress.FilesTransferred = 0; + *ppObj = &This->lpVtbl; return S_OK; } diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h index 08b4da3..8c32982 100644 --- a/dlls/qmgr/qmgr.h +++ b/dlls/qmgr/qmgr.h @@ -28,6 +28,7 @@ #include "bits.h"
#include <string.h> +#include "wine/list.h"
/* Background copy job vtbl and related data */ typedef struct @@ -37,6 +38,8 @@ typedef struct LPWSTR displayName; BG_JOB_TYPE type; GUID jobId; + struct list files; + BG_JOB_PROGRESS jobProgress; } BackgroundCopyJobImpl;
/* Enum background copy jobs vtbl and related data */ @@ -52,6 +55,7 @@ typedef struct const IBackgroundCopyFileVtbl *lpVtbl; LONG ref; BG_FILE_INFO info; + struct list entryFromJob; } BackgroundCopyFileImpl;
/* Background copy manager vtbl and related data */ @@ -73,6 +77,8 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID *pJobId, LPVOID *ppObj); HRESULT EnumBackgroundCopyJobsConstructor(LPVOID *ppObj, IBackgroundCopyManager* copyManager); +HRESULT BackgroundCopyFileConstructor(LPCWSTR remoteName, + LPCWSTR localName, LPVOID *ppObj);
/* Little helper functions */ static inline char * diff --git a/dlls/qmgr/tests/Makefile.in b/dlls/qmgr/tests/Makefile.in index 0508656..9e71b09 100644 --- a/dlls/qmgr/tests/Makefile.in +++ b/dlls/qmgr/tests/Makefile.in @@ -3,7 +3,7 @@ TOPOBJDIR = ../../.. SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = qmgr.dll -IMPORTS = ole32 kernel32 +IMPORTS = ole32 user32 kernel32
CTESTS = \ job.c \ diff --git a/dlls/qmgr/tests/job.c b/dlls/qmgr/tests/job.c index 65ac06c..7aec1a7 100644 --- a/dlls/qmgr/tests/job.c +++ b/dlls/qmgr/tests/job.c @@ -27,11 +27,67 @@
/* Globals used by many tests */ static const WCHAR test_displayName[] = {'T', 'e', 's', 't', 0}; +static const WCHAR test_remoteNameA[] = {'r','e','m','o','t','e','A', 0}; +static const WCHAR test_remoteNameB[] = {'r','e','m','o','t','e','B', 0}; +static const WCHAR test_localNameA[] = {'l','o','c','a','l','A', 0}; +static const WCHAR test_localNameB[] = {'l','o','c','a','l','B', 0}; +static WCHAR *test_currentDir; +static WCHAR *test_remotePathA; +static WCHAR *test_remotePathB; +static WCHAR *test_localPathA; +static WCHAR *test_localPathB; static IBackgroundCopyManager *test_manager; static IBackgroundCopyJob *test_job; static GUID test_jobId; static BG_JOB_TYPE test_type;
+static BOOL init_paths(void) +{ + static const WCHAR format[] = {'%','s','\','%','s', 0}; + DWORD n; + + n = GetCurrentDirectoryW(0, NULL); + if (n == 0) + { + skip("Couldn't get current directory size\n"); + return FALSE; + } + + test_currentDir = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR)); + test_localPathA + = HeapAlloc(GetProcessHeap(), 0, + (n + 1 + lstrlenW(test_localNameA)) * sizeof(WCHAR)); + test_localPathB + = HeapAlloc(GetProcessHeap(), 0, + (n + 1 + lstrlenW(test_localNameB)) * sizeof(WCHAR)); + test_remotePathA + = HeapAlloc(GetProcessHeap(), 0, + (n + 1 + lstrlenW(test_remoteNameA)) * sizeof(WCHAR)); + test_remotePathB + = HeapAlloc(GetProcessHeap(), 0, + (n + 1 + lstrlenW(test_remoteNameB)) * sizeof(WCHAR)); + + if (!test_currentDir || !test_localPathA || !test_localPathB + || !test_remotePathA || !test_remotePathB) + { + skip("Couldn't allocate memory for full paths\n"); + return FALSE; + } + + if (GetCurrentDirectoryW(n, test_currentDir) != n - 1) + { + skip("Couldn't get current directory\n"); + return FALSE; + } + + wsprintfW(test_localPathA, format, test_currentDir, test_localNameA); + wsprintfW(test_localPathB, format, test_currentDir, test_localNameB); + wsprintfW(test_remotePathA, format, test_currentDir, test_remoteNameA); + wsprintfW(test_remotePathB, format, test_currentDir, test_remoteNameB); + + return TRUE; +} + /* Generic test setup */ static BOOL setup(void) { @@ -116,6 +172,25 @@ static void test_GetName(void) CoTaskMemFree(displayName); }
+/* Test adding a file */ +static void test_AddFile(void) +{ + HRESULT hres; + + hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathA, + test_localPathA); + ok(hres == S_OK, "First call to AddFile failed: 0x%08x\n", hres); + if (hres != S_OK) + { + skip("Unable to add first file to job\n"); + return; + } + + hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathB, + test_localPathB); + ok(hres == S_OK, "Second call to AddFile failed: 0x%08x\n", hres); +} + typedef void (*test_t)(void);
START_TEST(job) @@ -124,10 +199,14 @@ START_TEST(job) test_GetId, test_GetType, test_GetName, + test_AddFile, 0 }; const test_t *test;
+ if (!init_paths()) + return; + CoInitialize(NULL); for (test = tests; *test; ++test) {