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.

411 lines
12 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: cdomain.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _CDOMAIN_H
  11. #define _CDOMAIN_H
  12. #include "resource.h" // main symbols
  13. extern const CLSID CLSID_DomainSnapinAbout;
  14. extern const CLSID CLSID_DomainAdmin; // In-Proc server GUID
  15. extern const GUID cDefaultNodeType; // Main NodeType GUID on numeric format
  16. extern const wchar_t* cszDefaultNodeType; // Main NodeType GUID on string format
  17. extern const wchar_t* CCF_DS_DOMAIN_TREE_SNAPIN_INTERNAL;
  18. /////////////////////////////////////////////////////////////////////////////
  19. // macros
  20. #define FREE_INTERNAL(pInternal) \
  21. ASSERT(pInternal != NULL); \
  22. do { if (pInternal != NULL) \
  23. GlobalFree(pInternal); } \
  24. while(0);
  25. /////////////////////////////////////////////////////////////////////////////
  26. // forward declarations
  27. class CDomainObject;
  28. class CComponentImpl;
  29. class CComponentDataImpl;
  30. class CHiddenWnd;
  31. class CDataObject;
  32. /////////////////////////////////////////////////////////////////////////////
  33. // constants
  34. // Note - This is the offset in my image list that represents the folder
  35. const DOMAIN_IMAGE_DEFAULT_IDX = 0;
  36. const DOMAIN_IMAGE_IDX = 1;
  37. /////////////////////////////////////////////////////////////////////////////
  38. // global functions
  39. void DialogContextHelp(DWORD* pTable, HELPINFO* pHelpInfo);
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CInternalFormatCracker
  42. class CInternalFormatCracker
  43. {
  44. public:
  45. CInternalFormatCracker(CComponentDataImpl* pCD)
  46. {
  47. m_pCD = pCD;
  48. m_pInternalFormat = NULL;
  49. }
  50. ~CInternalFormatCracker()
  51. {
  52. if (m_pInternalFormat != NULL)
  53. FREE_INTERNAL(m_pInternalFormat);
  54. }
  55. BOOL Extract(LPDATAOBJECT lpDataObject);
  56. BOOL GetContext(LPDATAOBJECT pDataObject, // input
  57. CFolderObject** ppFolderObject, // output
  58. DATA_OBJECT_TYPES* pType // output
  59. );
  60. INTERNAL* GetInternal()
  61. {
  62. return m_pInternalFormat;
  63. }
  64. private:
  65. INTERNAL* m_pInternalFormat;
  66. CComponentDataImpl* m_pCD;
  67. };
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CComponentDataImpl (i.e. scope pane side)
  70. class CRootFolderObject; // fwd decl
  71. class CComponentDataImpl:
  72. public IComponentData,
  73. public IExtendPropertySheet,
  74. public IExtendContextMenu,
  75. public ISnapinHelp2,
  76. public CComObjectRoot,
  77. public CComCoClass<CComponentDataImpl, &CLSID_DomainAdmin>
  78. {
  79. friend class CComponentImpl;
  80. BEGIN_COM_MAP(CComponentDataImpl)
  81. COM_INTERFACE_ENTRY(IComponentData)
  82. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  83. COM_INTERFACE_ENTRY(IExtendContextMenu)
  84. COM_INTERFACE_ENTRY(ISnapinHelp2)
  85. END_COM_MAP()
  86. DECLARE_REGISTRY_CLSID()
  87. friend class CComponentImpl;
  88. friend class CDataObject;
  89. CComponentDataImpl();
  90. HRESULT FinalConstruct();
  91. ~CComponentDataImpl();
  92. void FinalRelease();
  93. public:
  94. // IComponentData interface members
  95. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  96. STDMETHOD(CreateComponent)(LPCOMPONENT* ppComponent);
  97. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  98. STDMETHOD(Destroy)();
  99. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject);
  100. STDMETHOD(GetDisplayInfo)(SCOPEDATAITEM* pScopeDataItem);
  101. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  102. // IExtendPropertySheet interface
  103. public:
  104. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  105. LONG_PTR handle,
  106. LPDATAOBJECT lpIDataObject);
  107. STDMETHOD(QueryPagesFor)(LPDATAOBJECT lpDataObject);
  108. // IExtendContextMenu
  109. public:
  110. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject,
  111. LPCONTEXTMENUCALLBACK pCallbackUnknown,
  112. long *pInsertionAllowed);
  113. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  114. // ISnapinHelp2 interface members
  115. STDMETHOD(GetHelpTopic)(LPOLESTR* lpCompiledHelpFile);
  116. STDMETHOD(GetLinkedTopics)(LPOLESTR* lpCompiledHelpFile);
  117. // Notify handler declarations
  118. private:
  119. HRESULT OnExpand(CFolderObject* pFolderObject, LPARAM arg, LPARAM param);
  120. HRESULT OnPropertyChange(LPARAM param);
  121. #if DBG==1
  122. public:
  123. ULONG InternalAddRef()
  124. {
  125. return CComObjectRoot::InternalAddRef();
  126. }
  127. ULONG InternalRelease()
  128. {
  129. return CComObjectRoot::InternalRelease();
  130. }
  131. #endif // DBG==1
  132. public:
  133. MyBasePathsInfo* GetBasePathsInfo() { return &m_basePathsInfo;}
  134. CRootFolderObject* GetRootFolder() { return &m_rootFolder;}
  135. CDsDisplaySpecOptionsCFHolder* GetDsDisplaySpecOptionsCFHolder()
  136. { return &m_DsDisplaySpecOptionsCFHolder;}
  137. HRESULT AddFolder(CFolderObject* pFolderObject,
  138. HSCOPEITEM pParentScopeItem,
  139. BOOL bHasChildren);
  140. HRESULT AddDomainIcon();
  141. HRESULT AddDomainIconToResultPane(LPIMAGELIST lpImageList);
  142. int GetDomainImageIndex();
  143. HRESULT GetMainWindow(HWND* phWnd) { return m_pConsole->GetMainWindow(phWnd);}
  144. // Scope item creation helpers
  145. private:
  146. void EnumerateScopePane(CFolderObject* pFolderObject, HSCOPEITEM pParent);
  147. BOOL IsScopePaneNode(LPDATAOBJECT lpDataObject);
  148. private:
  149. LPCONSOLENAMESPACE m_pConsoleNameSpace;
  150. LPCONSOLE m_pConsole;
  151. void HandleStandardVerbsHelper(CComponentImpl* pComponentImpl,
  152. LPCONSOLEVERB pConsoleVerb,
  153. BOOL bScope, BOOL bSelect,
  154. CFolderObject* pFolderObject,
  155. DATA_OBJECT_TYPES type);
  156. void OnRefreshVerbHandler(CFolderObject* pFolderObject,
  157. CComponentImpl* pComponentImpl,
  158. BOOL bBindAgain=FALSE);
  159. void _OnSheetClose(CFolderObject* pCookie);
  160. void _OnSheetCreate(PDSA_SEC_PAGE_INFO pDsaSecondaryPageInfo, PWSTR pwzDC);
  161. // sheet API's
  162. void _SheetLockCookie(CFolderObject* pCookie);
  163. void _SheetUnlockCookie(CFolderObject* pCookie);
  164. public:
  165. HWND GetHiddenWindow();
  166. CCookieSheetTable* GetCookieSheet() { return &m_sheetCookieTable; }
  167. void SetInit() { m_bInitSuccess = TRUE; }
  168. protected:
  169. void _DeleteHiddenWnd();
  170. CHiddenWnd* m_pHiddenWnd;
  171. private:
  172. friend class CHiddenWnd; // to access thread notification handlers
  173. private:
  174. CRootFolderObject m_rootFolder; // root folder
  175. MyBasePathsInfo m_basePathsInfo; // container of base path info
  176. CDsDisplaySpecOptionsCFHolder m_DsDisplaySpecOptionsCFHolder; // cached clipbard format.
  177. HICON m_hDomainIcon;
  178. BOOL m_bInitSuccess;
  179. friend class CRootFolderObject;
  180. CCookieSheetTable m_sheetCookieTable; // table of cookies having a sheet up
  181. CSecondaryPagesManager<CDomainObject> m_secondaryPagesManager;
  182. };
  183. /////////////////////////////////////////////////////////////////////////////
  184. // CComponentImpl (i.e. result pane side)
  185. class CComponentImpl :
  186. public IComponent,
  187. public IExtendContextMenu,
  188. public IResultDataCompare,
  189. public CComObjectRoot
  190. {
  191. public:
  192. CComponentImpl();
  193. ~CComponentImpl();
  194. BEGIN_COM_MAP(CComponentImpl)
  195. COM_INTERFACE_ENTRY(IComponent)
  196. COM_INTERFACE_ENTRY(IExtendContextMenu)
  197. COM_INTERFACE_ENTRY(IResultDataCompare)
  198. END_COM_MAP()
  199. friend class CDataObject;
  200. // IComponent interface members
  201. public:
  202. STDMETHOD(Initialize)(LPCONSOLE lpConsole);
  203. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param);
  204. STDMETHOD(Destroy)(MMC_COOKIE cookie);
  205. STDMETHOD(GetResultViewType)(MMC_COOKIE cookie, LPOLESTR* ppViewType,
  206. long *pViewOptions);
  207. STDMETHOD(QueryDataObject)(MMC_COOKIE cookie, DATA_OBJECT_TYPES type,
  208. LPDATAOBJECT* ppDataObject);
  209. STDMETHOD(GetDisplayInfo)(RESULTDATAITEM* pResultDataItem);
  210. STDMETHOD(CompareObjects)(LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB);
  211. // IResultDataCompare
  212. STDMETHOD(Compare)(LPARAM lUserParam, MMC_COOKIE cookieA, MMC_COOKIE cookieB, int* pnResult);
  213. // Helpers for CComponentImpl
  214. public:
  215. void SetIComponentData(CComponentDataImpl* pData);
  216. void SetSelection(CFolderObject* pSelectedFolderObject, DATA_OBJECT_TYPES selectedType)
  217. {
  218. m_pSelectedFolderObject = pSelectedFolderObject;
  219. m_selectedType = selectedType;
  220. }
  221. #if DBG==1
  222. public:
  223. int dbg_cRef;
  224. ULONG InternalAddRef()
  225. {
  226. ++dbg_cRef;
  227. return CComObjectRoot::InternalAddRef();
  228. }
  229. ULONG InternalRelease()
  230. {
  231. --dbg_cRef;
  232. return CComObjectRoot::InternalRelease();
  233. }
  234. #endif // DBG==1
  235. // Notify event handlers
  236. protected:
  237. HRESULT OnShow(CFolderObject* pFolderObject, LPARAM arg, LPARAM param);
  238. HRESULT OnAddImages(CFolderObject* pFolderObject, LPARAM arg, LPARAM param);
  239. HRESULT OnPropertyChange(LPDATAOBJECT lpDataObject);
  240. HRESULT OnUpdateView(LPDATAOBJECT lpDataObject);
  241. // IExtendContextMenu
  242. public:
  243. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject,
  244. LPCONTEXTMENUCALLBACK pCallbackUnknown,
  245. long *pInsertionAllowed);
  246. STDMETHOD(Command)(long nCommandID, LPDATAOBJECT pDataObject);
  247. // Helper functions
  248. protected:
  249. BOOL IsEnumerating(LPDATAOBJECT lpDataObject);
  250. void Construct();
  251. void LoadResources();
  252. HRESULT InitializeHeaders(CFolderObject* pFolderObject);
  253. void Enumerate(CFolderObject* pFolderObject, HSCOPEITEM pParent);
  254. void Refresh(CFolderObject* pFolderObject);
  255. // Result pane helpers
  256. HRESULT InitializeBitmaps(CFolderObject* pFolderObject);
  257. // UI Helpers
  258. void HandleStandardVerbs(BOOL bScope, BOOL bSelect,
  259. CFolderObject* pFolderObject, DATA_OBJECT_TYPES type);
  260. // Interface pointers
  261. protected:
  262. LPCONSOLE m_pConsole; // Console's IFrame interface
  263. LPHEADERCTRL m_pHeader; // Result pane's header control interface
  264. LPCOMPONENTDATA m_pComponentData;
  265. CComponentDataImpl* m_pCD;
  266. LPRESULTDATA m_pResult; // My interface pointer to the result pane
  267. LPIMAGELIST m_pImageResult; // My interface pointer to the result pane image list
  268. LPCONSOLEVERB m_pConsoleVerb; // pointer the console verb
  269. // Header titles for each nodetype(s)
  270. protected:
  271. CString m_column1; // Name
  272. CString m_column2; // Type
  273. // state variables for this window
  274. CFolderObject* m_pSelectedFolderObject; // item selection (MMC_SELECT)
  275. DATA_OBJECT_TYPES m_selectedType; // matching m_pSelectedNode
  276. };
  277. inline void CComponentImpl::SetIComponentData(CComponentDataImpl* pData)
  278. {
  279. ASSERT(pData);
  280. ASSERT(m_pCD == NULL);
  281. ASSERT(m_pComponentData == NULL);
  282. m_pCD = pData;
  283. LPUNKNOWN pUnk = pData->GetUnknown();
  284. HRESULT hr;
  285. hr = pUnk->QueryInterface(IID_IComponentData, reinterpret_cast<void**>(&m_pComponentData));
  286. ASSERT(hr == S_OK);
  287. }
  288. //////////////////////////////////////////////////////////////////////////
  289. // CDomainSnapinAbout
  290. class CDomainSnapinAbout :
  291. public CSnapinAbout,
  292. public CComCoClass<CDomainSnapinAbout, &CLSID_DomainSnapinAbout>
  293. {
  294. public:
  295. DECLARE_REGISTRY_CLSID()
  296. CDomainSnapinAbout();
  297. };
  298. ////////////////////////////////////////////////////////////////////
  299. // CHiddenWnd
  300. class CHiddenWnd : public CWindowImpl<CHiddenWnd>
  301. {
  302. public:
  303. DECLARE_WND_CLASS(L"DSAHiddenWindow")
  304. static const UINT s_SheetCloseNotificationMessage;
  305. static const UINT s_SheetCreateNotificationMessage;
  306. CHiddenWnd(CComponentDataImpl* pCD)
  307. {
  308. ASSERT(pCD != NULL);
  309. m_pCD = pCD;
  310. }
  311. BOOL Create();
  312. // message handlers
  313. LRESULT OnSheetCloseNotification(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  314. LRESULT OnSheetCreateNotification(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  315. BEGIN_MSG_MAP(CHiddenWnd)
  316. MESSAGE_HANDLER( CHiddenWnd::s_SheetCloseNotificationMessage, OnSheetCloseNotification )
  317. MESSAGE_HANDLER( CHiddenWnd::s_SheetCreateNotificationMessage, OnSheetCreateNotification )
  318. END_MSG_MAP()
  319. private:
  320. CComponentDataImpl* m_pCD;
  321. };
  322. #endif // _CDOMAIN_H