Dan Hipschman : qmgr: Implement IBackgroundCopyJob_Resume.

Alexandre Julliard julliard at winehq.org
Wed Mar 5 06:24:13 CST 2008


Module: wine
Branch: master
Commit: eb7043699341d0bbf861529d6e07a557e990a298
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eb7043699341d0bbf861529d6e07a557e990a298

Author: Dan Hipschman <dsh at linux.ucla.edu>
Date:   Tue Mar  4 16:01:43 2008 -0800

qmgr: Implement IBackgroundCopyJob_Resume.

---

 dlls/qmgr/job.c       |   32 ++++++++++++++++++++++++++++----
 dlls/qmgr/qmgr.h      |    1 +
 dlls/qmgr/tests/job.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c
index 8e3bce4..2a894ba 100644
--- a/dlls/qmgr/job.c
+++ b/dlls/qmgr/job.c
@@ -119,8 +119,25 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_Suspend(
 static HRESULT WINAPI BITS_IBackgroundCopyJob_Resume(
     IBackgroundCopyJob* iface)
 {
-    FIXME("Not implemented\n");
-    return E_NOTIMPL;
+    BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
+
+    if (This->state == BG_JOB_STATE_CANCELLED
+        || This->state == BG_JOB_STATE_ACKNOWLEDGED)
+    {
+        return BG_E_INVALID_STATE;
+    }
+
+    if (This->jobProgress.FilesTransferred == This->jobProgress.FilesTotal)
+        return BG_E_EMPTY;
+
+    if (This->state == BG_JOB_STATE_CONNECTING
+        || This->state == BG_JOB_STATE_TRANSFERRING)
+    {
+        return S_OK;
+    }
+
+    This->state = BG_JOB_STATE_QUEUED;
+    return S_OK;
 }
 
 static HRESULT WINAPI BITS_IBackgroundCopyJob_Cancel(
@@ -188,8 +205,13 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_GetState(
     IBackgroundCopyJob* iface,
     BG_JOB_STATE *pVal)
 {
-    FIXME("Not implemented\n");
-    return E_NOTIMPL;
+    BackgroundCopyJobImpl *This = (BackgroundCopyJobImpl *) iface;
+
+    if (!pVal)
+        return E_INVALIDARG;
+
+    *pVal = This->state;
+    return S_OK;
 }
 
 static HRESULT WINAPI BITS_IBackgroundCopyJob_GetError(
@@ -446,6 +468,8 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
     This->jobProgress.FilesTotal = 0;
     This->jobProgress.FilesTransferred = 0;
 
+    This->state = BG_JOB_STATE_SUSPENDED;
+
     *ppObj = &This->lpVtbl;
     return S_OK;
 }
diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h
index 2ab3f57..f40b1a5 100644
--- a/dlls/qmgr/qmgr.h
+++ b/dlls/qmgr/qmgr.h
@@ -40,6 +40,7 @@ typedef struct
     GUID jobId;
     struct list files;
     BG_JOB_PROGRESS jobProgress;
+    BG_JOB_STATE state;
     struct list entryFromQmgr;
 } BackgroundCopyJobImpl;
 
diff --git a/dlls/qmgr/tests/job.c b/dlls/qmgr/tests/job.c
index 26cbfe9..fab1c8d 100644
--- a/dlls/qmgr/tests/job.c
+++ b/dlls/qmgr/tests/job.c
@@ -239,6 +239,47 @@ static void test_GetProgress_preTransfer(void)
     ok(progress.FilesTransferred == 0, "Incorrect FilesTransferred %u\n", progress.FilesTransferred);
 }
 
+/* Test getting job state */
+static void test_GetState(void)
+{
+    HRESULT hres;
+    BG_JOB_STATE state;
+
+    state = BG_JOB_STATE_ERROR;
+    hres = IBackgroundCopyJob_GetState(test_job, &state);
+    ok(hres == S_OK, "GetState failed: 0x%08x\n", hres);
+    if (hres != S_OK)
+    {
+        skip("Unable to get job state\n");
+        return;
+    }
+    ok(state == BG_JOB_STATE_SUSPENDED, "Incorrect job state: %d\n", state);
+}
+
+/* Test resuming a job */
+static void test_ResumeEmpty(void)
+{
+    HRESULT hres;
+    BG_JOB_STATE state;
+
+    hres = IBackgroundCopyJob_Resume(test_job);
+    ok(hres == BG_E_EMPTY, "Resume failed to return BG_E_EMPTY error: 0x%08x\n", hres);
+    if (hres != BG_E_EMPTY)
+    {
+        skip("Failed calling resume job\n");
+        return;
+    }
+
+    state = BG_JOB_STATE_ERROR;
+    hres = IBackgroundCopyJob_GetState(test_job, &state);
+    if (hres != S_OK)
+    {
+        skip("Unable to get job state\n");
+        return;
+    }
+    ok(state == BG_JOB_STATE_SUSPENDED, "Incorrect job state: %d\n", state);
+}
+
 typedef void (*test_t)(void);
 
 START_TEST(job)
@@ -250,6 +291,8 @@ START_TEST(job)
         test_AddFile,
         test_EnumFiles,
         test_GetProgress_preTransfer,
+        test_GetState,
+        test_ResumeEmpty,
         0
     };
     const test_t *test;




More information about the wine-cvs mailing list