[PATCH] qmgr: Class factory for the queue manager.
Roy Shea
roy at cs.hmc.edu
Thu Dec 20 18:38:31 CST 2007
---
dlls/qmgr/Makefile.in | 1 +
dlls/qmgr/factory.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++
dlls/qmgr/factory.h | 34 ++++++++++++++
3 files changed, 154 insertions(+), 0 deletions(-)
create mode 100644 dlls/qmgr/factory.c
create mode 100644 dlls/qmgr/factory.h
diff --git a/dlls/qmgr/Makefile.in b/dlls/qmgr/Makefile.in
index 3a32cbe..a19eea6 100644
--- a/dlls/qmgr/Makefile.in
+++ b/dlls/qmgr/Makefile.in
@@ -7,6 +7,7 @@ IMPORTS = kernel32
EXTRALIBS = -luuid
C_SRCS = \
+ factory.c \
qmgr.c \
qmgr_main.c
diff --git a/dlls/qmgr/factory.c b/dlls/qmgr/factory.c
new file mode 100644
index 0000000..8db9222
--- /dev/null
+++ b/dlls/qmgr/factory.c
@@ -0,0 +1,119 @@
+/*
+ * Class factory interface for Queue Manager (BITS)
+ *
+ * Copyright (C) 2007 Google (Roy Shea)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "qmgr.h"
+#include "factory.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
+
+/* Add a reference to the iface pointer */
+static ULONG WINAPI BITS_IClassFactory_AddRef(LPCLASSFACTORY iface)
+{
+ ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
+ ULONG ref;
+
+ TRACE("\n");
+
+ ref = InterlockedIncrement(&This->ref);
+ return ref;
+}
+
+/* Attempt to provide a new interface to interact with iface */
+static HRESULT WINAPI BITS_IClassFactory_QueryInterface(
+ LPCLASSFACTORY iface,
+ REFIID riid,
+ LPVOID *ppvObj)
+{
+ ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
+
+ TRACE("IID: %s\n", debugstr_guid(riid));
+
+ if (IsEqualGUID(riid, &IID_IUnknown) ||
+ IsEqualGUID(riid, &IID_IClassFactory))
+ {
+ *ppvObj = &This->lpVtbl;
+ BITS_IClassFactory_AddRef(iface);
+ return S_OK;
+ }
+
+ *ppvObj = NULL;
+ return E_NOINTERFACE;
+}
+
+/* Release an interface to iface */
+static ULONG WINAPI BITS_IClassFactory_Release(LPCLASSFACTORY iface)
+{
+ ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
+ ULONG ref;
+
+ TRACE("\n");
+
+ ref = InterlockedDecrement(&This->ref);
+ return ref;
+}
+
+/* Create an instance of BackgroundCopyManager */
+static HRESULT WINAPI BITS_IClassFactory_CreateInstance(
+ LPCLASSFACTORY iface,
+ LPUNKNOWN pUnkOuter,
+ REFIID riid,
+ LPVOID *ppvObj)
+{
+ HRESULT res;
+ IUnknown *punk = NULL;
+
+ TRACE("IID: %s\n", debugstr_guid(riid));
+
+ /* No aggregation support */
+ if (pUnkOuter != NULL)
+ {
+ return CLASS_E_NOAGGREGATION;
+ }
+
+ res = BackgroundCopyManagerConstructor(pUnkOuter, (LPVOID*) &punk);
+ if (res != S_OK)
+ {
+ return res;
+ }
+
+ res = IBackgroundCopyManager_QueryInterface(punk, riid, ppvObj);
+
+ /* Release punk and return res from call to QueryInterface*/
+ IBackgroundCopyManager_Release(punk);
+ return res;
+}
+
+static HRESULT WINAPI BITS_IClassFactory_LockServer(
+ LPCLASSFACTORY iface,
+ BOOL fLock)
+{
+ FIXME("Not implemented\n");
+ return E_NOTIMPL;
+}
+
+static const IClassFactoryVtbl BITS_IClassFactory_Vtbl =
+{
+ BITS_IClassFactory_QueryInterface,
+ BITS_IClassFactory_AddRef,
+ BITS_IClassFactory_Release,
+ BITS_IClassFactory_CreateInstance,
+ BITS_IClassFactory_LockServer
+};
diff --git a/dlls/qmgr/factory.h b/dlls/qmgr/factory.h
new file mode 100644
index 0000000..aa61450
--- /dev/null
+++ b/dlls/qmgr/factory.h
@@ -0,0 +1,34 @@
+/*
+ * Factory interface for BITS
+ *
+ * Copyright 2007 Google (Roy Shea)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __FACTORY_H__
+#define __FACTORY_H__
+
+#include "windef.h"
+#include "objbase.h"
+
+/* Factory vtbl and related data */
+typedef struct
+{
+ const IClassFactoryVtbl *lpVtbl;
+ LONG ref;
+} ClassFactoryImpl;
+
+#endif /* __FACTORY_H__ */
--
1.5.3.1
More information about the wine-patches
mailing list