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.

139 lines
7.6 KiB

  1. /*****************************************************************************\
  2. FILE: isf.h
  3. DESCRIPTION:
  4. This is a base class that implements the default behavior of IShellFolder.
  5. \*****************************************************************************/
  6. #ifndef _DEFAULT_ISHELLFOLDER_H
  7. #define _DEFAULT_ISHELLFOLDER_H
  8. #include "cowsite.h"
  9. /*****************************************************************************\
  10. CLASS: CBaseFolder
  11. DESCRIPTION:
  12. The stuff that tracks the state of a folder.
  13. The cBusy field tracks how many sub-objects have been created
  14. (e.g., IEnumIDList) which still contain references to this
  15. folder's identity. You cannot change the folder's identity
  16. (via IPersistFolder::Initialize) while there are outstanding
  17. subobjects.
  18. The number of cBusy's never exceeds the number of cRef's, because
  19. each subobject that requires the folder identity must retain a
  20. reference to the folder itself. That way, the folder won't be
  21. Release()d while the identity is still needed.
  22. Name Space description (for m_pidlComplete & m_nIDOffsetToOurNameSpaceRoot):
  23. The name space is provided by the shell to describe resources for the user.
  24. This class is a base implementation so users can create their own name space
  25. that is rooted in the shell's name space. A PIDL is a list of ItemID, each of
  26. which represent one level in the name space. The list provides a path thru
  27. the name space to a specific item. Example:
  28. [Desktop][My Computer][C:\][Dir1][Dir2][File.htm][#goto_description_secion]
  29. [Desktop][The Internet][ftp://server/][Dir1][Dir2][file.txt]
  30. [Desktop][My Computer][PrivateNS lvl1][lvl2][lvl3]...
  31. (Public Name Space) (Private Name Space)
  32. [GNS Level1][GNS Levl2][Pri LVL1][P LVL2][P LVL3]...
  33. In the example immediately above, this CBaseFolder can create a name space
  34. under "My Computer" that has 3 levels (lvl1, lvl2, lvl3). An instance of this
  35. COM object will be positioned at one level of the sub name space (lvl1, lvl2, or lvl3).
  36. m_pidlComplete - is the list of ItemIDs from the base [Desktop] to the current location
  37. maybe lvl2.
  38. m_nIDOffsetToOurNameSpaceRoot - is the number of bytes of m_pidlComplete that you need
  39. to skip to get to the first ItemID in the private name space (which
  40. is the name space owned by this class).
  41. \*****************************************************************************/
  42. class CBaseFolder : public IShellFolder2
  43. , public IPersistFolder3
  44. , public CObjectWithSite
  45. {
  46. public:
  47. //////////////////////////////////////////////////////
  48. // Public Interfaces
  49. //////////////////////////////////////////////////////
  50. // *** IUnknown ***
  51. virtual STDMETHODIMP_(ULONG) AddRef(void);
  52. virtual STDMETHODIMP_(ULONG) Release(void);
  53. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  54. // *** IShellFolder ***
  55. virtual STDMETHODIMP ParseDisplayName(HWND hwndOwner, LPBC pbcReserved, LPOLESTR lpszDisplayName,
  56. ULONG * pchEaten, LPITEMIDLIST * ppidl, ULONG *pdwAttributes);
  57. virtual STDMETHODIMP EnumObjects(HWND hwndOwner, DWORD grfFlags, LPENUMIDLIST * ppenumIDList);
  58. virtual STDMETHODIMP BindToObject(LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut);
  59. virtual STDMETHODIMP BindToStorage(LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvObj);
  60. virtual STDMETHODIMP CompareIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  61. virtual STDMETHODIMP CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID * ppvOut);
  62. virtual STDMETHODIMP GetAttributesOf(UINT cidl, LPCITEMIDLIST * apidl, ULONG * rgfInOut);
  63. virtual STDMETHODIMP GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut);
  64. virtual STDMETHODIMP GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD uFlags, LPSTRRET lpName);
  65. virtual STDMETHODIMP SetNameOf(HWND hwndOwner, LPCITEMIDLIST pidl, LPCOLESTR lpszName, DWORD uFlags, LPITEMIDLIST * ppidlOut);
  66. // *** IShellFolder2 ***
  67. virtual STDMETHODIMP GetDefaultSearchGUID(GUID *pguid) {return E_NOTIMPL;};
  68. virtual STDMETHODIMP EnumSearches(IEnumExtraSearch **ppenum) {return E_NOTIMPL;};
  69. virtual STDMETHODIMP GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) {return E_NOTIMPL;};
  70. virtual STDMETHODIMP GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags) {return E_NOTIMPL;};
  71. virtual STDMETHODIMP GetDetailsEx(LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv) {return E_NOTIMPL;};
  72. virtual STDMETHODIMP GetDetailsOf(LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd) {return E_NOTIMPL;};
  73. virtual STDMETHODIMP MapColumnToSCID(UINT iCol, SHCOLUMNID *pscid) {return E_NOTIMPL;};
  74. // *** IPersist ***
  75. virtual STDMETHODIMP GetClassID(LPCLSID lpClassID);
  76. // *** IPersistFolder ***
  77. virtual STDMETHODIMP Initialize(LPCITEMIDLIST pidl);
  78. // *** IPersistFolder2 ***
  79. virtual STDMETHODIMP GetCurFolder(LPITEMIDLIST *ppidl);
  80. // *** IPersistFolder3 ***
  81. virtual STDMETHODIMP InitializeEx(IBindCtx *pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO *ppfti);
  82. virtual STDMETHODIMP GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO *ppfti);
  83. public:
  84. CBaseFolder(LPCLSID pClassID);
  85. virtual ~CBaseFolder(void);
  86. // Public Member Functions
  87. virtual HRESULT _GetUIObjectOf(HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut, BOOL fFromCreateViewObject);
  88. virtual HRESULT _Initialize(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlAliasRoot, int nBytesToPrivate);
  89. virtual HRESULT _CreateShellView(HWND hwndOwner, void ** ppvObj) = 0; // PURE
  90. virtual HRESULT _CreateShellView(HWND hwndOwner, void ** ppvObj, LONG lEvents, FOLDERVIEWMODE fvm, IShellFolderViewCB * psfvCallBack,
  91. LPCITEMIDLIST pidl, LPFNVIEWCALLBACK pfnCallback);
  92. LPCITEMIDLIST GetPublicTargetPidlReference(void) { return m_pidl;};
  93. LPITEMIDLIST GetPublicTargetPidlClone(void) { return ILClone(GetPublicTargetPidlReference());};
  94. LPCITEMIDLIST GetPublicRootPidlReference(void) { return (m_pidlRoot ? m_pidlRoot : m_pidl);};
  95. LPITEMIDLIST GetPublicRootPidlClone(void) { return ILClone(GetPublicRootPidlReference());};
  96. LPCITEMIDLIST GetPrivatePidlReference(void);
  97. LPITEMIDLIST GetPrivatePidlClone(void) { return ILClone(GetPrivatePidlReference());};
  98. LPITEMIDLIST GetPublicPidlRootIDClone(void);
  99. LPITEMIDLIST CreateFullPublicPidlFromRelative(LPCITEMIDLIST pidlPrivateSubPidl);
  100. LPITEMIDLIST CreateFullPrivatePidl(LPCITEMIDLIST pidlPrivateSubPidl);
  101. LPITEMIDLIST CreateFullPublicPidl(LPCITEMIDLIST pidlPrivatePidl);
  102. LPCITEMIDLIST GetFolderPidl(void) { return m_pidlRoot;};
  103. protected:
  104. int m_cRef;
  105. int GetPidlByteOffset(void) { return m_nIDOffsetToPrivate;};
  106. private:
  107. LPITEMIDLIST m_pidl; // Public Pidl - Complete list of IDs from very base of NameSpace to this name space and into this name space to the point of being rooted.
  108. LPITEMIDLIST m_pidlRoot; // Pidl of Folder Shortcut.
  109. int m_nIDOffsetToPrivate; // number of bytes from the start of m_pidlComplete to the first ItemID in our name space.
  110. LPCLSID m_pClassID; // My CLSID
  111. };
  112. #endif // _DEFAULT_ISHELLFOLDER_H