From: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=24812 --- dlls/shell32/Makefile.in | 1 + dlls/shell32/new_menu.c | 116 +++++++++++++++++++++++++++++++ dlls/shell32/shell32_classes.idl | 6 ++ dlls/shell32/shell32_main.h | 2 + dlls/shell32/shellole.c | 1 + dlls/shell32/tests/shlview.c | 16 ++--- 6 files changed, 132 insertions(+), 10 deletions(-) create mode 100644 dlls/shell32/new_menu.c
diff --git a/dlls/shell32/Makefile.in b/dlls/shell32/Makefile.in index 743df597ee4..4a906ac59db 100644 --- a/dlls/shell32/Makefile.in +++ b/dlls/shell32/Makefile.in @@ -23,6 +23,7 @@ SOURCES = \ enumidlist.c \ folders.c \ iconcache.c \ + new_menu.c \ pidl.c \ recyclebin.c \ resources/audio.svg \ diff --git a/dlls/shell32/new_menu.c b/dlls/shell32/new_menu.c new file mode 100644 index 00000000000..8fc29e7138b --- /dev/null +++ b/dlls/shell32/new_menu.c @@ -0,0 +1,116 @@ +/* + * Copyright 2015 Michael Müller + * + * 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 "shobjidl.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(shell); + +struct new_menu +{ + IShellExtInit IShellExtInit_iface; + LONG refcount; +}; + +static struct new_menu *impl_from_IShellExtInit(IShellExtInit *iface) +{ + return CONTAINING_RECORD(iface, struct new_menu, IShellExtInit_iface); +} + +static HRESULT WINAPI ext_init_QueryInterface(IShellExtInit *iface, REFIID iid, void **out) +{ + struct new_menu *menu = impl_from_IShellExtInit(iface); + + TRACE("menu %p, iid %s, out %p.\n", menu, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IShellExtInit)) + *out = &menu->IShellExtInit_iface; + else + { + *out = NULL; + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*out); + return S_OK; +} + +static ULONG WINAPI ext_init_AddRef(IShellExtInit *iface) +{ + struct new_menu *menu = impl_from_IShellExtInit(iface); + ULONG refcount = InterlockedIncrement(&menu->refcount); + + TRACE("%p increasing refcount to %lu.\n", menu, refcount); + + return refcount; +} + +static ULONG WINAPI ext_init_Release(IShellExtInit *iface) +{ + struct new_menu *menu = impl_from_IShellExtInit(iface); + ULONG refcount = InterlockedDecrement(&menu->refcount); + + TRACE("%p decreasing refcount to %lu.\n", menu, refcount); + + if (!refcount) + free(menu); + + return refcount; +} + +static HRESULT WINAPI ext_init_Initialize(IShellExtInit *iface, LPCITEMIDLIST pidl, IDataObject *obj, HKEY key) +{ + struct new_menu *menu = impl_from_IShellExtInit(iface); + + TRACE("menu %p, pidl %p, obj %p, key %p.\n", menu, pidl, obj, key); + + return S_OK; +} + +static const IShellExtInitVtbl ext_init_vtbl = +{ + ext_init_QueryInterface, + ext_init_AddRef, + ext_init_Release, + ext_init_Initialize, +}; + +HRESULT WINAPI new_menu_create(IUnknown *outer, REFIID iid, void **out) +{ + struct new_menu *menu; + HRESULT hr; + + if (outer) + return CLASS_E_NOAGGREGATION; + + if (!(menu = malloc(sizeof(*menu)))) + return E_OUTOFMEMORY; + + menu->IShellExtInit_iface.lpVtbl = &ext_init_vtbl; + menu->refcount = 1; + + TRACE("Created New menu %p.\n", menu); + + hr = IShellExtInit_QueryInterface(&menu->IShellExtInit_iface, iid, out); + IShellExtInit_Release(&menu->IShellExtInit_iface); + return hr; +} diff --git a/dlls/shell32/shell32_classes.idl b/dlls/shell32/shell32_classes.idl index dc65ed3728d..135ef52f7b0 100644 --- a/dlls/shell32/shell32_classes.idl +++ b/dlls/shell32/shell32_classes.idl @@ -183,3 +183,9 @@ coclass KnownFolderManager { interface IKnownFolderManager; } threading(apartment), uuid(75048700-ef1f-11d0-9888-006097deacf9) ] coclass ActiveDesktop { interface IActiveDesktop; } + +[ + threading(apartment), + uuid(d969a300-e7ff-11d0-a93b-00a0c90f2719) +] +coclass NewMenu {} diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h index 3f94385a60f..52c7d44f39f 100644 --- a/dlls/shell32/shell32_main.h +++ b/dlls/shell32/shell32_main.h @@ -114,6 +114,8 @@ HRESULT WINAPI ApplicationAssociationRegistration_Constructor(IUnknown *outer, R HRESULT WINAPI ApplicationDestinations_Constructor(IUnknown *outer, REFIID riid, LPVOID *ppv); HRESULT WINAPI ApplicationDocumentLists_Constructor(IUnknown *outer, REFIID riid, LPVOID *ppv);
+HRESULT WINAPI new_menu_create(IUnknown *outer, REFIID iid, void **out); + HRESULT IShellLink_ConstructFromFile(IUnknown * pUnkOuter, REFIID riid, LPCITEMIDLIST pidl, IUnknown **ppv);
LPEXTRACTICONA IExtractIconA_Constructor(LPCITEMIDLIST); diff --git a/dlls/shell32/shellole.c b/dlls/shell32/shellole.c index 52123ac0004..aa9bd3e0f3e 100644 --- a/dlls/shell32/shellole.c +++ b/dlls/shell32/shellole.c @@ -70,6 +70,7 @@ static const struct { {&CLSID_MyComputer, ISF_MyComputer_Constructor}, {&CLSID_MyDocuments, MyDocuments_Constructor}, {&CLSID_NetworkPlaces, ISF_NetworkPlaces_Constructor}, + {&CLSID_NewMenu, new_menu_create}, {&CLSID_Printers, Printers_Constructor}, {&CLSID_QueryAssociations, QueryAssociations_Constructor}, {&CLSID_RecycleBin, RecycleBin_Constructor}, diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c index 89ff2e71eb0..316eb228bae 100644 --- a/dlls/shell32/tests/shlview.c +++ b/dlls/shell32/tests/shlview.c @@ -1482,25 +1482,21 @@ static void test_newmenu(void) HRESULT hr;
hr = CoCreateInstance(&CLSID_NewMenu, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk); - todo_wine ok(hr == S_OK, "Failed to create NewMenu object, hr %#lx.\n", hr); - if (hr != S_OK) - { - skip("NewMenu is not supported.\n"); - return; - }
hr = IUnknown_QueryInterface(unk, &IID_IShellExtInit, (void **)&unk2); ok(hr == S_OK, "Failed to get IShellExtInit, hr %#lx.\n", hr); IUnknown_Release(unk2);
hr = IUnknown_QueryInterface(unk, &IID_IContextMenu3, (void **)&unk2); - ok(hr == S_OK, "Failed to get IContextMenu3, hr %#lx.\n", hr); - IUnknown_Release(unk2); + todo_wine ok(hr == S_OK, "Failed to get IContextMenu3, hr %#lx.\n", hr); + if (hr == S_OK) + IUnknown_Release(unk2);
hr = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void **)&unk2); - ok(hr == S_OK, "Failed to get IObjectWithSite, hr %#lx.\n", hr); - IUnknown_Release(unk2); + todo_wine ok(hr == S_OK, "Failed to get IObjectWithSite, hr %#lx.\n", hr); + if (hr == S_OK) + IUnknown_Release(unk2);
IUnknown_Release(unk); }
From: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=24812 --- dlls/shell32/new_menu.c | 85 ++++++++++++++++++++++++++++++++++++ dlls/shell32/tests/shlview.c | 5 +-- 2 files changed, 87 insertions(+), 3 deletions(-)
diff --git a/dlls/shell32/new_menu.c b/dlls/shell32/new_menu.c index 8fc29e7138b..83e07b70988 100644 --- a/dlls/shell32/new_menu.c +++ b/dlls/shell32/new_menu.c @@ -27,6 +27,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); struct new_menu { IShellExtInit IShellExtInit_iface; + IContextMenu3 IContextMenu3_iface; LONG refcount; };
@@ -43,6 +44,10 @@ static HRESULT WINAPI ext_init_QueryInterface(IShellExtInit *iface, REFIID iid,
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IShellExtInit)) *out = &menu->IShellExtInit_iface; + else if (IsEqualGUID(iid, &IID_IContextMenu) + || IsEqualGUID(iid, &IID_IContextMenu2) + || IsEqualGUID(iid, &IID_IContextMenu3)) + *out = &menu->IContextMenu3_iface; else { *out = NULL; @@ -94,6 +99,85 @@ static const IShellExtInitVtbl ext_init_vtbl = ext_init_Initialize, };
+static struct new_menu *impl_from_IContextMenu3(IContextMenu3 *iface) +{ + return CONTAINING_RECORD(iface, struct new_menu, IContextMenu3_iface); +} + +static HRESULT WINAPI context_menu_QueryInterface(IContextMenu3 *iface, REFIID iid, void **out) +{ + struct new_menu *menu = impl_from_IContextMenu3(iface); + + return IShellExtInit_QueryInterface(&menu->IShellExtInit_iface, iid, out); +} + +static ULONG WINAPI context_menu_AddRef(IContextMenu3 *iface) +{ + struct new_menu *menu = impl_from_IContextMenu3(iface); + + return IShellExtInit_AddRef(&menu->IShellExtInit_iface); +} + +static ULONG WINAPI context_menu_Release(IContextMenu3 *iface) +{ + struct new_menu *menu = impl_from_IContextMenu3(iface); + + return IShellExtInit_Release(&menu->IShellExtInit_iface); +} + +static HRESULT WINAPI context_menu_QueryContextMenu(IContextMenu3 *iface, + HMENU hmenu, UINT index, UINT min_id, UINT max_id, UINT flags) +{ + FIXME("iface %p, hmenu %p, index %u, min_id %u, max_id %u, flags %#x, stub!\n", + iface, hmenu, index, min_id, max_id, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI context_menu_InvokeCommand(IContextMenu3 *iface, CMINVOKECOMMANDINFO *info) +{ + FIXME("iface %p, info %p, stub!\n", iface, info); + + return E_NOTIMPL; +} + +static HRESULT WINAPI context_menu_GetCommandString(IContextMenu3 *iface, + UINT_PTR id, UINT type, UINT *reserved, char *string, UINT size) +{ + FIXME("iface %p, id %Iu, type %#x, reserved %p, string %p, size %u, stub!\n", + iface, id, type, reserved, string, size); + + return E_NOTIMPL; +} + +static HRESULT WINAPI context_menu_HandleMenuMsg(IContextMenu3 *iface, UINT msg, WPARAM wparam, LPARAM lparam) +{ + FIXME("iface %p, msg %#x, wparam %#Ix, lparam %#Ix, stub!\n", iface, msg, wparam, lparam); + + return E_NOTIMPL; +} + +static HRESULT WINAPI context_menu_HandleMenuMsg2(IContextMenu3 *iface, + UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *result) +{ + FIXME("iface %p, msg %#x, wparam %#Ix, lparam %#Ix, result %p, stub!\n", + iface, msg, wparam, lparam, result); + + return E_NOTIMPL; +} + +static const IContextMenu3Vtbl context_menu_vtbl = +{ + context_menu_QueryInterface, + context_menu_AddRef, + context_menu_Release, + context_menu_QueryContextMenu, + context_menu_InvokeCommand, + context_menu_GetCommandString, + context_menu_HandleMenuMsg, + context_menu_HandleMenuMsg2, +}; + HRESULT WINAPI new_menu_create(IUnknown *outer, REFIID iid, void **out) { struct new_menu *menu; @@ -106,6 +190,7 @@ HRESULT WINAPI new_menu_create(IUnknown *outer, REFIID iid, void **out) return E_OUTOFMEMORY;
menu->IShellExtInit_iface.lpVtbl = &ext_init_vtbl; + menu->IContextMenu3_iface.lpVtbl = &context_menu_vtbl; menu->refcount = 1;
TRACE("Created New menu %p.\n", menu); diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c index 316eb228bae..d2eeafd3323 100644 --- a/dlls/shell32/tests/shlview.c +++ b/dlls/shell32/tests/shlview.c @@ -1489,9 +1489,8 @@ static void test_newmenu(void) IUnknown_Release(unk2);
hr = IUnknown_QueryInterface(unk, &IID_IContextMenu3, (void **)&unk2); - todo_wine ok(hr == S_OK, "Failed to get IContextMenu3, hr %#lx.\n", hr); - if (hr == S_OK) - IUnknown_Release(unk2); + ok(hr == S_OK, "Failed to get IContextMenu3, hr %#lx.\n", hr); + IUnknown_Release(unk2);
hr = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void **)&unk2); todo_wine ok(hr == S_OK, "Failed to get IObjectWithSite, hr %#lx.\n", hr);
From: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=24812 --- dlls/shell32/new_menu.c | 53 ++++++++++++++++++++++++++++++++++++ dlls/shell32/tests/shlview.c | 5 ++-- 2 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/dlls/shell32/new_menu.c b/dlls/shell32/new_menu.c index 83e07b70988..87ea93f9964 100644 --- a/dlls/shell32/new_menu.c +++ b/dlls/shell32/new_menu.c @@ -28,6 +28,7 @@ struct new_menu { IShellExtInit IShellExtInit_iface; IContextMenu3 IContextMenu3_iface; + IObjectWithSite IObjectWithSite_iface; LONG refcount; };
@@ -48,6 +49,8 @@ static HRESULT WINAPI ext_init_QueryInterface(IShellExtInit *iface, REFIID iid, || IsEqualGUID(iid, &IID_IContextMenu2) || IsEqualGUID(iid, &IID_IContextMenu3)) *out = &menu->IContextMenu3_iface; + else if (IsEqualGUID(iid, &IID_IObjectWithSite)) + *out = &menu->IObjectWithSite_iface; else { *out = NULL; @@ -178,6 +181,55 @@ static const IContextMenu3Vtbl context_menu_vtbl = context_menu_HandleMenuMsg2, };
+static struct new_menu *impl_from_IObjectWithSite(IObjectWithSite *iface) +{ + return CONTAINING_RECORD(iface, struct new_menu, IObjectWithSite_iface); +} + +static HRESULT WINAPI object_with_site_QueryInterface(IObjectWithSite *iface, REFIID iid, void **out) +{ + struct new_menu *menu = impl_from_IObjectWithSite(iface); + + return IShellExtInit_QueryInterface(&menu->IShellExtInit_iface, iid, out); +} + +static ULONG WINAPI object_with_site_AddRef(IObjectWithSite *iface) +{ + struct new_menu *menu = impl_from_IObjectWithSite(iface); + + return IShellExtInit_AddRef(&menu->IShellExtInit_iface); +} + +static ULONG WINAPI object_with_site_Release(IObjectWithSite *iface) +{ + struct new_menu *menu = impl_from_IObjectWithSite(iface); + + return IShellExtInit_Release(&menu->IShellExtInit_iface); +} + +static HRESULT WINAPI object_with_site_SetSite(IObjectWithSite *iface, IUnknown *site) +{ + FIXME("iface %p, site %p, stub!\n", iface, site); + + return E_NOTIMPL; +} + +static HRESULT WINAPI object_with_site_GetSite(IObjectWithSite *iface, REFIID iid, void **out) +{ + FIXME("iface %p, iid %s, out %p, stub!\n", iface, debugstr_guid(iid), out); + + return E_NOTIMPL; +} + +static const IObjectWithSiteVtbl object_with_site_vtbl = +{ + object_with_site_QueryInterface, + object_with_site_AddRef, + object_with_site_Release, + object_with_site_SetSite, + object_with_site_GetSite, +}; + HRESULT WINAPI new_menu_create(IUnknown *outer, REFIID iid, void **out) { struct new_menu *menu; @@ -191,6 +243,7 @@ HRESULT WINAPI new_menu_create(IUnknown *outer, REFIID iid, void **out)
menu->IShellExtInit_iface.lpVtbl = &ext_init_vtbl; menu->IContextMenu3_iface.lpVtbl = &context_menu_vtbl; + menu->IObjectWithSite_iface.lpVtbl = &object_with_site_vtbl; menu->refcount = 1;
TRACE("Created New menu %p.\n", menu); diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c index d2eeafd3323..0de7f2768c1 100644 --- a/dlls/shell32/tests/shlview.c +++ b/dlls/shell32/tests/shlview.c @@ -1493,9 +1493,8 @@ static void test_newmenu(void) IUnknown_Release(unk2);
hr = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void **)&unk2); - todo_wine ok(hr == S_OK, "Failed to get IObjectWithSite, hr %#lx.\n", hr); - if (hr == S_OK) - IUnknown_Release(unk2); + ok(hr == S_OK, "Failed to get IObjectWithSite, hr %#lx.\n", hr); + IUnknown_Release(unk2);
IUnknown_Release(unk); }