[PATCH] bits: Add implementation of BITS_IClassFactory_CreateInstance (9/12)

Roy Shea roy at cs.hmc.edu
Thu Nov 15 10:24:13 CST 2007


Implementation of BITS_IClassFactory_CreateInstance ond the support function
BackgroundCopyManagerConstructor.
---
 dlls/Makefile.in         |    5 +++++
 dlls/qmgr/factory.c      |   43 +++++++++++++++++++++++++++++++++++++++----
 dlls/qmgr/qmgr.c         |   20 ++++++++++++++++++++
 dlls/qmgr/qmgr_private.h |    5 ++---
 4 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 0d2f3e4..29d0b4a 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -162,6 +162,7 @@ BASEDIRS = \
 	pstorec \
 	qcap \
 	qmgr \
+	qmgrprxy \
 	quartz \
 	query \
 	rasapi32 \
@@ -577,6 +578,7 @@ IMPORT_LIBS = \
 	pdh/libpdh.$(IMPLIBEXT) \
 	powrprof/libpowrprof.$(IMPLIBEXT) \
 	psapi/libpsapi.$(IMPLIBEXT) \
+	qmgrprxy/libqmgrprxy.$(IMPLIBEXT) \
 	quartz/libquartz.$(IMPLIBEXT) \
 	rasapi32/librasapi32.$(IMPLIBEXT) \
 	resutils/libresutils.$(IMPLIBEXT) \
@@ -883,6 +885,9 @@ powrprof/libpowrprof.$(IMPLIBEXT): powrprof/powrprof.spec $(WINEBUILD)
 psapi/libpsapi.$(IMPLIBEXT): psapi/psapi.spec $(WINEBUILD)
 	@cd psapi && $(MAKE) libpsapi.$(IMPLIBEXT)
 
+qmgrprxy/libqmgrprxy.$(IMPLIBEXT): qmgrprxy/qmgrprxy.spec $(WINEBUILD)
+	@cd qmgrprxy && $(MAKE) libqmgrprxy.$(IMPLIBEXT)
+
 quartz/libquartz.$(IMPLIBEXT): quartz/quartz.spec $(WINEBUILD)
 	@cd quartz && $(MAKE) libquartz.$(IMPLIBEXT)
 
diff --git a/dlls/qmgr/factory.c b/dlls/qmgr/factory.c
index 70e548f..f70fdef 100644
--- a/dlls/qmgr/factory.c
+++ b/dlls/qmgr/factory.c
@@ -27,6 +27,9 @@
 #include "qmgr_private.h"
 #include "wine/debug.h"
 
+#define COBJMACROS
+#include "bits.h"
+
 WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
 
 static ULONG WINAPI BITS_IClassFactory_AddRef(LPCLASSFACTORY iface)
@@ -81,10 +84,14 @@ static ULONG WINAPI BITS_IClassFactory_Release(LPCLASSFACTORY iface)
 
     TRACE("\n");
 
-    if (This == NULL) return E_POINTER;
+    if (This == NULL)
+    {
+        return E_POINTER;
+    }
 
     ref = InterlockedDecrement(&This->ref);
-    if (ref == 0) {
+    if (ref == 0)
+    {
         HeapFree(GetProcessHeap(), 0, This);
         InterlockedDecrement(&dll_ref);
     }
@@ -97,8 +104,36 @@ static HRESULT WINAPI BITS_IClassFactory_CreateInstance(
         REFIID riid,
         LPVOID *ppvObj)
 {
-    FIXME("Not implemented\n");
-    return E_NOTIMPL;
+    ICOM_THIS_MULTI(ClassFactoryImpl, classFactoryVtbl, iface);
+    HRESULT res;
+    IUnknown *punk = NULL;
+
+    TRACE("IID: %s\n",debugstr_guid(riid));
+
+    if (This == NULL || ppvObj == NULL)
+    {
+        return E_POINTER;
+    }
+
+    if (pUnkOuter != NULL)
+    {
+        return CLASS_E_NOAGGREGATION;
+    }
+
+    res = BackgroundCopyManagerConstructor(pUnkOuter, (LPVOID*) &punk);
+    if (FAILED(res))
+    {
+        return res;
+    }
+
+    res = IBackgroundCopyManager_QueryInterface(punk, riid, ppvObj);
+    if (FAILED(res))
+    {
+        return res;
+    }
+
+    IBackgroundCopyManager_Release(punk);
+    return res;
 }
 
 static HRESULT WINAPI BITS_IClassFactory_LockServer(
diff --git a/dlls/qmgr/qmgr.c b/dlls/qmgr/qmgr.c
index 3247dc0..a42479b 100644
--- a/dlls/qmgr/qmgr.c
+++ b/dlls/qmgr/qmgr.c
@@ -110,3 +110,23 @@ BackgroundCopyManagerImpl BITS_BackgroundCopyManager =
     0
 };
 
+HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj)
+{
+    BackgroundCopyManagerImpl *bcm;
+
+    TRACE("(%p,%p)\n", pUnkOuter, ppObj);
+
+    bcm = HeapAlloc(GetProcessHeap(), 0, sizeof(*bcm));
+    if (!bcm)
+    {
+        return E_OUTOFMEMORY;
+    }
+
+    bcm->bitsVtbl = &BITS_IBackgroundCopyManager_Vtbl;
+    bcm->ref = 1;
+
+    *ppObj = &bcm->bitsVtbl;
+    return S_OK;
+}
+
+
diff --git a/dlls/qmgr/qmgr_private.h b/dlls/qmgr/qmgr_private.h
index 8dead77..d3de168 100644
--- a/dlls/qmgr/qmgr_private.h
+++ b/dlls/qmgr/qmgr_private.h
@@ -27,6 +27,7 @@
 #include "winbase.h"
 #include "objbase.h"
 
+#define COBJMACROS
 #include "bits.h"
 
 #define ICOM_THIS_MULTI(impl,field,iface) \
@@ -53,9 +54,7 @@ typedef struct
 extern ClassFactoryImpl BITS_ClassFactory;
 extern BackgroundCopyManagerImpl BITS_BackgroundCopyManager;
 
-/*
-extern HRESULT CountConstructor(IUnknown *pUnkOuter, LPVOID *ppObj);
-*/
+HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj);
 
 #endif /* __QMGR_PRIVATE_H__ */
 
-- 
1.5.3.1




More information about the wine-patches mailing list