Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

558 lines
27 KiB

  1. #include "fstreex.h" // public stuff
  2. #include "filetbl.h"
  3. #include <caggunk.h>
  4. #include <idhidden.h>
  5. #include "lmcons.h"
  6. #include "pidl.h"
  7. #include <enumt.h>
  8. class CFSDropTarget;
  9. class CFSFolderViewCB;
  10. class CFileSysEnum;
  11. class CFSFolderEnumSTATSTG;
  12. class CFSFolder;
  13. class CFileSysItemString;
  14. #define INDEX_PROPERTYBAG_HKCU 0
  15. #define INDEX_PROPERTYBAG_HKLM 1
  16. #define INDEX_PROPERTYBAG_DESKTOPINI 2
  17. class CFSFolderPropertyBag : public IPropertyBag
  18. {
  19. friend CFSFolder;
  20. public:
  21. // IUnknown
  22. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  23. STDMETHODIMP_(ULONG) AddRef();
  24. STDMETHODIMP_(ULONG) Release();
  25. // IPropertyBag
  26. STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog);
  27. STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT *pVar);
  28. protected:
  29. CFSFolderPropertyBag(CFSFolder *pff, DWORD grfMode);
  30. HRESULT _Init(LPCIDFOLDER pidfLast);
  31. private:
  32. virtual ~CFSFolderPropertyBag();
  33. LONG _cRef;
  34. DWORD _grfMode;
  35. CFSFolder* _pFSFolder;
  36. IPropertyBag* _pPropertyBags[3];
  37. };
  38. #define UASTROFFW(pfsi, cb) (LPNWSTR)(((LPBYTE)(pfsi)) + (cb))
  39. #define UASTROFFA(pfsi, cb) (LPSTR)(((LPBYTE)(pfsi)) + (cb))
  40. // This enum is simply an index into c_rgFolderType and c_wvContent (TODO: merge these),
  41. // therefore this *is* the Folder Type:
  42. typedef enum {
  43. FVCBFT_NOTSPECIFIED = -1,
  44. FVCBFT_DOCUMENTS = 0, // "0" is default until otherwise specified
  45. FVCBFT_MYDOCUMENTS,
  46. FVCBFT_PICTURES,
  47. FVCBFT_MYPICTURES,
  48. FVCBFT_PHOTOALBUM,
  49. FVCBFT_MUSIC,
  50. FVCBFT_MYMUSIC,
  51. FVCBFT_MUSICARTIST,
  52. FVCBFT_MUSICALBUM,
  53. FVCBFT_VIDEOS,
  54. FVCBFT_MYVIDEOS,
  55. FVCBFT_VIDEOALBUM,
  56. FVCBFT_USELEGACYHTT,
  57. FVCBFT_COMMONDOCUMENTS,
  58. FVCBFT_NUM_FOLDERTYPES
  59. } FVCBFOLDERTYPE;
  60. typedef enum
  61. {
  62. FSINAME_NONE = 0x0000,
  63. FSINAME_FS = 0x0001,
  64. FSINAME_UI = 0x0002,
  65. FSINAME_FSUI = 0x0003,
  66. FSINAME_RESOURCE = 0x0004,
  67. FSINAME_CLASS = 0x0008,
  68. } FSINAME;
  69. class CFileSysItem
  70. {
  71. public:
  72. CFileSysItem(LPCIDFOLDER pidf);
  73. BOOL HasResourceName() { return ((_pidfx && _pidfx->offResourceA)); }
  74. BOOL IsLegacy() { return _pidfx == NULL; }
  75. BOOL CantRename(CFSFolder *pfs);
  76. LPCWSTR MayCopyFSName(BOOL fMustCopy, LPWSTR psz, DWORD cch);
  77. LPCWSTR MayCopyClassName(BOOL fMustCopy, LPTSTR pszClass, UINT cch);
  78. protected: // methods
  79. TRIBIT _IsMine(CFSFolder *pfs);
  80. BOOL _IsPersonalized();
  81. protected: // members
  82. LPCIDFOLDER _pidf;
  83. PCIDFOLDEREX _pidfx;
  84. PCIDPERSONALIZED _pidp;
  85. };
  86. class CFileSysItemString : public CFileSysItem
  87. {
  88. public:
  89. CFileSysItemString(LPCIDFOLDER pidf);
  90. LPCWSTR FSName();
  91. LPCSTR AltName();
  92. LPCWSTR UIName(CFSFolder *pfs);
  93. LPCWSTR ResourceName();
  94. LPCWSTR Class();
  95. HRESULT GetFindData(WIN32_FIND_DATAW *pfd);
  96. HRESULT GetFindDataSimple(WIN32_FIND_DATAW *pfd);
  97. BOOL ShowExtension(BOOL fDefShowExt);
  98. PERCEIVED PerceivedType();
  99. BOOL IsShimgvwImage();
  100. BOOL GetJunctionClsid(CLSID *pclsid, BOOL fShellExtOk);
  101. HRESULT AssocCreate(CFSFolder *pfs, BOOL fForCtxMenu, REFIID riid, void **ppv);
  102. DWORD ClassFlags(BOOL fNeedsIconBits)
  103. { return _ClassFlags(NULL, fNeedsIconBits); }
  104. protected: // methods
  105. BOOL _LoadResource(CFSFolder *pfs);
  106. BOOL _MakePossessiveName(LPCWSTR pszFormat);
  107. int _GetPersonalizedRes(int csidl, BOOL fIsMine);
  108. void _FormatTheirs(LPCWSTR pszFormat);
  109. BOOL _ResourceName(LPWSTR psz, DWORD cch, BOOL fIsTheirs);
  110. LPCWSTR _Class();
  111. DWORD _ClassFlags(IUnknown *punkAssoc, BOOL fNeedsIconBits);
  112. void _QueryClassFlags(IAssociationArray *paa);
  113. void _QueryIconIndex(IAssociationArray *paa);
  114. protected: // members
  115. LPCWSTR _pszFSName; // points inside the pidfx
  116. LPCWSTR _pszUIName; // points inside the pidfx
  117. LPCWSTR _pszClass; // points inside the pidfx
  118. DWORD _dwClass;
  119. FSINAME _fsin;
  120. WCHAR _sz[MAX_PATH];
  121. };
  122. class CFSAssocEnumData : public CEnumAssociationElements
  123. {
  124. public:
  125. CFSAssocEnumData(BOOL fIsUnknown, CFSFolder *pfs, LPCIDFOLDER pidf);
  126. ~CFSAssocEnumData() { if (_pidl) ILFree(_pidl); }
  127. protected:
  128. virtual BOOL _Next(IAssociationElement **ppae);
  129. protected:
  130. BOOL _fIsUnknown;
  131. BOOL _fIsSystemFolder;
  132. WCHAR _szPath[MAX_PATH];
  133. LPITEMIDLIST _pidl;
  134. };
  135. // This struct is used for caching the column info
  136. typedef struct {
  137. SHCOLUMNINFO shci;
  138. IColumnProvider *pcp;
  139. UINT iColumnId; // This is the 'real' column number, think of it as an index to the scid, which can be provided multiple times
  140. // ie 3 column handlers each provide the same 5 cols, this goes from 0-4
  141. } COLUMNLISTENTRY;
  142. typedef struct
  143. {
  144. UINT cbResource;
  145. CHAR szResource[MAX_PATH];
  146. IDPERSONALIZED idp;
  147. } EXSTRINGS;
  148. STDAPI_(BOOL) SetFolderString(BOOL fCreate, LPCTSTR pszFolder, LPCTSTR pszProvider, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszData);
  149. STDAPI_(BOOL) GetFolderString(LPCTSTR pszFolder, LPCTSTR pszProvider, LPTSTR pszOut, int cch, LPCTSTR pszKey);
  150. STDAPI SHMultiFileProperties(IDataObject *pdtobj, DWORD dwFlags);
  151. STDAPI CFSFolder_CreateLinks(HWND hwnd, IShellFolder *psf, IDataObject *pdtobj, LPCTSTR pszDir, DWORD fMask);
  152. STDAPI CFSFolder_IconEvent(LONG lEvent, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlExtra);
  153. STDAPI_(void) CFSFolder_UpdateIcon(IShellFolder *psf, LPCITEMIDLIST pidl);
  154. class CFSFolder : public CAggregatedUnknown,
  155. public IShellFolder2,
  156. public IShellIcon,
  157. public IShellIconOverlay,
  158. public IPersistFolder3,
  159. public IStorage,
  160. public ITransferDest,
  161. public IPropertySetStorage,
  162. public IItemNameLimits,
  163. public IContextMenuCB,
  164. public ISetFolderEnumRestriction,
  165. public IOleCommandTarget
  166. {
  167. friend CFSFolderViewCB;
  168. friend CFSDropTarget;
  169. friend CFileSysEnum;
  170. friend CFSFolderEnumSTATSTG;
  171. friend CFSFolderPropertyBag;
  172. friend CFileSysItem;
  173. friend CFileSysItemString;
  174. friend CFSAssocEnumData;
  175. // these are evil, get rid of as many of these as possible
  176. friend HRESULT SHMultiFileProperties(IDataObject *pdtobj, DWORD dwFlags);
  177. friend HRESULT CFSFolder_CreateLinks(HWND hwnd, IShellFolder *psf, IDataObject *pdtobj, LPCTSTR pszDir, DWORD fMask);
  178. friend HRESULT CFSFolder_IconEvent(LONG lEvent, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlExtra);
  179. friend void CFSFolder_UpdateIcon(IShellFolder *psf, LPCITEMIDLIST pidl);
  180. friend HRESULT CFSFolder_CompareNames(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  181. friend DWORD CFSFolder_PropertiesThread(void *pv);
  182. friend HRESULT CFSFolder_CreateFolder(IUnknown *punkOuter, LPBC pbc, LPCITEMIDLIST pidl,
  183. const PERSIST_FOLDER_TARGET_INFO *pf, REFIID riid, void **ppv);
  184. friend LPCIDFOLDER CFSFolder_IsValidID(LPCITEMIDLIST pidl);
  185. friend BOOL CFSFolder_IsCommonItem(LPCITEMIDLIST pidl);
  186. public:
  187. // IUnknown
  188. STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { return CAggregatedUnknown::QueryInterface(riid, ppv); };
  189. STDMETHODIMP_(ULONG) AddRef(void) { return CAggregatedUnknown::AddRef(); };
  190. STDMETHODIMP_(ULONG) Release(void) { return CAggregatedUnknown::Release(); };
  191. // IShellFolder
  192. STDMETHODIMP ParseDisplayName(HWND hwnd, LPBC pbc, LPOLESTR pszName, ULONG *pchEaten, LPITEMIDLIST *ppidl, ULONG *pdwAttributes);
  193. STDMETHODIMP EnumObjects(HWND hwnd, DWORD grfFlags, IEnumIDList **ppenumIDList);
  194. STDMETHODIMP BindToObject(LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppv);
  195. STDMETHODIMP BindToStorage(LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppv);
  196. STDMETHODIMP CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  197. STDMETHODIMP CreateViewObject (HWND hwndOwner, REFIID riid, void **ppv);
  198. STDMETHODIMP GetAttributesOf(UINT cidl, LPCITEMIDLIST * apidl, ULONG *rgfInOut);
  199. STDMETHODIMP GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, void **ppv);
  200. STDMETHODIMP GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD uFlags, STRRET *pName);
  201. STDMETHODIMP SetNameOf(HWND hwnd, LPCITEMIDLIST pidl, LPCOLESTR pszName, DWORD uFlags, LPITEMIDLIST * ppidlOut);
  202. // IShellFolder2
  203. STDMETHODIMP GetDefaultSearchGUID(GUID *pGuid);
  204. STDMETHODIMP EnumSearches(IEnumExtraSearch **ppenum);
  205. STDMETHODIMP GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay);
  206. STDMETHODIMP GetDefaultColumnState(UINT iColumn, DWORD *pbState);
  207. STDMETHODIMP GetDetailsEx(LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv);
  208. STDMETHODIMP GetDetailsOf(LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *pDetails);
  209. STDMETHODIMP MapColumnToSCID(UINT iColumn, SHCOLUMNID *pscid);
  210. // IPersist
  211. STDMETHODIMP GetClassID(LPCLSID lpClassID);
  212. // IPersistFolder
  213. STDMETHODIMP Initialize(LPCITEMIDLIST pidl);
  214. // IPersistFolder2
  215. STDMETHODIMP GetCurFolder(LPITEMIDLIST *ppidl);
  216. // IPersistFolder3
  217. STDMETHODIMP InitializeEx(IBindCtx *pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO *pfti);
  218. STDMETHODIMP GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO *pfti);
  219. // IShellIcon methods
  220. STDMETHODIMP GetIconOf(LPCITEMIDLIST pidl, UINT flags, int *piIndex);
  221. // IShellIconOverlay methods
  222. STDMETHODIMP GetOverlayIndex(LPCITEMIDLIST pidl, int * pIndex);
  223. STDMETHODIMP GetOverlayIconIndex(LPCITEMIDLIST pidl, int * pIndex);
  224. // IStorage
  225. STDMETHODIMP CreateStream(LPCWSTR pszRel, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm);
  226. STDMETHODIMP OpenStream(LPCWSTR pszRel, VOID *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm);
  227. STDMETHODIMP CreateStorage(LPCWSTR pszRel, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage **ppstg);
  228. STDMETHODIMP OpenStorage(LPCWSTR pszRel, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg);;
  229. STDMETHODIMP CopyTo(DWORD ciidExclude, const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest);
  230. STDMETHODIMP MoveElementTo(LPCWSTR pszRel, IStorage *pstgDest, LPCWSTR pwcsNewName, DWORD grfFlags);
  231. STDMETHODIMP Commit(DWORD grfCommitFlags);
  232. STDMETHODIMP Revert();
  233. STDMETHODIMP EnumElements(DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum);
  234. STDMETHODIMP DestroyElement(LPCWSTR pszRel);
  235. STDMETHODIMP RenameElement(LPCWSTR pwcsOldName, LPCWSTR pwcsNewName);
  236. STDMETHODIMP SetElementTimes(LPCWSTR pszRel, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime);
  237. STDMETHODIMP SetClass(REFCLSID clsid);
  238. STDMETHODIMP SetStateBits(DWORD grfStateBits, DWORD grfMask);
  239. STDMETHODIMP Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  240. // ITransferDest
  241. STDMETHODIMP Advise(ITransferAdviseSink *pAdvise, DWORD *pdwCookie);
  242. STDMETHODIMP Unadvise(DWORD dwCookie);
  243. STDMETHODIMP OpenElement(const WCHAR *pwcsName, STGXMODE grfMode, DWORD *pdwType, REFIID riid, void **ppunk);
  244. STDMETHODIMP CreateElement(const WCHAR *pwcsName, IShellItem *psiTemplate, STGXMODE grfMode, DWORD dwType, REFIID riid, void **ppunk);
  245. STDMETHODIMP MoveElement(IShellItem *psiItem, WCHAR *pwcsNewName, STGXMOVE grfOptions);
  246. STDMETHODIMP DestroyElement(const WCHAR *pwcsName, STGXDESTROY grfOptions);
  247. // IPropertySetStorage methods
  248. STDMETHODIMP Create(REFFMTID fmtid, const CLSID * pclsid, DWORD grfFlags, DWORD grfMode, IPropertyStorage** ppPropStg);
  249. STDMETHODIMP Open(REFFMTID fmtid, DWORD grfMode, IPropertyStorage** ppPropStg);
  250. STDMETHODIMP Delete(REFFMTID fmtid);
  251. STDMETHODIMP Enum(IEnumSTATPROPSETSTG** ppenum);
  252. // IContextMenuCB
  253. STDMETHODIMP CallBack(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam);
  254. // IItemNameLimits
  255. STDMETHODIMP GetValidCharacters(LPWSTR *ppwszValidChars, LPWSTR *ppwszInvalidChars);
  256. STDMETHODIMP GetMaxLength(LPCWSTR pszName, int *piMaxNameLen);
  257. // ISetFolderEnumRestriction
  258. STDMETHODIMP SetEnumRestriction(DWORD dwRequired, DWORD dwForbidden);
  259. // IOleCommandTarget
  260. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup,
  261. ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  262. STDMETHODIMP Exec(const GUID *pguidCmdGroup,
  263. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  264. CFSFolder(IUnknown *punkOuter);
  265. protected:
  266. LPCITEMIDLIST _GetIDList() { return _pidl; };
  267. HRESULT v_InternalQueryInterface(REFIID riid, void **ppv);
  268. virtual ~CFSFolder();
  269. HRESULT _GetPathForItems(LPCIDFOLDER pidfParent, LPCIDFOLDER pidfLast, LPTSTR pszPath, DWORD cchPath);
  270. HRESULT _GetPathForItem(LPCIDFOLDER pidf, LPWSTR pszPath, DWORD cchPath);
  271. HRESULT _GetPath(PTSTR pszPath, DWORD cchPath);
  272. static HRESULT _GetAltDisplayName(LPCIDFOLDER pidf, LPTSTR pszName, DWORD cchName);
  273. static HRESULT _MakePossessiveName(LPCTSTR pszFile, LPCTSTR pszOwner, LPTSTR pszBuffer, INT cchBuffer);
  274. HRESULT _GetUsersDisplayName(LPCTSTR pszOwner, LPTSTR pszBuffer, INT cchBuffer);
  275. HRESULT _SetLocalizedDisplayName(LPCIDFOLDER pidf, LPCTSTR pszName);
  276. void _UpdateItem(LPCIDFOLDER pidf);
  277. DWORD _Attributes();
  278. UINT _GetCSIDL();
  279. BOOL _IsCSIDL(UINT csidl);
  280. UINT _GetItemExStrings(LPCIDFOLDER pidfSimpleParent, const WIN32_FIND_DATA *pfd, EXSTRINGS *pxs);
  281. HRESULT _CreateIDList(const WIN32_FIND_DATA *pfd, LPCIDFOLDER pidfSimpleParent, LPITEMIDLIST *ppidl);
  282. HRESULT _Properties(LPCITEMIDLIST pidlParent, IDataObject *pdtobj, LPCTSTR pStartPage);
  283. HRESULT _Reset();
  284. HRESULT _CreateInstance(HWND hwnd, IDropTarget** ppdt);
  285. HRESULT _CreateEnum(IUnknown *punk, HWND hwnd, DWORD grfFlags, IEnumIDList **ppenum);
  286. HRESULT _GetJunctionForBind(LPCIDFOLDER pidf, LPIDFOLDER *ppidfBind, LPCITEMIDLIST *ppidlRight);
  287. LPCTSTR _BindHandlerName(REFIID riid);
  288. HRESULT _Bind(LPBC pbc, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  289. HRESULT _LoadHandler(LPCIDFOLDER pidf, DWORD grfMode, LPCTSTR pszHandlerType, REFIID riid, void **ppv);
  290. HRESULT _HandlerCreateInstance(LPCIDFOLDER pidf, PCWSTR pszClsid, DWORD grfMode, REFIID riid, void **ppv);
  291. HRESULT _CreateShimgvwExtractor(LPCIDFOLDER pidf, REFIID riid, void **ppv);
  292. BOOL _IsSlowPath();
  293. HRESULT _GetToolTipForItem(LPCIDFOLDER pidf, REFIID riid, void **ppv);
  294. HRESULT _GetIntroText(LPCIDFOLDER pidf, WCHAR* pwszIntroText, UINT cchIntroText);
  295. // GetUIObjectOf() helpers.
  296. HRESULT _GetContextMenu(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  297. HRESULT _GetDataObject(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  298. HRESULT _GetDropTarget(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  299. HRESULT _GetAssoc(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  300. HRESULT _GetExtractIcon(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  301. HRESULT _GetCustomIconManager(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  302. HRESULT _GetExtractImage(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  303. HRESULT _GetExtractLogo(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  304. HRESULT _GetQueryInfo(HWND hwnd, LPCITEMIDLIST *apidl, UINT cidl, LPCIDFOLDER pidf, REFIID riid, void **ppv);
  305. // GetDetailsEx() helpers.
  306. HRESULT _GetFindData(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  307. HRESULT _GetDescriptionId(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  308. HRESULT _GetFolderIntroText(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  309. HRESULT _GetSize(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  310. HRESULT _GetFreeSpace(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  311. HRESULT _GetLastWriteTime(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  312. HRESULT _GetCreateTime(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  313. HRESULT _GetLastAccessTime(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  314. HRESULT _GetDirectory(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  315. HRESULT _GetInfotip(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  316. HRESULT _GetHtmlInfotipFile(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  317. HRESULT _GetAttributesDescription(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  318. HRESULT _GetAttributesDescriptionBuilder(LPWSTR szAttributes, size_t cchAttributes, LPWSTR szAttribute);
  319. HRESULT _GetLinkTarget(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  320. HRESULT _GetNetworkLocation(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  321. HRESULT _GetComputerName(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  322. HRESULT _GetComputerName_FromPath(PCWSTR pwszPath, VARIANT *pv);
  323. HRESULT _GetComputerName_FromUNC(PWSTR pwszPath, VARIANT *pv);
  324. HRESULT _GetCSCStatus(LPCIDFOLDER pidf, LPCSHCOLUMNID pscid, VARIANT *pv);
  325. BOOL _GetFolderFlags(LPCIDFOLDER pidf, UINT *prgfFlags);
  326. BOOL _GetFolderIconPath(LPCIDFOLDER pidf, LPTSTR pszIcon, int cchMax, UINT *pIndex);
  327. static DWORD CALLBACK _PropertiesThread(void *pv);
  328. static DWORD _GetClassFlags(LPCIDFOLDER pidf);
  329. UINT _GetContextMenuKeys(LPCIDFOLDER pidf, HKEY *aKeys, UINT cKeys, IAssociationArray **ppaa);
  330. BOOL _CheckDefaultIni(LPCIDFOLDER pidfLast, LPTSTR pszIniPath, DWORD cchIniPath);
  331. HRESULT _CompareExtendedProp(int iColumn, LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  332. static HRESULT _CompareModifiedDate(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  333. static HRESULT _CompareCreateTime(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  334. static HRESULT _CompareAccessTime(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  335. static HRESULT _CompareAttribs(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  336. static HRESULT _CompareFileTypes(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  337. HRESULT _CompareNames(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2, BOOL fCaseSensitive, BOOL fCanonical);
  338. static HRESULT _CompareFolderness(LPCIDFOLDER pidf1, LPCIDFOLDER pidf2);
  339. BOOL _DefaultShowExt();
  340. BOOL _ShowExtension(LPCIDFOLDER pidf);
  341. static HRESULT _GetClassKey(LPCIDFOLDER pidf, HKEY *phkeyProgID);
  342. // file system, non junction point folder
  343. static BOOL _IsJunction(LPCIDFOLDER pidf);
  344. static BYTE _GetType(LPCIDFOLDER pidf);
  345. static BOOL _IsSimpleID(LPCIDFOLDER pidf);
  346. static LPIDFOLDER _FindLastID(LPCIDFOLDER pidf);
  347. static LPIDFOLDER _Next(LPCIDFOLDER pidf);
  348. static LPCIDFOLDER _IsValidID(LPCITEMIDLIST pidl);
  349. static LPCIDFOLDER _IsValidIDHack(LPCITEMIDLIST pidl);
  350. static BOOL _IsCommonItem(LPCITEMIDLIST pidl);
  351. static BOOL _IsFile(LPCIDFOLDER pidf);
  352. static BOOL _IsFolder(LPCIDFOLDER pidf);
  353. static BOOL _IsFileFolder(LPCIDFOLDER pidf);
  354. static BOOL _IsSystemFolder(LPCIDFOLDER pidf);
  355. static BOOL _IsReal(LPCIDFOLDER pidf);
  356. BOOL _IsSelfSystemFolder();
  357. BOOL _HasLocalizedFileNames();
  358. static BOOL _IsOffline(LPCIDFOLDER pidf) { return pidf && (pidf->wAttrs & FILE_ATTRIBUTE_OFFLINE); }
  359. BOOL _IsOfflineCSC(LPCIDFOLDER pidf);
  360. BOOL _IsOfflineCSC(LPCTSTR pszPath);
  361. HRESULT _InitFolder(IBindCtx *pbc, LPCIDFOLDER pidf, IUnknown **ppunk);
  362. BOOL _GetMountingPointInfo(LPCIDFOLDER pidf, LPTSTR pszMountPoint, DWORD cchMountPoint);
  363. HRESULT _CreateContextMenu(HWND hwnd, LPCIDFOLDER pidf, LPCITEMIDLIST *apidl, UINT cidl, IContextMenu **ppcm);
  364. HRESULT _AssocCreate(LPCIDFOLDER pidf, REFIID riid, void **ppv);
  365. static BOOL _GetJunctionClsid(LPCIDFOLDER pidf, CLSID *pclsidRet);
  366. static LPCTSTR _GetTypeName(LPCIDFOLDER pidf);
  367. static HRESULT _GetTypeNameBuf(LPCIDFOLDER pidf, LPTSTR pszName, int cchNameMax);
  368. static LPWSTR _CopyName(LPCIDFOLDER pidf, LPWSTR pszName, UINT cchName);
  369. static int _CopyUIName(LPCIDFOLDER pidf, LPTSTR pszName, UINT cchName);
  370. static HRESULT _AppendItemToPath(PTSTR pszPath, DWORD cchPath, LPCIDFOLDER pidl);
  371. static LPTSTR _CopyAltName(LPCIDFOLDER pidf, LPTSTR pszName, UINT cchName);
  372. static LPCSTR _GetAltName(LPCIDFOLDER pidf);
  373. static HRESULT _FindDataFromIDFolder(LPCIDFOLDER pidf, WIN32_FIND_DATAW *pfd, BOOL fAllowSimplePid);
  374. static DWORD _GetUID(LPCIDFOLDER pidf);
  375. static LPCIDFOLDER _FindJunction(LPCIDFOLDER pidf);
  376. static LPCITEMIDLIST _FindJunctionNext(LPCIDFOLDER pidf);
  377. ULONGLONG _Size(LPCIDFOLDER pidf);
  378. HRESULT _NormalGetDisplayNameOf(LPCIDFOLDER pidf, STRRET *pStrRet);
  379. HRESULT _NormalDisplayName(LPCIDFOLDER pidf, LPWSTR psz, UINT cch);
  380. BOOL _GetBindCLSID(IBindCtx *pbc, LPCIDFOLDER pidf, CLSID *pclsid);
  381. HRESULT _InitColData(LPCIDFOLDER pidf, SHCOLUMNDATA* pscd);
  382. LPIDFOLDER _MarkAsJunction(LPCIDFOLDER pidfSimpleParent, LPIDFOLDER pidf, LPCTSTR pszName);
  383. HRESULT _CreateIDListFromName(LPCTSTR pszName, DWORD dwAttribs, IBindCtx *pbc, LPITEMIDLIST *ppidl);
  384. BOOL _CanSeeInThere(LPCTSTR pszName);
  385. HRESULT _ParseSimple(LPCWSTR pszPath, const WIN32_FIND_DATA *pfdLast, LPITEMIDLIST *ppidl);
  386. HRESULT _FindDataFromName(LPCTSTR pszName, DWORD dwAttribs, IBindCtx *pbc, WIN32_FIND_DATA **ppfd);
  387. HRESULT _CheckDriveRestriction(HWND hwnd, REFIID riid);
  388. HRESULT _CreateUIHandler(REFIID riid, void **ppv);
  389. BOOL _IsNetPath();
  390. int _GetDefaultFolderIcon();
  391. HRESULT _CreateDefExtIcon(LPCIDFOLDER pidf, REFIID riid, void **ppxicon);
  392. HRESULT _CreateFileFolderDefExtIcon(LPCIDFOLDER pidf, REFIID riid, void **ppxicon);
  393. HRESULT _CreatePerInstanceDefExtIcon(LPCIDFOLDER pidf, DWORD shcf, REFIID riid, void **ppxicon);
  394. HRESULT _CreatePerClassDefExtIcon(LPCIDFOLDER pidf, DWORD shcf, REFIID riid, void **ppxicon);
  395. BOOL _FindColHandler(UINT iCol, UINT iN, COLUMNLISTENTRY *pcle);
  396. void _AdjustDefShowColumn(UINT iColumn, DWORD *pdwState);
  397. BOOL _ShouldShowExtendedColumn(const SHCOLUMNID* pscid);
  398. HRESULT _MapSCIDToColumn(const SHCOLUMNID* pscid, UINT* puCol);
  399. HRESULT _ExtendedColumn(LPCIDFOLDER pidf, UINT iColumn, SHELLDETAILS *pDetails);
  400. HRESULT _LoadColumnHandlers();
  401. HRESULT _GetOverlayInfo(LPCITEMIDLIST pidl, int * pIndex, DWORD dwFlags);
  402. void _DestroyColHandlers();
  403. HRESULT _GetFullPath(LPCWSTR pszRelPath, LPWSTR pszFull);
  404. HRESULT _Delete(LPCWSTR pszFile);
  405. HRESULT _OpenCreateStorage(LPCWSTR pwcsName, DWORD grfMode, IStorage **ppstg, BOOL fCreate);
  406. HRESULT _OpenCreateStream(LPCWSTR pwcsName, DWORD grfMode, IStream **ppstm, BOOL fCreate);
  407. HRESULT _SetStgMode(DWORD grfMode);
  408. HRESULT _LoadPropHandler();
  409. HRESULT _CreateFolderPropertyBag(DWORD grfMode, LPCIDFOLDER pidfLast, REFIID riid, void **ppv);
  410. HRESULT _GetPropertyUI();
  411. LPITEMIDLIST _pidl; // Absolute IDList (location in the name space)
  412. LPITEMIDLIST _pidlTarget; // Absolute IDList for folder target (location in namespace to enumerate)
  413. // WARNING: _csidlTrack overrides _pidlTarget
  414. LPTSTR _pszPath; // file system path (may be different from _pidl)
  415. LPTSTR _pszNetProvider; // network provider (for net calls we may need to make)
  416. CLSID _clsidBind; // use CLSID_NULL for normal case
  417. int _cHiddenFiles; // view callback and enumerator share these
  418. ULONGLONG _cbSize;
  419. UINT _csidl; // CSIDL_ value of this folder (if known)
  420. DWORD _dwAttributes; // attributes of this folder (if known)
  421. int _csidlTrack; // CSIDL_ that we follow dynamically
  422. BOOL _fCachedCLSID : 1; // clsidView is already cached
  423. BOOL _fHasCLSID : 1; // clsidView has a valid CLSID
  424. CLSID _clsidView; // CLSID for View object
  425. HDSA _hdsaColHandlers; // cached list of columns and handlers
  426. DWORD _dwColCount; // count of unique columns
  427. int _iFolderIcon; // icon for sub folders to inherit
  428. BOOL _bUpdateExtendedCols; // set to TRUE in response to SFVM_INSERTITEM callback, passed to IColumnProvider::GetItemData then cleared
  429. BOOL _bSlowPath; // Lazy-calculated value of whether the folder is on a slow path
  430. BOOL _fDontForceCreate; // don't succeed with STGM_CREATE passed to ParseDisplayName for a non-existent item
  431. FVCBFOLDERTYPE _nFolderType;
  432. TRIBIT _tbHasLocalizedFileNamesSection; // Lazy-calculated value of whether the folder has a desktop.ini with a LocalizedFileNames section
  433. TRIBIT _tbDefShowExt; // cache of SHGetSetSettings(SSF_SHOWEXTENSIONS)
  434. TRIBIT _tbOfflineCSC; // cache of _IsOfflineCSC(_pidl)
  435. DWORD _grfFlags;
  436. DWORD _dwEnumRequired; // SetEnumRestriction
  437. DWORD _dwEnumForbidden; // SetEnumRestriction
  438. IPropertySetStorage *_pstg;
  439. IPropertyUI *_pPropertyUI;
  440. ITransferAdviseSink * _pAdvise;
  441. };
  442. // fstree.cpp
  443. STDAPI CFSFolderCallback_Create(CFSFolder *pFSFolder, IShellFolderViewCB **ppsfvcb);
  444. STDAPI CFSDropTarget_CreateInstance(CFSFolder* pFSFolder, HWND hwnd, IDropTarget** ppdt);
  445. STDAPI CFSFolder_CreateEnum(CFSFolder *pfsf, HWND hwnd, DWORD grfFlags, IEnumIDList **ppenum);
  446. STDAPI CFolderExtractImage_Create(IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, void **ppvObj);
  447. class CFSIconManager : public ICustomIconManager
  448. {
  449. public:
  450. // IUnknown
  451. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  452. STDMETHODIMP_(ULONG) AddRef(void);
  453. STDMETHODIMP_(ULONG) Release(void);
  454. // ICustomIconManager
  455. STDMETHODIMP SetIcon(LPCWSTR pszIconPath,int iIcon);
  456. STDMETHODIMP SetDefaultIcon();
  457. STDMETHODIMP GetDefaultIconHandle(HICON *phIcon);
  458. STDMETHODIMP GetIcon(LPWSTR pszIconPath, int cchszIconPath, int *piIconIndex) = 0;
  459. protected:
  460. HRESULT _Init(LPCITEMIDLIST pidl, IShellFolder *psf);
  461. WCHAR _wszPath[MAX_PATH];
  462. CFSIconManager();
  463. virtual STDMETHODIMP _SetIconEx(LPCWSTR pszIconPath,int iIconIndex, BOOL fChangeNotify) = 0;
  464. virtual STDMETHODIMP _SetDefaultIconEx(BOOL fChangeNotify) = 0;
  465. private:
  466. long _cRef;
  467. };
  468. class CFileFolderIconManager : public CFSIconManager
  469. {
  470. public:
  471. friend HRESULT CFileFolderIconManager_Create(IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, void **ppv);
  472. // ICustomIconManager
  473. STDMETHODIMP GetIcon(LPWSTR pszIconPath, int cchszIconPath, int *piIconIndex);
  474. protected:
  475. STDMETHODIMP _SetIconEx(LPCWSTR pszIconPath,int iIconIndex, BOOL fChangeNotify);
  476. STDMETHODIMP _SetDefaultIconEx(BOOL fChangeNotify);
  477. };