[PATCH v2 2/5] shell32: Stub out FolderItems.

Alex Henrie alexhenrie24 at gmail.com
Tue Jul 5 00:47:27 CDT 2016


Cc: Christian Costa <titan.costa at gmail.com>
Cc: Sebastian Lackner <sebastian at fds-team.de>

Wine Staging has included a similar patch since 1.7.51, however this
patch is not based on theirs.

FolderItems2 worked in Windows 2000, but it was removed when
FolderItems3 was introduced in Windows XP. However, it doesn't hurt us
to provide this interface anyway for any old applications that might
want it.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/shell32/shell32_main.h  |   1 +
 dlls/shell32/shelldispatch.c | 207 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 206 insertions(+), 2 deletions(-)

diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h
index 492f79f..64a26bb 100644
--- a/dlls/shell32/shell32_main.h
+++ b/dlls/shell32/shell32_main.h
@@ -234,6 +234,7 @@ enum tid_t {
     IShellDispatch6_tid,
     IShellFolderViewDual3_tid,
     Folder3_tid,
+    FolderItems3_tid,
     FolderItem2_tid,
     FolderItemVerb_tid,
     FolderItemVerbs_tid,
diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c
index 6dece6d..3661430 100644
--- a/dlls/shell32/shelldispatch.c
+++ b/dlls/shell32/shelldispatch.c
@@ -65,6 +65,11 @@ typedef struct {
 } FolderImpl;
 
 typedef struct {
+    FolderItems3 FolderItems3_iface;
+    LONG ref;
+} FolderItemsImpl;
+
+typedef struct {
     FolderItem2 FolderItem2_iface;
     LONG ref;
     VARIANT dir;
@@ -97,6 +102,11 @@ static inline FolderImpl *impl_from_Folder(Folder3 *iface)
     return CONTAINING_RECORD(iface, FolderImpl, Folder3_iface);
 }
 
+static inline FolderItemsImpl *impl_from_FolderItems(FolderItems3 *iface)
+{
+    return CONTAINING_RECORD(iface, FolderItemsImpl, FolderItems3_iface);
+}
+
 static inline FolderItemImpl *impl_from_FolderItem(FolderItem2 *iface)
 {
     return CONTAINING_RECORD(iface, FolderItemImpl, FolderItem2_iface);
@@ -939,6 +949,200 @@ static HRESULT FolderItem_Constructor(VARIANT *dir, FolderItem **ppfi)
     return ret;
 }
 
+static HRESULT WINAPI FolderItemsImpl_QueryInterface(FolderItems3 *iface,
+        REFIID riid, LPVOID *ppv)
+{
+    FolderItemsImpl *This = impl_from_FolderItems(iface);
+
+    TRACE("(%p,%p,%p)\n", iface, riid, ppv);
+
+    if (!ppv) return E_INVALIDARG;
+
+    if (IsEqualIID(&IID_IUnknown, riid) ||
+        IsEqualIID(&IID_IDispatch, riid) ||
+        IsEqualIID(&IID_FolderItems, riid) ||
+        IsEqualIID(&IID_FolderItems2, riid) ||
+        IsEqualIID(&IID_FolderItems3, riid))
+        *ppv = &This->FolderItems3_iface;
+    else
+    {
+        FIXME("not implemented for %s\n", shdebugstr_guid(riid));
+        *ppv = NULL;
+        return E_NOINTERFACE;
+    }
+    IUnknown_AddRef((IUnknown*)*ppv);
+    return S_OK;
+}
+
+static ULONG WINAPI FolderItemsImpl_AddRef(FolderItems3 *iface)
+{
+    FolderItemsImpl *This = impl_from_FolderItems(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p), new refcount=%i\n", iface, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI FolderItemsImpl_Release(FolderItems3 *iface)
+{
+    FolderItemsImpl *This = impl_from_FolderItems(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p), new refcount=%i\n", iface, ref);
+
+    if (!ref)
+        HeapFree(GetProcessHeap(), 0, This);
+    return ref;
+}
+
+static HRESULT WINAPI FolderItemsImpl_GetTypeInfoCount(FolderItems3 *iface,
+        UINT *pctinfo)
+{
+    TRACE("(%p,%p)\n", iface, pctinfo);
+
+    *pctinfo = 1;
+    return S_OK;
+}
+
+static HRESULT WINAPI FolderItemsImpl_GetTypeInfo(FolderItems3 *iface, UINT iTInfo,
+        LCID lcid, ITypeInfo **ppTInfo)
+{
+    HRESULT hr;
+
+    TRACE("(%p,%u,%d,%p)\n", iface, iTInfo, lcid, ppTInfo);
+
+    hr = get_typeinfo(FolderItems3_tid, ppTInfo);
+    if (SUCCEEDED(hr))
+        ITypeInfo_AddRef(*ppTInfo);
+    return hr;
+}
+
+static HRESULT WINAPI FolderItemsImpl_GetIDsOfNames(FolderItems3 *iface,
+        REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
+        DISPID *rgDispId)
+{
+    ITypeInfo *ti;
+    HRESULT hr;
+
+    TRACE("(%p,%p,%p,%u,%d,%p)\n", iface, riid, rgszNames, cNames, lcid,
+            rgDispId);
+
+    hr = get_typeinfo(FolderItems3_tid, &ti);
+    if (SUCCEEDED(hr))
+        hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
+    return hr;
+}
+
+static HRESULT WINAPI FolderItemsImpl_Invoke(FolderItems3 *iface,
+        DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
+        DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
+        UINT *puArgErr)
+{
+    FolderItemsImpl *This = impl_from_FolderItems(iface);
+    ITypeInfo *ti;
+    HRESULT hr;
+
+    TRACE("(%p,%d,%p,%d,%u,%p,%p,%p,%p)\n", iface, dispIdMember, riid, lcid,
+            wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+
+    hr = get_typeinfo(FolderItems3_tid, &ti);
+    if (SUCCEEDED(hr))
+        hr = ITypeInfo_Invoke(ti, This, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+    return hr;
+}
+
+static HRESULT WINAPI FolderItemsImpl_get_Count(FolderItems3 *iface, LONG *count)
+{
+    FIXME("(%p,%p)\n", iface, count);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI FolderItemsImpl_get_Application(FolderItems3 *iface, IDispatch **ppid)
+{
+    FIXME("(%p,%p)\n", iface, ppid);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI FolderItemsImpl_get_Parent(FolderItems3 *iface, IDispatch **ppid)
+{
+    FIXME("(%p,%p)\n", iface, ppid);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI FolderItemsImpl_Item(FolderItems3 *iface, VARIANT index, FolderItem **ppid)
+{
+    FIXME("(%p,%s,%p)\n", iface, debugstr_variant(&index), ppid);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI FolderItemsImpl__NewEnum(FolderItems3 *iface, IUnknown **ppunk)
+{
+    FIXME("(%p,%p)\n", iface, ppunk);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI FolderItemsImpl_InvokeVerbEx(FolderItems3 *iface, VARIANT verb, VARIANT args)
+{
+    FIXME("(%p,%s,%s)\n", iface, debugstr_variant(&verb), debugstr_variant(&args));
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI FolderItemsImpl_Filter(FolderItems3 *iface, LONG flags, BSTR spec)
+{
+    FIXME("(%p,%d,%s)\n", iface, flags, wine_dbgstr_w(spec));
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI FolderItemsImpl_get_Verbs(FolderItems3 *iface, FolderItemVerbs **ppfic)
+{
+    FIXME("(%p,%p)\n", iface, ppfic);
+
+    return E_NOTIMPL;
+}
+
+static const FolderItems3Vtbl FolderItemsImpl_Vtbl = {
+    FolderItemsImpl_QueryInterface,
+    FolderItemsImpl_AddRef,
+    FolderItemsImpl_Release,
+    FolderItemsImpl_GetTypeInfoCount,
+    FolderItemsImpl_GetTypeInfo,
+    FolderItemsImpl_GetIDsOfNames,
+    FolderItemsImpl_Invoke,
+    FolderItemsImpl_get_Count,
+    FolderItemsImpl_get_Application,
+    FolderItemsImpl_get_Parent,
+    FolderItemsImpl_Item,
+    FolderItemsImpl__NewEnum,
+    FolderItemsImpl_InvokeVerbEx,
+    FolderItemsImpl_Filter,
+    FolderItemsImpl_get_Verbs
+};
+
+static HRESULT FolderItems_Constructor(FolderItems **ppfi)
+{
+    FolderItemsImpl *This;
+
+    TRACE("\n");
+
+    *ppfi = NULL;
+
+    This = HeapAlloc(GetProcessHeap(), 0, sizeof(FolderItemsImpl));
+    if (!This) return E_OUTOFMEMORY;
+    This->FolderItems3_iface.lpVtbl = &FolderItemsImpl_Vtbl;
+    This->ref = 1;
+
+    *ppfi = (FolderItems*)&This->FolderItems3_iface;
+    return S_OK;
+}
+
 static HRESULT WINAPI FolderImpl_QueryInterface(Folder3 *iface, REFIID riid,
         LPVOID *ppv)
 {
@@ -1093,8 +1297,7 @@ static HRESULT WINAPI FolderImpl_Items(Folder3 *iface, FolderItems **ppid)
 {
     FIXME("(%p,%p)\n", iface, ppid);
 
-    *ppid = NULL;
-    return E_NOTIMPL;
+    return FolderItems_Constructor(ppid);
 }
 
 static HRESULT WINAPI FolderImpl_ParseName(Folder3 *iface, BSTR name, FolderItem **item)
-- 
2.9.0




More information about the wine-patches mailing list