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.

245 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. BOOL _ContainsCommonItem(LPCITEMIDLIST pidl);
  120. HRESULT _New(LPCITEMIDLIST pidlWrap, CMergedFolder **ppmf);
  121. HRESULT _IsWrap(LPCITEMIDLIST pidlTest);
  122. HRESULT _CreateWrap(LPCITEMIDLIST pidlSrc, UINT nSrcID, LPITEMIDLIST *ppidlWrap);
  123. HRESULT _WrapAddIDList(LPCITEMIDLIST pidlSrc, UINT nSrcID, IN OUT LPITEMIDLIST *ppidlWrap);
  124. ULONG _GetSourceCount(IN LPCITEMIDLIST pidl);
  125. BOOL _ContainsSrcID(LPCITEMIDLIST pidlWrap, UINT uSrcID);
  126. HRESULT _WrapRemoveIDList(LPITEMIDLIST pidlWrap, UINT nSrcID, LPITEMIDLIST *ppidl);
  127. HRESULT _WrapRemoveIDListAbs(LPITEMIDLIST pidlWrapAbs, UINT nSrcID, LPITEMIDLIST *ppidlAbs);
  128. HRESULT _GetSubPidl(LPCITEMIDLIST pidlWrap, int i, UINT* pnSrcID, LPITEMIDLIST *ppidl, CMergedFldrNamespace **ppns);
  129. HRESULT _ForceParseDisplayName(LPCITEMIDLIST pidlAbsNamespace, LPTSTR pszDisplayName, BOOL fForce, BOOL *pfOthersInwrap, LPITEMIDLIST *ppidl);
  130. HRESULT _AbsPidlToAbsWrap(CMergedFldrNamespace *pns, LPCITEMIDLIST pidl, BOOL fForce, BOOL *pfOthersInwrap, LPITEMIDLIST *ppidl);
  131. HRESULT _AddComposite(const COMPFOLDERINIT *pcfi);
  132. void _SetSimple(LPITEMIDLIST *ppidl);
  133. BOOL _IsSimple(LPCITEMIDLIST pidl);
  134. HRESULT _FixStrRetOffset(LPCITEMIDLIST pidl, STRRET *psr);
  135. BOOL _IsFolder(LPCITEMIDLIST pidl);
  136. HRESULT _CreateOtherNameSpace(IShellFolder **ppsf);
  137. HRESULT _CompareSingleLevelIDs(LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  138. static int CALLBACK _SearchByName(void *p1, void *p2, LPARAM lParam);
  139. static void *_Merge(UINT uMsg, void * pv1, void * pv2, LPARAM lParam);
  140. static int _CompareArbitraryPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  141. static int _Compare(void *pv1, void *pv2, LPARAM lParam);
  142. HRESULT _SearchForPidl(int iNamespace, CMergedFldrNamespace *pns, LPCITEMIDLIST pidl, BOOL fFolder, int* piIndex, CMergedFldrItem** ppmfi);
  143. HRESULT _GetTargetUIObjectOf(IShellFolder *psf, HWND hwnd, UINT cidl, LPCITEMIDLIST *apidl, REFIID riid, UINT *prgf, void **ppv);
  144. HRESULT _GetContextMenu(HWND hwnd, UINT cidl, LPCITEMIDLIST *apidl, REFIID riid, void **ppv);
  145. int _NamespaceCount() const;
  146. void _FreeNamespaces();
  147. int _AcquireObjects();
  148. void _FreeObjects();
  149. int _ObjectCount() const;
  150. CMergedFldrItem *_GetObject(int i);
  151. BOOL _IsFolderEvent(LONG lEvent);
  152. LPITEMIDLIST _ILCombineBase(LPCITEMIDLIST pidlContainingBase, LPCITEMIDLIST pidlRel);
  153. static int _DestroyObjectsProc(void *pv, void *pvData);
  154. static int _SetOwnerProc(void *, void *);
  155. static int _SetNotifyProc(void *, void *);
  156. static int _DestroyNamespacesProc(void *pv, void *pvData);
  157. BOOL _IsChildIDInternal(LPCITEMIDLIST pidl, BOOL fImmediate, int* iShellFolder);
  158. void _GetKeyForProperty(LPWSTR pszName, LPWSTR pszValue, LPWSTR pszBuffer, INT cchBuffer);
  159. HRESULT _AddNameSpaceFromPropertyBag(IPropertyBag *ppb, LPWSTR pszName);
  160. HRESULT _SimpleAddNamespace(CMergedFldrNamespace *pns);
  161. BOOL _IsOurColumn(UINT iColumn);
  162. HRESULT _GetWhichFolderColumn(LPCITEMIDLIST pidl, LPTSTR pszBuffer, INT cchBuffer);
  163. HRESULT _GetDestinationStorage(DWORD grfMode, IStorage **ppstg);
  164. void _AddAllOtherNamespaces(LPITEMIDLIST *ppidl);
  165. public:
  166. LPITEMIDLIST _pidl; // CMergedFolder is a base class for several IShellFolders, and their IShellFolderViewCBs need access to this
  167. private:
  168. CLSID _clsid; // our identity
  169. LONG _cRef; // reference count.
  170. HDPA _hdpaNamespaces; // source _Namespace collection
  171. HDPA _hdpaObjects; // array of (CMergedFldrItem *)
  172. CMergedFolder *_pmfParent; // parent folder (if any)
  173. UINT _iColumnOffset; // offset to my column set (-1 if unknown)
  174. DWORD _dwDropEffect; // default drop effect for this folder
  175. BOOL _fInShellView; // true if we're in the view. used in TranslateIDs.
  176. BOOL _fDontMerge; // true means don't merge the items in the view (but still navigate like we're merged).
  177. BOOL _fPartialMerge; // true if only some namespaces should be merged
  178. BOOL _fCDBurn; // true means we're the cdburn case.
  179. IStorage *_pstg; // hold onto the storage for the first namespace (default for IStorage operations).
  180. BOOL _fAcquiring; // correct for architecture problem where state is kept in the folder about the enumeration
  181. friend CMergedFldrEnum;
  182. friend CMergedFldrDropTarget;
  183. friend CMergedFldrContextMenu;
  184. friend CMergedCategorizer;
  185. friend CMergedFolderViewCB;
  186. };
  187. class CMergedFolderViewCB : public CBaseShellFolderViewCB
  188. {
  189. public:
  190. CMergedFolderViewCB(CMergedFolder *pmf);
  191. STDMETHODIMP RealMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  192. protected:
  193. virtual ~CMergedFolderViewCB();
  194. CMergedFolder *_pmf;
  195. private:
  196. HRESULT _OnGetWebViewTemplate(DWORD pv, UINT uViewMode, SFVM_WEBVIEW_TEMPLATE_DATA* pvi);
  197. HRESULT _OnFSNotify(DWORD pv, LPCITEMIDLIST *ppidl, LPARAM lp);
  198. HRESULT _RefreshObjectsWithSameName(IShellFolderView *psfv, LPITEMIDLIST pidl);
  199. };
  200. #endif // _mergfldr_h_