3 * Virtual MyDocuments Folder
5 * Copyright 2007 Johannes Anderwald
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 WINE_DEFAULT_DEBUG_CHANNEL (mydocs
);
26 /***********************************************************************
27 * MyDocumentsfolder implementation
31 const IShellFolder2Vtbl
*lpVtbl
;
32 const IPersistFolder2Vtbl
*lpPF2
;
35 /* both paths are parsible from the MyDocuments */
36 LPWSTR sPathTarget
; /* complete path to target used for enumeration and ChangeNotify */
37 LPITEMIDLIST pidlRoot
; /* absolute pidl */
39 UINT cfShellIDList
; /* clipboardformat for IDropTarget */
40 BOOL fAcceptFmt
; /* flag for pending Drop */
41 } IGenericSFImpl
, *LPIGenericSFImpl
;
43 #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
44 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
46 static const shvheader MyDocumentsSFHeader
[] = {
47 {IDS_SHV_COLUMN1
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
48 {IDS_SHV_COLUMN2
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
49 {IDS_SHV_COLUMN3
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
50 {IDS_SHV_COLUMN4
, SHCOLSTATE_TYPE_DATE
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 12},
51 {IDS_SHV_COLUMN5
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 5}
54 #define MYDOCUMENTSSHELLVIEWCOLUMNS 5
56 /**************************************************************************
57 * ISF_MyDocuments_fnQueryInterface
59 * NOTES supports not IPersist/IPersistFolder
61 static HRESULT WINAPI
ISF_MyDocuments_fnQueryInterface(
62 IShellFolder2
* iface
, REFIID riid
, LPVOID
* ppvObj
)
64 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
66 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
70 if (IsEqualIID (riid
, &IID_IUnknown
) ||
71 IsEqualIID (riid
, &IID_IShellFolder
) ||
72 IsEqualIID (riid
, &IID_IShellFolder2
))
76 else if (IsEqualIID (riid
, &IID_IPersistFolder
) ||
77 IsEqualIID (riid
, &IID_IPersistFolder2
))
79 *ppvObj
= (void *)&This
->lpPF2
;
83 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
84 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj
, *ppvObj
);
87 TRACE ("-- Interface: E_NOINTERFACE\n");
91 static ULONG WINAPI
ISF_MyDocuments_fnAddRef (IShellFolder2
* iface
)
93 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
94 ULONG refCount
= InterlockedIncrement(&This
->ref
);
96 TRACE ("(%p)->(count=%u)\n", This
, refCount
- 1);
101 static ULONG WINAPI
ISF_MyDocuments_fnRelease (IShellFolder2
* iface
)
103 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
104 ULONG refCount
= InterlockedDecrement(&This
->ref
);
106 TRACE ("(%p)->(count=%u)\n", This
, refCount
+ 1);
110 TRACE ("-- destroying IShellFolder(%p)\n", This
);
111 SHFree (This
->pidlRoot
);
112 HeapFree(GetProcessHeap(), 0, This
->sPathTarget
);
113 HeapFree(GetProcessHeap(), 0, This
);
120 WINAPI
ISF_MyDocuments_fnParseDisplayName (IShellFolder2
* iface
,
121 HWND hwndOwner
, LPBC pbc
, LPOLESTR lpszDisplayName
,
122 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
124 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
125 WCHAR szElement
[MAX_PATH
];
126 LPCWSTR szNext
= NULL
;
127 LPITEMIDLIST pidlTemp
= NULL
;
131 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
132 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
),
133 pchEaten
, ppidl
, pdwAttributes
);
135 if (!lpszDisplayName
|| !ppidl
)
141 *pchEaten
= 0; /* strange but like the original */
143 if (lpszDisplayName
[0] == ':' && lpszDisplayName
[1] == ':')
145 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
146 TRACE ("-- element: %s\n", debugstr_w (szElement
));
147 CLSIDFromString (szElement
+ 2, &clsid
);
148 pidlTemp
= _ILCreateGuid (PT_GUID
, &clsid
);
150 else if( (pidlTemp
= SHELL32_CreatePidlFromBindCtx(pbc
, lpszDisplayName
)) )
157 /* it's a filesystem path on the desktop. Let a FSFolder parse it */
159 if (*lpszDisplayName
)
161 WCHAR szPath
[MAX_PATH
];
164 /* build a complete path to create a simple pidl */
165 lstrcpynW(szPath
, This
->sPathTarget
, MAX_PATH
);
166 pathPtr
= PathAddBackslashW(szPath
);
169 lstrcpynW(pathPtr
, lpszDisplayName
, MAX_PATH
- (pathPtr
- szPath
));
170 hr
= _ILCreateFromPathW(szPath
, &pidlTemp
);
174 /* should never reach here, but for completeness */
175 hr
= HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
);
179 pidlTemp
= _ILCreateMyDocuments();
184 if (SUCCEEDED(hr
) && pidlTemp
)
186 if (szNext
&& *szNext
)
188 hr
= SHELL32_ParseNextElement(iface
, hwndOwner
, pbc
,
189 &pidlTemp
, (LPOLESTR
) szNext
, pchEaten
, pdwAttributes
);
193 if (pdwAttributes
&& *pdwAttributes
)
194 hr
= SHELL32_GetItemAttributes(_IShellFolder_ (This
),
195 pidlTemp
, pdwAttributes
);
201 TRACE ("(%p)->(-- ret=0x%08x)\n", This
, hr
);
206 /**************************************************************************
207 * CreateMyDocumentsEnumList()
209 static BOOL
CreateMyDocumentsEnumList(IEnumIDList
*list
, DWORD dwFlags
)
212 WCHAR szPath
[MAX_PATH
] = {0};
214 TRACE("(%p)->(flags=0x%08x)\n", list
, dwFlags
);
216 /* enumerate the elements in %windir%\desktop */
217 ret
= SHGetSpecialFolderPathW(0, szPath
, CSIDL_PERSONAL
, FALSE
);
218 ret
= ret
&& CreateFolderEnumList(list
, szPath
, dwFlags
);
223 /**************************************************************************
224 * ISF_MyDocuments_fnEnumObjects
226 static HRESULT WINAPI
ISF_MyDocuments_fnEnumObjects (IShellFolder2
* iface
,
227 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
229 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
231 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n",
232 This
, hwndOwner
, dwFlags
, ppEnumIDList
);
234 *ppEnumIDList
= IEnumIDList_Constructor();
236 CreateMyDocumentsEnumList(*ppEnumIDList
, dwFlags
);
238 TRACE ("-- (%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
240 return *ppEnumIDList
? S_OK
: E_OUTOFMEMORY
;
243 /**************************************************************************
244 * ISF_MyDocuments_fnBindToObject
246 static HRESULT WINAPI
ISF_MyDocuments_fnBindToObject (IShellFolder2
* iface
,
247 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
249 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
251 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
252 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
254 return SHELL32_BindToChild( This
->pidlRoot
, This
->sPathTarget
, pidl
, riid
, ppvOut
);
257 /**************************************************************************
258 * ISF_MyDocuments_fnBindToStorage
263 ISF_MyDocuments_fnBindToStorage (IShellFolder2
* iface
,
264 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
266 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
268 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
269 This
, pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
275 /**************************************************************************
276 * ISF_MyDocuments_fnCompareIDs
278 static HRESULT WINAPI
ISF_MyDocuments_fnCompareIDs (IShellFolder2
* iface
,
279 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
281 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
284 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
285 nReturn
= SHELL32_CompareIDs (_IShellFolder_ (This
), lParam
, pidl1
, pidl2
);
286 TRACE ("-- %i\n", nReturn
);
290 /**************************************************************************
291 * ISF_MyDocuments_fnCreateViewObject
293 static HRESULT WINAPI
ISF_MyDocuments_fnCreateViewObject (IShellFolder2
* iface
,
294 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
296 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
297 LPSHELLVIEW pShellView
;
298 HRESULT hr
= E_INVALIDARG
;
300 TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
301 This
, hwndOwner
, shdebugstr_guid (riid
), ppvOut
);
308 if (IsEqualIID (riid
, &IID_IDropTarget
))
310 WARN ("IDropTarget not implemented\n");
313 else if (IsEqualIID (riid
, &IID_IContextMenu
))
315 WARN ("IContextMenu not implemented\n");
318 else if (IsEqualIID (riid
, &IID_IShellView
))
320 pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
323 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
324 IShellView_Release (pShellView
);
327 TRACE ("-- (%p)->(interface=%p)\n", This
, ppvOut
);
331 /**************************************************************************
332 * ISF_MyDocuments_fnGetAttributesOf
334 static HRESULT WINAPI
ISF_MyDocuments_fnGetAttributesOf (IShellFolder2
* iface
,
335 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
337 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
339 static const DWORD dwMyDocumentsAttributes
=
340 SFGAO_STORAGE
| SFGAO_HASPROPSHEET
| SFGAO_STORAGEANCESTOR
| SFGAO_CANCOPY
|
341 SFGAO_FILESYSANCESTOR
| SFGAO_FOLDER
| SFGAO_FILESYSTEM
| SFGAO_HASSUBFOLDER
| SFGAO_CANRENAME
| SFGAO_CANDELETE
;
343 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
344 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
355 *rgfInOut
&= dwMyDocumentsAttributes
;
357 while (cidl
> 0 && *apidl
) {
359 if (_ILIsMyDocuments(*apidl
)) {
360 *rgfInOut
&= dwMyDocumentsAttributes
;
362 SHELL32_GetItemAttributes (_IShellFolder_ (This
), *apidl
, rgfInOut
);
368 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
369 *rgfInOut
&= ~SFGAO_VALIDATE
;
371 TRACE ("-- result=0x%08x\n", *rgfInOut
);
376 /**************************************************************************
377 * ISF_MyDocuments_fnGetUIObjectOf
380 * HWND hwndOwner, //[in ] Parent window for any output
381 * UINT cidl, //[in ] array size
382 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
383 * REFIID riid, //[in ] Requested Interface
384 * UINT* prgfInOut, //[ ] reserved
385 * LPVOID* ppvObject) //[out] Resulting Interface
388 static HRESULT WINAPI
ISF_MyDocuments_fnGetUIObjectOf (IShellFolder2
* iface
,
389 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
,
390 REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
392 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
395 IUnknown
*pObj
= NULL
;
396 HRESULT hr
= E_INVALIDARG
;
398 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
399 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
406 if (IsEqualIID (riid
, &IID_IContextMenu
))
408 hr
= CDefFolderMenu_Create2(This
->pidlRoot
, hwndOwner
, cidl
, apidl
, (IShellFolder
*)iface
, NULL
, 0, NULL
, (IContextMenu
**)&pObj
);
410 else if (IsEqualIID (riid
, &IID_IDataObject
) && (cidl
>= 1))
412 pObj
= (LPUNKNOWN
) IDataObject_Constructor( hwndOwner
,
413 This
->pidlRoot
, apidl
, cidl
);
416 else if (IsEqualIID (riid
, &IID_IExtractIconA
) && (cidl
== 1))
418 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
419 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
423 else if (IsEqualIID (riid
, &IID_IExtractIconW
) && (cidl
== 1))
425 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
426 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
430 else if (IsEqualIID (riid
, &IID_IDropTarget
) && (cidl
>= 1))
432 hr
= IShellFolder_QueryInterface (iface
,
433 &IID_IDropTarget
, (LPVOID
*) & pObj
);
435 else if ((IsEqualIID(riid
,&IID_IShellLinkW
) ||
436 IsEqualIID(riid
,&IID_IShellLinkA
)) && (cidl
== 1))
438 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
439 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, (LPVOID
*)&pObj
);
445 if (SUCCEEDED(hr
) && !pObj
)
449 TRACE ("(%p)->hr=0x%08x\n", This
, hr
);
455 WINAPI
ISF_MyDocuments_fnGetDisplayNameOf (IShellFolder2
* iface
,
456 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
458 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
462 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This
, pidl
, dwFlags
, strRet
);
468 pszPath
= CoTaskMemAlloc((MAX_PATH
+1) * sizeof(WCHAR
));
470 return E_OUTOFMEMORY
;
472 ZeroMemory(pszPath
, (MAX_PATH
+1) * sizeof(WCHAR
));
474 if (_ILIsMyDocuments (pidl
))
476 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
477 (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
))
478 wcscpy(pszPath
, This
->sPathTarget
);
480 HCR_GetClassNameW(&CLSID_MyDocuments
, pszPath
, MAX_PATH
);
483 else if (_ILIsPidlSimple (pidl
))
487 if ((clsid
= _ILGetGUIDPointer (pidl
)))
489 if (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
)
491 int bWantsForParsing
;
494 * We can only get a filesystem path from a shellfolder if the
495 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
497 * Exception: The MyComputer folder doesn't have this key,
498 * but any other filesystem backed folder it needs it.
500 if (IsEqualIID (clsid
, &CLSID_MyDocuments
))
502 bWantsForParsing
= TRUE
;
506 /* get the "WantsFORPARSING" flag from the registry */
507 static const WCHAR clsidW
[] =
508 { 'C','L','S','I','D','\\',0 };
509 static const WCHAR shellfolderW
[] =
510 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
511 static const WCHAR wantsForParsingW
[] =
512 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
514 WCHAR szRegPath
[100];
517 wcscpy (szRegPath
, clsidW
);
518 SHELL32_GUIDToStringW (clsid
, &szRegPath
[6]);
519 wcscat (szRegPath
, shellfolderW
);
520 r
= SHGetValueW(HKEY_CLASSES_ROOT
, szRegPath
,
521 wantsForParsingW
, NULL
, NULL
, NULL
);
522 if (r
== ERROR_SUCCESS
)
523 bWantsForParsing
= TRUE
;
525 bWantsForParsing
= FALSE
;
528 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
532 * we need the filesystem path to the destination folder.
533 * Only the folder itself can know it
535 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
542 /* parsing name like ::{...} */
545 SHELL32_GUIDToStringW (clsid
, &pszPath
[2]);
551 /* user friendly name */
552 HCR_GetClassNameW (clsid
, pszPath
, MAX_PATH
);
560 /* file system folder or file rooted at the desktop */
561 if ((GET_SHGDN_FOR(dwFlags
) == SHGDN_FORPARSING
) &&
562 (GET_SHGDN_RELATION(dwFlags
) != SHGDN_INFOLDER
))
564 lstrcpynW(pszPath
, This
->sPathTarget
, MAX_PATH
- 1);
565 TRACE("CP %s\n", debugstr_w(pszPath
));
568 if (!_ILIsDesktop(pidl
))
570 PathAddBackslashW(pszPath
);
571 cLen
= wcslen(pszPath
);
572 _ILSimpleGetTextW(pidl
, pszPath
+ cLen
, MAX_PATH
- cLen
);
573 if (!_ILIsFolder(pidl
))
575 SHELL_FS_ProcessDisplayFilename(pszPath
, dwFlags
);
583 /* a complex pidl, let the subfolder do the work */
584 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
, dwFlags
,
591 strRet
->uType
= STRRET_WSTR
;
592 strRet
->u
.pOleStr
= pszPath
;
595 CoTaskMemFree(pszPath
);
597 TRACE ("-- (%p)->(%s,0x%08x)\n", This
, debugstr_w(strRet
->u
.pOleStr
), hr
);
601 static HRESULT WINAPI
ISF_MyDocuments_fnSetNameOf (IShellFolder2
* iface
,
602 HWND hwndOwner
, LPCITEMIDLIST pidl
, /* simple pidl */
603 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
605 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
607 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This
, hwndOwner
, pidl
,
608 debugstr_w (lpName
), dwFlags
, pPidlOut
);
613 static HRESULT WINAPI
ISF_MyDocuments_fnGetDefaultSearchGUID(IShellFolder2
*iface
,
616 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
618 FIXME ("(%p)\n", This
);
622 static HRESULT WINAPI
ISF_MyDocuments_fnEnumSearches (IShellFolder2
*iface
,
623 IEnumExtraSearch
** ppenum
)
625 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
626 FIXME ("(%p)\n", This
);
633 ISF_MyDocuments_fnGetDefaultColumn (IShellFolder2
* iface
,
634 DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
636 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
638 TRACE ("(%p)\n", This
);
650 ISF_MyDocuments_fnGetDefaultColumnState (IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
652 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
654 TRACE ("(%p)\n", This
);
656 if (!pcsFlags
|| iColumn
>= MYDOCUMENTSSHELLVIEWCOLUMNS
)
659 *pcsFlags
= MyDocumentsSFHeader
[iColumn
].pcsFlags
;
667 ISF_MyDocuments_fnGetDetailsEx (IShellFolder2
* iface
, LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
669 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
670 FIXME ("(%p)\n", This
);
678 ISF_MyDocuments_fnGetDetailsOf (IShellFolder2
* iface
, LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
680 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
684 TRACE ("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
686 if (!psd
|| iColumn
>= MYDOCUMENTSSHELLVIEWCOLUMNS
)
691 psd
->fmt
= MyDocumentsSFHeader
[iColumn
].fmt
;
692 psd
->cxChar
= MyDocumentsSFHeader
[iColumn
].cxChar
;
693 psd
->str
.uType
= STRRET_CSTR
;
694 LoadStringA (shell32_hInstance
, MyDocumentsSFHeader
[iColumn
].colnameid
,
695 psd
->str
.u
.cStr
, MAX_PATH
);
699 /* the data from the pidl */
700 psd
->str
.uType
= STRRET_CSTR
;
704 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
,
705 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
708 _ILGetFileSize (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
711 _ILGetFileType (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
714 _ILGetFileDate (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
716 case 4: /* attributes */
717 _ILGetFileAttributes (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
727 ISF_MyDocuments_fnMapColumnToSCID (IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
729 IGenericSFImpl
*This
= (IGenericSFImpl
*)iface
;
730 FIXME ("(%p)\n", This
);
734 static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2
=
736 ISF_MyDocuments_fnQueryInterface
,
737 ISF_MyDocuments_fnAddRef
,
738 ISF_MyDocuments_fnRelease
,
739 ISF_MyDocuments_fnParseDisplayName
,
740 ISF_MyDocuments_fnEnumObjects
,
741 ISF_MyDocuments_fnBindToObject
,
742 ISF_MyDocuments_fnBindToStorage
,
743 ISF_MyDocuments_fnCompareIDs
,
744 ISF_MyDocuments_fnCreateViewObject
,
745 ISF_MyDocuments_fnGetAttributesOf
,
746 ISF_MyDocuments_fnGetUIObjectOf
,
747 ISF_MyDocuments_fnGetDisplayNameOf
,
748 ISF_MyDocuments_fnSetNameOf
,
750 ISF_MyDocuments_fnGetDefaultSearchGUID
,
751 ISF_MyDocuments_fnEnumSearches
,
752 ISF_MyDocuments_fnGetDefaultColumn
,
753 ISF_MyDocuments_fnGetDefaultColumnState
,
754 ISF_MyDocuments_fnGetDetailsEx
,
755 ISF_MyDocuments_fnGetDetailsOf
,
756 ISF_MyDocuments_fnMapColumnToSCID
759 static LPIGenericSFImpl __inline
impl_from_IPersistFolder2( IPersistFolder2
*iface
)
761 return (LPIGenericSFImpl
)((char*)iface
- FIELD_OFFSET(IGenericSFImpl
, lpPF2
));
764 static HRESULT WINAPI
765 ISF_MyDocuments_PersistFolder2_fnQueryInterface (IPersistFolder2
* iface
, REFIID iid
, LPVOID
* ppvObj
)
767 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
769 TRACE ("(%p)\n", This
);
771 return ISF_MyDocuments_fnQueryInterface ((IShellFolder2
*)This
, iid
, ppvObj
);
775 ISF_MyDocuments_PersistFolder2_fnAddRef (IPersistFolder2
* iface
)
777 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
779 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
781 return ISF_MyDocuments_fnAddRef((IShellFolder2
*)This
);
785 ISF_MyDocuments_PersistFolder2_fnRelease (IPersistFolder2
* iface
)
787 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
789 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
791 return ISF_MyDocuments_fnRelease ((IShellFolder2
*)This
);
794 static HRESULT WINAPI
795 ISF_MyDocuments_PersistFolder2_fnGetClassID (IPersistFolder2
* iface
, CLSID
* lpClassId
)
797 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
799 static GUID
const CLSID_MyDocuments
=
800 { 0x450d8fba, 0xad25, 0x11d0, {0x98,0xa8,0x08,0x00,0x36,0x1b,0x11,0x03} };
802 TRACE ("(%p)\n", This
);
807 memcpy(lpClassId
, &CLSID_MyDocuments
, sizeof(GUID
));
811 static HRESULT WINAPI
812 ISF_MyDocuments_PersistFolder2_fnInitialize (IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
814 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
816 TRACE ("(%p)->(%p)\n", This
, pidl
);
821 static HRESULT WINAPI
822 ISF_MyDocuments_PersistFolder2_fnGetCurFolder (IPersistFolder2
* iface
,
825 IGenericSFImpl
*This
= impl_from_IPersistFolder2(iface
);
827 TRACE ("(%p)->(%p)\n", This
, pidl
);
829 if (!pidl
) return E_POINTER
;
830 *pidl
= ILClone (This
->pidlRoot
);
834 static const IPersistFolder2Vtbl vt_FSFldr_PersistFolder2
=
836 ISF_MyDocuments_PersistFolder2_fnQueryInterface
,
837 ISF_MyDocuments_PersistFolder2_fnAddRef
,
838 ISF_MyDocuments_PersistFolder2_fnRelease
,
839 ISF_MyDocuments_PersistFolder2_fnGetClassID
,
840 ISF_MyDocuments_PersistFolder2_fnInitialize
,
841 ISF_MyDocuments_PersistFolder2_fnGetCurFolder
,
845 /**************************************************************************
846 * ISF_MyDocuments_Constructor
848 HRESULT WINAPI
ISF_MyDocuments_Constructor (
849 IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
851 static IGenericSFImpl
*cached_sf
;
852 WCHAR szMyPath
[MAX_PATH
];
854 TRACE ("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
859 return CLASS_E_NOAGGREGATION
;
865 if (!SHGetSpecialFolderPathW( 0, szMyPath
, CSIDL_PERSONAL
, TRUE
))
868 sf
= LocalAlloc( LMEM_ZEROINIT
, sizeof (IGenericSFImpl
) );
870 return E_OUTOFMEMORY
;
873 sf
->lpVtbl
= &vt_MCFldr_ShellFolder2
;
874 sf
->lpPF2
= &vt_FSFldr_PersistFolder2
;
875 sf
->pidlRoot
= _ILCreateMyDocuments(); /* my qualified pidl */
876 sf
->sPathTarget
= SHAlloc( (wcslen(szMyPath
) + 1)*sizeof(WCHAR
) );
877 wcscpy( sf
->sPathTarget
, szMyPath
);
879 if (InterlockedCompareExchangePointer((void *)&cached_sf
, sf
, NULL
) != NULL
)
881 /* some other thread already been here */
882 SHFree( sf
->pidlRoot
);
883 SHFree( sf
->sPathTarget
);
888 return IUnknown_QueryInterface( _IUnknown_(cached_sf
), riid
, ppv
);