1 /* 2 * Virtual Desktop Folder 3 * 4 * Copyright 1997 Marcus Meissner 5 * Copyright 1998, 1999, 2002 Juergen Schmied 6 * Copyright 2009 Andrew Hill 7 * 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. 12 * 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. 17 * 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 21 */ 22 23 #ifndef _CDESKTOPFOLDER_H_ 24 #define _CDESKTOPFOLDER_H_ 25 26 class CDesktopFolder : 27 public CComCoClass<CDesktopFolder, &CLSID_ShellDesktop>, 28 public CComObjectRootEx<CComMultiThreadModelNoCS>, 29 public IShellFolder2, 30 public IPersistFolder2, 31 public IContextMenuCB, 32 public IItemNameLimits 33 { 34 private: 35 /* both paths are parsible from the desktop */ 36 CComPtr<IShellFolder2> m_DesktopFSFolder; 37 CComPtr<IShellFolder2> m_SharedDesktopFSFolder; 38 CComPtr<IShellFolder2> m_regFolder; 39 40 LPWSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */ 41 LPITEMIDLIST pidlRoot; /* absolute pidl */ 42 43 HRESULT _GetSFFromPidl(LPCITEMIDLIST pidl, IShellFolder2** psf); 44 45 static HRESULT GetColumnDetails(UINT iColumn, SHELLDETAILS &sd); 46 47 HRESULT _ParseDisplayNameByParent( 48 HWND hwndOwner, 49 LPBC pbc, 50 LPOLESTR pszPath, 51 DWORD *pchEaten, 52 PIDLIST_RELATIVE *ppidl, 53 DWORD *pdwAttributes); 54 55 STDMETHODIMP 56 ShellUrlParseDisplayName( 57 HWND hwndOwner, 58 LPBC pbc, 59 LPOLESTR lpszDisplayName, 60 DWORD *pchEaten, 61 PIDLIST_RELATIVE *ppidl, 62 DWORD *pdwAttributes); 63 64 STDMETHODIMP 65 HttpUrlParseDisplayName( 66 HWND hwndOwner, 67 LPBC pbc, 68 LPOLESTR lpszDisplayName, 69 DWORD *pchEaten, 70 PIDLIST_RELATIVE *ppidl, 71 DWORD *pdwAttributes); 72 73 public: 74 CDesktopFolder(); 75 ~CDesktopFolder(); 76 HRESULT WINAPI FinalConstruct(); 77 78 // *** IShellFolder methods *** 79 STDMETHOD(ParseDisplayName)(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes) override; 80 STDMETHOD(EnumObjects)(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) override; 81 STDMETHOD(BindToObject)(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override; 82 STDMETHOD(BindToStorage)(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override; 83 STDMETHOD(CompareIDs)(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) override; 84 STDMETHOD(CreateViewObject)(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) override; 85 STDMETHOD(GetAttributesOf)(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) override; 86 STDMETHOD(GetUIObjectOf)(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) override; 87 STDMETHOD(GetDisplayNameOf)(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) override; 88 STDMETHOD(SetNameOf)(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) override; 89 90 // *** IShellFolder2 methods *** 91 STDMETHOD(GetDefaultSearchGUID)(GUID *pguid) override; 92 STDMETHOD(EnumSearches)(IEnumExtraSearch **ppenum) override; 93 STDMETHOD(GetDefaultColumn)(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) override; 94 STDMETHOD(GetDefaultColumnState)(UINT iColumn, DWORD *pcsFlags) override; 95 STDMETHOD(GetDetailsEx)(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) override; 96 STDMETHOD(GetDetailsOf)(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) override; 97 STDMETHOD(MapColumnToSCID)(UINT column, SHCOLUMNID *pscid) override; 98 99 // *** IPersist methods *** 100 STDMETHOD(GetClassID)(CLSID *lpClassId) override; 101 102 // *** IPersistFolder methods *** 103 STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidl) override; 104 105 // *** IPersistFolder2 methods *** 106 STDMETHOD(GetCurFolder)(PIDLIST_ABSOLUTE * pidl) override; 107 108 // IContextMenuCB 109 STDMETHOD(CallBack)(IShellFolder *psf, HWND hwndOwner, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 110 111 /*** IItemNameLimits methods ***/ 112 113 STDMETHODIMP GetMaxLength(LPCWSTR pszName,int * piMaxNameLen)114 GetMaxLength(LPCWSTR pszName, int *piMaxNameLen) override 115 { 116 return E_NOTIMPL; 117 } 118 119 STDMETHODIMP GetValidCharacters(LPWSTR * ppwszValidChars,LPWSTR * ppwszInvalidChars)120 GetValidCharacters(LPWSTR *ppwszValidChars, LPWSTR *ppwszInvalidChars) override 121 { 122 if (ppwszValidChars) 123 { 124 *ppwszValidChars = NULL; 125 } 126 if (ppwszInvalidChars) 127 { 128 SHStrDupW(INVALID_FILETITLE_CHARACTERSW, ppwszInvalidChars); 129 } 130 return S_OK; 131 } 132 133 DECLARE_REGISTRY_RESOURCEID(IDR_SHELLDESKTOP) 134 DECLARE_CENTRAL_INSTANCE_NOT_AGGREGATABLE(CDesktopFolder) 135 136 DECLARE_PROTECT_FINAL_CONSTRUCT() 137 138 BEGIN_COM_MAP(CDesktopFolder) 139 COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2) 140 COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder) 141 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder) 142 COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2) 143 COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist) 144 COM_INTERFACE_ENTRY_IID(IID_IItemNameLimits, IItemNameLimits) 145 END_COM_MAP() 146 }; 147 148 class CDesktopFolderViewCB : 149 public CComObjectRootEx<CComMultiThreadModelNoCS>, 150 public IShellFolderViewCB, 151 public IFolderFilter 152 { 153 IShellView *m_pShellView; // Not ref-counted! 154 UINT8 m_IsProgmanHosted; 155 156 public: CDesktopFolderViewCB()157 CDesktopFolderViewCB() : m_IsProgmanHosted(0) {} Initialize(IShellView * psv)158 void Initialize(IShellView *psv) { m_pShellView = psv; } 159 static bool IsProgmanHostedBrowser(IShellView *psv); 160 bool IsProgmanHostedBrowser(); 161 162 // IShellFolderViewCB 163 STDMETHOD(MessageSFVCB)(UINT uMsg, WPARAM wParam, LPARAM lParam) override; 164 165 // IFolderFilter 166 STDMETHOD(ShouldShow)(IShellFolder *psf, PCIDLIST_ABSOLUTE pidlFolder, PCUITEMID_CHILD pidlItem) override; GetEnumFlags(IShellFolder *,PCIDLIST_ABSOLUTE,HWND *,DWORD *)167 STDMETHODIMP GetEnumFlags(IShellFolder*, PCIDLIST_ABSOLUTE, HWND*, DWORD*) override { return E_NOTIMPL; } 168 169 DECLARE_NO_REGISTRY() 170 DECLARE_NOT_AGGREGATABLE(CDesktopFolderViewCB) 171 BEGIN_COM_MAP(CDesktopFolderViewCB) 172 COM_INTERFACE_ENTRY_IID(IID_IShellFolderViewCB, IShellFolderViewCB) 173 COM_INTERFACE_ENTRY_IID(IID_IFolderFilter, IFolderFilter) 174 END_COM_MAP() 175 }; 176 177 #endif /* _CDESKTOPFOLDER_H_ */ 178