Module: wine Branch: master Commit: 58b73fa075f5c842e56adc3b8cd5ec6d50cebd4b URL: http://source.winehq.org/git/wine.git/?a=commit;h=58b73fa075f5c842e56adc3b8c...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Mon Sep 18 10:39:41 2017 +0300
shell32: Implement Parent() property for ShellDispatch objects.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/shell32/shelldispatch.c | 47 ++++++++++++++++++++++++++------------ dlls/shell32/tests/shelldispatch.c | 36 ++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 16 deletions(-)
diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c index ee6f340..c489eb6 100644 --- a/dlls/shell32/shelldispatch.c +++ b/dlls/shell32/shelldispatch.c @@ -298,7 +298,10 @@ static HRESULT WINAPI FolderItemVerbImpl_get_Application(FolderItemVerb *iface,
static HRESULT WINAPI FolderItemVerbImpl_get_Parent(FolderItemVerb *iface, IDispatch **disp) { - FIXME("(%p, %p)\n", iface, disp); + TRACE("(%p, %p)\n", iface, disp); + + if (disp) + *disp = NULL; return E_NOTIMPL; }
@@ -477,7 +480,10 @@ static HRESULT WINAPI FolderItemVerbsImpl_get_Application(FolderItemVerbs *iface
static HRESULT WINAPI FolderItemVerbsImpl_get_Parent(FolderItemVerbs *iface, IDispatch **disp) { - FIXME("(%p, %p)\n", iface, disp); + TRACE("(%p, %p)\n", iface, disp); + + if (disp) + *disp = NULL; return E_NOTIMPL; }
@@ -718,13 +724,19 @@ static HRESULT WINAPI FolderItemImpl_get_Application(FolderItem2 *iface, IDispat return Folder3_get_Application(&This->folder->Folder3_iface, disp); }
-static HRESULT WINAPI FolderItemImpl_get_Parent(FolderItem2 *iface, - IDispatch **ppid) +static HRESULT WINAPI FolderItemImpl_get_Parent(FolderItem2 *iface, IDispatch **disp) { - FIXME("(%p,%p)\n", iface, ppid); + FolderItemImpl *This = impl_from_FolderItem(iface);
- *ppid = NULL; - return E_NOTIMPL; + TRACE("(%p,%p)\n", iface, disp); + + if (disp) + { + *disp = (IDispatch *)&This->folder->Folder3_iface; + IDispatch_AddRef(*disp); + } + + return S_OK; }
static HRESULT WINAPI FolderItemImpl_get_Name(FolderItem2 *iface, BSTR *pbs) @@ -1429,11 +1441,12 @@ static HRESULT WINAPI FolderImpl_get_Application(Folder3 *iface, IDispatch **dis return S_OK; }
-static HRESULT WINAPI FolderImpl_get_Parent(Folder3 *iface, IDispatch **ppid) +static HRESULT WINAPI FolderImpl_get_Parent(Folder3 *iface, IDispatch **disp) { - FIXME("(%p,%p)\n", iface, ppid); + TRACE("(%p,%p)\n", iface, disp);
- *ppid = NULL; + if (disp) + *disp = NULL; return E_NOTIMPL; }
@@ -1760,13 +1773,17 @@ static HRESULT WINAPI ShellDispatch_get_Application(IShellDispatch6 *iface, return E_NOTIMPL; }
-static HRESULT WINAPI ShellDispatch_get_Parent(IShellDispatch6 *iface, - IDispatch **ppid) +static HRESULT WINAPI ShellDispatch_get_Parent(IShellDispatch6 *iface, IDispatch **disp) { - FIXME("(%p,%p)\n", iface, ppid); + TRACE("(%p,%p)\n", iface, disp);
- *ppid = NULL; - return E_NOTIMPL; + if (disp) + { + *disp = (IDispatch *)iface; + IDispatch_AddRef(*disp); + } + + return S_OK; }
static HRESULT WINAPI ShellDispatch_NameSpace(IShellDispatch6 *iface, diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c index eb8a8c7..fa7e8dc 100644 --- a/dlls/shell32/tests/shelldispatch.c +++ b/dlls/shell32/tests/shelldispatch.c @@ -124,11 +124,18 @@ static void test_namespace(void) FolderItem *item; VARIANT var; BSTR title, item_path; + IDispatch *disp; int len, i;
r = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, &IID_IShellDispatch, (void **)&sd); ok(SUCCEEDED(r), "Failed to create ShellDispatch object: %#x.\n", r);
+ disp = NULL; + r = IShellDispatch_get_Parent(sd, &disp); + ok(r == S_OK, "Failed to get Shell object parent, hr %#x.\n", r); + ok(disp == (IDispatch *)sd, "Unexpected parent pointer %p.\n", disp); + IDispatch_Release(disp); + VariantInit(&var); folder = (void*)0xdeadbeef; r = IShellDispatch_NameSpace(sd, var, &folder); @@ -266,6 +273,11 @@ todo_wine { r = IShellDispatch_NameSpace(sd, var, &folder); ok(r == S_OK, "IShellDispatch::NameSpace failed: %08x\n", r);
+ disp = (void *)0xdeadbeef; + r = Folder_get_Parent(folder, &disp); + ok(r == E_NOTIMPL, "Unexpected hr %#x.\n", r); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp); + r = Folder_get_Title(folder, &title); ok(r == S_OK, "Failed to get folder title: %#x.\n", r); ok(!lstrcmpW(title, winetestW), "Unexpected title: %s\n", wine_dbgstr_w(title)); @@ -480,6 +492,17 @@ static void test_items(void) r = FolderItems_Item(items, var, &item); ok(r == S_OK, "FolderItems::Item failed: %08x\n", r); ok(!!item, "item is null\n"); + + disp = (void *)0xdeadbeef; + r = FolderItems_get_Parent(items, &disp); + ok(r == E_NOTIMPL, "Unexpected hr %#x.\n", r); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp); + + r = FolderItem_get_Parent(item, &disp); + ok(r == S_OK, "Failed to get parent pointer, hr %#x.\n", r); + ok(disp == (IDispatch *)folder, "Unexpected parent pointer %p.\n", disp); + IDispatch_Release(disp); + if (item) FolderItem_Release(item); VariantClear(&var);
@@ -1209,6 +1232,7 @@ static void test_Verbs(void) IShellDispatch *sd; FolderItem *item; Folder2 *folder2; + IDispatch *disp; Folder *folder; HRESULT hr; LONG count, i; @@ -1241,6 +1265,11 @@ if (0) { /* crashes on some systems */ hr = FolderItem_Verbs(item, &verbs); ok(hr == S_OK, "got 0x%08x\n", hr);
+ disp = (void *)0xdeadbeef; + hr = FolderItemVerbs_get_Parent(verbs, &disp); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp); + if (0) { /* crashes on winxp/win2k3 */ hr = FolderItemVerbs_get_Count(verbs, NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); @@ -1267,7 +1296,12 @@ if (0) { /* crashes on winxp/win2k3 */ ok(hr == S_OK, "got 0x%08x\n", hr); ok(str != NULL, "%d: name %s\n", i, wine_dbgstr_w(str)); if (i == count) - ok(str[0] == 0, "%d: got teminating item %s\n", i, wine_dbgstr_w(str)); + ok(str[0] == 0, "%d: got terminating item %s\n", i, wine_dbgstr_w(str)); + + disp = (void *)0xdeadbeef; + hr = FolderItemVerb_get_Parent(verb, &disp); + ok(hr == E_NOTIMPL, "got %#x.\n", hr); + ok(disp == NULL, "Unexpected parent pointer %p.\n", disp);
SysFreeString(str); FolderItemVerb_Release(verb);