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
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
32 #include "shell32_main.h"
33 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL (shell);
42 const IShellFolder2Vtbl *lpVtbl;
43 const IPersistFolder2Vtbl *lpvtblPersistFolder2;
47 } IPrintersFolderImpl;
49 static inline IPrintersFolderImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
51 return (IPrintersFolderImpl *)((char*)iface - FIELD_OFFSET(IPrintersFolderImpl, lpvtblPersistFolder2));
54 static const shvheader printers_header[] = {
55 { IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 },
56 { IDS_SHV_COL_DOCS, SHCOLSTATE_TYPE_INT | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 12 },
57 { IDS_SHV_COL_STATUS, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 12 },
58 { IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30 },
59 { IDS_SHV_COL_LOCATION, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 },
60 { IDS_SHV_COL_MODEL, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 }
63 #define PRINTERS_FOLDER_COL_NUM sizeof(printers_header)/sizeof(shvheader)
65 static HRESULT WINAPI IShellFolder_Printers_fnQueryInterface(IShellFolder2 *iface,
66 REFIID riid, LPVOID *ppvObj)
68 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
70 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
74 if (IsEqualIID (riid, &IID_IUnknown) ||
75 IsEqualIID (riid, &IID_IShellFolder) ||
76 IsEqualIID (riid, &IID_IShellFolder2))
80 else if (IsEqualIID (riid, &IID_IPersist) ||
81 IsEqualIID (riid, &IID_IPersistFolder) ||
82 IsEqualIID (riid, &IID_IPersistFolder2))
84 *ppvObj = &This->lpvtblPersistFolder2;
89 IUnknown_AddRef ((IUnknown *) (*ppvObj));
90 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
94 ERR ("-- interface %s not supported\n", shdebugstr_guid (riid));
98 static ULONG WINAPI IShellFolder_Printers_fnAddRef (IShellFolder2 * iface)
100 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
101 ULONG refCount = InterlockedIncrement(&This->ref);
102 TRACE ("(%p)->(count=%u)\n", This, refCount - 1);
106 static ULONG WINAPI IShellFolder_Printers_fnRelease (IShellFolder2 * iface)
108 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
109 ULONG refCount = InterlockedDecrement(&This->ref);
111 TRACE ("(%p)->(count=%u)\n", This, refCount + 1);
115 TRACE ("-- destroying IShellFolder(%p)\n", This);
122 static HRESULT WINAPI IShellFolder_Printers_fnParseDisplayName (IShellFolder2 *iface,
123 HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName,
124 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
126 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
128 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p) stub\n", This,
129 hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
130 pchEaten, ppidl, pdwAttributes);
135 static HRESULT WINAPI IShellFolder_Printers_fnEnumObjects (IShellFolder2 *iface,
136 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
138 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
139 FIXME("(%p)->(HWND=%p flags=0x%08x pplist=%p) stub\n", This,
140 hwndOwner, dwFlags, ppEnumIDList);
144 static HRESULT WINAPI IShellFolder_Printers_fnBindToObject (IShellFolder2 *iface,
145 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
147 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
148 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
149 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
153 static HRESULT WINAPI IShellFolder_Printers_fnBindToStorage (IShellFolder2 * iface,
154 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
156 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
158 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
159 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
165 static HRESULT WINAPI IShellFolder_Printers_fnCompareIDs(IShellFolder2 *iface,
166 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
168 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
169 FIXME("(%p)->(0x%08lx,pidl1=%p,pidl2=%p) stub\n", This, lParam, pidl1, pidl2);
173 static HRESULT WINAPI IShellFolder_Printers_fnCreateViewObject(IShellFolder2 *iface,
174 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
176 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
177 HRESULT hr = E_NOTIMPL;
179 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This,
180 hwndOwner, shdebugstr_guid (riid), ppvOut);
187 if (IsEqualIID (riid, &IID_IShellView))
189 IShellView *pShellView = IShellView_Constructor ((IShellFolder *) iface);
192 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
193 IShellView_Release (pShellView);
197 WARN("unsupported interface %s\n", shdebugstr_guid (riid));
202 static HRESULT WINAPI IShellFolder_Printers_fnGetAttributesOf (IShellFolder2 * iface,
203 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
205 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
206 FIXME("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x)) stub\n",
207 This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
211 static HRESULT WINAPI IShellFolder_Printers_fnGetUIObjectOf (IShellFolder2 * iface,
212 HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid,
213 UINT * prgfInOut, LPVOID * ppvOut)
215 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
217 FIXME("(%p)->(%p,%u,apidl=%p,%s,%p,%p) stub\n", This,
218 hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
228 static HRESULT WINAPI IShellFolder_Printers_fnGetDisplayNameOf (IShellFolder2 *iface,
229 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
231 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
233 FIXME("(%p)->(pidl=%p,0x%08x,%p) stub\n", This, pidl, dwFlags, strRet);
241 static HRESULT WINAPI IShellFolder_Printers_fnSetNameOf (
242 IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,
243 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
245 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
246 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p) stub\n", This,
247 hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
251 static HRESULT WINAPI IShellFolder_Printers_fnGetDefaultSearchGUID (
252 IShellFolder2 * iface, GUID * pguid)
254 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
255 FIXME ("(%p) stub\n", This);
259 static HRESULT WINAPI IShellFolder_Printers_fnEnumSearches (
260 IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
262 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
263 FIXME ("(%p) stub\n", This);
267 static HRESULT WINAPI IShellFolder_Printers_fnGetDefaultColumn (
268 IShellFolder2 *iface, DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
270 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
271 FIXME("(%p) stub\n", This);
275 static HRESULT WINAPI IShellFolder_Printers_fnGetDefaultColumnState (
276 IShellFolder2 *iface, UINT iColumn, DWORD *pcsFlags)
278 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
280 TRACE("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
282 if (iColumn >= PRINTERS_FOLDER_COL_NUM)
285 *pcsFlags = printers_header[iColumn].pcsFlags;
290 static HRESULT WINAPI IShellFolder_Printers_fnGetDetailsEx (IShellFolder2 * iface,
291 LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
293 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
294 FIXME ("(%p) stub\n", This);
298 static HRESULT WINAPI IShellFolder_Printers_fnGetDetailsOf (IShellFolder2 *iface,
299 LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd)
301 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
303 TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
305 if (iColumn >= PRINTERS_FOLDER_COL_NUM)
309 return SHELL32_GetColumnDetails(printers_header, iColumn, psd);
311 FIXME("unimplemented for supplied pidl\n");
316 static HRESULT WINAPI IShellFolder_Printers_fnMapColumnToSCID (
317 IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
319 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
320 FIXME ("(%p)->(%u %p) stub\n", This, column, pscid);
324 static const IShellFolder2Vtbl vtbl_ShellFolder2 =
327 IShellFolder_Printers_fnQueryInterface,
328 IShellFolder_Printers_fnAddRef,
329 IShellFolder_Printers_fnRelease,
331 IShellFolder_Printers_fnParseDisplayName,
332 IShellFolder_Printers_fnEnumObjects,
333 IShellFolder_Printers_fnBindToObject,
334 IShellFolder_Printers_fnBindToStorage,
335 IShellFolder_Printers_fnCompareIDs,
336 IShellFolder_Printers_fnCreateViewObject,
337 IShellFolder_Printers_fnGetAttributesOf,
338 IShellFolder_Printers_fnGetUIObjectOf,
339 IShellFolder_Printers_fnGetDisplayNameOf,
340 IShellFolder_Printers_fnSetNameOf,
342 IShellFolder_Printers_fnGetDefaultSearchGUID,
343 IShellFolder_Printers_fnEnumSearches,
344 IShellFolder_Printers_fnGetDefaultColumn,
345 IShellFolder_Printers_fnGetDefaultColumnState,
346 IShellFolder_Printers_fnGetDetailsEx,
347 IShellFolder_Printers_fnGetDetailsOf,
348 IShellFolder_Printers_fnMapColumnToSCID
351 /*** IPersistFolder2 ***/
352 static HRESULT WINAPI IPersistFolder2_Printers_fnQueryInterface(IPersistFolder2 * iface,
353 REFIID iid, LPVOID * ppvObj)
355 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
356 return IUnknown_QueryInterface( (IUnknown*) This, iid, ppvObj);
359 static ULONG WINAPI IPersistFolder2_Printers_fnAddRef(IPersistFolder2 *iface)
361 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
362 return IUnknown_AddRef( (IUnknown*) This);
365 static ULONG WINAPI IPersistFolder2_Printers_fnRelease(IPersistFolder2 *iface)
367 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
368 return IUnknown_Release( (IUnknown*) This);
371 static HRESULT WINAPI IPersistFolder2_Printers_fnGetClassID(IPersistFolder2 *iface, CLSID *classId)
373 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
375 FIXME("(%p) stub\n", This);
383 static HRESULT WINAPI IPersistFolder2_Printers_fnInitialize(IPersistFolder2 *iface, LPCITEMIDLIST pidl)
385 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
387 TRACE("(%p)->(%p)\n", This, pidl);
390 This->pidl = ILClone(pidl);
395 static HRESULT WINAPI IPersistFolder2_Printers_fnGetCurFolder(IPersistFolder2 *iface, LPITEMIDLIST *pidl)
397 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
399 TRACE("(%p)->(%p)\n", This, pidl);
401 *pidl = ILClone(This->pidl);
403 return *pidl ? S_OK : S_FALSE;
406 static const IPersistFolder2Vtbl vtbl_PersistFolder2 =
408 IPersistFolder2_Printers_fnQueryInterface,
409 IPersistFolder2_Printers_fnAddRef,
410 IPersistFolder2_Printers_fnRelease,
411 IPersistFolder2_Printers_fnGetClassID,
412 IPersistFolder2_Printers_fnInitialize,
413 IPersistFolder2_Printers_fnGetCurFolder
416 HRESULT WINAPI Printers_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
418 IPrintersFolderImpl *sf;
420 TRACE("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
425 return CLASS_E_NOAGGREGATION;
427 sf = LocalAlloc(LMEM_FIXED, sizeof(IPrintersFolderImpl));
429 return E_OUTOFMEMORY;
433 sf->lpVtbl = &vtbl_ShellFolder2;
434 sf->lpvtblPersistFolder2 = &vtbl_PersistFolder2;
436 if (IUnknown_QueryInterface((IShellFolder2 *)sf, riid, ppv) != S_OK)
438 IUnknown_Release((IShellFolder2 *) sf);
439 return E_NOINTERFACE;
442 TRACE("--(%p)\n", sf);