kernel32: Support extended pathnames in GetShortPathName.
[wine.git] / dlls / shell32 / shfldr_printers.c
blobfb1b6a9467a8e810cfbe1d159f6ceb26740398f7
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 { IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 },
59 { IDS_SHV_COL_DOCS, SHCOLSTATE_TYPE_INT | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 12 },
60 { IDS_SHV_COL_STATUS, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 12 },
61 { IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30 },
62 { IDS_SHV_COL_LOCATION, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 },
63 { IDS_SHV_COL_MODEL, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20 }
66 #define PRINTERS_FOLDER_COL_NUM sizeof(printers_header)/sizeof(shvheader)
68 static HRESULT WINAPI IShellFolder_Printers_fnQueryInterface(IShellFolder2 *iface,
69 REFIID riid, LPVOID *ppvObj)
71 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
73 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
75 *ppvObj = NULL;
77 if (IsEqualIID (riid, &IID_IUnknown) ||
78 IsEqualIID (riid, &IID_IShellFolder) ||
79 IsEqualIID (riid, &IID_IShellFolder2))
81 *ppvObj = &This->IShellFolder2_iface;
83 else if (IsEqualIID (riid, &IID_IPersist) ||
84 IsEqualIID (riid, &IID_IPersistFolder) ||
85 IsEqualIID (riid, &IID_IPersistFolder2))
87 *ppvObj = &This->IPersistFolder2_iface;
90 if (*ppvObj)
92 IUnknown_AddRef ((IUnknown *) (*ppvObj));
93 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
94 return S_OK;
97 ERR ("-- interface %s not supported\n", shdebugstr_guid (riid));
98 return E_NOINTERFACE;
101 static ULONG WINAPI IShellFolder_Printers_fnAddRef (IShellFolder2 * iface)
103 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
104 ULONG refCount = InterlockedIncrement(&This->ref);
105 TRACE ("(%p)->(count=%u)\n", This, refCount - 1);
106 return refCount;
109 static ULONG WINAPI IShellFolder_Printers_fnRelease (IShellFolder2 * iface)
111 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
112 ULONG refCount = InterlockedDecrement(&This->ref);
114 TRACE ("(%p)->(count=%u)\n", This, refCount + 1);
116 if (!refCount)
118 TRACE ("-- destroying IShellFolder(%p)\n", This);
119 SHFree(This->pidl);
120 LocalFree (This);
122 return refCount;
125 static HRESULT WINAPI IShellFolder_Printers_fnParseDisplayName (IShellFolder2 *iface,
126 HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName,
127 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
129 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
131 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p) stub\n", This,
132 hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
133 pchEaten, ppidl, pdwAttributes);
135 return E_NOTIMPL;
138 static HRESULT WINAPI IShellFolder_Printers_fnEnumObjects (IShellFolder2 *iface,
139 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
141 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
142 FIXME("(%p)->(HWND=%p flags=0x%08x pplist=%p) stub\n", This,
143 hwndOwner, dwFlags, ppEnumIDList);
144 return E_NOTIMPL;
147 static HRESULT WINAPI IShellFolder_Printers_fnBindToObject (IShellFolder2 *iface,
148 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
150 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
151 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
152 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
153 return E_NOTIMPL;
156 static HRESULT WINAPI IShellFolder_Printers_fnBindToStorage (IShellFolder2 * iface,
157 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
159 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
161 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
162 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
164 *ppvOut = NULL;
165 return E_NOTIMPL;
168 static HRESULT WINAPI IShellFolder_Printers_fnCompareIDs(IShellFolder2 *iface,
169 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
171 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
172 FIXME("(%p)->(0x%08lx,pidl1=%p,pidl2=%p) stub\n", This, lParam, pidl1, pidl2);
173 return E_NOTIMPL;
176 static HRESULT WINAPI IShellFolder_Printers_fnCreateViewObject(IShellFolder2 *iface,
177 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
179 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
180 HRESULT hr = E_NOTIMPL;
182 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This,
183 hwndOwner, shdebugstr_guid (riid), ppvOut);
185 if (!ppvOut)
186 return E_INVALIDARG;
188 *ppvOut = NULL;
190 if (IsEqualIID (riid, &IID_IShellView))
192 IShellView *pShellView = IShellView_Constructor ((IShellFolder *) iface);
193 if (pShellView)
195 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
196 IShellView_Release (pShellView);
199 else
200 WARN("unsupported interface %s\n", shdebugstr_guid (riid));
202 return hr;
205 static HRESULT WINAPI IShellFolder_Printers_fnGetAttributesOf (IShellFolder2 * iface,
206 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
208 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
209 FIXME("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x)) stub\n",
210 This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
211 return E_NOTIMPL;
214 static HRESULT WINAPI IShellFolder_Printers_fnGetUIObjectOf (IShellFolder2 * iface,
215 HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid,
216 UINT * prgfInOut, LPVOID * ppvOut)
218 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
220 FIXME("(%p)->(%p,%u,apidl=%p,%s,%p,%p) stub\n", This,
221 hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
223 if (!ppvOut)
224 return E_INVALIDARG;
226 *ppvOut = NULL;
228 return E_NOTIMPL;
231 static HRESULT WINAPI IShellFolder_Printers_fnGetDisplayNameOf (IShellFolder2 *iface,
232 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
234 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
236 FIXME("(%p)->(pidl=%p,0x%08x,%p) stub\n", This, pidl, dwFlags, strRet);
238 if (!strRet)
239 return E_INVALIDARG;
241 return E_NOTIMPL;
244 static HRESULT WINAPI IShellFolder_Printers_fnSetNameOf (
245 IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,
246 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
248 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
249 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p) stub\n", This,
250 hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
251 return E_FAIL;
254 static HRESULT WINAPI IShellFolder_Printers_fnGetDefaultSearchGUID (
255 IShellFolder2 * iface, GUID * pguid)
257 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
258 FIXME ("(%p) stub\n", This);
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 (
271 IShellFolder2 *iface, DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
273 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
274 FIXME("(%p) stub\n", This);
275 return E_NOTIMPL;
278 static HRESULT WINAPI IShellFolder_Printers_fnGetDefaultColumnState (
279 IShellFolder2 *iface, UINT iColumn, DWORD *pcsFlags)
281 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
283 TRACE("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
285 if (iColumn >= PRINTERS_FOLDER_COL_NUM)
286 return E_INVALIDARG;
288 *pcsFlags = printers_header[iColumn].pcsFlags;
290 return S_OK;
293 static HRESULT WINAPI IShellFolder_Printers_fnGetDetailsEx (IShellFolder2 * iface,
294 LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
296 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
297 FIXME ("(%p) stub\n", This);
298 return E_NOTIMPL;
301 static HRESULT WINAPI IShellFolder_Printers_fnGetDetailsOf (IShellFolder2 *iface,
302 LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd)
304 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
306 TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
308 if (iColumn >= PRINTERS_FOLDER_COL_NUM)
309 return E_NOTIMPL;
311 if (!pidl)
312 return SHELL32_GetColumnDetails(printers_header, iColumn, psd);
314 FIXME("unimplemented for supplied pidl\n");
316 return E_NOTIMPL;
319 static HRESULT WINAPI IShellFolder_Printers_fnMapColumnToSCID (
320 IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
322 IPrintersFolderImpl *This = impl_from_IShellFolder2(iface);
323 FIXME ("(%p)->(%u %p) stub\n", This, column, pscid);
324 return E_NOTIMPL;
327 static const IShellFolder2Vtbl vtbl_ShellFolder2 =
329 /* IUnknown */
330 IShellFolder_Printers_fnQueryInterface,
331 IShellFolder_Printers_fnAddRef,
332 IShellFolder_Printers_fnRelease,
333 /* IShellFolder */
334 IShellFolder_Printers_fnParseDisplayName,
335 IShellFolder_Printers_fnEnumObjects,
336 IShellFolder_Printers_fnBindToObject,
337 IShellFolder_Printers_fnBindToStorage,
338 IShellFolder_Printers_fnCompareIDs,
339 IShellFolder_Printers_fnCreateViewObject,
340 IShellFolder_Printers_fnGetAttributesOf,
341 IShellFolder_Printers_fnGetUIObjectOf,
342 IShellFolder_Printers_fnGetDisplayNameOf,
343 IShellFolder_Printers_fnSetNameOf,
344 /* IShellFolder2 */
345 IShellFolder_Printers_fnGetDefaultSearchGUID,
346 IShellFolder_Printers_fnEnumSearches,
347 IShellFolder_Printers_fnGetDefaultColumn,
348 IShellFolder_Printers_fnGetDefaultColumnState,
349 IShellFolder_Printers_fnGetDetailsEx,
350 IShellFolder_Printers_fnGetDetailsOf,
351 IShellFolder_Printers_fnMapColumnToSCID
354 /*** IPersistFolder2 ***/
355 static HRESULT WINAPI IPersistFolder2_Printers_fnQueryInterface(IPersistFolder2 * iface,
356 REFIID iid, LPVOID * ppvObj)
358 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
359 return IShellFolder2_QueryInterface(&This->IShellFolder2_iface, iid, ppvObj);
362 static ULONG WINAPI IPersistFolder2_Printers_fnAddRef(IPersistFolder2 *iface)
364 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
365 return IShellFolder2_AddRef(&This->IShellFolder2_iface);
368 static ULONG WINAPI IPersistFolder2_Printers_fnRelease(IPersistFolder2 *iface)
370 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
371 return IShellFolder2_Release(&This->IShellFolder2_iface);
374 static HRESULT WINAPI IPersistFolder2_Printers_fnGetClassID(IPersistFolder2 *iface, CLSID *classId)
376 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
378 FIXME("(%p) stub\n", This);
380 if (!classId)
381 return E_POINTER;
383 return E_NOTIMPL;
386 static HRESULT WINAPI IPersistFolder2_Printers_fnInitialize(IPersistFolder2 *iface, LPCITEMIDLIST pidl)
388 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
390 TRACE("(%p)->(%p)\n", This, pidl);
392 SHFree(This->pidl);
393 This->pidl = ILClone(pidl);
395 return S_OK;
398 static HRESULT WINAPI IPersistFolder2_Printers_fnGetCurFolder(IPersistFolder2 *iface, LPITEMIDLIST *pidl)
400 IPrintersFolderImpl *This = impl_from_IPersistFolder2(iface);
402 TRACE("(%p)->(%p)\n", This, pidl);
404 *pidl = ILClone(This->pidl);
406 return *pidl ? S_OK : S_FALSE;
409 static const IPersistFolder2Vtbl vtbl_PersistFolder2 =
411 IPersistFolder2_Printers_fnQueryInterface,
412 IPersistFolder2_Printers_fnAddRef,
413 IPersistFolder2_Printers_fnRelease,
414 IPersistFolder2_Printers_fnGetClassID,
415 IPersistFolder2_Printers_fnInitialize,
416 IPersistFolder2_Printers_fnGetCurFolder
419 HRESULT WINAPI Printers_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
421 IPrintersFolderImpl *sf;
423 TRACE("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
425 if (!ppv)
426 return E_POINTER;
427 if (pUnkOuter)
428 return CLASS_E_NOAGGREGATION;
430 sf = LocalAlloc(LMEM_FIXED, sizeof(IPrintersFolderImpl));
431 if (!sf)
432 return E_OUTOFMEMORY;
434 sf->ref = 0;
435 sf->pidl = NULL;
436 sf->IShellFolder2_iface.lpVtbl = &vtbl_ShellFolder2;
437 sf->IPersistFolder2_iface.lpVtbl = &vtbl_PersistFolder2;
439 if (IShellFolder2_QueryInterface(&sf->IShellFolder2_iface, riid, ppv) != S_OK)
441 IShellFolder2_Release(&sf->IShellFolder2_iface);
442 return E_NOINTERFACE;
445 TRACE("--(%p)\n", sf);
446 return S_OK;