shell32: Add ::Initialize() and ::GetCurFolder() for printers folder IPersistFolder2 interface.

This commit is contained in:
Nikolay Sivov 2010-04-18 18:14:47 +04:00 committed by Alexandre Julliard
parent e51fe8e070
commit 90a5529de8
2 changed files with 44 additions and 4 deletions

View File

@ -42,6 +42,8 @@ typedef struct {
const IShellFolder2Vtbl *lpVtbl; const IShellFolder2Vtbl *lpVtbl;
const IPersistFolder2Vtbl *lpvtblPersistFolder2; const IPersistFolder2Vtbl *lpvtblPersistFolder2;
LONG ref; LONG ref;
LPITEMIDLIST pidl;
} IPrintersFolderImpl; } IPrintersFolderImpl;
static inline IPrintersFolderImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface) static inline IPrintersFolderImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
@ -111,6 +113,7 @@ static ULONG WINAPI IShellFolder_Printers_fnRelease (IShellFolder2 * iface)
if (!refCount) if (!refCount)
{ {
TRACE ("-- destroying IShellFolder(%p)\n", This); TRACE ("-- destroying IShellFolder(%p)\n", This);
SHFree(This->pidl);
LocalFree (This); LocalFree (This);
} }
return refCount; return refCount;
@ -380,15 +383,24 @@ static HRESULT WINAPI IPersistFolder2_Printers_fnGetClassID(IPersistFolder2 *ifa
static HRESULT WINAPI IPersistFolder2_Printers_fnInitialize(IPersistFolder2 *iface, LPCITEMIDLIST pidl) static HRESULT WINAPI IPersistFolder2_Printers_fnInitialize(IPersistFolder2 *iface, LPCITEMIDLIST pidl)
{ {
IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface); IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
FIXME("(%p) stub\n", This);
return E_NOTIMPL; TRACE("(%p)->(%p)\n", This, pidl);
SHFree(This->pidl);
This->pidl = ILClone(pidl);
return S_OK;
} }
static HRESULT WINAPI IPersistFolder2_Printers_fnGetCurFolder(IPersistFolder2 *iface, LPITEMIDLIST *pidl) static HRESULT WINAPI IPersistFolder2_Printers_fnGetCurFolder(IPersistFolder2 *iface, LPITEMIDLIST *pidl)
{ {
IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface); IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
FIXME("(%p) stub\n", This);
return E_NOTIMPL; TRACE("(%p)->(%p)\n", This, pidl);
*pidl = ILClone(This->pidl);
return *pidl ? S_OK : S_FALSE;
} }
static const IPersistFolder2Vtbl vtbl_PersistFolder2 = static const IPersistFolder2Vtbl vtbl_PersistFolder2 =
@ -417,6 +429,7 @@ HRESULT WINAPI Printers_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID *
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
sf->ref = 0; sf->ref = 0;
sf->pidl = NULL;
sf->lpVtbl = &vtbl_ShellFolder2; sf->lpVtbl = &vtbl_ShellFolder2;
sf->lpvtblPersistFolder2 = &vtbl_PersistFolder2; sf->lpvtblPersistFolder2 = &vtbl_PersistFolder2;

View File

@ -125,8 +125,10 @@ static void test_parse_for_control_panel(void)
static void test_printers_folder(void) static void test_printers_folder(void)
{ {
IShellFolder2 *folder; IShellFolder2 *folder;
IPersistFolder2 *pf;
SHELLDETAILS details; SHELLDETAILS details;
SHCOLSTATEF state; SHCOLSTATEF state;
LPITEMIDLIST pidl1, pidl2;
INT i; INT i;
HRESULT hr; HRESULT hr;
@ -145,6 +147,7 @@ if (0)
/* crashes on XP */ /* crashes on XP */
hr = IShellFolder2_GetDetailsOf(folder, NULL, 0, NULL); hr = IShellFolder2_GetDetailsOf(folder, NULL, 0, NULL);
hr = IShellFolder2_GetDefaultColumnState(folder, 0, NULL); hr = IShellFolder2_GetDefaultColumnState(folder, 0, NULL);
hr = IPersistFolder2_GetCurFolder(pf, NULL);
} }
/* 5 columns defined */ /* 5 columns defined */
@ -173,6 +176,30 @@ if (0)
ok(state == (SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT), "got 0x%x\n", state); ok(state == (SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT), "got 0x%x\n", state);
} }
/* default pidl */
hr = IShellFolder2_QueryInterface(folder, &IID_IPersistFolder2, (void**)&pf);
ok(hr == S_OK, "got 0x%08x\n", hr);
/* not initialized */
pidl1 = (void*)0xdeadbeef;
hr = IPersistFolder2_GetCurFolder(pf, &pidl1);
ok(hr == S_FALSE, "got 0x%08x\n", hr);
ok(pidl1 == NULL, "got %p\n", pidl1);
hr = SHGetSpecialFolderLocation(NULL, CSIDL_PRINTERS, &pidl2);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IPersistFolder2_Initialize(pf, pidl2);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IPersistFolder2_GetCurFolder(pf, &pidl1);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(ILIsEqual(pidl1, pidl2), "expected same PIDL\n");
IPersistFolder2_Release(pf);
ILFree(pidl1);
ILFree(pidl2);
IShellFolder2_Release(folder); IShellFolder2_Release(folder);
CoUninitialize(); CoUninitialize();