Commit bb19a58a authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

Return the correct attributes for the desktop folder.

Corresponding tests.
parent f95ef09b
...@@ -427,6 +427,9 @@ static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface, ...@@ -427,6 +427,9 @@ static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface,
{ {
IGenericSFImpl *This = (IGenericSFImpl *)iface; IGenericSFImpl *This = (IGenericSFImpl *)iface;
HRESULT hr = S_OK; HRESULT hr = S_OK;
const static DWORD dwDesktopAttributes =
SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGE_ANCESTOR |
SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08lx))\n", TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08lx))\n",
This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0); This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
...@@ -440,16 +443,15 @@ static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface, ...@@ -440,16 +443,15 @@ static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface,
*rgfInOut = ~0; *rgfInOut = ~0;
if(cidl == 0) { if(cidl == 0) {
IShellFolder *psfParent = NULL; *rgfInOut &= dwDesktopAttributes;
LPCITEMIDLIST rpidl = NULL;
hr = SHBindToParent(This->pidlRoot, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&rpidl);
if(SUCCEEDED(hr))
SHELL32_GetItemAttributes (psfParent, rpidl, rgfInOut);
} else { } else {
while (cidl > 0 && *apidl) { while (cidl > 0 && *apidl) {
pdump (*apidl); pdump (*apidl);
SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut); if (_ILIsDesktop(*apidl)) {
*rgfInOut &= dwDesktopAttributes;
} else {
SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
}
apidl++; apidl++;
cidl--; cidl--;
} }
......
...@@ -224,6 +224,7 @@ static void test_GetDisplayName(void) ...@@ -224,6 +224,7 @@ static void test_GetDisplayName(void)
WCHAR wszTestFile[MAX_PATH], wszTestFile2[MAX_PATH], wszTestDir[MAX_PATH]; WCHAR wszTestFile[MAX_PATH], wszTestFile2[MAX_PATH], wszTestDir[MAX_PATH];
STRRET strret; STRRET strret;
LPSHELLFOLDER psfDesktop, psfPersonal; LPSHELLFOLDER psfDesktop, psfPersonal;
IUnknown *psfFile;
LPITEMIDLIST pidlTestFile; LPITEMIDLIST pidlTestFile;
LPCITEMIDLIST pidlLast; LPCITEMIDLIST pidlLast;
static const WCHAR wszFileName[] = { 'w','i','n','e','t','e','s','t','.','f','o','o',0 }; static const WCHAR wszFileName[] = { 'w','i','n','e','t','e','s','t','.','f','o','o',0 };
...@@ -269,6 +270,15 @@ static void test_GetDisplayName(void) ...@@ -269,6 +270,15 @@ static void test_GetDisplayName(void)
return; return;
} }
/* It seems as if we can not bind to regular files on windows, but only directories.
* XP sp2 returns 0x80070002, which is not defined in the PSDK
*/
hr = IShellFolder_BindToObject(psfDesktop, pidlTestFile, NULL, &IID_IUnknown, (VOID**)&psfFile);
todo_wine { ok (hr == 0x80070002, "hr = %08lx\n", hr); }
if (SUCCEEDED(hr)) {
IShellFolder_Release(psfFile);
}
/* Deleting the file and the directory */ /* Deleting the file and the directory */
DeleteFileW(wszTestFile); DeleteFileW(wszTestFile);
RemoveDirectoryW(wszTestDir); RemoveDirectoryW(wszTestDir);
...@@ -302,6 +312,38 @@ static void test_GetDisplayName(void) ...@@ -302,6 +312,38 @@ static void test_GetDisplayName(void)
IShellFolder_Release(psfPersonal); IShellFolder_Release(psfPersonal);
} }
static void test_GetAttributesOf(void)
{
HRESULT hr;
LPSHELLFOLDER psfDesktop;
SHITEMID emptyitem = { 0, { 0 } };
LPCITEMIDLIST pidlEmpty = (LPCITEMIDLIST)&emptyitem;
DWORD dwFlags;
const static DWORD dwDesktopFlags = /* As observed on WinXP SP2 */
SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGE_ANCESTOR |
SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
hr = SHGetDesktopFolder(&psfDesktop);
ok (SUCCEEDED(hr), "SHGetDesktopFolder failed! hr = %08lx\n", hr);
if (FAILED(hr)) return;
/* The Desktop attributes can be queried with a single empty itemidlist, .. */
dwFlags = 0xffffffff;
hr = IShellFolder_GetAttributesOf(psfDesktop, 1, &pidlEmpty, &dwFlags);
ok (SUCCEEDED(hr), "Desktop->GetAttributesOf failed! hr = %08lx\n", hr);
ok (dwFlags == dwDesktopFlags, "Wrong Desktop attributes: %08lx, expected: %08lx\n",
dwFlags, dwDesktopFlags);
/* .. or with no itemidlist at all. */
dwFlags = 0xffffffff;
hr = IShellFolder_GetAttributesOf(psfDesktop, 0, NULL, &dwFlags);
ok (SUCCEEDED(hr), "Desktop->GetAttributesOf failed! hr = %08lx\n", hr);
ok (dwFlags == dwDesktopFlags, "Wrong Desktop attributes: %08lx, expected: %08lx\n",
dwFlags, dwDesktopFlags);
IShellFolder_Release(psfDesktop);
}
START_TEST(shlfolder) START_TEST(shlfolder)
{ {
ITEMIDLIST *newPIDL; ITEMIDLIST *newPIDL;
...@@ -334,6 +376,7 @@ START_TEST(shlfolder) ...@@ -334,6 +376,7 @@ START_TEST(shlfolder)
test_EnumObjects(testIShellFolder); test_EnumObjects(testIShellFolder);
test_BindToObject(); test_BindToObject();
test_GetDisplayName(); test_GetDisplayName();
test_GetAttributesOf();
hr = IShellFolder_Release(testIShellFolder); hr = IShellFolder_Release(testIShellFolder);
ok(hr == S_OK, "IShellFolder_Release failed %08lx\n", hr); ok(hr == S_OK, "IShellFolder_Release failed %08lx\n", hr);
......
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