gdi32: Recompute the background masks on every use to support PALETTEINDEX colors.
[wine/multimedia.git] / dlls / shell32 / shfldr_printers.c
blobe8d17d14f9abbe7ee043ac879de51c1013fb8ac9
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
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
28 #include "winerror.h"
29 #include "windef.h"
30 #include "winbase.h"
32 #include "shell32_main.h"
33 #include "wine/debug.h"
34 #include "debughlp.h"
36 #include "shresdef.h"
37 #include "shfldr.h"
39 WINE_DEFAULT_DEBUG_CHANNEL (shell);
41 typedef struct {
42 IShellFolder2 IShellFolder2_iface;
43 IPersistFolder2 IPersistFolder2_iface;
44 LONG ref;
46 LPITEMIDLIST pidl;
47 } IPrintersFolderImpl;
49 static inline IPrintersFolderImpl *impl_from_IShellFolder2(IShellFolder2 *iface)
51 return CONTAINING_RECORD(iface, IPrintersFolderImpl, IShellFolder2_iface);
54 static inline IPrintersFolderImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
56 return CONTAINING_RECORD(iface, IPrintersFolderImpl, IPersistFolder2_iface);
59 static const shvheader printers_header[] = {
60 { IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 },
61 { IDS_SHV_COL_DOCS, SHCOLSTATE_TYPE_INT | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 12 },
62 { IDS_SHV_COL_STATUS, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 12 },
63 { IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30 },
64 { IDS_SHV_COL_LOCATION, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 },
65 { IDS_SHV_COL_MODEL, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 }
68 #define PRINTERS_FOLDER_COL_NUM sizeof(printers_header)/sizeof(shvheader)
70 static HRESULT WINAPI IShellFolder_Printers_fnQueryInterface(IShellFolder2 *iface,
71 REFIID riid, LPVOID *ppvObj)
73 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
75 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
77 *ppvObj = NULL;
79 if (IsEqualIID (riid, &IID_IUnknown) ||
80 IsEqualIID (riid, &IID_IShellFolder) ||
81 IsEqualIID (riid, &IID_IShellFolder2))
83 *ppvObj = This;
85 else if (IsEqualIID (riid, &IID_IPersist) ||
86 IsEqualIID (riid, &IID_IPersistFolder) ||
87 IsEqualIID (riid, &IID_IPersistFolder2))
89 *ppvObj = &This->IPersistFolder2_iface;
92 if (*ppvObj)
94 IUnknown_AddRef ((IUnknown *) (*ppvObj));
95 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
96 return S_OK;
99 ERR ("-- interface %s not supported\n", shdebugstr_guid (riid));
100 return E_NOINTERFACE;
103 static ULONG WINAPI IShellFolder_Printers_fnAddRef (IShellFolder2 * iface)
105 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
106 ULONG refCount = InterlockedIncrement(&This->ref);
107 TRACE ("(%p)->(count=%u)\n", This, refCount - 1);
108 return refCount;
111 static ULONG WINAPI IShellFolder_Printers_fnRelease (IShellFolder2 * iface)
113 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
114 ULONG refCount = InterlockedDecrement(&This->ref);
116 TRACE ("(%p)->(count=%u)\n", This, refCount + 1);
118 if (!refCount)
120 TRACE ("-- destroying IShellFolder(%p)\n", This);
121 SHFree(This->pidl);
122 LocalFree (This);
124 return refCount;
127 static HRESULT WINAPI IShellFolder_Printers_fnParseDisplayName (IShellFolder2 *iface,
128 HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName,
129 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
131 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
133 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p) stub\n", This,
134 hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
135 pchEaten, ppidl, pdwAttributes);
137 return E_NOTIMPL;
140 static HRESULT WINAPI IShellFolder_Printers_fnEnumObjects (IShellFolder2 *iface,
141 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
143 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
144 FIXME("(%p)->(HWND=%p flags=0x%08x pplist=%p) stub\n", This,
145 hwndOwner, dwFlags, ppEnumIDList);
146 return E_NOTIMPL;
149 static HRESULT WINAPI IShellFolder_Printers_fnBindToObject (IShellFolder2 *iface,
150 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
152 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
153 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
154 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
155 return E_NOTIMPL;
158 static HRESULT WINAPI IShellFolder_Printers_fnBindToStorage (IShellFolder2 * iface,
159 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
161 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
163 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
164 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
166 *ppvOut = NULL;
167 return E_NOTIMPL;
170 static HRESULT WINAPI IShellFolder_Printers_fnCompareIDs(IShellFolder2 *iface,
171 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
173 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
174 FIXME("(%p)->(0x%08lx,pidl1=%p,pidl2=%p) stub\n", This, lParam, pidl1, pidl2);
175 return E_NOTIMPL;
178 static HRESULT WINAPI IShellFolder_Printers_fnCreateViewObject(IShellFolder2 *iface,
179 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
181 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
182 HRESULT hr = E_NOTIMPL;
184 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This,
185 hwndOwner, shdebugstr_guid (riid), ppvOut);
187 if (!ppvOut)
188 return E_INVALIDARG;
190 *ppvOut = NULL;
192 if (IsEqualIID (riid, &IID_IShellView))
194 IShellView *pShellView = IShellView_Constructor ((IShellFolder *) iface);
195 if (pShellView)
197 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
198 IShellView_Release (pShellView);
201 else
202 WARN("unsupported interface %s\n", shdebugstr_guid (riid));
204 return hr;
207 static HRESULT WINAPI IShellFolder_Printers_fnGetAttributesOf (IShellFolder2 * iface,
208 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
210 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
211 FIXME("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x)) stub\n",
212 This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
213 return E_NOTIMPL;
216 static HRESULT WINAPI IShellFolder_Printers_fnGetUIObjectOf (IShellFolder2 * iface,
217 HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid,
218 UINT * prgfInOut, LPVOID * ppvOut)
220 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
222 FIXME("(%p)->(%p,%u,apidl=%p,%s,%p,%p) stub\n", This,
223 hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
225 if (!ppvOut)
226 return E_INVALIDARG;
228 *ppvOut = NULL;
230 return E_NOTIMPL;
233 static HRESULT WINAPI IShellFolder_Printers_fnGetDisplayNameOf (IShellFolder2 *iface,
234 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
236 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
238 FIXME("(%p)->(pidl=%p,0x%08x,%p) stub\n", This, pidl, dwFlags, strRet);
240 if (!strRet)
241 return E_INVALIDARG;
243 return E_NOTIMPL;
246 static HRESULT WINAPI IShellFolder_Printers_fnSetNameOf (
247 IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,
248 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
250 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
251 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p) stub\n", This,
252 hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
253 return E_FAIL;
256 static HRESULT WINAPI IShellFolder_Printers_fnGetDefaultSearchGUID (
257 IShellFolder2 * iface, GUID * pguid)
259 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
260 FIXME ("(%p) stub\n", This);
261 return E_NOTIMPL;
264 static HRESULT WINAPI IShellFolder_Printers_fnEnumSearches (
265 IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
267 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
268 FIXME ("(%p) stub\n", This);
269 return E_NOTIMPL;
272 static HRESULT WINAPI IShellFolder_Printers_fnGetDefaultColumn (
273 IShellFolder2 *iface, DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
275 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
276 FIXME("(%p) stub\n", This);
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 >= PRINTERS_FOLDER_COL_NUM)
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 >= PRINTERS_FOLDER_COL_NUM)
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 (
322 IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
324 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
325 FIXME ("(%p)->(%u %p) stub\n", This, column, pscid);
326 return E_NOTIMPL;
329 static const IShellFolder2Vtbl vtbl_ShellFolder2 =
331 /* IUnknown */
332 IShellFolder_Printers_fnQueryInterface,
333 IShellFolder_Printers_fnAddRef,
334 IShellFolder_Printers_fnRelease,
335 /* IShellFolder */
336 IShellFolder_Printers_fnParseDisplayName,
337 IShellFolder_Printers_fnEnumObjects,
338 IShellFolder_Printers_fnBindToObject,
339 IShellFolder_Printers_fnBindToStorage,
340 IShellFolder_Printers_fnCompareIDs,
341 IShellFolder_Printers_fnCreateViewObject,
342 IShellFolder_Printers_fnGetAttributesOf,
343 IShellFolder_Printers_fnGetUIObjectOf,
344 IShellFolder_Printers_fnGetDisplayNameOf,
345 IShellFolder_Printers_fnSetNameOf,
346 /* IShellFolder2 */
347 IShellFolder_Printers_fnGetDefaultSearchGUID,
348 IShellFolder_Printers_fnEnumSearches,
349 IShellFolder_Printers_fnGetDefaultColumn,
350 IShellFolder_Printers_fnGetDefaultColumnState,
351 IShellFolder_Printers_fnGetDetailsEx,
352 IShellFolder_Printers_fnGetDetailsOf,
353 IShellFolder_Printers_fnMapColumnToSCID
356 /*** IPersistFolder2 ***/
357 static HRESULT WINAPI IPersistFolder2_Printers_fnQueryInterface(IPersistFolder2 * iface,
358 REFIID iid, LPVOID * ppvObj)
360 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
361 return IShellFolder2_QueryInterface(&This->IShellFolder2_iface, iid, ppvObj);
364 static ULONG WINAPI IPersistFolder2_Printers_fnAddRef(IPersistFolder2 *iface)
366 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
367 return IShellFolder2_AddRef(&This->IShellFolder2_iface);
370 static ULONG WINAPI IPersistFolder2_Printers_fnRelease(IPersistFolder2 *iface)
372 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
373 return IShellFolder2_Release(&This->IShellFolder2_iface);
376 static HRESULT WINAPI IPersistFolder2_Printers_fnGetClassID(IPersistFolder2 *iface, CLSID *classId)
378 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
380 FIXME("(%p) stub\n", This);
382 if (!classId)
383 return E_POINTER;
385 return E_NOTIMPL;
388 static HRESULT WINAPI IPersistFolder2_Printers_fnInitialize(IPersistFolder2 *iface, LPCITEMIDLIST pidl)
390 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
392 TRACE("(%p)->(%p)\n", This, pidl);
394 SHFree(This->pidl);
395 This->pidl = ILClone(pidl);
397 return S_OK;
400 static HRESULT WINAPI IPersistFolder2_Printers_fnGetCurFolder(IPersistFolder2 *iface, LPITEMIDLIST *pidl)
402 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
404 TRACE("(%p)->(%p)\n", This, pidl);
406 *pidl = ILClone(This->pidl);
408 return *pidl ? S_OK : S_FALSE;
411 static const IPersistFolder2Vtbl vtbl_PersistFolder2 =
413 IPersistFolder2_Printers_fnQueryInterface,
414 IPersistFolder2_Printers_fnAddRef,
415 IPersistFolder2_Printers_fnRelease,
416 IPersistFolder2_Printers_fnGetClassID,
417 IPersistFolder2_Printers_fnInitialize,
418 IPersistFolder2_Printers_fnGetCurFolder
421 HRESULT WINAPI Printers_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
423 IPrintersFolderImpl *sf;
425 TRACE("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
427 if (!ppv)
428 return E_POINTER;
429 if (pUnkOuter)
430 return CLASS_E_NOAGGREGATION;
432 sf = LocalAlloc(LMEM_FIXED, sizeof(IPrintersFolderImpl));
433 if (!sf)
434 return E_OUTOFMEMORY;
436 sf->ref = 0;
437 sf->pidl = NULL;
438 sf->IShellFolder2_iface.lpVtbl = &vtbl_ShellFolder2;
439 sf->IPersistFolder2_iface.lpVtbl = &vtbl_PersistFolder2;
441 if (IShellFolder2_QueryInterface(&sf->IShellFolder2_iface, riid, ppv) != S_OK)
443 IShellFolder2_Release(&sf->IShellFolder2_iface);
444 return E_NOINTERFACE;
447 TRACE("--(%p)\n", sf);
448 return S_OK;