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
);
199 FIXME("unsupported interface %s\n", shdebugstr_guid (riid
));
206 static HRESULT WINAPI
IShellFolder_Printers_fnGetAttributesOf (IShellFolder2
* iface
,
207 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
209 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
210 FIXME("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x)) stub\n",
211 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
215 static HRESULT WINAPI
IShellFolder_Printers_fnGetUIObjectOf (IShellFolder2
* iface
,
216 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
, REFIID riid
,
217 UINT
* prgfInOut
, LPVOID
* ppvOut
)
219 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
221 FIXME("(%p)->(%p,%u,apidl=%p,%s,%p,%p) stub\n", This
,
222 hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
232 static HRESULT WINAPI
IShellFolder_Printers_fnGetDisplayNameOf (IShellFolder2
*iface
,
233 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
235 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
237 FIXME("(%p)->(pidl=%p,0x%08x,%p) stub\n", This
, pidl
, dwFlags
, strRet
);
245 static HRESULT WINAPI
IShellFolder_Printers_fnSetNameOf (
246 IShellFolder2
* iface
, HWND hwndOwner
, LPCITEMIDLIST pidl
,
247 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
249 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
250 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p) stub\n", This
,
251 hwndOwner
, pidl
, debugstr_w (lpName
), dwFlags
, pPidlOut
);
255 static HRESULT WINAPI
IShellFolder_Printers_fnGetDefaultSearchGUID(IShellFolder2
*iface
, GUID
*guid
)
257 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
258 TRACE("(%p)->(%p)\n", This
, guid
);
262 static HRESULT WINAPI
IShellFolder_Printers_fnEnumSearches (
263 IShellFolder2
* iface
, IEnumExtraSearch
** ppenum
)
265 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
266 FIXME ("(%p) stub\n", This
);
270 static HRESULT WINAPI
IShellFolder_Printers_fnGetDefaultColumn(IShellFolder2
*iface
, DWORD reserved
,
271 ULONG
*sort
, ULONG
*display
)
273 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
275 TRACE("(%p)->(%#x, %p, %p)\n", This
, reserved
, sort
, display
);
280 static HRESULT WINAPI
IShellFolder_Printers_fnGetDefaultColumnState (
281 IShellFolder2
*iface
, UINT iColumn
, DWORD
*pcsFlags
)
283 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
285 TRACE("(%p)->(%d %p)\n", This
, iColumn
, pcsFlags
);
287 if (iColumn
>= ARRAY_SIZE(printers_header
))
290 *pcsFlags
= printers_header
[iColumn
].pcsFlags
;
295 static HRESULT WINAPI
IShellFolder_Printers_fnGetDetailsEx (IShellFolder2
* iface
,
296 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
298 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
299 FIXME ("(%p) stub\n", This
);
303 static HRESULT WINAPI
IShellFolder_Printers_fnGetDetailsOf (IShellFolder2
*iface
,
304 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
*psd
)
306 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
308 TRACE("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
310 if (iColumn
>= ARRAY_SIZE(printers_header
))
314 return SHELL32_GetColumnDetails(printers_header
, iColumn
, psd
);
316 FIXME("unimplemented for supplied pidl\n");
321 static HRESULT WINAPI
IShellFolder_Printers_fnMapColumnToSCID (IShellFolder2
*iface
, UINT column
, SHCOLUMNID
*scid
)
323 IPrintersFolderImpl
*This
= impl_from_IShellFolder2(iface
);
325 TRACE("(%p)->(%u %p)\n", This
, column
, scid
);
327 if (column
>= ARRAY_SIZE(printers_header
))
330 return shellfolder_map_column_to_scid(printers_header
, column
, scid
);
333 static const IShellFolder2Vtbl vtbl_ShellFolder2
=
336 IShellFolder_Printers_fnQueryInterface
,
337 IShellFolder_Printers_fnAddRef
,
338 IShellFolder_Printers_fnRelease
,
340 IShellFolder_Printers_fnParseDisplayName
,
341 IShellFolder_Printers_fnEnumObjects
,
342 IShellFolder_Printers_fnBindToObject
,
343 IShellFolder_Printers_fnBindToStorage
,
344 IShellFolder_Printers_fnCompareIDs
,
345 IShellFolder_Printers_fnCreateViewObject
,
346 IShellFolder_Printers_fnGetAttributesOf
,
347 IShellFolder_Printers_fnGetUIObjectOf
,
348 IShellFolder_Printers_fnGetDisplayNameOf
,
349 IShellFolder_Printers_fnSetNameOf
,
351 IShellFolder_Printers_fnGetDefaultSearchGUID
,
352 IShellFolder_Printers_fnEnumSearches
,
353 IShellFolder_Printers_fnGetDefaultColumn
,
354 IShellFolder_Printers_fnGetDefaultColumnState
,
355 IShellFolder_Printers_fnGetDetailsEx
,
356 IShellFolder_Printers_fnGetDetailsOf
,
357 IShellFolder_Printers_fnMapColumnToSCID
360 /*** IPersistFolder2 ***/
361 static HRESULT WINAPI
IPersistFolder2_Printers_fnQueryInterface(IPersistFolder2
* iface
,
362 REFIID iid
, LPVOID
* ppvObj
)
364 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
365 return IShellFolder2_QueryInterface(&This
->IShellFolder2_iface
, iid
, ppvObj
);
368 static ULONG WINAPI
IPersistFolder2_Printers_fnAddRef(IPersistFolder2
*iface
)
370 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
371 return IShellFolder2_AddRef(&This
->IShellFolder2_iface
);
374 static ULONG WINAPI
IPersistFolder2_Printers_fnRelease(IPersistFolder2
*iface
)
376 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
377 return IShellFolder2_Release(&This
->IShellFolder2_iface
);
380 static HRESULT WINAPI
IPersistFolder2_Printers_fnGetClassID(IPersistFolder2
*iface
, CLSID
*classId
)
382 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
384 FIXME("(%p) stub\n", This
);
392 static HRESULT WINAPI
IPersistFolder2_Printers_fnInitialize(IPersistFolder2
*iface
, LPCITEMIDLIST pidl
)
394 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
396 TRACE("(%p)->(%p)\n", This
, pidl
);
399 This
->pidl
= ILClone(pidl
);
404 static HRESULT WINAPI
IPersistFolder2_Printers_fnGetCurFolder(IPersistFolder2
*iface
, LPITEMIDLIST
*pidl
)
406 IPrintersFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
408 TRACE("(%p)->(%p)\n", This
, pidl
);
410 *pidl
= ILClone(This
->pidl
);
412 return *pidl
? S_OK
: S_FALSE
;
415 static const IPersistFolder2Vtbl vtbl_PersistFolder2
=
417 IPersistFolder2_Printers_fnQueryInterface
,
418 IPersistFolder2_Printers_fnAddRef
,
419 IPersistFolder2_Printers_fnRelease
,
420 IPersistFolder2_Printers_fnGetClassID
,
421 IPersistFolder2_Printers_fnInitialize
,
422 IPersistFolder2_Printers_fnGetCurFolder
425 HRESULT WINAPI
Printers_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
427 IPrintersFolderImpl
*sf
;
429 TRACE("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
434 return CLASS_E_NOAGGREGATION
;
436 sf
= LocalAlloc(LMEM_FIXED
, sizeof(IPrintersFolderImpl
));
438 return E_OUTOFMEMORY
;
442 sf
->IShellFolder2_iface
.lpVtbl
= &vtbl_ShellFolder2
;
443 sf
->IPersistFolder2_iface
.lpVtbl
= &vtbl_PersistFolder2
;
445 if (IShellFolder2_QueryInterface(&sf
->IShellFolder2_iface
, riid
, ppv
) != S_OK
)
447 IShellFolder2_Release(&sf
->IShellFolder2_iface
);
448 return E_NOINTERFACE
;
451 TRACE("--(%p)\n", sf
);