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); }