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.

559 lines
13 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: bennodes.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // BenefitsNodes.h
  11. //
  12. //////////////////////////////////////////////////////////////////////
  13. #if !defined(AFX_BENEFITSNODES_H__E0573E77_D325_11D1_846C_00104B211BE5__INCLUDED_)
  14. #define AFX_BENEFITSNODES_H__E0573E77_D325_11D1_846C_00104B211BE5__INCLUDED_
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif // _MSC_VER > 1000
  18. #include "Benefits.h"
  19. //
  20. // Added to support the generated COM dispatch interface.
  21. //
  22. #import "SampCtrl\SampCtrl.ocx"
  23. using namespace SampCtrl;
  24. class CRetirementNode : public CBenefitsData< CRetirementNode >
  25. {
  26. public:
  27. SNAPINMENUID( IDR_UPDATE_MENU )
  28. BEGIN_SNAPINCOMMAND_MAP( CRetirementNode, FALSE )
  29. SNAPINCOMMAND_ENTRY(ID_TASK_ENROLL, OnEnroll)
  30. SNAPINCOMMAND_ENTRY(ID_TOP_UPDATE, OnUpdate)
  31. END_SNAPINCOMMAND_MAP()
  32. BEGIN_SNAPINTOOLBARID_MAP( CRetirementNode )
  33. END_SNAPINTOOLBARID_MAP()
  34. CRetirementNode( CEmployee* pCurEmployee );
  35. virtual ~CRetirementNode();
  36. //
  37. // Overridden to display web page as results.
  38. //
  39. STDMETHOD( GetResultViewType )( LPOLESTR *ppViewType, long *pViewOptions );
  40. //
  41. // Overridden to provide strings for various columns.
  42. //
  43. LPOLESTR GetResultPaneColInfo(int nCol);
  44. //
  45. // Command handler for "Enroll" functionality.
  46. //
  47. STDMETHOD( OnEnroll )(bool& bHandled, CSnapInObjectRootBase* pObj);
  48. //
  49. // Command handler for "Update" functionality.
  50. //
  51. STDMETHOD( OnUpdate )(bool& bHandled, CSnapInObjectRootBase* pObj);
  52. //
  53. // Overridden to cache the OCX pointer.
  54. //
  55. STDMETHOD(Notify)( MMC_NOTIFY_TYPE event,
  56. long arg,
  57. long param,
  58. IComponentData* pComponentData,
  59. IComponent* pComponent,
  60. DATA_OBJECT_TYPES type)
  61. {
  62. HRESULT hr = E_NOTIMPL;
  63. switch (event)
  64. {
  65. case MMCN_SHOW:
  66. //
  67. // Always respond to the show call so that the
  68. // console knows this has been processed and can
  69. // properly seat toolbars, etc.
  70. //
  71. hr = S_OK;
  72. break;
  73. case MMCN_INITOCX:
  74. //
  75. // The IUnknown of the OCX is passed in. Do
  76. // any other initialization of the OCX here.
  77. //
  78. m_spControl = (IUnknown*) param;
  79. hr = S_OK;
  80. break;
  81. default:
  82. //
  83. // Always default to calling the base class implementation.
  84. //
  85. hr = CBenefitsData<CRetirementNode>::Notify( event,
  86. arg,
  87. param,
  88. pComponentData,
  89. pComponent,
  90. type );
  91. }
  92. return hr;
  93. }
  94. protected:
  95. //
  96. // Definition generated by compiler. IDispatch implementation.
  97. //
  98. _SampleControlPtr m_spControl;
  99. };
  100. #define TASKPAD_LOCALQUERY 100
  101. class CHealthNode : public CBenefitsData< CHealthNode >,
  102. public CTaskpadItem
  103. {
  104. public:
  105. SNAPINMENUID( IDR_ENROLL_MENU )
  106. BEGIN_SNAPINCOMMAND_MAP( CHealthNode, FALSE )
  107. SNAPINCOMMAND_ENTRY(ID_TASK_ENROLL, OnEnroll)
  108. SNAPINCOMMAND_ENTRY(ID_TOP_IMPORT, OnImport)
  109. SNAPINCOMMAND_ENTRY(ID_TOP_EXPORT, OnExport)
  110. SNAPINCOMMAND_ENTRY(ID_VIEW_TASKPAD, OnTaskpad)
  111. END_SNAPINCOMMAND_MAP()
  112. BEGIN_SNAPINTOOLBARID_MAP( CHealthNode )
  113. SNAPINTOOLBARID_ENTRY( IDR_ENROLLTOOLBAR )
  114. END_SNAPINTOOLBARID_MAP()
  115. CHealthNode( CEmployee* pCurEmployee );
  116. virtual ~CHealthNode();
  117. //
  118. // Overridden to display web page as results.
  119. //
  120. STDMETHOD( GetResultViewType )( LPOLESTR *ppViewType, long *pViewOptions );
  121. //
  122. // Overridden to provide strings for various columns.
  123. //
  124. LPOLESTR GetResultPaneColInfo(int nCol);
  125. //
  126. // Command handler for "Enroll" functionality.
  127. //
  128. STDMETHOD( OnEnroll )(bool& bHandled, CSnapInObjectRootBase* pObj);
  129. //
  130. // Restores any state, especially in the case of using a
  131. // taskpad, when the back and forward buttons are used by
  132. // the user for navigation.
  133. //
  134. STDMETHOD( OnRestoreView )( MMC_RESTORE_VIEW* pRestoreView, BOOL* pfHandled );
  135. //
  136. // Command handler for "OnTaskpad" functionality.
  137. //
  138. STDMETHOD( OnTaskpad )(bool& bHandled, CSnapInObjectRootBase* pObj)
  139. {
  140. UNUSED_ALWAYS( bHandled );
  141. CComPtr<IConsole> spConsole;
  142. //
  143. // Switch the current view mode to a taskpad view.
  144. //
  145. m_fTaskpad = !m_fTaskpad;
  146. //
  147. // Reselect the node to cause GetResultViewType() to get
  148. // called once again.
  149. //
  150. if ( pObj->m_nType == 1 )
  151. spConsole = ((CBenefits*)pObj)->m_spConsole;
  152. else
  153. spConsole = ((CBenefitsComponent*)pObj)->m_spConsole;
  154. spConsole->SelectScopeItem( m_scopeDataItem.ID );
  155. return( S_OK );
  156. }
  157. //
  158. // Overridden to set the checkmark state of the taskpad menuitem.
  159. //
  160. void UpdateMenuState(UINT id, LPTSTR pBuf, UINT *flags)
  161. {
  162. UNUSED_ALWAYS( pBuf );
  163. //
  164. // Check the menuitem if we are currently in "taskpad"
  165. // mode.
  166. //
  167. if ( id == ID_VIEW_TASKPAD )
  168. *flags |= m_fTaskpad ? MFS_CHECKED : MFS_UNCHECKED;
  169. }
  170. //
  171. // Overridden to enable the delete verb.
  172. //
  173. STDMETHOD(Notify)( MMC_NOTIFY_TYPE event,
  174. long arg,
  175. long param,
  176. IComponentData* pComponentData,
  177. IComponent* pComponent,
  178. DATA_OBJECT_TYPES type)
  179. {
  180. HRESULT hr = E_NOTIMPL;
  181. switch (event)
  182. {
  183. case MMCN_SELECT:
  184. hr = S_OK;
  185. break;
  186. case MMCN_RESTORE_VIEW:
  187. //
  188. // Called when the history list is used to navigate by
  189. // the user. Since we have a taskpad display, it's up
  190. // to us to restore that view, as appropriate.
  191. //
  192. hr = OnRestoreView( (MMC_RESTORE_VIEW*) arg, (BOOL*) param );
  193. break;
  194. case MMCN_SHOW:
  195. //
  196. // Always respond to the show call so that the
  197. // console knows this has been processed and can
  198. // properly seat toolbars, etc.
  199. //
  200. hr = S_OK;
  201. break;
  202. default:
  203. //
  204. // Always default to calling the base class implementation.
  205. //
  206. hr = CBenefitsData< CHealthNode >::Notify( event,
  207. arg,
  208. param,
  209. pComponentData,
  210. pComponent,
  211. type );
  212. }
  213. return hr;
  214. }
  215. //
  216. // Called when one of the tasks is clicked.
  217. //
  218. STDMETHOD( TaskNotify )( IConsole* pConsole, VARIANT* arg, VARIANT* param );
  219. //
  220. // Returns an enumerator for all of these tasks.
  221. //
  222. STDMETHOD( EnumTasks )( LPOLESTR szTaskGroup, IEnumTASK** ppEnumTASK );
  223. protected:
  224. //
  225. // Indicates whether we should be displayed in a taskpad view.
  226. //
  227. bool m_fTaskpad;
  228. };
  229. class CBuildingNode;
  230. class CKeyNode : public CChildrenBenefitsData< CKeyNode >
  231. {
  232. public:
  233. SNAPINMENUID( IDR_ACCESS_MENU )
  234. BEGIN_SNAPINCOMMAND_MAP( CKeyNode, FALSE )
  235. SNAPINCOMMAND_ENTRY(ID_NEW_BUILDINGACCESS, OnGrantAccess)
  236. END_SNAPINCOMMAND_MAP()
  237. BEGIN_SNAPINTOOLBARID_MAP( CKeyNode )
  238. SNAPINTOOLBARID_ENTRY( IDR_ACCESSTOOLBAR )
  239. END_SNAPINTOOLBARID_MAP()
  240. CKeyNode( CEmployee* pCurEmployee );
  241. virtual ~CKeyNode();
  242. //
  243. // Overridden to call the base class implementation.
  244. //
  245. STDMETHOD(Notify)( MMC_NOTIFY_TYPE event,
  246. long arg,
  247. long param,
  248. IComponentData* pComponentData,
  249. IComponent* pComponent,
  250. DATA_OBJECT_TYPES type)
  251. {
  252. ATLTRACE2( atlTraceSnapin, 0, _T( "CNotifyImpl::Notify\n" ) );
  253. // Add code to handle the different notifications.
  254. // Handle MMCN_SHOW and MMCN_EXPAND to enumerate children items.
  255. // In response to MMCN_SHOW you have to enumerate both the scope
  256. // and result pane items.
  257. // For MMCN_EXPAND you only need to enumerate the scope items
  258. // Use IConsoleNameSpace::InsertItem to insert scope pane items
  259. // Use IResultData::InsertItem to insert result pane item.
  260. HRESULT hr = E_NOTIMPL;
  261. _ASSERTE( pComponentData != NULL || pComponent != NULL );
  262. CComPtr<IConsole> spConsole;
  263. CComQIPtr<IHeaderCtrl, &IID_IHeaderCtrl> spHeader;
  264. if (pComponentData != NULL)
  265. spConsole = ((CBenefits*)pComponentData)->m_spConsole;
  266. else
  267. {
  268. spConsole = ((CBenefitsComponent*)pComponent)->m_spConsole;
  269. spHeader = spConsole;
  270. }
  271. switch (event)
  272. {
  273. case MMCN_SELECT:
  274. //
  275. // Call our select handler.
  276. //
  277. hr = OnSelect( spConsole );
  278. break;
  279. case MMCN_SHOW:
  280. //
  281. // Only setup colums if we're displaying the result pane.
  282. //
  283. if ( arg == TRUE )
  284. hr = OnShowColumn( spHeader );
  285. hr = OnShow( event, arg, param, spConsole, type );
  286. break;
  287. case MMCN_EXPAND:
  288. //
  289. // We do not expand as normal, since the building nodes are
  290. // only displayed in the result pane.
  291. //
  292. break;
  293. case MMCN_ADD_IMAGES:
  294. hr = OnAddImages( event, arg, param, spConsole, type );
  295. break;
  296. case MMCN_QUERY_PASTE:
  297. //
  298. // Called to determine if the current object can be pasted
  299. // or not into this context.
  300. //
  301. hr = OnQueryPaste( (LPDATAOBJECT) arg );
  302. break;
  303. case MMCN_PASTE:
  304. //
  305. // Called by MMC when the item should be pasted.
  306. //
  307. hr = OnPaste( spConsole, (LPDATAOBJECT) arg, (LPDATAOBJECT*) param );
  308. break;
  309. }
  310. return hr;
  311. }
  312. //
  313. // Ensures that the appropriate verbs are displayed.
  314. //
  315. STDMETHOD( OnSelect )( IConsole* pConsole )
  316. {
  317. HRESULT hr;
  318. CComPtr<IConsoleVerb> spConsoleVerb;
  319. //
  320. // Enable the delete verb.
  321. //
  322. hr = pConsole->QueryConsoleVerb( &spConsoleVerb );
  323. _ASSERTE( SUCCEEDED( hr ) );
  324. //
  325. // Enable the copy and paste verbs.
  326. //
  327. hr = spConsoleVerb->SetVerbState( MMC_VERB_PASTE, ENABLED, TRUE );
  328. _ASSERTE( SUCCEEDED( hr ) );
  329. return( hr );
  330. }
  331. //
  332. // Called by the console to determine if we can paste the
  333. // specified node.
  334. //
  335. STDMETHOD( OnQueryPaste )( LPDATAOBJECT pItem );
  336. //
  337. // Called by MMC when the item should be pasted.
  338. //
  339. STDMETHOD( OnPaste )( IConsole* pConsole, LPDATAOBJECT pItem, LPDATAOBJECT* pItemCut );
  340. //
  341. // Overridden to provide strings for various columns.
  342. //
  343. LPOLESTR GetResultPaneColInfo(int nCol);
  344. //
  345. // Overridden to add new columns to the results
  346. // display.
  347. //
  348. STDMETHOD( OnShowColumn )( IHeaderCtrl* pHeader );
  349. //
  350. // Command handler for "Grant Acess" functionality.
  351. //
  352. STDMETHOD( OnGrantAccess )( bool& bHandled, CSnapInObjectRootBase* pObj );
  353. //
  354. // Called by one of our children nodes to inform us that
  355. // they should be deleted. This occurs when the user selects
  356. // a delete action on the building. This function should not
  357. // only delete the building, but also handle the refresh of
  358. // the result display.
  359. //
  360. STDMETHOD( OnDeleteBuilding )( IConsole* pConsole, CBuildingNode* pChildNode );
  361. };
  362. class CBuildingNode : public CBenefitsData< CBuildingNode >
  363. {
  364. public:
  365. BEGIN_SNAPINCOMMAND_MAP(CBuildingNode, FALSE)
  366. END_SNAPINCOMMAND_MAP()
  367. BEGIN_SNAPINTOOLBARID_MAP(CBuildingNode)
  368. END_SNAPINTOOLBARID_MAP()
  369. CBuildingNode( CKeyNode* pParentNode, BSTR bstrName, BSTR bstrLocation );
  370. CBuildingNode( const CBuildingNode& inNode );
  371. //
  372. // Overridden to provide strings for various columns.
  373. //
  374. LPOLESTR GetResultPaneColInfo(int nCol);
  375. //
  376. // Hold the location of this building.
  377. //
  378. BSTR m_bstrLocation;
  379. //
  380. // Pointer to our parent node to handle deletion
  381. // issues.
  382. //
  383. CKeyNode* m_pParentNode;
  384. //
  385. // Overridden to enable the delete verb.
  386. //
  387. STDMETHOD(Notify)( MMC_NOTIFY_TYPE event,
  388. long arg,
  389. long param,
  390. IComponentData* pComponentData,
  391. IComponent* pComponent,
  392. DATA_OBJECT_TYPES type)
  393. {
  394. HRESULT hr = E_NOTIMPL;
  395. CComPtr<IConsole> spConsole;
  396. CComQIPtr<IHeaderCtrl, &IID_IHeaderCtrl> spHeader;
  397. if (pComponentData != NULL)
  398. spConsole = ((CBenefits*)pComponentData)->m_spConsole;
  399. else
  400. {
  401. spConsole = ((CBenefitsComponent*)pComponent)->m_spConsole;
  402. spHeader = spConsole;
  403. }
  404. switch (event)
  405. {
  406. case MMCN_DELETE:
  407. //
  408. // Call our delete handler.
  409. //
  410. hr = OnDelete( spConsole );
  411. break;
  412. case MMCN_SELECT:
  413. //
  414. // Call our select handler.
  415. //
  416. hr = OnSelect( spConsole );
  417. break;
  418. case MMCN_SHOW:
  419. //
  420. // Always respond to the show call so that the
  421. // console knows this has been processed and can
  422. // properly seat toolbars, etc.
  423. //
  424. hr = S_OK;
  425. break;
  426. default:
  427. //
  428. // Always default to calling the base class implementation.
  429. //
  430. hr = CBenefitsData< CBuildingNode >::Notify( event,
  431. arg,
  432. param,
  433. pComponentData,
  434. pComponent,
  435. type );
  436. }
  437. return hr;
  438. }
  439. //
  440. // Delete handler.
  441. //
  442. STDMETHOD( OnDelete )( IConsole* pConsole )
  443. {
  444. _ASSERT( m_pParentNode != NULL );
  445. HRESULT hr;
  446. //
  447. // Calls the parent node to tell it to delete
  448. // ourselves.
  449. //
  450. hr = m_pParentNode->OnDeleteBuilding( pConsole, this );
  451. return( hr );
  452. }
  453. //
  454. // Ensures that the appropriate verbs are displayed.
  455. //
  456. STDMETHOD( OnSelect )( IConsole* pConsole )
  457. {
  458. HRESULT hr;
  459. CComPtr<IConsoleVerb> spConsoleVerb;
  460. //
  461. // Enable the delete verb.
  462. //
  463. hr = pConsole->QueryConsoleVerb( &spConsoleVerb );
  464. _ASSERTE( SUCCEEDED( hr ) );
  465. hr = spConsoleVerb->SetVerbState( MMC_VERB_DELETE, ENABLED, TRUE );
  466. _ASSERTE( SUCCEEDED( hr ) );
  467. //
  468. // Enable the copy and paste verbs.
  469. //
  470. hr = spConsoleVerb->SetVerbState( MMC_VERB_COPY, ENABLED, TRUE );
  471. _ASSERTE( SUCCEEDED( hr ) );
  472. return( hr );
  473. }
  474. };
  475. #endif // !defined(AFX_BENEFTISNODES_H__E0573E77_D325_11D1_846C_00104B211BE5__INCLUDED_)