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.

244 lines
12 KiB

  1. #ifndef _mergfldr_h_
  2. #define _mergfldr_h_
  3. #include "sfstorage.h"
  4. #include "clsobj.h"
  5. class CMergedFolder;
  6. class CMergedFldrDropTarget;
  7. class CMergedFldrContextMenu;
  8. class CMergedFldrNamespace;
  9. class CMergedFldrItem;
  10. class CMergedFldrEnum;
  11. class CMergedCategorizer;
  12. class CMergedFolderViewCB;
  13. class CMergedFolder : public CSFStorage,
  14. public IAugmentedShellFolder3,
  15. public IShellService,
  16. public ITranslateShellChangeNotify,
  17. public IPersistFolder2,
  18. public IPersistPropertyBag,
  19. public IShellIconOverlay,
  20. public ICompositeFolder,
  21. public IItemNameLimits
  22. {
  23. public:
  24. // IUnknown
  25. STDMETHOD (QueryInterface)(REFIID, void **);
  26. STDMETHOD_(ULONG, AddRef)();
  27. STDMETHOD_(ULONG, Release)();
  28. // IShellFolder
  29. STDMETHOD(ParseDisplayName)(HWND hwnd, LPBC pbc, LPOLESTR pszName, ULONG * pchEaten, LPITEMIDLIST * ppidl, ULONG *pdwAttributes);
  30. STDMETHOD(EnumObjects)(HWND hwnd, DWORD grfFlags, IEnumIDList **ppenumIDList);
  31. STDMETHOD(BindToObject)(LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppvOut);
  32. STDMETHOD(BindToStorage)(LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, void **ppvObj);
  33. STDMETHOD(CompareIDs)(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  34. STDMETHOD(CreateViewObject)(HWND hwndOwner, REFIID riid, void **ppvOut);
  35. STDMETHOD(GetAttributesOf)(UINT cidl, LPCITEMIDLIST * apidl, ULONG *rgfInOut);
  36. STDMETHOD(GetUIObjectOf)(HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, void **ppvOut);
  37. STDMETHOD(GetDisplayNameOf)(LPCITEMIDLIST pidl, DWORD uFlags, LPSTRRET lpName);
  38. STDMETHOD(SetNameOf)(HWND hwnd, LPCITEMIDLIST pidl, LPCOLESTR pszName, DWORD uFlags, LPITEMIDLIST * ppidlOut);
  39. // IShellFolder2
  40. // stub implementation to indicate we support CompareIDs() for identity
  41. STDMETHOD(GetDefaultSearchGUID)(LPGUID)
  42. { return E_NOTIMPL; }
  43. STDMETHOD(EnumSearches)(LPENUMEXTRASEARCH *pe)
  44. { *pe = NULL; return E_NOTIMPL; }
  45. STDMETHOD(GetDefaultColumn)(DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
  46. { return E_NOTIMPL; };
  47. STDMETHOD(GetDefaultColumnState)(UINT iColumn, DWORD *pbState);
  48. STDMETHOD(GetDetailsEx)(LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv);
  49. STDMETHOD(GetDetailsOf)(LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *pDetails);
  50. STDMETHOD(MapColumnToSCID)(UINT iCol, SHCOLUMNID *pscid);
  51. // IAugmentedShellFolder
  52. STDMETHOD(AddNameSpace)(const GUID * pguidObject, IShellFolder * psf, LPCITEMIDLIST pidl, DWORD dwFlags);
  53. STDMETHOD(GetNameSpaceID)(LPCITEMIDLIST pidl, GUID * pguidOut);
  54. STDMETHOD(QueryNameSpace)(DWORD dwID, GUID * pguidOut, IShellFolder ** ppsf);
  55. STDMETHOD(EnumNameSpace)(DWORD cNameSpaces, DWORD * pdwID);
  56. // IAugmentedShellFolder2
  57. STDMETHOD(UnWrapIDList)(LPCITEMIDLIST pidlWrap, LONG cPidls, IShellFolder** apsf, LPITEMIDLIST* apidlFolder, LPITEMIDLIST* apidlItems, LONG* pcFetched);
  58. // IAugmentedShellFolder3
  59. STDMETHOD(QueryNameSpace2)(DWORD dwID, QUERYNAMESPACEINFO *pqnsi);
  60. // IShellService
  61. STDMETHOD(SetOwner)(IUnknown * punkOwner);
  62. // ITranslateShellChangeNotify
  63. STDMETHOD(TranslateIDs)(LONG *plEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2, LPITEMIDLIST *ppidlOut1, LPITEMIDLIST *ppidlOut2,
  64. LONG *plEvent2, LPITEMIDLIST *ppidlOut1Event2, LPITEMIDLIST *ppidlOut2Event2);
  65. STDMETHOD(IsChildID)(LPCITEMIDLIST pidlKid, BOOL fImmediate);
  66. STDMETHOD(IsEqualID)(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  67. STDMETHOD(Register)(HWND hwnd, UINT uMsg, long lEvents);
  68. STDMETHOD(Unregister)(void);
  69. // IPersist
  70. STDMETHOD(GetClassID)(CLSID *pclsid)
  71. { *pclsid = _clsid; return S_OK; };
  72. // IPersistFolder
  73. STDMETHOD(Initialize)(LPCITEMIDLIST pidl);
  74. // IPersistFolder2
  75. STDMETHOD(GetCurFolder)(LPITEMIDLIST *ppidl);
  76. // IPersistPropertyBag
  77. STDMETHOD(InitNew)()
  78. { return E_NOTIMPL; };
  79. STDMETHOD(Load)(IPropertyBag* ppb, IErrorLog *pErrLog);
  80. STDMETHOD(Save)(IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
  81. { return E_NOTIMPL; };
  82. // IShellIconOverlay
  83. STDMETHOD(GetOverlayIndex)(LPCITEMIDLIST pidl, int *pIndex);
  84. STDMETHOD(GetOverlayIconIndex)(LPCITEMIDLIST pidl, int *pIndex);
  85. // ICompositeFolder
  86. STDMETHOD(InitComposite)(WORD wSignature, REFCLSID refclsid, CFINITF cfiFlags, ULONG celt, const COMPFOLDERINIT *rgCFs);
  87. STDMETHOD(BindToParent)(LPCITEMIDLIST pidl, REFIID riid, void **ppv, LPITEMIDLIST *ppidlLast);
  88. // IItemNameLimits
  89. STDMETHOD(GetValidCharacters)(LPWSTR *ppwszValidChars, LPWSTR *ppwszInvalidChars)
  90. { return E_NOTIMPL; }
  91. STDMETHOD(GetMaxLength)(LPCWSTR pszName, int *piMaxNameLen)
  92. { return E_NOTIMPL; }
  93. protected:
  94. CMergedFolder(CMergedFolder*pmfParent, REFCLSID clsid);
  95. virtual ~CMergedFolder();
  96. friend HRESULT CMergedFolder_CreateInstance(IUnknown *punkOuter, REFIID riid, void **ppv);
  97. friend HRESULT CCompositeFolder_CreateInstance(IUnknown *punkOuter, REFIID riid, void **ppv);
  98. virtual HRESULT _CreateWithCLSID(CLSID clsid, CMergedFolder **ppmf);
  99. virtual BOOL _ShouldSuspend(REFGUID rguid);
  100. private:
  101. // CSFStorage
  102. STDMETHOD(_DeleteItemByIDList)(LPCITEMIDLIST pidl);
  103. STDMETHOD(_StgCreate)(LPCITEMIDLIST pidl, DWORD grfMode, REFIID riid, void **ppv);
  104. CMergedFldrNamespace* _Namespace(int iNamespace);
  105. HRESULT _Namespace(int i, CMergedFldrNamespace **ppns);
  106. HRESULT _NamespaceForItem(LPCITEMIDLIST pidlWrap, ULONG dwAttribMask, ULONG dwAttrib, IShellFolder** ppsf, LPITEMIDLIST *ppidl, CMergedFldrNamespace **ppns, BOOL fExact = FALSE);
  107. HRESULT _OldTranslateIDs(LONG *plEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2, LPITEMIDLIST *ppidlOut1, LPITEMIDLIST *ppidlOut2,
  108. LONG *plEvent2, LPITEMIDLIST *ppidlOut1Event2, LPITEMIDLIST *ppidlOut2Event2);
  109. HRESULT _NewTranslateIDs(LONG *plEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2, LPITEMIDLIST *ppidlOut1, LPITEMIDLIST *ppidlOut2,
  110. LONG *plEvent2, LPITEMIDLIST *ppidlOut1Event2, LPITEMIDLIST *ppidlOut2Event2);
  111. HRESULT _GetOverlayInfo(LPCITEMIDLIST pidl, int * pIndex, DWORD dwFlags);
  112. BOOL _NamespaceMatches(ULONG dwAttribMask, ULONG dwAttrib, LPCGUID pguid, CMergedFldrNamespace *pns);
  113. HRESULT _FindNamespace(ULONG dwAttribMask, ULONG dwAttrib, LPCGUID pguid, CMergedFldrNamespace **ppv, BOOL fFallback = FALSE);
  114. BOOL _ShouldMergeNamespaces(int iNS1, int iNS2);
  115. BOOL _ShouldMergeNamespaces(CMergedFldrNamespace *pns1, CMergedFldrNamespace *pns2);
  116. CMergedFolder*_Parent() { return _pmfParent; }
  117. HRESULT _GetPidl(int* piPos, DWORD grfEnumFlags, LPITEMIDLIST *ppidl);
  118. HRESULT _GetFolder2(LPCITEMIDLIST pidlWrap, LPITEMIDLIST *ppidlItem, IShellFolder2 **ppsf);
  119. HRESULT _New(LPCITEMIDLIST pidlWrap, CMergedFolder **ppmf);
  120. HRESULT _IsWrap(LPCITEMIDLIST pidlTest);
  121. HRESULT _CreateWrap(LPCITEMIDLIST pidlSrc, UINT nSrcID, LPITEMIDLIST *ppidlWrap);
  122. HRESULT _WrapAddIDList(LPCITEMIDLIST pidlSrc, UINT nSrcID, IN OUT LPITEMIDLIST *ppidlWrap);
  123. ULONG _GetSourceCount(IN LPCITEMIDLIST pidl);
  124. BOOL _ContainsSrcID(LPCITEMIDLIST pidlWrap, UINT uSrcID);
  125. HRESULT _WrapRemoveIDList(LPITEMIDLIST pidlWrap, UINT nSrcID, LPITEMIDLIST *ppidl);
  126. HRESULT _WrapRemoveIDListAbs(LPITEMIDLIST pidlWrapAbs, UINT nSrcID, LPITEMIDLIST *ppidlAbs);
  127. HRESULT _GetSubPidl(LPCITEMIDLIST pidlWrap, int i, UINT* pnSrcID, LPITEMIDLIST *ppidl, CMergedFldrNamespace **ppns);
  128. HRESULT _ForceParseDisplayName(LPCITEMIDLIST pidlAbsNamespace, LPTSTR pszDisplayName, BOOL fForce, BOOL *pfOthersInwrap, LPITEMIDLIST *ppidl);
  129. HRESULT _AbsPidlToAbsWrap(CMergedFldrNamespace *pns, LPCITEMIDLIST pidl, BOOL fForce, BOOL *pfOthersInwrap, LPITEMIDLIST *ppidl);
  130. HRESULT _AddComposite(const COMPFOLDERINIT *pcfi);
  131. void _SetSimple(LPITEMIDLIST *ppidl);
  132. BOOL _IsSimple(LPCITEMIDLIST pidl);
  133. HRESULT _FixStrRetOffset(LPCITEMIDLIST pidl, STRRET *psr);
  134. BOOL _IsFolder(LPCITEMIDLIST pidl);
  135. HRESULT _CreateOtherNameSpace(IShellFolder **ppsf);
  136. HRESULT _CompareSingleLevelIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  137. static int CALLBACK _SearchByName(void *p1, void *p2, LPARAM lParam);
  138. static void *_Merge(UINT uMsg, void * pv1, void * pv2, LPARAM lParam);
  139. static int _CompareArbitraryPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  140. static int _Compare(void *pv1, void *pv2, LPARAM lParam);
  141. HRESULT _SearchForPidl(int iNamespace, CMergedFldrNamespace *pns, LPCITEMIDLIST pidl, BOOL fFolder, int* piIndex, CMergedFldrItem** ppmfi);
  142. HRESULT _GetTargetUIObjectOf(IShellFolder *psf, HWND hwnd, UINT cidl, LPCITEMIDLIST *apidl, REFIID riid, UINT *prgf, void **ppv);
  143. HRESULT _GetContextMenu(HWND hwnd, UINT cidl, LPCITEMIDLIST *apidl, REFIID riid, void **ppv);
  144. int _NamespaceCount() const;
  145. void _FreeNamespaces();
  146. int _AcquireObjects();
  147. void _FreeObjects();
  148. int _ObjectCount() const;
  149. CMergedFldrItem *_GetObject(int i);
  150. BOOL _IsFolderEvent(LONG lEvent);
  151. LPITEMIDLIST _ILCombineBase(LPCITEMIDLIST pidlContainingBase, LPCITEMIDLIST pidlRel);
  152. static int _DestroyObjectsProc(void *pv, void *pvData);
  153. static int _SetOwnerProc(void *, void *);
  154. static int _SetNotifyProc(void *, void *);
  155. static int _DestroyNamespacesProc(void *pv, void *pvData);
  156. BOOL _IsChildIDInternal(LPCITEMIDLIST pidl, BOOL fImmediate, int* iShellFolder);
  157. void _GetKeyForProperty(LPWSTR pszName, LPWSTR pszValue, LPWSTR pszBuffer, INT cchBuffer);
  158. HRESULT _AddNameSpaceFromPropertyBag(IPropertyBag *ppb, LPWSTR pszName);
  159. HRESULT _SimpleAddNamespace(CMergedFldrNamespace *pns);
  160. BOOL _IsOurColumn(UINT iColumn);
  161. HRESULT _GetWhichFolderColumn(LPCITEMIDLIST pidl, LPTSTR pszBuffer, INT cchBuffer);
  162. HRESULT _GetDestinationStorage(DWORD grfMode, IStorage **ppstg);
  163. void _AddAllOtherNamespaces(LPITEMIDLIST *ppidl);
  164. public:
  165. LPITEMIDLIST _pidl; // CMergedFolder is a base class for several IShellFolders, and their IShellFolderViewCBs need access to this
  166. private:
  167. CLSID _clsid; // our identity
  168. LONG _cRef; // reference count.
  169. HDPA _hdpaNamespaces; // source _Namespace collection
  170. HDPA _hdpaObjects; // array of (CMergedFldrItem *)
  171. CMergedFolder *_pmfParent; // parent folder (if any)
  172. UINT _iColumnOffset; // offset to my column set (-1 if unknown)
  173. DWORD _dwDropEffect; // default drop effect for this folder
  174. BOOL _fInShellView; // true if we're in the view. used in TranslateIDs.
  175. BOOL _fDontMerge; // true means don't merge the items in the view (but still navigate like we're merged).
  176. BOOL _fPartialMerge; // true if only some namespaces should be merged
  177. BOOL _fCDBurn; // true means we're the cdburn case.
  178. IStorage *_pstg; // hold onto the storage for the first namespace (default for IStorage operations).
  179. BOOL _fAcquiring; // correct for architecture problem where state is kept in the folder about the enumeration
  180. friend CMergedFldrEnum;
  181. friend CMergedFldrDropTarget;
  182. friend CMergedFldrContextMenu;
  183. friend CMergedCategorizer;
  184. friend CMergedFolderViewCB;
  185. };
  186. class CMergedFolderViewCB : public CBaseShellFolderViewCB
  187. {
  188. public:
  189. CMergedFolderViewCB(CMergedFolder *pmf);
  190. STDMETHODIMP RealMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  191. protected:
  192. virtual ~CMergedFolderViewCB();
  193. CMergedFolder *_pmf;
  194. private:
  195. HRESULT _OnGetWebViewTemplate(DWORD pv, UINT uViewMode, SFVM_WEBVIEW_TEMPLATE_DATA* pvi);
  196. HRESULT _OnFSNotify(DWORD pv, LPCITEMIDLIST *ppidl, LPARAM lp);
  197. HRESULT _RefreshObjectsWithSameName(IShellFolderView *psfv, LPITEMIDLIST pidl);
  198. };
  199. #endif // _mergfldr_h_