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.

152 lines
7.0 KiB

  1. // Shell folder implementation for timewarp. The purpose of this object is
  2. // 1) to prevent write actions (move, delete) from being attempted
  3. // 2) to prevent upward navigation in the filesystem namespace
  4. // 3) to provide a friendly version of the date stamp as the folder name
  5. // NOTE: This object aggregates the file system folder so we get away with a
  6. // minimal set of interfaces on this object. The real file system folder does
  7. // stuff like IPersistFolder2 for us.
  8. extern const CLSID CLSID_TimeWarpFolder;// {9DB7A13C-F208-4981-8353-73CC61AE2783}
  9. #define TIMEWARP_SIGNATURE 0x5754 // "TW" in the debugger
  10. #pragma pack(1)
  11. typedef struct _IDTIMEWARP
  12. {
  13. // these memebers overlap DELEGATEITEMID struct
  14. // for our IDelegateFolder support
  15. WORD cbSize;
  16. WORD wOuter;
  17. WORD cbInner;
  18. // Timewarp stuff
  19. WORD wSignature;
  20. DWORD dwFlags; // currently unused
  21. FILETIME ftSnapTime;
  22. WCHAR wszPath[1]; // always room for at least NULL
  23. } IDTIMEWARP;
  24. typedef UNALIGNED IDTIMEWARP *PUIDTIMEWARP;
  25. typedef const UNALIGNED IDTIMEWARP *PCUIDTIMEWARP;
  26. #pragma pack()
  27. class CTimeWarpRegFolder : public IPersistFolder,
  28. public IDelegateFolder,
  29. public IShellFolder
  30. {
  31. public:
  32. static HRESULT CreateInstance(IUnknown *punkOuter, IUnknown **ppunk, LPCOBJECTINFO poi);
  33. // IUnknown
  34. STDMETHOD(QueryInterface)(REFIID riid, void **ppv);
  35. STDMETHOD_(ULONG, AddRef)();
  36. STDMETHOD_(ULONG, Release)();
  37. // IPersist, IPersistFreeThreadedObject
  38. STDMETHOD(GetClassID)(CLSID *pClassID);
  39. // IPersistFolder
  40. STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidl);
  41. // IDelegateFolder
  42. STDMETHOD(SetItemAlloc)(IMalloc *pmalloc);
  43. // IShellFolder
  44. STDMETHOD(ParseDisplayName)(HWND hwnd, LPBC pbc, LPOLESTR pDisplayName,
  45. ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes);
  46. STDMETHOD(EnumObjects)(HWND hwnd, DWORD grfFlags, IEnumIDList **ppEnumIDList);
  47. STDMETHOD(BindToObject)(PCUIDLIST_RELATIVE pidl, LPBC pbc, REFIID riid, void **ppv);
  48. STDMETHOD(BindToStorage)(PCUIDLIST_RELATIVE pidl, LPBC pbc, REFIID riid, void **ppv);
  49. STDMETHOD(CompareIDs)(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2);
  50. STDMETHOD(CreateViewObject)(HWND hwnd, REFIID riid, void **ppv);
  51. STDMETHOD(GetAttributesOf)(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, SFGAOF *rgfInOut);
  52. STDMETHOD(GetUIObjectOf)(HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, void **ppv);
  53. STDMETHOD(GetDisplayNameOf)(PCUITEMID_CHILD pidl, DWORD uFlags, STRRET *pName);
  54. STDMETHOD(SetNameOf)(HWND hwnd, PCUITEMID_CHILD pidl, LPCOLESTR pszName, SHGDNF uFlags, PITEMID_CHILD *ppidlOut);
  55. private:
  56. CTimeWarpRegFolder();
  57. ~CTimeWarpRegFolder();
  58. HRESULT _CreateAndInit(PCUIDLIST_RELATIVE pidl, LPBC pbc, REFIID riid, void **ppv);
  59. HRESULT _CreateDefExtIcon(PCUIDTIMEWARP pidTW, REFIID riid, void **ppv);
  60. static STDMETHODIMP ContextMenuCB(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam);
  61. LONG _cRef;
  62. IMalloc * _pmalloc;
  63. PIDLIST_ABSOLUTE _pidl; // copy of pidl passed to us in Initialize()
  64. };
  65. //
  66. // Note that we don't need to override any of the IShellFolder2 methods, but
  67. // we have to implement IShellFolder2 anyway. Otherwise, a caller could QI
  68. // for IShellFolder2, which would come from the aggregated CFSFolder code,
  69. // and then call IShellFolder methods on it. Those calls would go directly
  70. // to CFSFolder, bypassing our implementation of IShellFolder.
  71. //
  72. class CTimeWarpFolder : public IPersistFolder,
  73. public IShellFolder2
  74. {
  75. public:
  76. static STDMETHODIMP CreateInstance(REFCLSID rclsid, PCIDLIST_ABSOLUTE pidlRoot, PCIDLIST_ABSOLUTE pidlTarget,
  77. LPCWSTR pszTargetPath, const FILETIME UNALIGNED *pftSnapTime,
  78. REFIID riid, void **ppv);
  79. // IUnknown
  80. STDMETHOD(QueryInterface)(REFIID riid, void **ppv);
  81. STDMETHOD_(ULONG, AddRef)();
  82. STDMETHOD_(ULONG, Release)();
  83. // IPersist, IPersistFreeThreadedObject
  84. STDMETHOD(GetClassID)(CLSID *pClassID);
  85. // IPersistFolder
  86. STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidl);
  87. // IPersistFolder2, IPersistFolder3, etc are all implemented by
  88. // the folder we aggregate, CFSFolder, so we don't want to implement them
  89. // IShellFolder
  90. STDMETHOD(ParseDisplayName)(HWND hwnd, LPBC pbc, LPOLESTR pDisplayName,
  91. ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes);
  92. STDMETHOD(EnumObjects)(HWND hwnd, DWORD grfFlags, IEnumIDList **ppEnumIDList);
  93. STDMETHOD(BindToObject)(PCUIDLIST_RELATIVE pidl, LPBC pbc, REFIID riid, void **ppv);
  94. STDMETHOD(BindToStorage)(PCUIDLIST_RELATIVE pidl, LPBC pbc, REFIID riid, void **ppv);
  95. STDMETHOD(CompareIDs)(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2);
  96. STDMETHOD(CreateViewObject)(HWND hwnd, REFIID riid, void **ppv);
  97. STDMETHOD(GetAttributesOf)(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, SFGAOF *rgfInOut);
  98. STDMETHOD(GetUIObjectOf)(HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, void **ppv);
  99. STDMETHOD(GetDisplayNameOf)(PCUITEMID_CHILD pidl, DWORD uFlags, STRRET *pName);
  100. STDMETHOD(SetNameOf)(HWND hwnd, PCUITEMID_CHILD pidl, LPCOLESTR pszName, SHGDNF uFlags, PITEMID_CHILD *ppidlOut);
  101. // IShellFolder2
  102. STDMETHOD(GetDefaultSearchGUID)(LPGUID lpGuid);
  103. STDMETHOD(EnumSearches)(LPENUMEXTRASEARCH *ppenum);
  104. STDMETHOD(GetDefaultColumn)(DWORD dwRes, ULONG *pSort, ULONG *pDisplay);
  105. STDMETHOD(GetDefaultColumnState)(UINT iColumn, DWORD *pbState);
  106. STDMETHOD(GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv);
  107. STDMETHOD(GetDetailsOf))(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *pDetails);
  108. STDMETHOD(MapColumnToSCID)(UINT iCol, SHCOLUMNID *pscid);
  109. private:
  110. CTimeWarpFolder(const FILETIME UNALIGNED *pftSnapTime);
  111. ~CTimeWarpFolder();
  112. HRESULT _Init(REFCLSID rclsid, PCIDLIST_ABSOLUTE pidlRoot, PCIDLIST_ABSOLUTE pidlTarget, LPCWSTR pszTargetPath);
  113. HRESULT _CreateAndInit(REFCLSID rclsid, PCUIDLIST_RELATIVE pidl, LPBC pbc, REFIID riid, void **ppv);
  114. HRESULT _GetFolder();
  115. HRESULT _GetFolder2();
  116. HRESULT _GetClass(PCUITEMID_CHILD pidlChild, CLSID *pclsid);
  117. LONG _cRef;
  118. IUnknown * _punk; // points to IUnknown for shell folder in use...
  119. IShellFolder * _psf; // points to shell folder in use...
  120. IShellFolder2 * _psf2; // points to shell folder in use...
  121. IPersistFolder3 * _ppf3; // points to shell folder in use...
  122. PIDLIST_ABSOLUTE _pidlRoot; // copy of pidl passed to us in Initialize()
  123. FILETIME _ftSnapTime;
  124. };