2 * Virtual Printers folder
4 * Copyright 2010 Nikolay Sivov for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "shell32_main.h"
31 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL (shell
);
40 IShellFolder2 IShellFolder2_iface
;
41 IPersistFolder2 IPersistFolder2_iface
;
45 } IPrintersFolderImpl
;
47 static inline IPrintersFolderImpl
*impl_from_IShellFolder2(IShellFolder2
*iface
)
49 return CONTAINING_RECORD(iface
, IPrintersFolderImpl
, IShellFolder2_iface
);
52 static inline IPrintersFolderImpl
*impl_from_IPersistFolder2(IPersistFolder2
*iface
)
54 return CONTAINING_RECORD(iface
, IPrintersFolderImpl
, IPersistFolder2_iface
);
57 static const shvheader printers_header
[] = {
58 { &FMTID_Storage
, PID_STG_NAME
, IDS_SHV_COLUMN8
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 20 },
59 { NULL
, 0, IDS_SHV_COL_DOCS
, SHCOLSTATE_TYPE_INT
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 12 },
60 { NULL
, 0, IDS_SHV_COL_STATUS
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 12 },
61 { &FMTID_SummaryInformation
, PIDSI_COMMENTS
, IDS_SHV_COLUMN9
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 30 },
62 { NULL
, 0, IDS_SHV_COL_LOCATION
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 20 },
63 { NULL
, 0, IDS_SHV_COL_MODEL
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 20 }
66 static HRESULT WINAPI
IShellFolder_Printers_fnQueryInterface(IShellFolder2
*iface
,
67 REFIID riid
, LPVOID
*ppvObj
)
69 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
71 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
75 if (IsEqualIID (riid
, &IID_IUnknown
) ||
76 IsEqualIID (riid
, &IID_IShellFolder
) ||
77 IsEqualIID (riid
, &IID_IShellFolder2
))
79 *ppvObj
= &This
->IShellFolder2_iface
;
81 else if (IsEqualIID (riid
, &IID_IPersist
) ||
82 IsEqualIID (riid
, &IID_IPersistFolder
) ||
83 IsEqualIID (riid
, &IID_IPersistFolder2
))
85 *ppvObj
= &This
->IPersistFolder2_iface
;
90 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
91 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj
, *ppvObj
);
95 ERR ("-- interface %s not supported\n", shdebugstr_guid (riid
));
99 static ULONG WINAPI
IShellFolder_Printers_fnAddRef (IShellFolder2
* iface
)
101 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
102 ULONG refCount
= InterlockedIncrement(&This
->ref
);
103 TRACE ("(%p)->(count=%u)\n", This
, refCount
- 1);
107 static ULONG WINAPI
IShellFolder_Printers_fnRelease (IShellFolder2
* iface
)
109 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
110 ULONG refCount
= InterlockedDecrement(&This
->ref
);
112 TRACE ("(%p)->(count=%u)\n", This
, refCount
+ 1);
116 TRACE ("-- destroying IShellFolder(%p)\n", This
);
123 static HRESULT WINAPI
IShellFolder_Printers_fnParseDisplayName (IShellFolder2
*iface
,
124 HWND hwndOwner
, LPBC pbc
, LPOLESTR lpszDisplayName
,
125 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
127 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
129 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p) stub\n", This
,
130 hwndOwner
, pbc
, lpszDisplayName
, debugstr_w (lpszDisplayName
),
131 pchEaten
, ppidl
, pdwAttributes
);
136 static HRESULT WINAPI
IShellFolder_Printers_fnEnumObjects (IShellFolder2
*iface
,
137 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
*ppEnumIDList
)
139 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
140 FIXME("(%p)->(HWND=%p flags=0x%08x pplist=%p) stub\n", This
,
141 hwndOwner
, dwFlags
, ppEnumIDList
);
145 static HRESULT WINAPI
IShellFolder_Printers_fnBindToObject (IShellFolder2
*iface
,
146 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
148 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
149 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This
,
150 pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
154 static HRESULT WINAPI
IShellFolder_Printers_fnBindToStorage (IShellFolder2
* iface
,
155 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
157 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
159 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This
,
160 pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
166 static HRESULT WINAPI
IShellFolder_Printers_fnCompareIDs(IShellFolder2
*iface
,
167 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
169 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
170 FIXME("(%p)->(0x%08lx,pidl1=%p,pidl2=%p) stub\n", This
, lParam
, pidl1
, pidl2
);
174 static HRESULT WINAPI
IShellFolder_Printers_fnCreateViewObject(IShellFolder2
*iface
,
175 HWND hwndOwner
, REFIID riid
, LPVOID
*ppvOut
)
177 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
178 HRESULT hr
= E_NOTIMPL
;
180 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This
,
181 hwndOwner
, shdebugstr_guid (riid
), ppvOut
);
188 if (IsEqualIID (riid
, &IID_IShellView
))
190 IShellView
*pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
193 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
194 IShellView_Release (pShellView
);
198 WARN("unsupported interface %s\n", shdebugstr_guid (riid
));
203 static HRESULT WINAPI
IShellFolder_Printers_fnGetAttributesOf (IShellFolder2
* iface
,
204 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
206 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
207 FIXME("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x)) stub\n",
208 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
212 static HRESULT WINAPI
IShellFolder_Printers_fnGetUIObjectOf (IShellFolder2
* iface
,
213 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
, REFIID riid
,
214 UINT
* prgfInOut
, LPVOID
* ppvOut
)
216 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
218 FIXME("(%p)->(%p,%u,apidl=%p,%s,%p,%p) stub\n", This
,
219 hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
229 static HRESULT WINAPI
IShellFolder_Printers_fnGetDisplayNameOf (IShellFolder2
*iface
,
230 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
232 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
234 FIXME("(%p)->(pidl=%p,0x%08x,%p) stub\n", This
, pidl
, dwFlags
, strRet
);
242 static HRESULT WINAPI
IShellFolder_Printers_fnSetNameOf (
243 IShellFolder2
* iface
, HWND hwndOwner
, LPCITEMIDLIST pidl
,
244 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
246 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
247 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p) stub\n", This
,
248 hwndOwner
, pidl
, debugstr_w (lpName
), dwFlags
, pPidlOut
);
252 static HRESULT WINAPI
IShellFolder_Printers_fnGetDefaultSearchGUID(IShellFolder2
*iface
, GUID
*guid
)
254 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
255 TRACE("(%p)->(%p)\n", This
, guid
);
259 static HRESULT WINAPI
IShellFolder_Printers_fnEnumSearches (
260 IShellFolder2
* iface
, IEnumExtraSearch
** ppenum
)
262 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
263 FIXME ("(%p) stub\n", This
);
267 static HRESULT WINAPI
IShellFolder_Printers_fnGetDefaultColumn(IShellFolder2
*iface
, DWORD reserved
,
268 ULONG
*sort
, ULONG
*display
)
270 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
272 TRACE("(%p)->(%#x, %p, %p)\n", This
, reserved
, sort
, display
);
277 static HRESULT WINAPI
IShellFolder_Printers_fnGetDefaultColumnState (
278 IShellFolder2
*iface
, UINT iColumn
, DWORD
*pcsFlags
)
280 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
282 TRACE("(%p)->(%d %p)\n", This
, iColumn
, pcsFlags
);
284 if (iColumn
>= ARRAY_SIZE(printers_header
))
287 *pcsFlags
= printers_header
[iColumn
].pcsFlags
;
292 static HRESULT WINAPI
IShellFolder_Printers_fnGetDetailsEx (IShellFolder2
* iface
,
293 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
295 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
296 FIXME ("(%p) stub\n", This
);
300 static HRESULT WINAPI
IShellFolder_Printers_fnGetDetailsOf (IShellFolder2
*iface
,
301 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
*psd
)
303 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
305 TRACE("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
307 if (iColumn
>= ARRAY_SIZE(printers_header
))
311 return SHELL32_GetColumnDetails(printers_header
, iColumn
, psd
);
313 FIXME("unimplemented for supplied pidl\n");
318 static HRESULT WINAPI
IShellFolder_Printers_fnMapColumnToSCID (IShellFolder2
*iface
, UINT column
, SHCOLUMNID
*scid
)
320 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
322 TRACE("(%p)->(%u %p)\n", This
, column
, scid
);
324 if (column
>= ARRAY_SIZE(printers_header
))
327 return shellfolder_map_column_to_scid(printers_header
, column
, scid
);
330 static const IShellFolder2Vtbl vtbl_ShellFolder2
=
333 IShellFolder_Printers_fnQueryInterface
,
334 IShellFolder_Printers_fnAddRef
,
335 IShellFolder_Printers_fnRelease
,
337 IShellFolder_Printers_fnParseDisplayName
,
338 IShellFolder_Printers_fnEnumObjects
,
339 IShellFolder_Printers_fnBindToObject
,
340 IShellFolder_Printers_fnBindToStorage
,
341 IShellFolder_Printers_fnCompareIDs
,
342 IShellFolder_Printers_fnCreateViewObject
,
343 IShellFolder_Printers_fnGetAttributesOf
,
344 IShellFolder_Printers_fnGetUIObjectOf
,
345 IShellFolder_Printers_fnGetDisplayNameOf
,
346 IShellFolder_Printers_fnSetNameOf
,
348 IShellFolder_Printers_fnGetDefaultSearchGUID
,
349 IShellFolder_Printers_fnEnumSearches
,
350 IShellFolder_Printers_fnGetDefaultColumn
,
351 IShellFolder_Printers_fnGetDefaultColumnState
,
352 IShellFolder_Printers_fnGetDetailsEx
,
353 IShellFolder_Printers_fnGetDetailsOf
,
354 IShellFolder_Printers_fnMapColumnToSCID
357 /*** IPersistFolder2 ***/
358 static HRESULT WINAPI
IPersistFolder2_Printers_fnQueryInterface(IPersistFolder2
* iface
,
359 REFIID iid
, LPVOID
* ppvObj
)
361 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
362 return IShellFolder2_QueryInterface(&This
->IShellFolder2_iface
, iid
, ppvObj
);
365 static ULONG WINAPI
IPersistFolder2_Printers_fnAddRef(IPersistFolder2
*iface
)
367 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
368 return IShellFolder2_AddRef(&This
->IShellFolder2_iface
);
371 static ULONG WINAPI
IPersistFolder2_Printers_fnRelease(IPersistFolder2
*iface
)
373 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
374 return IShellFolder2_Release(&This
->IShellFolder2_iface
);
377 static HRESULT WINAPI
IPersistFolder2_Printers_fnGetClassID(IPersistFolder2
*iface
, CLSID
*classId
)
379 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
381 FIXME("(%p) stub\n", This
);
389 static HRESULT WINAPI
IPersistFolder2_Printers_fnInitialize(IPersistFolder2
*iface
, LPCITEMIDLIST pidl
)
391 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
393 TRACE("(%p)->(%p)\n", This
, pidl
);
396 This
->pidl
= ILClone(pidl
);
401 static HRESULT WINAPI
IPersistFolder2_Printers_fnGetCurFolder(IPersistFolder2
*iface
, LPITEMIDLIST
*pidl
)
403 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
405 TRACE("(%p)->(%p)\n", This
, pidl
);
407 *pidl
= ILClone(This
->pidl
);
409 return *pidl
? S_OK
: S_FALSE
;
412 static const IPersistFolder2Vtbl vtbl_PersistFolder2
=
414 IPersistFolder2_Printers_fnQueryInterface
,
415 IPersistFolder2_Printers_fnAddRef
,
416 IPersistFolder2_Printers_fnRelease
,
417 IPersistFolder2_Printers_fnGetClassID
,
418 IPersistFolder2_Printers_fnInitialize
,
419 IPersistFolder2_Printers_fnGetCurFolder
422 HRESULT WINAPI
Printers_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
424 IPrintersFolderImpl
*sf
;
426 TRACE("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
431 return CLASS_E_NOAGGREGATION
;
433 sf
= LocalAlloc(LMEM_FIXED
, sizeof(IPrintersFolderImpl
));
435 return E_OUTOFMEMORY
;
439 sf
->IShellFolder2_iface
.lpVtbl
= &vtbl_ShellFolder2
;
440 sf
->IPersistFolder2_iface
.lpVtbl
= &vtbl_PersistFolder2
;
442 if (IShellFolder2_QueryInterface(&sf
->IShellFolder2_iface
, riid
, ppv
) != S_OK
)
444 IShellFolder2_Release(&sf
->IShellFolder2_iface
);
445 return E_NOINTERFACE
;
448 TRACE("--(%p)\n", sf
);