wia: Implement IWiaDevMgr::EnumDeviceInfo by returning an empty, enumeration of devices

Mikael Ståldal mikael at staldal.nu
Fri May 2 16:15:43 CDT 2014


Implement IWiaDevMgr::EnumDeviceInfo by returning an empty enumeration 
of devices. Fix for bug bug 27775.

Tested on Ubuntu 12.04.
-------------- next part --------------
>From 8dc2d302493f0bf4a4d568686eb1110e42dcf875 Mon Sep 17 00:00:00 2001
From: mikaelstaldal <mikael at staldal.nu>
Date: Fri, 2 May 2014 22:43:51 +0200
Subject: Implement IWiaDevMgr::EnumDeviceInfo by returning an empty
 enumeration of devices
To: wine-patches <wine-patches at winehq.org>
Reply-To: wine-devel <wine-devel at winehq.org>

---
 dlls/wiaservc/Makefile.in        |    1 +
 dlls/wiaservc/enumwiadevinfo.c   |  138 ++++++++++++++++++++++++++++++++++++++
 dlls/wiaservc/wiadevmgr.c        |   14 +++-
 dlls/wiaservc/wiaservc_private.h |    8 +++
 include/wia_lh.idl               |   30 ++++++++-
 include/wia_xp.idl               |   30 ++++++++-
 6 files changed, 217 insertions(+), 4 deletions(-)
 create mode 100644 dlls/wiaservc/enumwiadevinfo.c

diff --git a/dlls/wiaservc/Makefile.in b/dlls/wiaservc/Makefile.in
index b40c8f0..0bdbff1 100644
--- a/dlls/wiaservc/Makefile.in
+++ b/dlls/wiaservc/Makefile.in
@@ -4,6 +4,7 @@ IMPORTS   = uuid ole32 advapi32
 C_SRCS = \
 	factory.c \
 	service.c \
+	enumwiadevinfo.c \
 	wiadevmgr.c \
 	wiaservc_main.c
 
diff --git a/dlls/wiaservc/enumwiadevinfo.c b/dlls/wiaservc/enumwiadevinfo.c
new file mode 100644
index 0000000..0412f08
--- /dev/null
+++ b/dlls/wiaservc/enumwiadevinfo.c
@@ -0,0 +1,138 @@
+/*
+ * IEnumWIA_DEV_INFO implementation. 
+ * This is a stub implementation of an empty enumeration.
+ *
+ * Copyright 2014 Mikael Ståldal
+ *
+ * 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
+
+#include "objbase.h"
+#include "wia_lh.h"
+
+#include "wiaservc_private.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wia);
+
+static inline enumwiadevinfo *impl_from_IEnumWIA_DEV_INFO(IEnumWIA_DEV_INFO *iface)
+{
+    return CONTAINING_RECORD(iface, enumwiadevinfo, IEnumWIA_DEV_INFO_iface);
+}
+
+static HRESULT WINAPI enumwiadevinfo_QueryInterface(IEnumWIA_DEV_INFO *iface, REFIID riid, void **ppvObject)
+{
+    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
+
+    TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObject);
+
+    if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumWIA_DEV_INFO))
+        *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 enumwiadevinfo_AddRef(IEnumWIA_DEV_INFO *iface)
+{
+    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
+    return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI enumwiadevinfo_Release(IEnumWIA_DEV_INFO *iface)
+{
+    ULONG ref;
+    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
+
+    ref = InterlockedDecrement(&This->ref);
+    if (ref == 0)
+        HeapFree(GetProcessHeap(), 0, This);
+    return ref;
+}
+
+static HRESULT WINAPI enumwiadevinfo_Next(IEnumWIA_DEV_INFO *iface, ULONG celt, IWiaPropertyStorage **rgelt, ULONG *pceltFetched)
+{
+    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
+    TRACE("(%p, %d, %p, %p)\n", This, celt, rgelt, pceltFetched);
+    *pceltFetched = 0;
+    return S_FALSE;
+}
+
+static HRESULT WINAPI enumwiadevinfo_Skip(IEnumWIA_DEV_INFO *iface, ULONG celt)
+{
+    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
+    TRACE("(%p, %d)\n", This, celt);
+    return S_FALSE;
+}
+
+static HRESULT WINAPI enumwiadevinfo_Reset(IEnumWIA_DEV_INFO *iface)
+{
+    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
+    TRACE("(%p)\n", This);
+    return S_OK;
+}
+
+static HRESULT WINAPI enumwiadevinfo_Clone(IEnumWIA_DEV_INFO *iface, IEnumWIA_DEV_INFO **ppIEnum)
+{
+    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
+    FIXME("(%p, %p): stub\n", This, ppIEnum);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI enumwiadevinfo_GetCount(IEnumWIA_DEV_INFO *iface, ULONG *celt)
+{
+    enumwiadevinfo *This = impl_from_IEnumWIA_DEV_INFO(iface);
+    TRACE("(%p, %p)\n", This, celt);
+    *celt = 0;
+    return S_OK;
+}
+
+
+static const IEnumWIA_DEV_INFOVtbl WIASERVC_IEnumWIA_DEV_INFO_Vtbl =
+{
+    enumwiadevinfo_QueryInterface,
+    enumwiadevinfo_AddRef,
+    enumwiadevinfo_Release,
+    enumwiadevinfo_Next,
+    enumwiadevinfo_Skip,
+    enumwiadevinfo_Reset,
+    enumwiadevinfo_Clone,
+    enumwiadevinfo_GetCount
+};
+
+HRESULT enumwiadevinfo_Constructor(LPVOID *ppObj)
+{
+    enumwiadevinfo *This;
+    TRACE("(%p)\n", ppObj);
+    This = HeapAlloc(GetProcessHeap(), 0, sizeof(enumwiadevinfo));
+    if (This)
+    {
+        This->IEnumWIA_DEV_INFO_iface.lpVtbl = &WIASERVC_IEnumWIA_DEV_INFO_Vtbl;
+        This->ref = 1;
+        *ppObj = This;
+        return S_OK;
+    }
+    *ppObj = NULL;
+    return E_OUTOFMEMORY;
+}
+
diff --git a/dlls/wiaservc/wiadevmgr.c b/dlls/wiaservc/wiadevmgr.c
index 2f0907b..19c23b6 100644
--- a/dlls/wiaservc/wiadevmgr.c
+++ b/dlls/wiaservc/wiadevmgr.c
@@ -72,8 +72,18 @@ static ULONG WINAPI wiadevmgr_Release(IWiaDevMgr *iface)
 static HRESULT WINAPI wiadevmgr_EnumDeviceInfo(IWiaDevMgr *iface, LONG lFlag, IEnumWIA_DEV_INFO **ppIEnum)
 {
     wiadevmgr *This = impl_from_IWiaDevMgr(iface);
-    FIXME("(%p, %d, %p): stub\n", This, lFlag, ppIEnum);
-    return E_NOTIMPL;
+    HRESULT res;
+    IUnknown *punk = NULL;
+
+    FIXME("(%p, %d, %p): returning empty IEnumWIA_DEV_INFO\n", This, lFlag, ppIEnum);
+
+    res = enumwiadevinfo_Constructor((LPVOID*) &punk);
+    if (FAILED(res))
+        return res;
+
+    res = IUnknown_QueryInterface(punk, &IID_IEnumWIA_DEV_INFO, ppIEnum);
+    IUnknown_Release(punk);
+    return res;
 }
 
 static HRESULT WINAPI wiadevmgr_CreateDevice(IWiaDevMgr *iface, BSTR bstrDeviceID, IWiaItem **ppWiaItemRoot)
diff --git a/dlls/wiaservc/wiaservc_private.h b/dlls/wiaservc/wiaservc_private.h
index b7faf89..08b7d9b 100644
--- a/dlls/wiaservc/wiaservc_private.h
+++ b/dlls/wiaservc/wiaservc_private.h
@@ -36,6 +36,14 @@ typedef struct
 
 HRESULT wiadevmgr_Constructor(LPVOID *ppObj) DECLSPEC_HIDDEN;
 
+typedef struct
+{
+    IEnumWIA_DEV_INFO IEnumWIA_DEV_INFO_iface;
+    LONG ref;
+} enumwiadevinfo;
+
+HRESULT enumwiadevinfo_Constructor(LPVOID *ppObj) DECLSPEC_HIDDEN;
+
 /* Little helper functions */
 static inline char *
 wiaservc_strdup(const char *s)
