ntoskrnl.exe/tests: Add some IOCTL_HID_WRITE_REPORT tests.
[wine.git] / dlls / shell32 / shfldr_printers.c
blob76375525c52c910fda0b5f6d3a52635d5ba2f9ae
1 /*
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
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "winerror.h"
27 #include "windef.h"
28 #include "winbase.h"
30 #include "shell32_main.h"
31 #include "wine/debug.h"
32 #include "debughlp.h"
34 #include "shresdef.h"
35 #include "shfldr.h"
37 WINE_DEFAULT_DEBUG_CHANNEL (shell);
39 typedef struct {
40 IShellFolder2 IShellFolder2_iface;
41 IPersistFolder2 IPersistFolder2_iface;
42 LONG ref;
44 LPITEMIDLIST pidl;
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);
73 *ppvObj = NULL;
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;
88 if (*ppvObj)
90 IUnknown_AddRef ((IUnknown *) (*ppvObj));
91 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
92 return S_OK;
95 ERR ("-- interface %s not supported\n", shdebugstr_guid (riid));
96 return E_NOINTERFACE;
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);
104 return refCount;
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);
114 if (!refCount)
116 TRACE ("-- destroying IShellFolder(%p)\n", This);
117 SHFree(This->pidl);
118 LocalFree (This);
120 return refCount;
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);
133 return E_NOTIMPL;
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);
142 return E_NOTIMPL;
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);
151 return E_NOTIMPL;
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);
162 *ppvOut = NULL;
163 return E_NOTIMPL;
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);
171 return E_NOTIMPL;
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);
183 if (!ppvOut)
184 return E_INVALIDARG;
186 *ppvOut = NULL;
188 if (IsEqualIID (riid, &IID_IShellView))
190 IShellView *pShellView = IShellView_Constructor ((IShellFolder *) iface);
191 if (pShellView)
193 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
194 IShellView_Release (pShellView);
197 else
199 FIXME("unsupported interface %s\n", shdebugstr_guid (riid));
200 hr = E_NOINTERFACE;
203 return hr;
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);
212 return E_NOTIMPL;
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);
224 if (!ppvOut)
225 return E_INVALIDARG;
227 *ppvOut = NULL;
229 return E_NOTIMPL;
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);
239 if (!strRet)
240 return E_INVALIDARG;
242 return E_NOTIMPL;
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);
252 return E_FAIL;
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);
259 return E_NOTIMPL;
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);
267 return E_NOTIMPL;
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);
277 return E_NOTIMPL;
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))
288 return E_INVALIDARG;
290 *pcsFlags = printers_header[iColumn].pcsFlags;
292 return S_OK;
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);
300 return E_NOTIMPL;
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))
311 return E_NOTIMPL;
313 if (!pidl)
314 return SHELL32_GetColumnDetails(printers_header, iColumn, psd);
316 FIXME("unimplemented for supplied pidl\n");
318 return E_NOTIMPL;
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))
328 return E_INVALIDARG;
330 return shellfolder_map_column_to_scid(printers_header, column, scid);
333 static const IShellFolder2Vtbl vtbl_ShellFolder2 =
335 /* IUnknown */
336 IShellFolder_Printers_fnQueryInterface,
337 IShellFolder_Printers_fnAddRef,
338 IShellFolder_Printers_fnRelease,
339 /* IShellFolder */
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,
350 /* IShellFolder2 */
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);
386 if (!classId)
387 return E_POINTER;
389 return E_NOTIMPL;
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);
398 SHFree(This->pidl);
399 This->pidl = ILClone(pidl);
401 return S_OK;
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));
431 if (!ppv)
432 return E_POINTER;
433 if (pUnkOuter)
434 return CLASS_E_NOAGGREGATION;
436 sf = LocalAlloc(LMEM_FIXED, sizeof(IPrintersFolderImpl));
437 if (!sf)
438 return E_OUTOFMEMORY;
440 sf->ref = 0;
441 sf->pidl = NULL;
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);
452 return S_OK;