Nikolay Sivov : qmgr: Implement Get/SetNotifyInterface().
Alexandre Julliard
julliard at winehq.org
Fri Nov 29 13:24:27 CST 2013
Module: wine
Branch: master
Commit: f2e9854483eb98e7423c95815ad33f73d5999d8a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f2e9854483eb98e7423c95815ad33f73d5999d8a
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu Nov 28 09:31:24 2013 +0400
qmgr: Implement Get/SetNotifyInterface().
---
dlls/qmgr/job.c | 42 ++++++++++++++++++++++++++++++++++++++----
dlls/qmgr/qmgr.h | 6 +++++-
dlls/qmgr/qmgr_local.idl | 1 +
dlls/qmgr/tests/job.c | 12 ++++++++++++
4 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c
index 52c7b7f..fdbf234 100644
--- a/dlls/qmgr/job.c
+++ b/dlls/qmgr/job.c
@@ -77,6 +77,8 @@ static ULONG WINAPI BackgroundCopyJob_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);
@@ -418,6 +420,7 @@ static HRESULT WINAPI BackgroundCopyJob_SetNotifyFlags(
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;
@@ -443,8 +446,29 @@ static HRESULT WINAPI BackgroundCopyJob_SetNotifyInterface(
IUnknown *Val)
{
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
- FIXME("(%p)->(%p): stub\n", This, Val);
- return E_NOTIMPL;
+ 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 BackgroundCopyJob_GetNotifyInterface(
@@ -452,8 +476,16 @@ static HRESULT WINAPI BackgroundCopyJob_GetNotifyInterface(
IUnknown **pVal)
{
BackgroundCopyJobImpl *This = impl_from_IBackgroundCopyJob2(iface);
- FIXME("(%p)->(%p): stub\n", This, pVal);
- return E_NOTIMPL;
+
+ 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 BackgroundCopyJob_SetMinimumRetryDelay(
@@ -705,6 +737,8 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
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;
diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h
index eb982a0..4a9bb15 100644
--- a/dlls/qmgr/qmgr.h
+++ b/dlls/qmgr/qmgr.h
@@ -22,10 +22,12 @@
#define __QMGR_H__
#include "windef.h"
-#include "objbase.h"
#define COBJMACROS
+#include "objbase.h"
+
#include "bits1_5.h"
+#include "bits3_0.h"
#include <string.h>
#include "wine/list.h"
@@ -44,6 +46,8 @@ typedef struct
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;
diff --git a/dlls/qmgr/qmgr_local.idl b/dlls/qmgr/qmgr_local.idl
index 4bbcf7b..edbe71e 100644
--- a/dlls/qmgr/qmgr_local.idl
+++ b/dlls/qmgr/qmgr_local.idl
@@ -22,3 +22,4 @@
#define DO_NO_IMPORTS
#include "bits1_5.idl"
+#include "bits3_0.idl"
diff --git a/dlls/qmgr/tests/job.c b/dlls/qmgr/tests/job.c
index 108bf6b..d42e3a5 100644
--- a/dlls/qmgr/tests/job.c
+++ b/dlls/qmgr/tests/job.c
@@ -446,6 +446,17 @@ static void test_NotifyFlags(void)
ok(flags == (BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_TRANSFERRED), "flags 0x%08x\n", flags);
}
+static void test_NotifyInterface(void)
+{
+ HRESULT hr;
+ IUnknown *unk;
+
+ unk = (IUnknown*)0xdeadbeef;
+ hr = IBackgroundCopyJob_GetNotifyInterface(test_job, &unk);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(unk == NULL, "got %p\n", unk);
+}
+
typedef void (*test_t)(void);
START_TEST(job)
@@ -458,6 +469,7 @@ START_TEST(job)
test_GetState,
test_ResumeEmpty,
test_NotifyFlags,
+ test_NotifyInterface,
0
};
static const test_t tests_bits20[] = {
More information about the wine-cvs
mailing list