1 /* 2 * PROJECT: shell32 3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 * PURPOSE: file system folder 5 * COPYRIGHT: Copyright 1997 Marcus Meissner 6 * Copyright 1998, 1999, 2002 Juergen Schmied 7 * Copyright 2009 Andrew Hill 8 * Copyright 2020 Mark Jansen (mark.jansen@reactos.org) 9 */ 10 11 #ifndef _CFSFOLDER_H_ 12 #define _CFSFOLDER_H_ 13 14 class CFSFolder : 15 public CComCoClass<CFSFolder, &CLSID_ShellFSFolder>, 16 public CComObjectRootEx<CComMultiThreadModelNoCS>, 17 public IShellFolder2, 18 public IPersistFolder3, 19 public IContextMenuCB, 20 public IShellFolderViewCB, 21 public IItemNameLimits 22 { 23 private: 24 const CLSID *m_pclsid; 25 26 /* both paths are parsible from the desktop */ 27 LPWSTR m_sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ 28 29 LPITEMIDLIST m_pidlRoot; /* absolute pidl */ 30 31 DWORD m_bGroupPolicyActive; 32 HRESULT _CreateShellExtInstance(const CLSID *pclsid, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut); 33 HRESULT _CreateExtensionUIObject(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut); 34 HRESULT _GetDropTarget(LPCITEMIDLIST pidl, LPVOID *ppvOut); 35 HRESULT _GetIconHandler(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut); 36 37 HRESULT _ParseSimple( 38 _In_ LPOLESTR lpszDisplayName, 39 _Inout_ WIN32_FIND_DATAW *pFind, 40 _Out_ LPITEMIDLIST *ppidl); 41 BOOL _GetFindDataFromName(_In_ LPCWSTR pszName, _Out_ WIN32_FIND_DATAW *pFind); 42 HRESULT _CreateIDListFromName(LPCWSTR pszName, DWORD attrs, IBindCtx *pbc, LPITEMIDLIST *ppidl); 43 44 public: 45 CFSFolder(); 46 ~CFSFolder(); 47 48 // IShellFolder 49 STDMETHOD(ParseDisplayName)(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes) override; 50 STDMETHOD(EnumObjects)(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) override; 51 STDMETHOD(BindToObject)(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override; 52 STDMETHOD(BindToStorage)(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override; 53 STDMETHOD(CompareIDs)(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) override; 54 STDMETHOD(CreateViewObject)(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) override; 55 STDMETHOD(GetAttributesOf)(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) override; 56 STDMETHOD(GetUIObjectOf)(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) override; 57 STDMETHOD(GetDisplayNameOf)(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) override; 58 STDMETHOD(SetNameOf)(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) override; 59 60 /* ShellFolder2 */ 61 STDMETHOD(GetDefaultSearchGUID)(GUID *pguid) override; 62 STDMETHOD(EnumSearches)(IEnumExtraSearch **ppenum) override; 63 STDMETHOD(GetDefaultColumn)(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) override; 64 STDMETHOD(GetDefaultColumnState)(UINT iColumn, DWORD *pcsFlags) override; 65 STDMETHOD(GetDetailsEx)(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) override; 66 STDMETHOD(GetDetailsOf)(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) override; 67 STDMETHOD(MapColumnToSCID)(UINT column, SHCOLUMNID *pscid) override; 68 69 // IPersist 70 STDMETHOD(GetClassID)(CLSID *lpClassId) override; 71 72 // IPersistFolder 73 STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidl) override; 74 75 // IPersistFolder2 76 STDMETHOD(GetCurFolder)(PIDLIST_ABSOLUTE * pidl) override; 77 78 // IPersistFolder3 79 STDMETHOD(InitializeEx)(IBindCtx *pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO *ppfti) override; 80 STDMETHOD(GetFolderTargetInfo)(PERSIST_FOLDER_TARGET_INFO *ppfti) override; 81 82 // IContextMenuCB 83 STDMETHOD(CallBack)(IShellFolder *psf, HWND hwndOwner, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 84 85 // IShellFolderViewCB 86 STDMETHOD(MessageSFVCB)(UINT uMsg, WPARAM wParam, LPARAM lParam) override; 87 88 /*** IItemNameLimits methods ***/ 89 90 STDMETHODIMP 91 GetMaxLength(LPCWSTR pszName, int *piMaxNameLen) override 92 { 93 return E_NOTIMPL; 94 } 95 96 STDMETHODIMP 97 GetValidCharacters(LPWSTR *ppwszValidChars, LPWSTR *ppwszInvalidChars) override 98 { 99 if (ppwszValidChars) 100 { 101 *ppwszValidChars = NULL; 102 } 103 if (ppwszInvalidChars) 104 { 105 SHStrDupW(INVALID_FILETITLE_CHARACTERSW, ppwszInvalidChars); 106 } 107 return S_OK; 108 } 109 110 DECLARE_REGISTRY_RESOURCEID(IDR_SHELLFSFOLDER) 111 DECLARE_NOT_AGGREGATABLE(CFSFolder) 112 113 DECLARE_PROTECT_FINAL_CONSTRUCT() 114 115 BEGIN_COM_MAP(CFSFolder) 116 COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2) 117 COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder) 118 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder) 119 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2) 120 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder3, IPersistFolder3) 121 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist) 122 COM_INTERFACE_ENTRY_IID(IID_IShellFolderViewCB, IShellFolderViewCB) 123 COM_INTERFACE_ENTRY_IID(IID_IItemNameLimits, IItemNameLimits) 124 END_COM_MAP() 125 126 protected: 127 HRESULT WINAPI GetCustomViewInfo(ULONG unknown, SFVM_CUSTOMVIEWINFO_DATA *data); 128 129 public: 130 // Helper functions shared with CDesktopFolder 131 static HRESULT GetFSColumnDetails(UINT iColumn, SHELLDETAILS &sd); 132 static HRESULT GetDefaultFSColumnState(UINT iColumn, SHCOLSTATEF &csFlags); 133 }; 134 135 #endif /* _CFSFOLDER_H_ */ 136