David Hedberg : explorerframe: Implement RemoveRoot and RemoveAllRoots.
Alexandre Julliard
julliard at winehq.org
Wed Aug 4 12:27:24 CDT 2010
Module: wine
Branch: master
Commit: b431995cc45eb5f4e9002ef074ba2dfa97852851
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b431995cc45eb5f4e9002ef074ba2dfa97852851
Author: David Hedberg <david.hedberg at gmail.com>
Date: Wed Aug 4 03:57:49 2010 +0200
explorerframe: Implement RemoveRoot and RemoveAllRoots.
---
dlls/explorerframe/nstc.c | 75 ++++++++++++++++++++++++++++++++++++--
dlls/explorerframe/tests/nstc.c | 29 +++++++++++++++
2 files changed, 100 insertions(+), 4 deletions(-)
diff --git a/dlls/explorerframe/nstc.c b/dlls/explorerframe/nstc.c
index 9116f66..e5d3913 100644
--- a/dlls/explorerframe/nstc.c
+++ b/dlls/explorerframe/nstc.c
@@ -99,6 +99,19 @@ static HRESULT events_OnItemAdded(NSTC2Impl *This, IShellItem *psi, BOOL fIsRoot
return ret;
}
+static HRESULT events_OnItemDeleted(NSTC2Impl *This, IShellItem *psi, BOOL fIsRoot)
+{
+ HRESULT ret;
+ LONG refcount;
+ if(!This->pnstce) return S_OK;
+
+ refcount = IShellItem_AddRef(psi);
+ ret = INameSpaceTreeControlEvents_OnItemDeleted(This->pnstce, psi, fIsRoot);
+ if(IShellItem_Release(psi) < refcount - 1)
+ ERR("ShellItem was released by client - please file a bug.\n");
+ return ret;
+}
+
/*************************************************************************
* NamespaceTree helper functions
*/
@@ -270,11 +283,22 @@ static LRESULT destroy_namespacetree(NSTC2Impl *This)
{
TRACE("%p\n", This);
+ INameSpaceTreeControl_RemoveAllRoots((INameSpaceTreeControl*)This);
+
/* This reference was added in create_namespacetree */
INameSpaceTreeControl_Release((INameSpaceTreeControl*)This);
return TRUE;
}
+static LRESULT on_tvn_deleteitemw(NSTC2Impl *This, LPARAM lParam)
+{
+ NMTREEVIEWW *nmtv = (NMTREEVIEWW*)lParam;
+ TRACE("%p\n", This);
+
+ IShellItem_Release((IShellItem*)nmtv->itemOld.lParam);
+ return TRUE;
+}
+
static LRESULT on_tvn_getdispinfow(NSTC2Impl *This, LPARAM lParam)
{
NMTVDISPINFOW *dispinfo = (NMTVDISPINFOW*)lParam;
@@ -349,6 +373,7 @@ static LRESULT CALLBACK NSTC2_WndProc(HWND hWnd, UINT uMessage,
nmhdr = (NMHDR*)lParam;
switch(nmhdr->code)
{
+ case TVN_DELETEITEMW: return on_tvn_deleteitemw(This, lParam);
case TVN_GETDISPINFOW: return on_tvn_getdispinfow(This, lParam);
default: break;
}
@@ -601,15 +626,57 @@ static HRESULT WINAPI NSTC2_fnRemoveRoot(INameSpaceTreeControl2* iface,
IShellItem *psiRoot)
{
NSTC2Impl *This = (NSTC2Impl*)iface;
- FIXME("stub, %p (%p)\n", This, psiRoot);
- return E_NOTIMPL;
+ nstc_root *cursor, *root = NULL;
+ TRACE("%p (%p)\n", This, psiRoot);
+
+ if(!psiRoot)
+ return E_NOINTERFACE;
+
+ LIST_FOR_EACH_ENTRY(cursor, &This->roots, nstc_root, entry)
+ {
+ HRESULT hr;
+ int order;
+ hr = IShellItem_Compare(psiRoot, cursor->psi, SICHINT_DISPLAY, &order);
+ if(hr == S_OK)
+ {
+ root = cursor;
+ break;
+ }
+ }
+
+ TRACE("root %p\n", root);
+ if(root)
+ {
+ SendMessageW(This->hwnd_tv, TVM_DELETEITEM, 0, (LPARAM)root->htreeitem);
+ events_OnItemDeleted(This, root->psi, TRUE);
+ list_remove(&root->entry);
+ HeapFree(GetProcessHeap(), 0, root);
+ return S_OK;
+ }
+ else
+ {
+ WARN("No matching root found.\n");
+ return E_FAIL;
+ }
}
static HRESULT WINAPI NSTC2_fnRemoveAllRoots(INameSpaceTreeControl2* iface)
{
NSTC2Impl *This = (NSTC2Impl*)iface;
- FIXME("stub, %p\n", This);
- return E_NOTIMPL;
+ nstc_root *cur1, *cur2;
+ UINT removed = 0;
+ TRACE("%p\n", This);
+
+ LIST_FOR_EACH_ENTRY_SAFE(cur1, cur2, &This->roots, nstc_root, entry)
+ {
+ NSTC2_fnRemoveRoot(iface, cur1->psi);
+ removed++;
+ }
+
+ if(removed)
+ return S_OK;
+ else
+ return E_INVALIDARG;
}
static HRESULT WINAPI NSTC2_fnGetRootItems(INameSpaceTreeControl2* iface,
diff --git a/dlls/explorerframe/tests/nstc.c b/dlls/explorerframe/tests/nstc.c
index 2f8caa0..f51698c 100644
--- a/dlls/explorerframe/tests/nstc.c
+++ b/dlls/explorerframe/tests/nstc.c
@@ -541,6 +541,12 @@ static void test_basics(void)
ok(hr == S_OK, "Failed to initialize control (0x%08x)\n", hr);
/* Some tests on an uninitialized control */
+ hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
+ ok(hr == E_INVALIDARG, "Got (0x%08x)\n", hr);
+ hr = INameSpaceTreeControl_RemoveRoot(pnstc, psidesktop);
+ ok(hr == E_FAIL, "Got (0x%08x)\n", hr);
+ hr = INameSpaceTreeControl_RemoveRoot(pnstc, NULL);
+ ok(hr == E_NOINTERFACE, "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_AppendRoot(pnstc, psidesktop, SHCONTF_NONFOLDERS, 0, NULL);
ok(hr == E_FAIL, "Got (0x%08x)\n", hr);
process_msgs();
@@ -763,6 +769,9 @@ static void test_basics(void)
skip("INameSpaceTreeControl2 missing.\n");
}
+ hr = INameSpaceTreeControl_RemoveRoot(pnstc, NULL);
+ ok(hr == E_NOINTERFACE, "Got (0x%08x)\n", hr);
+
/* Append / Insert root */
if(0)
{
@@ -780,6 +789,23 @@ static void test_basics(void)
ok(hr == S_OK, "Got (0x%08x)\n", hr);
process_msgs();
+ hr = INameSpaceTreeControl_RemoveRoot(pnstc, psidesktop);
+ ok(hr == S_OK, "Got (0x%08x)\n", hr);
+ hr = INameSpaceTreeControl_RemoveRoot(pnstc, psidesktop);
+ ok(hr == S_OK, "Got (0x%08x)\n", hr);
+ hr = INameSpaceTreeControl_RemoveRoot(pnstc, psidesktop);
+ ok(hr == S_OK, "Got (0x%08x)\n", hr);
+
+ hr = INameSpaceTreeControl_RemoveRoot(pnstc, psidesktop);
+ ok(hr == E_FAIL, "Got (0x%08x)\n", hr);
+ hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
+ ok(hr == E_INVALIDARG, "Got (0x%08x)\n", hr);
+
+ hr = INameSpaceTreeControl_AppendRoot(pnstc, psidesktop, SHCONTF_FOLDERS, 0, NULL);
+ ok(hr == S_OK, "Got (0x%08x)\n", hr);
+ hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
+ ok(hr == S_OK, "Got (0x%08x)\n", hr);
+
hr = INameSpaceTreeControl_InsertRoot(pnstc, 0, psidesktop, SHCONTF_FOLDERS, 0, NULL);
ok(hr == S_OK, "Got (0x%08x)\n", hr);
hr = INameSpaceTreeControl_InsertRoot(pnstc, -1, psidesktop, SHCONTF_FOLDERS, 0, NULL);
@@ -791,6 +817,9 @@ static void test_basics(void)
hr = INameSpaceTreeControl_InsertRoot(pnstc, 1, psidesktop, SHCONTF_FOLDERS, 0, NULL);
ok(hr == S_OK, "Got (0x%08x)\n", hr);
+ hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
+ ok(hr == S_OK, "Got (0x%08x)\n", hr);
+
IShellItem_Release(psidesktop);
IShellItem_Release(psidesktop2);
More information about the wine-cvs
mailing list