diff --git a/include/wia_lh.idl b/include/wia_lh.idl
index e13a658..7cadbc6 100644
--- a/include/wia_lh.idl
+++ b/include/wia_lh.idl
@@ -21,6 +21,7 @@ import "oaidl.idl";
 import "propidl.idl";
 
 interface IEnumWIA_DEV_INFO;
+interface IWiaPropertyStorage;
 interface IWiaItem;
 interface IWiaEventCallback;
 
@@ -98,7 +99,34 @@ interface IWiaDevMgr : IUnknown
 ]
 interface IEnumWIA_DEV_INFO : IUnknown
 {
-    /* fill in */
+  HRESULT Next(
+    [in] ULONG celt,
+    [out, size_is(celt), length_is(*pceltFetched)] IWiaPropertyStorage **rgelt,
+    [out] ULONG *pceltFetched
+  );
+
+  HRESULT Skip(
+    [in]  ULONG celt
+  );
+
+  HRESULT Reset();
+
+  HRESULT Clone(
+    [out] IEnumWIA_DEV_INFO **ppIEnum
+  );
+
+  HRESULT GetCount(
+    [out] ULONG *celt
+  );
+}
+
+[
+    object,
+    uuid(98B5E8A0-29CC-491a-AAC0-E6DB4FDCCEB6)
+]
+interface IWiaPropertyStorage : IUnknown
+{
+    /* FIXME: fill in */
 }
 
 [
diff --git a/include/wia_xp.idl b/include/wia_xp.idl
index e13a658..7cadbc6 100644
--- a/include/wia_xp.idl
+++ b/include/wia_xp.idl
@@ -21,6 +21,7 @@ import "oaidl.idl";
 import "propidl.idl";
 
 interface IEnumWIA_DEV_INFO;
+interface IWiaPropertyStorage;
 interface IWiaItem;
 interface IWiaEventCallback;
 
@@ -98,7 +99,34 @@ interface IWiaDevMgr : IUnknown
 ]
 interface IEnumWIA_DEV_INFO : IUnknown
 {
-    /* fill in */
+  HRESULT Next(
+    [in] ULONG celt,
+    [out, size_is(celt), length_is(*pceltFetched)] IWiaPropertyStorage **rgelt,
+    [out] ULONG *pceltFetched
+  );
+
+  HRESULT Skip(
+    [in]  ULONG celt
+  );
+
+  HRESULT Reset();
+
+  HRESULT Clone(
+    [out] IEnumWIA_DEV_INFO **ppIEnum
+  );
+
+  HRESULT GetCount(
+    [out] ULONG *celt
+  );
+}
+
+[
+    object,
+    uuid(98B5E8A0-29CC-491a-AAC0-E6DB4FDCCEB6)
+]
+interface IWiaPropertyStorage : IUnknown
+{
+    /* FIXME: fill in */
 }
 
 [
-- 
1.7.9.5



More information about the wine-patches mailing list