Commit 68e57283 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

shell32: Add partial ControlPanel GetAttributesOf implementation.

parent e5c47b6a
......@@ -536,6 +536,34 @@ static HRESULT WINAPI ISF_ControlPanel_fnCreateViewObject(IShellFolder2 *iface,
return hr;
}
static BOOL validate_name_space(const ITEMIDLIST *pidl)
{
HKEY hkey, hitem;
WCHAR *guidW;
GUID *guid;
LSTATUS r;
if (!_ILIsPidlSimple(pidl))
return FALSE;
guid = _ILGetGUIDPointer(pidl);
if (!guid)
return FALSE;
if (StringFromCLSID(guid, &guidW) != S_OK)
return FALSE;
r = RegOpenKeyW(HKEY_LOCAL_MACHINE, name_spaceW, &hkey);
if (r == ERROR_SUCCESS)
{
r = RegOpenKeyW(hkey, guidW, &hitem);
if (r == ERROR_SUCCESS)
RegCloseKey(hitem);
RegCloseKey(hkey);
}
CoTaskMemFree(guidW);
return r == ERROR_SUCCESS;
}
/**************************************************************************
* ISF_ControlPanel_fnGetAttributesOf
*/
......@@ -559,12 +587,17 @@ static HRESULT WINAPI ISF_ControlPanel_fnGetAttributesOf(IShellFolder2 *iface, U
while(cidl > 0 && *apidl) {
pdump(*apidl);
SHELL32_GetItemAttributes(&This->IShellFolder2_iface, *apidl, rgfInOut);
/* TODO: panel with GUID can contain sub-items but we don't support it yet */
if (!(*rgfInOut & SFGAO_VALIDATE) || _ILGetCPanelPointer(*apidl)
|| validate_name_space(*apidl))
*rgfInOut &= SFGAO_CANLINK;
else
*rgfInOut &= SFGAO_VALIDATE;
apidl++;
cidl--;
}
/* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
*rgfInOut &= ~SFGAO_VALIDATE;
TRACE("-- result=0x%08lx\n", *rgfInOut);
return hr;
......
......@@ -956,6 +956,8 @@ static void test_GetAttributesOf(void)
static WCHAR cTestDirW[] = {'t','e','s','t','d','i','r',0};
IShellFolder *IDesktopFolder, *testIShellFolder;
ITEMIDLIST *newPIDL;
IEnumIDList *list;
ULONG fetch;
int len;
hr = SHGetDesktopFolder(&psfDesktop);
......@@ -1070,6 +1072,57 @@ static void test_GetAttributesOf(void)
Cleanup();
/* test Control Panel elements */
hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL,
(WCHAR *)L"::{21EC2020-3AEA-1069-A2DD-08002B30309D}", NULL, &newPIDL, 0);
ok(hr == S_OK, "ParseDisplayName failed %08lx\n", hr);
hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL,
&IID_IShellFolder, (void**)&testIShellFolder);
ok(hr == S_OK, "BindToObject failed %08lx\n", hr);
ILFree(newPIDL);
hr = IShellFolder_EnumObjects(testIShellFolder, NULL, SHCONTF_NONFOLDERS, &list);
ok(hr == S_OK, "EnumObjects failed %08lx\n", hr);
while (IEnumIDList_Next(list, 1, &newPIDL, &fetch) == S_OK)
{
WCHAR name[256];
STRRET strret;
hr = IShellFolder_GetDisplayNameOf(testIShellFolder, newPIDL, SHGDN_FORPARSING, &strret);
ok(hr == S_OK, "GetDisplayNameOf failed %08lx\n", hr);
StrRetToBufW(&strret, newPIDL, name, ARRAY_SIZE(name));
dwFlags = ~0;
hr = IShellFolder_GetAttributesOf(testIShellFolder, 1,
(LPCITEMIDLIST*)&newPIDL, &dwFlags);
ok(hr == S_OK, "ControlPanel->GetAttributesOf failed %08lx\n", hr);
ok(dwFlags == SFGAO_CANLINK ||
broken(!wcsncmp(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}\\", name, 41)
&& dwFlags == SFGAO_VALIDATE),
"%s dwFlags = %08lx\n", debugstr_w(name), dwFlags);
ILFree(newPIDL);
}
IEnumIDList_Release(list);
hr = IShellFolder_ParseDisplayName(IDesktopFolder, NULL, NULL,
(WCHAR*)L"c:\\", NULL, &newPIDL, 0);
ok(hr == S_OK, "ParseDisplayName failed %08lx\n", hr);
dwFlags = ~0;
hr = IShellFolder_GetAttributesOf(testIShellFolder, 1,
(LPCITEMIDLIST*)&newPIDL, &dwFlags);
ok(hr == S_OK, "ControlPanel->GetAttributesOf failed %08lx\n", hr);
ok(dwFlags == SFGAO_VALIDATE, "dwFlags = %08lx\n", dwFlags);
dwFlags = ~0 & ~SFGAO_VALIDATE;
hr = IShellFolder_GetAttributesOf(testIShellFolder, 1,
(LPCITEMIDLIST*)&newPIDL, &dwFlags);
ok(hr == S_OK, "ControlPanel->GetAttributesOf failed %08lx\n", hr);
ok(dwFlags == SFGAO_CANLINK, "dwFlags = %08lx\n", dwFlags);
ILFree(newPIDL);
IShellFolder_Release(testIShellFolder);
IShellFolder_Release(IDesktopFolder);
}
......
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