2 * Network Places (Neighbourhood) folder
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998, 1999, 2002 Juergen Schmied
6 * Copyright 2003 Mike McCormack for CodeWeavers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/port.h"
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
41 #include "enumidlist.h"
42 #include "undocshell.h"
43 #include "shell32_main.h"
45 #include "wine/debug.h"
49 WINE_DEFAULT_DEBUG_CHANNEL (shell);
51 /***********************************************************************
52 * IShellFolder implementation
56 const IShellFolder2Vtbl *lpVtbl;
58 const IPersistFolder2Vtbl *lpVtblPersistFolder2;
60 /* both paths are parsible from the desktop */
61 LPITEMIDLIST pidlRoot; /* absolute pidl */
64 static const IShellFolder2Vtbl vt_ShellFolder2;
65 static const IPersistFolder2Vtbl vt_NP_PersistFolder2;
68 #define _IPersistFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2)))
69 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
71 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
72 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
73 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2)
75 static shvheader NetworkPlacesSFHeader[] = {
76 {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
77 {IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}
80 #define NETWORKPLACESSHELLVIEWCOLUMNS 2
82 /**************************************************************************
83 * ISF_NetworkPlaces_Constructor
85 HRESULT WINAPI ISF_NetworkPlaces_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
89 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
94 return CLASS_E_NOAGGREGATION;
96 sf = (IGenericSFImpl *) HeapAlloc ( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (IGenericSFImpl));
101 sf->lpVtbl = &vt_ShellFolder2;
102 sf->lpVtblPersistFolder2 = &vt_NP_PersistFolder2;
103 sf->pidlRoot = _ILCreateNetHood(); /* my qualified pidl */
105 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv)))
107 IUnknown_Release (_IUnknown_ (sf));
108 return E_NOINTERFACE;
111 TRACE ("--(%p)\n", sf);
115 /**************************************************************************
116 * ISF_NetworkPlaces_fnQueryInterface
119 * supports not IPersist/IPersistFolder
121 static HRESULT WINAPI ISF_NetworkPlaces_fnQueryInterface (IShellFolder2 *iface, REFIID riid, LPVOID *ppvObj)
123 IGenericSFImpl *This = (IGenericSFImpl *)iface;
125 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
129 if (IsEqualIID (riid, &IID_IUnknown) ||
130 IsEqualIID (riid, &IID_IShellFolder) ||
131 IsEqualIID (riid, &IID_IShellFolder2))
135 else if (IsEqualIID (riid, &IID_IPersist) ||
136 IsEqualIID (riid, &IID_IPersistFolder) ||
137 IsEqualIID (riid, &IID_IPersistFolder2))
139 *ppvObj = _IPersistFolder2_ (This);
144 IUnknown_AddRef ((IUnknown *) (*ppvObj));
145 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
148 TRACE ("-- Interface: E_NOINTERFACE\n");
149 return E_NOINTERFACE;
152 static ULONG WINAPI ISF_NetworkPlaces_fnAddRef (IShellFolder2 * iface)
154 IGenericSFImpl *This = (IGenericSFImpl *)iface;
155 ULONG refCount = InterlockedIncrement(&This->ref);
157 TRACE ("(%p)->(count=%u)\n", This, refCount - 1);
162 static ULONG WINAPI ISF_NetworkPlaces_fnRelease (IShellFolder2 * iface)
164 IGenericSFImpl *This = (IGenericSFImpl *)iface;
165 ULONG refCount = InterlockedDecrement(&This->ref);
167 TRACE ("(%p)->(count=%u)\n", This, refCount + 1);
170 TRACE ("-- destroying IShellFolder(%p)\n", This);
171 SHFree (This->pidlRoot);
172 HeapFree (GetProcessHeap(), 0, This);
177 /**************************************************************************
178 * ISF_NetworkPlaces_fnParseDisplayName
180 static HRESULT WINAPI ISF_NetworkPlaces_fnParseDisplayName (IShellFolder2 * iface,
181 HWND hwndOwner, LPBC pbcReserved, LPOLESTR lpszDisplayName,
182 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
184 IGenericSFImpl *This = (IGenericSFImpl *)iface;
186 HRESULT hr = E_UNEXPECTED;
188 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This,
189 hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName),
190 pchEaten, ppidl, pdwAttributes);
194 *pchEaten = 0; /* strange but like the original */
196 TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr);
201 /**************************************************************************
202 * ISF_NetworkPlaces_fnEnumObjects
204 static HRESULT WINAPI ISF_NetworkPlaces_fnEnumObjects (IShellFolder2 * iface,
205 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
207 IGenericSFImpl *This = (IGenericSFImpl *)iface;
209 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This,
210 hwndOwner, dwFlags, ppEnumIDList);
212 *ppEnumIDList = IEnumIDList_Constructor();
214 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
216 return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
219 /**************************************************************************
220 * ISF_NetworkPlaces_fnBindToObject
222 static HRESULT WINAPI ISF_NetworkPlaces_fnBindToObject (IShellFolder2 * iface,
223 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
225 IGenericSFImpl *This = (IGenericSFImpl *)iface;
227 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This,
228 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
230 return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut);
233 /**************************************************************************
234 * ISF_NetworkPlaces_fnBindToStorage
236 static HRESULT WINAPI ISF_NetworkPlaces_fnBindToStorage (IShellFolder2 * iface,
237 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
239 IGenericSFImpl *This = (IGenericSFImpl *)iface;
241 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
242 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
248 /**************************************************************************
249 * ISF_NetworkPlaces_fnCompareIDs
252 static HRESULT WINAPI ISF_NetworkPlaces_fnCompareIDs (IShellFolder2 * iface,
253 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
255 IGenericSFImpl *This = (IGenericSFImpl *)iface;
258 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
259 nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
260 TRACE ("-- %i\n", nReturn);
264 /**************************************************************************
265 * ISF_NetworkPlaces_fnCreateViewObject
267 static HRESULT WINAPI ISF_NetworkPlaces_fnCreateViewObject (IShellFolder2 * iface,
268 HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
270 IGenericSFImpl *This = (IGenericSFImpl *)iface;
271 LPSHELLVIEW pShellView;
272 HRESULT hr = E_INVALIDARG;
274 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This,
275 hwndOwner, shdebugstr_guid (riid), ppvOut);
282 if (IsEqualIID (riid, &IID_IDropTarget))
284 WARN ("IDropTarget not implemented\n");
287 else if (IsEqualIID (riid, &IID_IContextMenu))
289 WARN ("IContextMenu not implemented\n");
292 else if (IsEqualIID (riid, &IID_IShellView))
294 pShellView = IShellView_Constructor ((IShellFolder *) iface);
297 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
298 IShellView_Release (pShellView);
301 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
305 /**************************************************************************
306 * ISF_NetworkPlaces_fnGetAttributesOf
308 static HRESULT WINAPI ISF_NetworkPlaces_fnGetAttributesOf (IShellFolder2 * iface,
309 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
311 IGenericSFImpl *This = (IGenericSFImpl *)iface;
314 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", This,
315 cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
327 IShellFolder *psfParent = NULL;
328 LPCITEMIDLIST rpidl = NULL;
330 hr = SHBindToParent(This->pidlRoot, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&rpidl);
333 SHELL32_GetItemAttributes (psfParent, rpidl, rgfInOut);
334 IShellFolder_Release(psfParent);
339 while (cidl > 0 && *apidl)
342 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
348 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
349 *rgfInOut &= ~SFGAO_VALIDATE;
351 TRACE ("-- result=0x%08x\n", *rgfInOut);
355 /**************************************************************************
356 * ISF_NetworkPlaces_fnGetUIObjectOf
359 * hwndOwner [in] Parent window for any output
360 * cidl [in] array size
361 * apidl [in] simple pidl array
362 * riid [in] Requested Interface
363 * prgfInOut [ ] reserved
364 * ppvObject [out] Resulting Interface
367 static HRESULT WINAPI ISF_NetworkPlaces_fnGetUIObjectOf (IShellFolder2 * iface,
368 HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid,
369 UINT * prgfInOut, LPVOID * ppvOut)
371 IGenericSFImpl *This = (IGenericSFImpl *)iface;
374 IUnknown *pObj = NULL;
375 HRESULT hr = E_INVALIDARG;
377 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This,
378 hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
385 if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1))
387 pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
390 else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
392 pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
395 else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
397 pidl = ILCombine (This->pidlRoot, apidl[0]);
398 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
402 else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
404 pidl = ILCombine (This->pidlRoot, apidl[0]);
405 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
409 else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
411 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
416 if (SUCCEEDED(hr) && !pObj)
420 TRACE ("(%p)->hr=0x%08x\n", This, hr);
424 /**************************************************************************
425 * ISF_NetworkPlaces_fnGetDisplayNameOf
428 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDisplayNameOf (IShellFolder2 * iface,
429 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
431 IGenericSFImpl *This = (IGenericSFImpl *)iface;
433 FIXME ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
442 /**************************************************************************
443 * ISF_NetworkPlaces_fnSetNameOf
444 * Changes the name of a file object or subfolder, possibly changing its item
445 * identifier in the process.
448 * hwndOwner [in] Owner window for output
449 * pidl [in] simple pidl of item to change
450 * lpszName [in] the items new display name
451 * dwFlags [in] SHGNO formatting flags
452 * ppidlOut [out] simple pidl returned
454 static HRESULT WINAPI ISF_NetworkPlaces_fnSetNameOf (IShellFolder2 * iface,
455 HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
456 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
458 IGenericSFImpl *This = (IGenericSFImpl *)iface;
459 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This,
460 hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
464 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultSearchGUID (
465 IShellFolder2 * iface, GUID * pguid)
467 IGenericSFImpl *This = (IGenericSFImpl *)iface;
468 FIXME ("(%p)\n", This);
472 static HRESULT WINAPI ISF_NetworkPlaces_fnEnumSearches (IShellFolder2 * iface,
473 IEnumExtraSearch ** ppenum)
475 IGenericSFImpl *This = (IGenericSFImpl *)iface;
476 FIXME ("(%p)\n", This);
480 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultColumn (IShellFolder2 * iface,
481 DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
483 IGenericSFImpl *This = (IGenericSFImpl *)iface;
485 TRACE ("(%p)\n", This);
495 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultColumnState (
496 IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
498 IGenericSFImpl *This = (IGenericSFImpl *)iface;
500 TRACE ("(%p)\n", This);
502 if (!pcsFlags || iColumn >= NETWORKPLACESSHELLVIEWCOLUMNS)
504 *pcsFlags = NetworkPlacesSFHeader[iColumn].pcsFlags;
508 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDetailsEx (IShellFolder2 * iface,
509 LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
511 IGenericSFImpl *This = (IGenericSFImpl *)iface;
512 FIXME ("(%p)\n", This);
516 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDetailsOf (IShellFolder2 * iface,
517 LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
519 IGenericSFImpl *This = (IGenericSFImpl *)iface;
521 FIXME ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
526 static HRESULT WINAPI ISF_NetworkPlaces_fnMapColumnToSCID (IShellFolder2 * iface,
527 UINT column, SHCOLUMNID * pscid)
529 IGenericSFImpl *This = (IGenericSFImpl *)iface;
531 FIXME ("(%p)\n", This);
536 static const IShellFolder2Vtbl vt_ShellFolder2 = {
537 ISF_NetworkPlaces_fnQueryInterface,
538 ISF_NetworkPlaces_fnAddRef,
539 ISF_NetworkPlaces_fnRelease,
540 ISF_NetworkPlaces_fnParseDisplayName,
541 ISF_NetworkPlaces_fnEnumObjects,
542 ISF_NetworkPlaces_fnBindToObject,
543 ISF_NetworkPlaces_fnBindToStorage,
544 ISF_NetworkPlaces_fnCompareIDs,
545 ISF_NetworkPlaces_fnCreateViewObject,
546 ISF_NetworkPlaces_fnGetAttributesOf,
547 ISF_NetworkPlaces_fnGetUIObjectOf,
548 ISF_NetworkPlaces_fnGetDisplayNameOf,
549 ISF_NetworkPlaces_fnSetNameOf,
551 ISF_NetworkPlaces_fnGetDefaultSearchGUID,
552 ISF_NetworkPlaces_fnEnumSearches,
553 ISF_NetworkPlaces_fnGetDefaultColumn,
554 ISF_NetworkPlaces_fnGetDefaultColumnState,
555 ISF_NetworkPlaces_fnGetDetailsEx,
556 ISF_NetworkPlaces_fnGetDetailsOf,
557 ISF_NetworkPlaces_fnMapColumnToSCID
560 /************************************************************************
561 * INPFldr_PersistFolder2_QueryInterface
563 static HRESULT WINAPI INPFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface,
564 REFIID iid, LPVOID * ppvObj)
566 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
568 TRACE ("(%p)\n", This);
570 return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj);
573 /************************************************************************
574 * INPFldr_PersistFolder2_AddRef
576 static ULONG WINAPI INPFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
578 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
580 TRACE ("(%p)->(count=%u)\n", This, This->ref);
582 return IUnknown_AddRef (_IUnknown_ (This));
585 /************************************************************************
586 * ISFPersistFolder_Release
588 static ULONG WINAPI INPFldr_PersistFolder2_Release (IPersistFolder2 * iface)
590 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
592 TRACE ("(%p)->(count=%u)\n", This, This->ref);
594 return IUnknown_Release (_IUnknown_ (This));
597 /************************************************************************
598 * INPFldr_PersistFolder2_GetClassID
600 static HRESULT WINAPI INPFldr_PersistFolder2_GetClassID (
601 IPersistFolder2 * iface, CLSID * lpClassId)
603 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
605 TRACE ("(%p)\n", This);
610 *lpClassId = CLSID_NetworkPlaces;
615 /************************************************************************
616 * INPFldr_PersistFolder2_Initialize
618 * NOTES: it makes no sense to change the pidl
620 static HRESULT WINAPI INPFldr_PersistFolder2_Initialize (
621 IPersistFolder2 * iface, LPCITEMIDLIST pidl)
623 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
625 TRACE ("(%p)->(%p)\n", This, pidl);
630 /**************************************************************************
631 * IPersistFolder2_fnGetCurFolder
633 static HRESULT WINAPI INPFldr_PersistFolder2_GetCurFolder (
634 IPersistFolder2 * iface, LPITEMIDLIST * pidl)
636 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
638 TRACE ("(%p)->(%p)\n", This, pidl);
643 *pidl = ILClone (This->pidlRoot);
648 static const IPersistFolder2Vtbl vt_NP_PersistFolder2 =
650 INPFldr_PersistFolder2_QueryInterface,
651 INPFldr_PersistFolder2_AddRef,
652 INPFldr_PersistFolder2_Release,
653 INPFldr_PersistFolder2_GetClassID,
654 INPFldr_PersistFolder2_Initialize,
655 INPFldr_PersistFolder2_GetCurFolder