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 "undocshell.h"
42 #include "shell32_main.h"
44 #include "wine/debug.h"
45 #include "wine/unicode.h"
49 WINE_DEFAULT_DEBUG_CHANNEL (shell);
51 /***********************************************************************
52 * IShellFolder implementation
56 IShellFolder2 IShellFolder2_iface;
57 IPersistFolder2 IPersistFolder2_iface;
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;
67 static inline IGenericSFImpl *impl_from_IShellFolder2(IShellFolder2 *iface)
69 return CONTAINING_RECORD(iface, IGenericSFImpl, IShellFolder2_iface);
72 static inline IGenericSFImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
74 return CONTAINING_RECORD(iface, IGenericSFImpl, IPersistFolder2_iface);
78 static const shvheader networkplaces_header[] = {
79 {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
80 {IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}
83 #define NETWORKPLACESSHELLVIEWCOLUMNS sizeof(networkplaces_header)/sizeof(shvheader)
85 /**************************************************************************
86 * ISF_NetworkPlaces_Constructor
88 HRESULT WINAPI ISF_NetworkPlaces_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
92 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
97 return CLASS_E_NOAGGREGATION;
99 sf = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (IGenericSFImpl));
101 return E_OUTOFMEMORY;
104 sf->IShellFolder2_iface.lpVtbl = &vt_ShellFolder2;
105 sf->IPersistFolder2_iface.lpVtbl = &vt_NP_PersistFolder2;
106 sf->pidlRoot = _ILCreateNetHood(); /* my qualified pidl */
108 if (FAILED (IShellFolder2_QueryInterface (&sf->IShellFolder2_iface, riid, ppv)))
110 IShellFolder2_Release (&sf->IShellFolder2_iface);
111 return E_NOINTERFACE;
114 TRACE ("--(%p)\n", sf);
118 /**************************************************************************
119 * ISF_NetworkPlaces_fnQueryInterface
122 * supports not IPersist/IPersistFolder
124 static HRESULT WINAPI ISF_NetworkPlaces_fnQueryInterface (IShellFolder2 *iface, REFIID riid, LPVOID *ppvObj)
126 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
128 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
132 if (IsEqualIID (riid, &IID_IUnknown) ||
133 IsEqualIID (riid, &IID_IShellFolder) ||
134 IsEqualIID (riid, &IID_IShellFolder2))
138 else if (IsEqualIID (riid, &IID_IPersist) ||
139 IsEqualIID (riid, &IID_IPersistFolder) ||
140 IsEqualIID (riid, &IID_IPersistFolder2))
142 *ppvObj = &This->IPersistFolder2_iface;
147 IUnknown_AddRef ((IUnknown *) (*ppvObj));
148 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
151 TRACE ("-- Interface: E_NOINTERFACE\n");
152 return E_NOINTERFACE;
155 static ULONG WINAPI ISF_NetworkPlaces_fnAddRef (IShellFolder2 * iface)
157 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
158 ULONG refCount = InterlockedIncrement(&This->ref);
160 TRACE ("(%p)->(count=%u)\n", This, refCount - 1);
165 static ULONG WINAPI ISF_NetworkPlaces_fnRelease (IShellFolder2 * iface)
167 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
168 ULONG refCount = InterlockedDecrement(&This->ref);
170 TRACE ("(%p)->(count=%u)\n", This, refCount + 1);
173 TRACE ("-- destroying IShellFolder(%p)\n", This);
174 SHFree (This->pidlRoot);
175 HeapFree (GetProcessHeap(), 0, This);
180 /**************************************************************************
181 * ISF_NetworkPlaces_fnParseDisplayName
183 static HRESULT WINAPI ISF_NetworkPlaces_fnParseDisplayName (IShellFolder2 * iface,
184 HWND hwndOwner, LPBC pbcReserved, LPOLESTR lpszDisplayName,
185 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
187 static const WCHAR wszEntireNetwork[] = {'E','n','t','i','r','e','N','e','t','w','o','r','k'}; /* not nul-terminated */
188 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
189 HRESULT hr = E_INVALIDARG;
190 LPCWSTR szNext = NULL;
191 WCHAR szElement[MAX_PATH];
192 LPITEMIDLIST pidlTemp = NULL;
195 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This,
196 hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName),
197 pchEaten, ppidl, pdwAttributes);
201 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
202 len = strlenW(szElement);
203 if (len == sizeof(wszEntireNetwork)/sizeof(wszEntireNetwork[0]) &&
204 !strncmpiW(szElement, wszEntireNetwork, sizeof(wszEntireNetwork)/sizeof(wszEntireNetwork[0])))
206 pidlTemp = _ILCreateEntireNetwork();
213 FIXME("not implemented for %s\n", debugstr_w(lpszDisplayName));
215 if (SUCCEEDED(hr) && pidlTemp)
217 if (szNext && *szNext)
219 hr = SHELL32_ParseNextElement(iface, hwndOwner, pbcReserved,
220 &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
224 if (pdwAttributes && *pdwAttributes)
225 hr = SHELL32_GetItemAttributes((IShellFolder *)&This->IShellFolder2_iface, pidlTemp,
235 TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr);
240 /**************************************************************************
241 * ISF_NetworkPlaces_fnEnumObjects
243 static HRESULT WINAPI ISF_NetworkPlaces_fnEnumObjects (IShellFolder2 * iface,
244 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
246 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
247 IEnumIDListImpl *list;
249 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This,
250 hwndOwner, dwFlags, ppEnumIDList);
252 if (!(list = IEnumIDList_Constructor()))
253 return E_OUTOFMEMORY;
254 *ppEnumIDList = &list->IEnumIDList_iface;
256 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
261 /**************************************************************************
262 * ISF_NetworkPlaces_fnBindToObject
264 static HRESULT WINAPI ISF_NetworkPlaces_fnBindToObject (IShellFolder2 * iface,
265 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
267 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
269 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This,
270 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
272 return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut);
275 /**************************************************************************
276 * ISF_NetworkPlaces_fnBindToStorage
278 static HRESULT WINAPI ISF_NetworkPlaces_fnBindToStorage (IShellFolder2 * iface,
279 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
281 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
283 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
284 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
290 /**************************************************************************
291 * ISF_NetworkPlaces_fnCompareIDs
294 static HRESULT WINAPI ISF_NetworkPlaces_fnCompareIDs (IShellFolder2 * iface,
295 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
297 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
300 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
301 nReturn = SHELL32_CompareIDs ((IShellFolder *)&This->IShellFolder2_iface, lParam, pidl1, pidl2);
302 TRACE ("-- %i\n", nReturn);
306 /**************************************************************************
307 * ISF_NetworkPlaces_fnCreateViewObject
309 static HRESULT WINAPI ISF_NetworkPlaces_fnCreateViewObject (IShellFolder2 * iface,
310 HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
312 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
313 LPSHELLVIEW pShellView;
314 HRESULT hr = E_INVALIDARG;
316 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This,
317 hwndOwner, shdebugstr_guid (riid), ppvOut);
324 if (IsEqualIID (riid, &IID_IDropTarget))
326 WARN ("IDropTarget not implemented\n");
329 else if (IsEqualIID (riid, &IID_IContextMenu))
331 WARN ("IContextMenu not implemented\n");
334 else if (IsEqualIID (riid, &IID_IShellView))
336 pShellView = IShellView_Constructor ((IShellFolder *) iface);
339 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
340 IShellView_Release (pShellView);
343 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
347 /**************************************************************************
348 * ISF_NetworkPlaces_fnGetAttributesOf
350 static HRESULT WINAPI ISF_NetworkPlaces_fnGetAttributesOf (IShellFolder2 * iface,
351 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
353 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
356 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", This,
357 cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
369 IShellFolder *psfParent = NULL;
370 LPCITEMIDLIST rpidl = NULL;
372 hr = SHBindToParent(This->pidlRoot, &IID_IShellFolder, (void**)&psfParent, &rpidl);
375 SHELL32_GetItemAttributes (psfParent, rpidl, rgfInOut);
376 IShellFolder_Release(psfParent);
381 while (cidl > 0 && *apidl)
384 SHELL32_GetItemAttributes ((IShellFolder *)&This->IShellFolder2_iface, *apidl, rgfInOut);
390 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
391 *rgfInOut &= ~SFGAO_VALIDATE;
393 TRACE ("-- result=0x%08x\n", *rgfInOut);
397 /**************************************************************************
398 * ISF_NetworkPlaces_fnGetUIObjectOf
401 * hwndOwner [in] Parent window for any output
402 * cidl [in] array size
403 * apidl [in] simple pidl array
404 * riid [in] Requested Interface
405 * prgfInOut [ ] reserved
406 * ppvObject [out] Resulting Interface
409 static HRESULT WINAPI ISF_NetworkPlaces_fnGetUIObjectOf (IShellFolder2 * iface,
410 HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid,
411 UINT * prgfInOut, LPVOID * ppvOut)
413 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
416 IUnknown *pObj = NULL;
417 HRESULT hr = E_INVALIDARG;
419 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This,
420 hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
427 if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1))
429 pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
432 else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
434 pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
437 else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
439 pidl = ILCombine (This->pidlRoot, apidl[0]);
440 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
444 else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
446 pidl = ILCombine (This->pidlRoot, apidl[0]);
447 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
451 else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
453 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
458 if (SUCCEEDED(hr) && !pObj)
462 TRACE ("(%p)->hr=0x%08x\n", This, hr);
466 /**************************************************************************
467 * ISF_NetworkPlaces_fnGetDisplayNameOf
470 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDisplayNameOf (IShellFolder2 * iface,
471 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
473 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
475 FIXME ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
484 /**************************************************************************
485 * ISF_NetworkPlaces_fnSetNameOf
486 * Changes the name of a file object or subfolder, possibly changing its item
487 * identifier in the process.
490 * hwndOwner [in] Owner window for output
491 * pidl [in] simple pidl of item to change
492 * lpszName [in] the items new display name
493 * dwFlags [in] SHGNO formatting flags
494 * ppidlOut [out] simple pidl returned
496 static HRESULT WINAPI ISF_NetworkPlaces_fnSetNameOf (IShellFolder2 * iface,
497 HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
498 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
500 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
502 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This,
503 hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
507 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultSearchGUID (
508 IShellFolder2 * iface, GUID * pguid)
510 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
512 FIXME ("(%p)\n", This);
516 static HRESULT WINAPI ISF_NetworkPlaces_fnEnumSearches (IShellFolder2 * iface,
517 IEnumExtraSearch ** ppenum)
519 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
521 FIXME ("(%p)\n", This);
525 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultColumn (IShellFolder2 * iface,
526 DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
528 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
530 TRACE ("(%p)\n", This);
540 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultColumnState (
541 IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
543 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
545 TRACE ("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
547 if (!pcsFlags || iColumn >= NETWORKPLACESSHELLVIEWCOLUMNS)
550 *pcsFlags = networkplaces_header[iColumn].pcsFlags;
555 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDetailsEx (IShellFolder2 * iface,
556 LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
558 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
560 FIXME ("(%p)\n", This);
564 static HRESULT WINAPI ISF_NetworkPlaces_fnGetDetailsOf (IShellFolder2 * iface,
565 LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
567 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
569 FIXME ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
574 static HRESULT WINAPI ISF_NetworkPlaces_fnMapColumnToSCID (IShellFolder2 * iface,
575 UINT column, SHCOLUMNID * pscid)
577 IGenericSFImpl *This = impl_from_IShellFolder2(iface);
579 FIXME ("(%p)\n", This);
584 static const IShellFolder2Vtbl vt_ShellFolder2 = {
585 ISF_NetworkPlaces_fnQueryInterface,
586 ISF_NetworkPlaces_fnAddRef,
587 ISF_NetworkPlaces_fnRelease,
588 ISF_NetworkPlaces_fnParseDisplayName,
589 ISF_NetworkPlaces_fnEnumObjects,
590 ISF_NetworkPlaces_fnBindToObject,
591 ISF_NetworkPlaces_fnBindToStorage,
592 ISF_NetworkPlaces_fnCompareIDs,
593 ISF_NetworkPlaces_fnCreateViewObject,
594 ISF_NetworkPlaces_fnGetAttributesOf,
595 ISF_NetworkPlaces_fnGetUIObjectOf,
596 ISF_NetworkPlaces_fnGetDisplayNameOf,
597 ISF_NetworkPlaces_fnSetNameOf,
599 ISF_NetworkPlaces_fnGetDefaultSearchGUID,
600 ISF_NetworkPlaces_fnEnumSearches,
601 ISF_NetworkPlaces_fnGetDefaultColumn,
602 ISF_NetworkPlaces_fnGetDefaultColumnState,
603 ISF_NetworkPlaces_fnGetDetailsEx,
604 ISF_NetworkPlaces_fnGetDetailsOf,
605 ISF_NetworkPlaces_fnMapColumnToSCID
608 /************************************************************************
609 * INPFldr_PersistFolder2_QueryInterface
611 static HRESULT WINAPI INPFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface,
612 REFIID iid, LPVOID * ppvObj)
614 IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
616 TRACE ("(%p)\n", This);
618 return IShellFolder2_QueryInterface (&This->IShellFolder2_iface, iid, ppvObj);
621 /************************************************************************
622 * INPFldr_PersistFolder2_AddRef
624 static ULONG WINAPI INPFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
626 IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
628 TRACE ("(%p)->(count=%u)\n", This, This->ref);
630 return IShellFolder2_AddRef (&This->IShellFolder2_iface);
633 /************************************************************************
634 * ISFPersistFolder_Release
636 static ULONG WINAPI INPFldr_PersistFolder2_Release (IPersistFolder2 * iface)
638 IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
640 TRACE ("(%p)->(count=%u)\n", This, This->ref);
642 return IShellFolder2_Release (&This->IShellFolder2_iface);
645 /************************************************************************
646 * INPFldr_PersistFolder2_GetClassID
648 static HRESULT WINAPI INPFldr_PersistFolder2_GetClassID (
649 IPersistFolder2 * iface, CLSID * lpClassId)
651 IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
653 TRACE ("(%p)\n", This);
658 *lpClassId = CLSID_NetworkPlaces;
663 /************************************************************************
664 * INPFldr_PersistFolder2_Initialize
666 * NOTES: it makes no sense to change the pidl
668 static HRESULT WINAPI INPFldr_PersistFolder2_Initialize (
669 IPersistFolder2 * iface, LPCITEMIDLIST pidl)
671 IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
673 TRACE ("(%p)->(%p)\n", This, pidl);
678 /**************************************************************************
679 * IPersistFolder2_fnGetCurFolder
681 static HRESULT WINAPI INPFldr_PersistFolder2_GetCurFolder (
682 IPersistFolder2 * iface, LPITEMIDLIST * pidl)
684 IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
686 TRACE ("(%p)->(%p)\n", This, pidl);
691 *pidl = ILClone (This->pidlRoot);
696 static const IPersistFolder2Vtbl vt_NP_PersistFolder2 =
698 INPFldr_PersistFolder2_QueryInterface,
699 INPFldr_PersistFolder2_AddRef,
700 INPFldr_PersistFolder2_Release,
701 INPFldr_PersistFolder2_GetClassID,
702 INPFldr_PersistFolder2_Initialize,
703 INPFldr_PersistFolder2_GetCurFolder