Source code of Windows XP (NT5)
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.

221 lines
7.8 KiB

  1. #ifndef CAFOLDER_H__
  2. #define CAFOLDER_H__
  3. #ifdef __cplusplus
  4. #include <debug.h>
  5. #include "iface.h"
  6. // Forward class declarations
  7. class CCacheFolderEnum;
  8. class CCacheFolder;
  9. class CCacheItem;
  10. #define LOTS_OF_FILES (10)
  11. // PIDL format for cache folder...
  12. struct CEIPIDL : public BASEPIDL
  13. {
  14. // USHORT cb;
  15. // USHORT usSign;
  16. TCHAR szTypeName[80];
  17. INTERNET_CACHE_ENTRY_INFO cei;
  18. };
  19. typedef UNALIGNED CEIPIDL *LPCEIPIDL;
  20. #define IS_VALID_CEIPIDL(pidl) ((pidl) && \
  21. (((LPCEIPIDL)pidl)->cb >= sizeof(CEIPIDL)) && \
  22. (((LPCEIPIDL)pidl)->usSign == (USHORT)CEIPIDL_SIGN))
  23. #define CEI_SOURCEURLNAME(pceipidl) ((LPTSTR)((DWORD_PTR)(pceipidl)->cei.lpszSourceUrlName + (LPBYTE)(&(pceipidl)->cei)))
  24. #define CEI_LOCALFILENAME(pceipidl) ((LPTSTR)((DWORD_PTR)(pceipidl)->cei.lpszLocalFileName + (LPBYTE)(&(pceipidl)->cei)))
  25. #define CEI_FILEEXTENSION(pceipidl) ((LPTSTR)((DWORD_PTR)(pceipidl)->cei.lpszFileExtension + (LPBYTE)(&(pceipidl)->cei)))
  26. #define CEI_CACHEENTRYTYPE(pcei) ((DWORD)(pcei)->cei.CacheEntryType)
  27. inline UNALIGNED const TCHAR* _GetURLTitle(LPCEIPIDL pcei)
  28. {
  29. return _FindURLFileName(CEI_SOURCEURLNAME(pcei));
  30. }
  31. inline void _GetCacheItemTitle(LPCEIPIDL pcei, LPTSTR pszTitle, DWORD cchBufferSize)
  32. {
  33. int iLen;
  34. ualstrcpyn(pszTitle, _GetURLTitle(pcei), cchBufferSize);
  35. iLen = lstrlen(pszTitle) - 1; // we want the last char
  36. if (pszTitle[iLen] == TEXT('/'))
  37. pszTitle[iLen] = TEXT('\0');
  38. }
  39. inline LPCTSTR CPidlToSourceUrl(LPCEIPIDL pidl)
  40. {
  41. return CEI_SOURCEURLNAME(pidl);
  42. }
  43. inline int _CompareCFolderPidl(LPCEIPIDL pidl1, LPCEIPIDL pidl2)
  44. {
  45. return StrCmpI(CPidlToSourceUrl(pidl1), CPidlToSourceUrl(pidl2));
  46. }
  47. ///////////////////////
  48. //
  49. // Warn on Cookie deletion
  50. //
  51. enum {
  52. DEL_COOKIE_WARN = 0,
  53. DEL_COOKIE_YES,
  54. DEL_COOKIE_NO
  55. };
  56. // Forward declarations for create instance functions
  57. HRESULT CCacheItem_CreateInstance(CCacheFolder *pHCFolder, HWND hwndOwner, UINT cidl, LPCITEMIDLIST *ppidl, REFIID riid, void **ppvOut);
  58. //////////////////////////////////////////////////////////////////////////////
  59. //
  60. // CCacheFolderEnum Object
  61. //
  62. //////////////////////////////////////////////////////////////////////////////
  63. class CCacheFolderEnum : public IEnumIDList
  64. {
  65. public:
  66. CCacheFolderEnum(DWORD grfFlags, CCacheFolder *pHCFolder);
  67. // IUnknown Methods
  68. STDMETHODIMP QueryInterface(REFIID,void **);
  69. STDMETHODIMP_(ULONG) AddRef(void);
  70. STDMETHODIMP_(ULONG) Release(void);
  71. // IEnumIDList
  72. STDMETHODIMP Next(ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched);
  73. STDMETHODIMP Skip(ULONG celt);
  74. STDMETHODIMP Reset();
  75. STDMETHODIMP Clone(IEnumIDList **ppenum);
  76. protected:
  77. ~CCacheFolderEnum();
  78. LONG _cRef; // ref count
  79. CCacheFolder *_pCFolder;// this is what we enumerate
  80. UINT _grfFlags; // enumeration flags
  81. UINT _uFlags; // local flags
  82. LPINTERNET_CACHE_ENTRY_INFO _pceiWorking;
  83. HANDLE _hEnum;
  84. };
  85. class CCacheFolder :
  86. public IShellFolder2,
  87. public IShellIcon,
  88. public IPersistFolder2
  89. {
  90. // CCacheFolder interfaces
  91. friend CCacheFolderEnum;
  92. friend CCacheItem;
  93. friend HRESULT CacheFolderView_CreateInstance(CCacheFolder *pHCFolder, void **ppvOut);
  94. friend HRESULT CacheFolderView_DidDragDrop(IDataObject *pdo, DWORD dwEffect);
  95. public:
  96. CCacheFolder();
  97. // IUnknown Methods
  98. STDMETHODIMP QueryInterface(REFIID, void **);
  99. STDMETHODIMP_(ULONG) AddRef(void);
  100. STDMETHODIMP_(ULONG) Release(void);
  101. // IShellFolder methods
  102. STDMETHODIMP ParseDisplayName(HWND hwnd, LPBC pbc, LPOLESTR pszDisplayName,
  103. ULONG *pchEaten, LPITEMIDLIST *ppidl, ULONG *pdwAttributes);
  104. STDMETHODIMP EnumObjects(HWND hwnd, DWORD grfFlags, IEnumIDList **ppenumIDList);
  105. STDMETHODIMP BindToObject(LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppvOut);
  106. STDMETHODIMP BindToStorage(LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppvObj);
  107. STDMETHODIMP CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  108. STDMETHODIMP CreateViewObject(HWND hwnd, REFIID riid, void **ppvOut);
  109. STDMETHODIMP GetAttributesOf(UINT cidl, LPCITEMIDLIST *apidl, ULONG *rgfInOut);
  110. STDMETHODIMP GetUIObjectOf(HWND hwnd, UINT cidl, LPCITEMIDLIST * apidl,
  111. REFIID riid, UINT * prgfInOut, void **ppvOut);
  112. STDMETHODIMP GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD uFlags, LPSTRRET lpName);
  113. STDMETHODIMP SetNameOf(HWND hwnd, LPCITEMIDLIST pidl,
  114. LPCOLESTR lpszName, DWORD uFlags, LPITEMIDLIST * ppidlOut);
  115. // IShellFolder2
  116. STDMETHODIMP GetDefaultSearchGUID(LPGUID lpGuid) { return E_NOTIMPL; };
  117. STDMETHODIMP EnumSearches(LPENUMEXTRASEARCH *ppenum) { *ppenum = NULL; return E_NOTIMPL; };
  118. STDMETHODIMP GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay);
  119. STDMETHODIMP GetDefaultColumnState(UINT iColumn, DWORD *pbState) { return E_NOTIMPL; };
  120. STDMETHODIMP GetDetailsEx(LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv) { return E_NOTIMPL; };
  121. STDMETHODIMP GetDetailsOf(LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *pDetails);
  122. STDMETHODIMP MapColumnToSCID(UINT iCol, SHCOLUMNID *pscid) { return E_NOTIMPL; };
  123. // IShellIcon
  124. STDMETHODIMP GetIconOf(LPCITEMIDLIST pidl, UINT flags, LPINT lpIconIndex);
  125. // IPersist
  126. STDMETHODIMP GetClassID(CLSID *pClassID);
  127. // IPersistFolder
  128. STDMETHODIMP Initialize(LPCITEMIDLIST pidl);
  129. // IPersistFolder2 Methods
  130. STDMETHODIMP GetCurFolder(LPITEMIDLIST *ppidl);
  131. protected:
  132. ~CCacheFolder();
  133. HRESULT GetDisplayNameOfCEI(LPCITEMIDLIST pidl, DWORD uFlags, LPSTRRET lpName);
  134. HRESULT _CompareAlignedIDs(LPARAM lParam, LPCEIPIDL pidl1, LPCEIPIDL pidl2);
  135. HRESULT _GetInfoTip(LPCITEMIDLIST pidl, DWORD dwFlags, WCHAR **ppwszTip);
  136. STDMETHODIMP _GetDetail(LPCITEMIDLIST pidl, UINT iColumn, LPTSTR pszStr, UINT cchStr);
  137. HRESULT _GetFileSysFolder(IShellFolder2 **ppsf);
  138. static HRESULT CALLBACK _sViewCallback(IShellView *psv, IShellFolder *psf, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  139. LONG _cRef;
  140. UINT _uFlags; // copied from CacheFolder struct
  141. LPITEMIDLIST _pidl; // copied from CacheFolder struct
  142. IShellFolder2* _pshfSys; // system IShellFolder
  143. };
  144. class CCacheItem : public CBaseItem
  145. {
  146. // CCacheItem interfaces
  147. friend HRESULT CacheFolderView_DidDragDrop(IDataObject *pdo, DWORD dwEffect);
  148. public:
  149. CCacheItem();
  150. HRESULT Initialize(CCacheFolder *pHCFolder, HWND hwnd, UINT cidl, LPCITEMIDLIST *ppidl);
  151. // IUnknown Methods
  152. STDMETHODIMP QueryInterface(REFIID,void **);
  153. // IQueryInfo Methods
  154. STDMETHODIMP GetInfoTip(DWORD dwFlags, WCHAR **ppwszTip);
  155. // IContextMenu Methods
  156. STDMETHODIMP QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst,
  157. UINT idCmdLast, UINT uFlags);
  158. STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpici);
  159. // IDataObject Methods...
  160. STDMETHODIMP GetData(LPFORMATETC pFEIn, LPSTGMEDIUM pSTM);
  161. STDMETHODIMP QueryGetData(LPFORMATETC pFE);
  162. STDMETHODIMP EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC *ppEnum);
  163. // IExtractIconA Methods
  164. STDMETHODIMP GetIconLocation(UINT uFlags, LPSTR pszIconFile, UINT ucchMax, PINT pniIcon, PUINT puFlags);
  165. protected:
  166. ~CCacheItem();
  167. virtual LPCTSTR _GetUrl(int nIndex);
  168. virtual LPCTSTR _PidlToSourceUrl(LPCITEMIDLIST pidl);
  169. virtual UNALIGNED const TCHAR* _GetURLTitle(LPCITEMIDLIST pcei);
  170. BOOL _ZoneCheck(int nIndex, DWORD dwUrlAction);
  171. HRESULT _CreateHDROP(STGMEDIUM *pmedium);
  172. CCacheFolder* _pCFolder; // back pointer to our shell folder
  173. DWORD _dwDelCookie;
  174. static INT_PTR CALLBACK _sPropDlgProc(HWND, UINT, WPARAM, LPARAM);
  175. };
  176. #endif // __cplusplus
  177. #endif