Commit b431995c authored by David Hedberg's avatar David Hedberg Committed by Alexandre Julliard

explorerframe: Implement RemoveRoot and RemoveAllRoots.

parent 658ec55a
......@@ -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,
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment