Nikolay Sivov : shell32: Add ::Initialize() and ::GetCurFolder() for printers folder IPersistFolder2 interface.
Alexandre Julliard
julliard at winehq.org
Mon Apr 19 11:51:18 CDT 2010
Module: wine
Branch: master
Commit: 90a5529de8aa7f376945df620bd604e6696a4b69
URL: http://source.winehq.org/git/wine.git/?a=commit;h=90a5529de8aa7f376945df620bd604e6696a4b69
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun Apr 18 18:14:47 2010 +0400
shell32: Add ::Initialize() and ::GetCurFolder() for printers folder IPersistFolder2 interface.
---
dlls/shell32/shfldr_printers.c | 21 +++++++++++++++++----
dlls/shell32/tests/shfldr_special.c | 27 +++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/shfldr_printers.c b/dlls/shell32/shfldr_printers.c
index 7bb954e..66fa571 100644
--- a/dlls/shell32/shfldr_printers.c
+++ b/dlls/shell32/shfldr_printers.c
@@ -42,6 +42,8 @@ typedef struct {
const IShellFolder2Vtbl *lpVtbl;
const IPersistFolder2Vtbl *lpvtblPersistFolder2;
LONG ref;
+
+ LPITEMIDLIST pidl;
} IPrintersFolderImpl;
static inline IPrintersFolderImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
@@ -111,6 +113,7 @@ static ULONG WINAPI IShellFolder_Printers_fnRelease (IShellFolder2 * iface)
if (!refCount)
{
TRACE ("-- destroying IShellFolder(%p)\n", This);
+ SHFree(This->pidl);
LocalFree (This);
}
return refCount;
@@ -380,15 +383,24 @@ static HRESULT WINAPI IPersistFolder2_Printers_fnGetClassID(IPersistFolder2 *ifa
static HRESULT WINAPI IPersistFolder2_Printers_fnInitialize(IPersistFolder2 *iface, LPCITEMIDLIST pidl)
{
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)
{
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 =
@@ -417,6 +429,7 @@ HRESULT WINAPI Printers_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID *
return E_OUTOFMEMORY;
sf->ref = 0;
+ sf->pidl = NULL;
sf->lpVtbl = &vtbl_ShellFolder2;
sf->lpvtblPersistFolder2 = &vtbl_PersistFolder2;
diff --git a/dlls/shell32/tests/shfldr_special.c b/dlls/shell32/tests/shfldr_special.c
index e971270..3320130 100644
--- a/dlls/shell32/tests/shfldr_special.c
+++ b/dlls/shell32/tests/shfldr_special.c
@@ -125,8 +125,10 @@ static void test_parse_for_control_panel(void)
static void test_printers_folder(void)
{
IShellFolder2 *folder;
+ IPersistFolder2 *pf;
SHELLDETAILS details;
SHCOLSTATEF state;
+ LPITEMIDLIST pidl1, pidl2;
INT i;
HRESULT hr;
@@ -145,6 +147,7 @@ if (0)
/* crashes on XP */
hr = IShellFolder2_GetDetailsOf(folder, NULL, 0, NULL);
hr = IShellFolder2_GetDefaultColumnState(folder, 0, NULL);
+ hr = IPersistFolder2_GetCurFolder(pf, NULL);
}
/* 5 columns defined */
@@ -173,6 +176,30 @@ if (0)
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);
CoUninitialize();
More information about the wine-cvs
mailing list