wiaservc: add the class factory and IWiaDevMgr stubs

Damjan Jovanovic damjan.jov at gmail.com
Sat Oct 31 09:06:18 CDT 2009


Changelog:
* wiaservc: add the class factory and IWiaDevMgr stubs

Damjan Jovanovic
-------------- next part --------------
diff --git a/dlls/wiaservc/Makefile.in b/dlls/wiaservc/Makefile.in
index 8fbffd0..67db949 100644
--- a/dlls/wiaservc/Makefile.in
+++ b/dlls/wiaservc/Makefile.in
@@ -6,7 +6,9 @@ MODULE    = wiaservc.dll
 IMPORTS   = uuid ole32 advapi32 kernel32
 
 C_SRCS = \
+	factory.c \
 	service.c \
+	wiadevmgr.c \
 	wiaservc_main.c
 
 @MAKE_DLL_RULES@
diff --git a/dlls/wiaservc/factory.c b/dlls/wiaservc/factory.c
new file mode 100644
index 0000000..db58222
--- /dev/null
+++ b/dlls/wiaservc/factory.c
@@ -0,0 +1,105 @@
+/*
+ * Class factory interface for WiaServc
+ *
+ * Copyright (C) 2009 Damjan Jovanovic
+ *
+ * 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
+ */
+
+#define COBJMACROS
+
+#define _WIN32_WINNT 0x0600
+
+#include "objbase.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "initguid.h"
+#include "wia.h"
+
+#include "wiaservc_private.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wia);
+
+static ULONG WINAPI
+WIASERVC_IClassFactory_AddRef(LPCLASSFACTORY iface)
+{
+    return 2;
+}
+
+static HRESULT WINAPI
+WIASERVC_IClassFactory_QueryInterface(LPCLASSFACTORY iface, REFIID riid,
+                                      LPVOID *ppvObj)
+{
+    ClassFactoryImpl *This = (ClassFactoryImpl *) iface;
+
+    if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IClassFactory))
+    {
+        *ppvObj = &This->lpVtbl;
+        return S_OK;
+    }
+
+    *ppvObj = NULL;
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI
+WIASERVC_IClassFactory_Release(LPCLASSFACTORY iface)
+{
+    return 1;
+}
+
+static HRESULT WINAPI
+WIASERVC_IClassFactory_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter,
+                                      REFIID riid, LPVOID *ppvObj)
+{
+    HRESULT res;
+    IUnknown *punk = NULL;
+
+    TRACE("IID: %s\n", debugstr_guid(riid));
+
+    if (pUnkOuter)
+        return CLASS_E_NOAGGREGATION;
+
+    res = wiadevmgr_Constructor(pUnkOuter, (LPVOID*) &punk);
+    if (FAILED(res))
+        return res;
+
+    res = IUnknown_QueryInterface(punk, riid, ppvObj);
+    IUnknown_Release(punk);
+    return res;
+}
+
+static HRESULT WINAPI
+WIASERVC_IClassFactory_LockServer(LPCLASSFACTORY iface, BOOL fLock)
+{
+    FIXME("Not implemented\n");
+    return E_NOTIMPL;
+}
+
+static const IClassFactoryVtbl WIASERVC_IClassFactory_Vtbl =
+{
+    WIASERVC_IClassFactory_QueryInterface,
+    WIASERVC_IClassFactory_AddRef,
+    WIASERVC_IClassFactory_Release,
+    WIASERVC_IClassFactory_CreateInstance,
+    WIASERVC_IClassFactory_LockServer
+};
+
+ClassFactoryImpl WIASERVC_ClassFactory =
+{
+    &WIASERVC_IClassFactory_Vtbl
+};
diff --git a/dlls/wiaservc/service.c b/dlls/wiaservc/service.c
index 4e91c41..b7d1f81 100644
--- a/dlls/wiaservc/service.c
+++ b/dlls/wiaservc/service.c
@@ -18,11 +18,15 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#define _WIN32_WINNT 0x0600
+
 #include "windef.h"
 #include "objbase.h"
 #include "winsvc.h"
 #include "wia.h"
 
