xcopy: Remove spaces before '\n's in the Korean translation.
[wine/hramrach.git] / dlls / shell32 / shfldr_printers.c
blob66fa571d5cc6316bcbf593ba29eb310e913c2684
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 const IShellFolder2Vtbl *lpVtbl;
43 const IPersistFolder2Vtbl *lpvtblPersistFolder2;
44 LONG ref;
46 LPITEMIDLIST pidl;
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);
72 *ppvObj = NULL;
74 if (IsEqualIID (riid, &IID_IUnknown) ||
75 IsEqualIID (riid, &IID_IShellFolder) ||
76 IsEqualIID (riid, &IID_IShellFolder2))
78 *ppvObj = This;
80 else if (IsEqualIID (riid, &IID_IPersist) ||
81 IsEqualIID (riid, &IID_IPersistFolder) ||
82 IsEqualIID (riid, &IID_IPersistFolder2))
84 *ppvObj = &This->lpvtblPersistFolder2;
87 if (*ppvObj)
89 IUnknown_AddRef ((IUnknown *) (*ppvObj));
90 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
91 return S_OK;
94 ERR ("-- interface %s not supported\n", shdebugstr_guid (riid));
95 return E_NOINTERFACE;
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);
103 return refCount;
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);
113 if (!refCount)
115 TRACE ("-- destroying IShellFolder(%p)\n", This);
116 SHFree(This->pidl);
117 LocalFree (This);
119 return refCount;
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);
132 return E_NOTIMPL;
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);
141 return E_NOTIMPL;
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);
150 return E_NOTIMPL;
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);
161 *ppvOut = NULL;
162 return E_NOTIMPL;
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);
170 return E_NOTIMPL;
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);
182 if (!ppvOut)
183 return E_INVALIDARG;
185 *ppvOut = NULL;
187 if (IsEqualIID (riid, &IID_IShellView))
189 IShellView *pShellView = IShellView_Constructor ((IShellFolder *) iface);
190 if (pShellView)
192 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
193 IShellView_Release (pShellView);
196 else
197 WARN("unsupported interface %s\n", shdebugstr_guid (riid));
199 return hr;
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);
208 return E_NOTIMPL;
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);
220 if (!ppvOut)
221 return E_INVALIDARG;
223 *ppvOut = NULL;
225 return E_NOTIMPL;
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);
235 if (!strRet)
236 return E_INVALIDARG;
238 return E_NOTIMPL;
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);
248 return E_FAIL;
251 static HRESULT WINAPI IShellFolder_Printers_fnGetDefaultSearchGUID (
252 IShellFolder2 * iface, GUID * pguid)
254 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
255 FIXME ("(%p) stub\n", This);
256 return E_NOTIMPL;
259 static HRESULT WINAPI IShellFolder_Printers_fnEnumSearches (
260 IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
262 IPrintersFolderImpl *This = (IPrintersFolderImpl *)iface;
263 FIXME ("(%p) stub\n", This);
264 return E_NOTIMPL;
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);
272 return E_NOTIMPL;
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)
283 return E_INVALIDARG;
285 *pcsFlags = printers_header[iColumn].pcsFlags;
287 return S_OK;
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);
295 return E_NOTIMPL;
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)
306 return E_NOTIMPL;
308 if (!pidl)
309 return SHELL32_GetColumnDetails(printers_header, iColumn, psd);
311 FIXME("unimplemented for supplied pidl\n");
313 return E_NOTIMPL;
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);
321 return E_NOTIMPL;
324 static const IShellFolder2Vtbl vtbl_ShellFolder2 =
326 /* IUnknown */
327 IShellFolder_Printers_fnQueryInterface,
328 IShellFolder_Printers_fnAddRef,
329 IShellFolder_Printers_fnRelease,
330 /* IShellFolder */
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,
341 /* IShellFolder2 */
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);
377 if (!classId)
378 return E_POINTER;
380 return E_NOTIMPL;
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);
389 SHFree(This->pidl);
390 This->pidl = ILClone(pidl);
392 return S_OK;
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));
422 if (!ppv)
423 return E_POINTER;
424 if (pUnkOuter)
425 return CLASS_E_NOAGGREGATION;
427 sf = LocalAlloc(LMEM_FIXED, sizeof(IPrintersFolderImpl));
428 if (!sf)
429 return E_OUTOFMEMORY;
431 sf->ref = 0;
432 sf->pidl = NULL;
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);
443 return S_OK;