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.

219 lines
9.3 KiB

  1. //-------------------------------------------------------------------------//
  2. //
  3. // AugMisf.h - Augmented Merge IShellFolder class declaration.
  4. //
  5. //-------------------------------------------------------------------------//
  6. #ifndef __AUGMISF_H__
  7. #define __AUGMISF_H__
  8. class CAugISFEnumItem
  9. {
  10. public:
  11. CAugISFEnumItem() {};
  12. BOOL Init(IShellFolder* psf, int iShellFolder, LPCITEMIDLIST pidl);
  13. BOOL InitWithWrappedToOwn(IShellFolder* psf, int iShellFolder, LPITEMIDLIST pidl);
  14. ~CAugISFEnumItem()
  15. {
  16. Str_SetPtr(&_pszDisplayName, NULL);
  17. ILFree(_pidlWrap);
  18. }
  19. void SetDisplayName(LPTSTR pszDispName)
  20. {
  21. Str_SetPtr(&_pszDisplayName, pszDispName);
  22. }
  23. ULONG _rgfAttrib;
  24. LPTSTR _pszDisplayName;
  25. LPITEMIDLIST _pidlWrap;
  26. };
  27. // Forwards:
  28. //-------------//
  29. class CNamespace ;
  30. STDAPI CAugmentedISF2_CreateInstance( IUnknown*, IUnknown**, LPCOBJECTINFO );
  31. class IAugmentedMergedShellFolderInternal : public IUnknown
  32. {
  33. public:
  34. STDMETHOD(GetPidl)(THIS_ int* /*in|out*/ piPos, DWORD grfEnumFlags, LPITEMIDLIST* ppidl) PURE;
  35. };
  36. //-------------------------------------------------------------------------//
  37. // Supports hierarchically merged shell namespaces
  38. class CAugmentedMergeISF : public IAugmentedShellFolder2,
  39. public IShellFolder2,
  40. public IShellService,
  41. public ITranslateShellChangeNotify,
  42. public IDropTarget,
  43. public IAugmentedMergedShellFolderInternal
  44. //-------------------------------------------------------------------------//
  45. {
  46. public:
  47. // *** IUnknown methods ***
  48. STDMETHOD ( QueryInterface ) ( REFIID, void ** ) ;
  49. STDMETHOD_( ULONG, AddRef ) ( ) ;
  50. STDMETHOD_( ULONG, Release ) ( ) ;
  51. // *** IShellFolder methods ***
  52. STDMETHOD( BindToObject ) ( LPCITEMIDLIST, LPBC, REFIID, LPVOID * ) ;
  53. STDMETHOD( BindToStorage ) ( LPCITEMIDLIST, LPBC, REFIID, LPVOID * ) ;
  54. STDMETHOD( CompareIDs ) ( LPARAM, LPCITEMIDLIST, LPCITEMIDLIST) ;
  55. STDMETHOD( CreateViewObject ) ( HWND, REFIID, LPVOID * ) ;
  56. STDMETHOD( EnumObjects ) ( HWND, DWORD, LPENUMIDLIST * ) ;
  57. STDMETHOD( GetAttributesOf ) ( UINT, LPCITEMIDLIST * , ULONG * ) ;
  58. STDMETHOD( GetDisplayNameOf ) ( LPCITEMIDLIST , DWORD , LPSTRRET ) ;
  59. STDMETHOD( GetUIObjectOf ) ( HWND, UINT, LPCITEMIDLIST *, REFIID, UINT *, LPVOID * ) ;
  60. STDMETHOD( ParseDisplayName ) ( HWND, LPBC, LPOLESTR, ULONG *, LPITEMIDLIST *, ULONG * ) ;
  61. STDMETHOD( SetNameOf ) ( HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST *) ;
  62. // *** IShellFolder2 methods ***
  63. // stub implementation to indicate we support CompareIDs() for identity
  64. STDMETHOD( GetDefaultSearchGUID)( LPGUID ) { return E_NOTIMPL; }
  65. STDMETHOD( EnumSearches ) ( LPENUMEXTRASEARCH *pe) { *pe = NULL; return E_NOTIMPL; }
  66. STDMETHOD(GetDefaultColumn)(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) { return E_NOTIMPL; };
  67. STDMETHOD(GetDefaultColumnState)(UINT iColumn, DWORD *pbState) { return E_NOTIMPL; };
  68. STDMETHOD(GetDetailsEx)(LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, VARIANT *pv) { return E_NOTIMPL; };
  69. STDMETHOD(GetDetailsOf)(LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *pDetails){ return E_NOTIMPL; };
  70. STDMETHOD(MapColumnToSCID)(UINT iCol, SHCOLUMNID *pscid) { return E_NOTIMPL; };
  71. // *** IAugmentedShellFolder methods ***
  72. STDMETHOD( AddNameSpace ) ( const GUID * pguidObject, IShellFolder * psf, LPCITEMIDLIST pidl, DWORD dwFlags ) ;
  73. STDMETHOD( GetNameSpaceID ) ( LPCITEMIDLIST pidl, GUID * pguidOut ) ;
  74. STDMETHOD( QueryNameSpace ) ( DWORD dwID, GUID * pguidOut, IShellFolder ** ppsf ) ;
  75. STDMETHOD( EnumNameSpace ) ( DWORD cNameSpaces, DWORD * pdwID ) ;
  76. // *** IAugmentedShellFolder2 methods ***
  77. // not used anywhere
  78. //STDMETHOD( GetNameSpaceCount ) ( OUT LONG* pcNamespaces ) ;
  79. //STDMETHOD( GetIDListWrapCount) ( LPCITEMIDLIST pidlWrap, OUT LONG * pcPidls) ;
  80. STDMETHOD( UnWrapIDList) ( LPCITEMIDLIST pidlWrap, LONG cPidls, IShellFolder** apsf, LPITEMIDLIST* apidlFolder, LPITEMIDLIST* apidlItems, LONG* pcFetched ) ;
  81. // *** IShellService methods ***
  82. STDMETHOD( SetOwner ) ( IUnknown * punkOwner ) ;
  83. // *** ITranslateShellChangeNotify methods ***
  84. STDMETHOD( TranslateIDs ) ( LONG *plEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2, LPITEMIDLIST * ppidlOut1, LPITEMIDLIST * ppidlOut2,
  85. LONG *plEvent2, LPITEMIDLIST * ppidlOut1Event2, LPITEMIDLIST * ppidlOut2Event2);
  86. STDMETHOD( IsChildID ) ( LPCITEMIDLIST pidlKid, BOOL fImmediate );
  87. STDMETHOD( IsEqualID ) ( LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2 );
  88. STDMETHOD( Register ) ( HWND hwnd, UINT uMsg, long lEvents );
  89. STDMETHOD( Unregister ) ( void );
  90. // *** IDropTarget methods ***
  91. STDMETHOD(DragEnter)(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  92. STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  93. STDMETHOD(DragLeave)(void);
  94. STDMETHOD(Drop)(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  95. // *** IAugmentedMergedShellFolderInternal ***
  96. STDMETHODIMP GetPidl(int* piPos, DWORD grfEnumFlags, LPITEMIDLIST* ppidl);
  97. // Construction, Destruction
  98. protected:
  99. CAugmentedMergeISF() ;
  100. virtual ~CAugmentedMergeISF() ;
  101. // Miscellaneous helpers
  102. protected:
  103. STDMETHOD( QueryNameSpace ) ( DWORD dwID, OUT PVOID* ppvNameSpace ) ;
  104. // pidl crackers
  105. STDMETHOD_( LPITEMIDLIST, GetNativePidl )( LPCITEMIDLIST pidl, LPARAM lParam /*int nID*/) ;
  106. BOOL _IsCommonPidl(LPCITEMIDLIST pidlItem);
  107. HRESULT _SearchForPidl(IShellFolder* psf, LPCITEMIDLIST pidl, BOOL fFolder, int* piIndex, CAugISFEnumItem** ppEnumItem);
  108. HRESULT _GetNamespaces(LPCITEMIDLIST pidlWrap, CNamespace** ppnsCommon, UINT* pnCommonID,
  109. CNamespace** ppnsUser, UINT* pnUserID,
  110. LPITEMIDLIST* ppidl, BOOL *pbIsFolder);
  111. HRESULT _GetContextMenu(HWND hwnd, UINT cidl, LPCITEMIDLIST * apidl,
  112. UINT * prgfInOut, LPVOID* ppvOut);
  113. BOOL _AffectAllUsers();
  114. // namespace utility methods
  115. STDMETHOD( GetDefNamespace ) ( LPCITEMIDLIST pidl, ULONG, OUT IShellFolder** ppsf, OUT LPITEMIDLIST* ppv) ;
  116. STDMETHOD( GetDefNamespace ) ( ULONG dwAttrib, OUT PVOID* ppv, OUT UINT *pnID, OUT PVOID* ppv0) ;
  117. CNamespace* Namespace( int iNamespace ) ;
  118. int NamespaceCount() const ;
  119. void FreeNamespaces() ;
  120. int AcquireObjects() ;
  121. void FreeObjects() ;
  122. static int CALLBACK DestroyObjectsProc( LPVOID pv, LPVOID pvData ) ;
  123. friend int CALLBACK AugMISFSearchForWrappedPidl(LPVOID p1, LPVOID p2, LPARAM lParam);
  124. BOOL IsChildIDInternal(LPCITEMIDLIST pidl, BOOL fImmediate, int* iShellFolder);
  125. #ifdef DEBUG
  126. void DumpObjects();
  127. #endif
  128. // Callback routines
  129. private:
  130. static int SetOwnerProc( LPVOID, LPVOID ) ;
  131. static int DestroyNamespacesProc(LPVOID pv, LPVOID pvData) ;
  132. // Data
  133. protected:
  134. HDPA _hdpaNamespaces ; // source namespace collection
  135. LPUNKNOWN _punkOwner ; // owner object
  136. LONG _cRef; // reference count.
  137. IDropTarget* _pdt;
  138. HWND _hwnd;
  139. BITBOOL _fCommon : 1; // is _pdt a common programs folder (or its child)
  140. #ifdef DEBUG
  141. BITBOOL _fInternalGDNO:1 ;
  142. #endif
  143. HDPA _hdpaObjects;
  144. int _count;
  145. DWORD _grfDragEnterKeyState;
  146. DWORD _dwDragEnterEffect;
  147. friend HRESULT CAugmentedISF2_CreateInstance( IUnknown*, IUnknown**, LPCOBJECTINFO );
  148. } ;
  149. //-------------------------------------------------------------------------//
  150. // inline implementation
  151. inline int CAugmentedMergeISF::NamespaceCount() const {
  152. return _hdpaNamespaces ? DPA_GetPtrCount( _hdpaNamespaces ) : 0 ;
  153. }
  154. inline CNamespace* CAugmentedMergeISF::Namespace( int iNamespace ) {
  155. return _hdpaNamespaces ?
  156. (CNamespace*)DPA_GetPtr( _hdpaNamespaces, iNamespace ) : NULL ;
  157. }
  158. //-------------------------------------------------------------------------//
  159. // CAugmentedMergeISF enumerator object.
  160. class CEnum : public IEnumIDList
  161. //-------------------------------------------------------------------------//
  162. {
  163. // Public interface methods
  164. public:
  165. // *** IUnknown methods ***
  166. STDMETHOD ( QueryInterface ) (REFIID, void ** ) ;
  167. STDMETHOD_( ULONG,AddRef ) () ;
  168. STDMETHOD_( ULONG,Release ) () ;
  169. // *** IEnumIDList methods ***
  170. STDMETHOD( Next ) (ULONG, LPITEMIDLIST*, ULONG* ) ;
  171. STDMETHOD( Skip ) (ULONG) ;
  172. STDMETHOD( Reset ) ();
  173. STDMETHOD( Clone ) (IEnumIDList** ) ;
  174. // Construction, destruction, assignment:
  175. public:
  176. CEnum(IAugmentedMergedShellFolderInternal* psmsfi, DWORD grfEnumFlags, int iPos = 0);
  177. ~CEnum() ;
  178. // Miscellaneous methods, data
  179. protected:
  180. IAugmentedMergedShellFolderInternal* _psmsfi;
  181. DWORD _grfEnumFlags;
  182. LONG _cRef;
  183. int _iPos;
  184. } ;
  185. #endif __AUGMISF_H__