+#include "wiaservc_private.h"
+
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(wia);
@@ -92,14 +96,13 @@ StartCount(void)
     if (FAILED(hr))
         return FALSE;
 
-/* FIXME: implement
     hr = CoRegisterClassObject(&CLSID_WiaDevMgr,
                                (IUnknown *) &WIASERVC_ClassFactory,
                                CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE,
                                &dwReg);
     if (FAILED(hr))
         return FALSE;
- */
+
     return TRUE;
 }
 
diff --git a/dlls/wiaservc/wiadevmgr.c b/dlls/wiaservc/wiadevmgr.c
new file mode 100644
index 0000000..fd1ae43
--- /dev/null
+++ b/dlls/wiaservc/wiadevmgr.c
@@ -0,0 +1,183 @@
+/*
+ * WiaDevMgr functions
+ *
+ * Copyright 2009 Damjan Jovanovic
+ *
+ * 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
+ */
+
+#define COBJMACROS
+#define _WIN32_WINNT 0x0600
+
+#include "objbase.h"
+#include "wia.h"
+
+#include "wiaservc_private.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wia);
+
+static inline wiadevmgr *impl_from_WiaDevMgr(IWiaDevMgr *iface)
+{
+    return (wiadevmgr *)((char*)iface - FIELD_OFFSET(wiadevmgr, lpVtbl));
+}
+
+static HRESULT WINAPI wiadevmgr_QueryInterface(IWiaDevMgr *iface, REFIID riid, void **ppvObject)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+
+    TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
+
+    if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IWiaDevMgr))
+        *ppvObject = iface;
+    else
+    {
+        FIXME("interface %s not implemented\n", debugstr_guid(riid));
+        *ppvObject = NULL;
+        return E_NOINTERFACE;
+    }
+    IUnknown_AddRef((IUnknown*) *ppvObject);
+    return S_OK;
+}
+
+static ULONG WINAPI wiadevmgr_AddRef(IWiaDevMgr *iface)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI wiadevmgr_Release(IWiaDevMgr *iface)
+{
+    ULONG ref;
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+
+    ref = InterlockedDecrement(&This->ref);
+    if (ref == 0)
+        HeapFree(GetProcessHeap(), 0, This);
+    return ref;
+}
+
+static HRESULT WINAPI wiadevmgr_EnumDeviceInfo(IWiaDevMgr *iface, LONG lFlag, IEnumWIA_DEV_INFO **ppIEnum)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, %d, %p): stub\n", This, lFlag, ppIEnum);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wiadevmgr_CreateDevice(IWiaDevMgr *iface, BSTR bstrDeviceID, IWiaItem **ppWiaItemRoot)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, %s, %p): stub\n", This, debugstr_w(bstrDeviceID), ppWiaItemRoot);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wiadevmgr_SelectDeviceDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
+                                                LONG lFlags, BSTR *pbstrDeviceID, IWiaItem **ppItemRoot)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, %p, %d, 0x%x, %p, %p): stub\n", This, hwndParent, lDeviceType, lFlags, pbstrDeviceID, ppItemRoot);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wiadevmgr_SelectDeviceDlgID(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
+                                                  LONG lFlags, BSTR *pbstrDeviceID)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, %p, %d, 0x%x, %p): stub\n", This, hwndParent, lDeviceType, lFlags, pbstrDeviceID);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wiadevmgr_GetImageDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lDeviceType,
+                                            LONG lFlags, LONG lIntent, IWiaItem *pItemRoot,
+                                            BSTR bstrFilename, GUID *pguidFormat)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, %p, %d, 0x%x, %d, %p, %s, %s): stub\n", This, hwndParent, lDeviceType, lFlags,
+        lIntent, pItemRoot, debugstr_w(bstrFilename), debugstr_guid(pguidFormat));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wiadevmgr_RegisterEventCallbackProgram(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
+                                                             const GUID *pEventGUID, BSTR bstrCommandline,
+                                                             BSTR bstrName, BSTR bstrDescription, BSTR bstrIcon)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, 0x%x, %s, %s, %s, %s, %s, %s): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
+        debugstr_guid(pEventGUID), debugstr_w(bstrCommandline), debugstr_w(bstrName),
+        debugstr_w(bstrDescription), debugstr_w(bstrIcon));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wiadevmgr_RegisterEventCallbackInterface(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
+                                                               const GUID *pEventGUID, IWiaEventCallback *pIWiaEventCallback,
+                                                               IUnknown **pEventObject)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, 0x%x, %s, %s, %p, %p): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
+        debugstr_guid(pEventGUID), pIWiaEventCallback, pEventObject);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wiadevmgr_RegisterEventCallbackCLSID(IWiaDevMgr *iface, LONG lFlags, BSTR bstrDeviceID,
+                                                           const GUID *pEventGUID, const GUID *pClsID, BSTR bstrName,
+                                                           BSTR bstrDescription, BSTR bstrIcon)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, 0x%x, %s, %s, %s, %s, %s, %s): stub\n", This, lFlags, debugstr_w(bstrDeviceID),
+        debugstr_guid(pEventGUID), debugstr_guid(pClsID), debugstr_w(bstrName),
+        debugstr_w(bstrDescription), debugstr_w(bstrIcon));
+    return E_NOTIMPL;
+}
+        
+static HRESULT WINAPI wiadevmgr_AddDeviceDlg(IWiaDevMgr *iface, HWND hwndParent, LONG lFlags)
+{
+    wiadevmgr *This = impl_from_WiaDevMgr(iface);
+    FIXME("(%p, %p, 0x%x): stub\n", This, hwndParent, lFlags);
+    return E_NOTIMPL;
+}
+
+static const IWiaDevMgrVtbl WIASERVC_IWiaDevMgr_Vtbl =
+{
+    wiadevmgr_QueryInterface,
+    wiadevmgr_AddRef,
+    wiadevmgr_Release,
+    wiadevmgr_EnumDeviceInfo,
+    wiadevmgr_CreateDevice,
+    wiadevmgr_SelectDeviceDlg,
+    wiadevmgr_SelectDeviceDlgID,
+    wiadevmgr_GetImageDlg,
+    wiadevmgr_RegisterEventCallbackProgram,
+    wiadevmgr_RegisterEventCallbackInterface,
+    wiadevmgr_RegisterEventCallbackCLSID,
+    wiadevmgr_AddDeviceDlg
+};
+
+HRESULT wiadevmgr_Constructor(IUnknown *pUnkOuter, LPVOID *ppObj)
+{
+    wiadevmgr *This;
+    TRACE("(%p,%p)\n", pUnkOuter, ppObj);
+    This = HeapAlloc(GetProcessHeap(), 0, sizeof(wiadevmgr));
+    if (This)
+    {
+        This->lpVtbl = &WIASERVC_IWiaDevMgr_Vtbl;
+        This->ref = 1;
+        *ppObj = This;
+        return S_OK;
+    }
+    *ppObj = NULL;
+    return E_OUTOFMEMORY;
+}
+
diff --git a/dlls/wiaservc/wiaservc_private.h b/dlls/wiaservc/wiaservc_private.h
new file mode 100644
index 0000000..80f3ace
--- /dev/null
+++ b/dlls/wiaservc/wiaservc_private.h
@@ -0,0 +1,40 @@
+/*
+ * WiaServc definitions
+ *
+ * Copyright 2009 Damjan Jovanovic
+ *
+ * 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 __WIASERVC_PRIVATE__
+#define __WIASERVC_PRIVATE__
+
+typedef struct
+{
+    const IClassFactoryVtbl *lpVtbl;
+} ClassFactoryImpl;
+
+extern ClassFactoryImpl WIASERVC_ClassFactory;
+
+typedef struct
+{
+    const IWiaDevMgrVtbl *lpVtbl;
+    LONG ref;
+} wiadevmgr;
+
+HRESULT wiadevmgr_Constructor(IUnknown *pUnkOuter, LPVOID *ppObj);
+
+#endif /* __WIASERVC_PRIVATE__ */
+


More information about the wine-patches mailing list