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.

968 lines
26 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. provider.cpp
  7. Filter node handler
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "server.h"
  12. #include "FltrNode.h"
  13. #include "SpdUtil.h"
  14. #include "fltrpp.h"
  15. #include "srchfltr.h"
  16. /*---------------------------------------------------------------------------
  17. Class CFilterHandler implementation
  18. ---------------------------------------------------------------------------*/
  19. /*---------------------------------------------------------------------------
  20. Constructor and destructor
  21. Description
  22. Author: NSun
  23. ---------------------------------------------------------------------------*/
  24. CFilterHandler::CFilterHandler
  25. (
  26. ITFSComponentData * pComponentData
  27. ) : CIpsmHandler(pComponentData),
  28. m_FltrType(FILTER_TYPE_ANY) //by default we display both transport and tunnel filters
  29. {
  30. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  31. }
  32. CFilterHandler::~CFilterHandler()
  33. {
  34. }
  35. /*!--------------------------------------------------------------------------
  36. CFilterHandler::InitializeNode
  37. Initializes node specific data
  38. Author: NSun
  39. ---------------------------------------------------------------------------*/
  40. HRESULT
  41. CFilterHandler::InitializeNode
  42. (
  43. ITFSNode * pNode
  44. )
  45. {
  46. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  47. CString strTemp;
  48. strTemp.LoadString(IDS_FILTER_NODE);
  49. SetDisplayName(strTemp);
  50. // Make the node immediately visible
  51. pNode->SetVisibilityState(TFS_VIS_SHOW);
  52. pNode->SetData(TFS_DATA_COOKIE, (LPARAM) pNode);
  53. pNode->SetData(TFS_DATA_IMAGEINDEX, ICON_IDX_FOLDER_CLOSED);
  54. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, ICON_IDX_FOLDER_OPEN);
  55. pNode->SetData(TFS_DATA_USER, (LPARAM) this);
  56. pNode->SetData(TFS_DATA_TYPE, IPSECMON_FILTER);
  57. pNode->SetData(TFS_DATA_SCOPE_LEAF_NODE, TRUE);
  58. SetColumnStringIDs(&aColumns[IPSECMON_FILTER][0]);
  59. SetColumnWidths(&aColumnWidths[IPSECMON_FILTER][0]);
  60. return hrOK;
  61. }
  62. /*---------------------------------------------------------------------------
  63. CFilterHandler::GetImageIndex
  64. -
  65. Author: NSun
  66. ---------------------------------------------------------------------------*/
  67. int
  68. CFilterHandler::GetImageIndex(BOOL bOpenImage)
  69. {
  70. int nIndex = -1;
  71. return nIndex;
  72. }
  73. /*---------------------------------------------------------------------------
  74. Overridden base handler functions
  75. ---------------------------------------------------------------------------*/
  76. /*---------------------------------------------------------------------------
  77. CFilterHandler::OnAddMenuItems
  78. Adds context menu items for the SA scope pane node
  79. Author: NSun
  80. ---------------------------------------------------------------------------*/
  81. STDMETHODIMP
  82. CFilterHandler::OnAddMenuItems
  83. (
  84. ITFSNode * pNode,
  85. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  86. LPDATAOBJECT lpDataObject,
  87. DATA_OBJECT_TYPES type,
  88. DWORD dwType,
  89. long * pInsertionAllowed
  90. )
  91. {
  92. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  93. LONG fFlags = 0, fLoadingFlags = 0;
  94. HRESULT hr = S_OK;
  95. CString strMenuItem;
  96. if (type == CCT_SCOPE)
  97. {
  98. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TOP)
  99. {
  100. }
  101. }
  102. return hr;
  103. }
  104. /*!--------------------------------------------------------------------------
  105. CFilterHandler::AddMenuItems
  106. Adds context menu items for virtual list box (result pane) items
  107. Author: NSun
  108. ---------------------------------------------------------------------------*/
  109. STDMETHODIMP
  110. CFilterHandler::AddMenuItems
  111. (
  112. ITFSComponent * pComponent,
  113. MMC_COOKIE cookie,
  114. LPDATAOBJECT pDataObject,
  115. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  116. long * pInsertionAllowed
  117. )
  118. {
  119. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  120. HRESULT hr = hrOK;
  121. CString strMenuItem;
  122. SPINTERNAL spInternal;
  123. LONG fFlags = 0;
  124. spInternal = ExtractInternalFormat(pDataObject);
  125. // virtual listbox notifications come to the handler of the node that is selected.
  126. // check to see if this notification is for a virtual listbox item or this SA
  127. // node itself.
  128. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_VIEW)
  129. {
  130. //load and view menu items here
  131. }
  132. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_VIEW)
  133. {
  134. strMenuItem.LoadString(IDS_VIEW_ALL_FLTR);
  135. hr = LoadAndAddMenuItem( pContextMenuCallback,
  136. strMenuItem,
  137. IDS_VIEW_ALL_FLTR,
  138. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  139. (FILTER_TYPE_ANY == m_FltrType) ? MF_CHECKED : 0 );
  140. strMenuItem.LoadString(IDS_VIEW_TRANSPORT_FLTR);
  141. hr = LoadAndAddMenuItem( pContextMenuCallback,
  142. strMenuItem,
  143. IDS_VIEW_TRANSPORT_FLTR,
  144. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  145. (FILTER_TYPE_TRANSPORT == m_FltrType) ? MF_CHECKED : 0 );
  146. strMenuItem.LoadString(IDS_VIEW_TUNNEL_FLTR);
  147. hr = LoadAndAddMenuItem( pContextMenuCallback,
  148. strMenuItem,
  149. IDS_VIEW_TUNNEL_FLTR,
  150. CCM_INSERTIONPOINTID_PRIMARY_VIEW,
  151. (FILTER_TYPE_TUNNEL == m_FltrType) ? MF_CHECKED : 0 );
  152. ASSERT( SUCCEEDED(hr) );
  153. }
  154. return hr;
  155. }
  156. /*!--------------------------------------------------------------------------
  157. CFilterHandler::OnRefresh
  158. Default implementation for the refresh functionality
  159. Author: NSun
  160. ---------------------------------------------------------------------------*/
  161. HRESULT
  162. CFilterHandler::OnRefresh
  163. (
  164. ITFSNode * pNode,
  165. LPDATAOBJECT pDataObject,
  166. DWORD dwType,
  167. LPARAM arg,
  168. LPARAM param
  169. )
  170. {
  171. HRESULT hr = S_OK;
  172. int i = 0;
  173. SPIConsole spConsole;
  174. CORg(CHandler::OnRefresh(pNode, pDataObject, dwType, arg, param));
  175. CORg(m_spSpdInfo->EnumQmFilters());
  176. i = m_spSpdInfo->GetQmFilterCountOfCurrentViewType();
  177. // now notify the virtual listbox
  178. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  179. CORg ( spConsole->UpdateAllViews(pDataObject, i, RESULT_PANE_SET_VIRTUAL_LB_SIZE));
  180. Error:
  181. return hr;
  182. }
  183. /*---------------------------------------------------------------------------
  184. CFilterHandler::OnCommand
  185. Handles context menu commands for SA scope pane node
  186. Author: NSun
  187. ---------------------------------------------------------------------------*/
  188. STDMETHODIMP
  189. CFilterHandler::OnCommand
  190. (
  191. ITFSNode * pNode,
  192. long nCommandId,
  193. DATA_OBJECT_TYPES type,
  194. LPDATAOBJECT pDataObject,
  195. DWORD dwType
  196. )
  197. {
  198. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  199. //handle the scope context menu commands here
  200. return S_OK;
  201. }
  202. /*!--------------------------------------------------------------------------
  203. CFilterHandler::Command
  204. Handles context menu commands for virtual listbox items
  205. Author: NSun
  206. ---------------------------------------------------------------------------*/
  207. STDMETHODIMP
  208. CFilterHandler::Command
  209. (
  210. ITFSComponent * pComponent,
  211. MMC_COOKIE cookie,
  212. int nCommandID,
  213. LPDATAOBJECT pDataObject
  214. )
  215. {
  216. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  217. HRESULT hr = S_OK;
  218. SPITFSNode spNode;
  219. m_spResultNodeMgr->FindNode(cookie, &spNode);
  220. FILTER_TYPE NewFltrType = m_FltrType;
  221. // handle result context menu and view menus here
  222. switch (nCommandID)
  223. {
  224. case IDS_VIEW_ALL_FLTR:
  225. NewFltrType = FILTER_TYPE_ANY;
  226. break;
  227. case IDS_VIEW_TRANSPORT_FLTR:
  228. NewFltrType = FILTER_TYPE_TRANSPORT;
  229. break;
  230. case IDS_VIEW_TUNNEL_FLTR:
  231. NewFltrType = FILTER_TYPE_TUNNEL;
  232. break;
  233. default:
  234. break;
  235. }
  236. //Update the views if a different view is selected.
  237. if (NewFltrType != m_FltrType)
  238. {
  239. UpdateViewType(spNode, NewFltrType);
  240. }
  241. return hr;
  242. }
  243. /*!--------------------------------------------------------------------------
  244. CFilterHandler::HasPropertyPages
  245. Implementation of ITFSNodeHandler::HasPropertyPages
  246. NOTE: the root node handler has to over-ride this function to
  247. handle the snapin manager property page (wizard) case!!!
  248. Author: KennT
  249. ---------------------------------------------------------------------------*/
  250. STDMETHODIMP
  251. CFilterHandler::HasPropertyPages
  252. (
  253. ITFSNode * pNode,
  254. LPDATAOBJECT pDataObject,
  255. DATA_OBJECT_TYPES type,
  256. DWORD dwType
  257. )
  258. {
  259. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  260. return hrFalse;
  261. }
  262. /*---------------------------------------------------------------------------
  263. CFilterHandler::CreatePropertyPages
  264. Description
  265. Author: NSun
  266. ---------------------------------------------------------------------------*/
  267. STDMETHODIMP
  268. CFilterHandler::CreatePropertyPages
  269. (
  270. ITFSNode * pNode,
  271. LPPROPERTYSHEETCALLBACK lpSA,
  272. LPDATAOBJECT pDataObject,
  273. LONG_PTR handle,
  274. DWORD dwType
  275. )
  276. {
  277. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  278. DWORD dwError;
  279. DWORD dwDynDnsFlags;
  280. //
  281. // Create the property page
  282. //
  283. SPIComponentData spComponentData;
  284. m_spNodeMgr->GetComponentData(&spComponentData);
  285. //CServerProperties * pServerProp = new CServerProperties(pNode, spComponentData, m_spTFSCompData, NULL);
  286. //
  287. // Object gets deleted when the page is destroyed
  288. //
  289. Assert(lpSA != NULL);
  290. //return pServerProp->CreateModelessSheet(lpSA, handle);
  291. return hrFalse;
  292. }
  293. /*---------------------------------------------------------------------------
  294. CFilterHandler::OnPropertyChange
  295. Description
  296. Author: NSun
  297. ---------------------------------------------------------------------------*/
  298. HRESULT
  299. CFilterHandler::OnPropertyChange
  300. (
  301. ITFSNode * pNode,
  302. LPDATAOBJECT pDataobject,
  303. DWORD dwType,
  304. LPARAM arg,
  305. LPARAM lParam
  306. )
  307. {
  308. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  309. //CServerProperties * pServerProp = reinterpret_cast<CServerProperties *>(lParam);
  310. LONG_PTR changeMask = 0;
  311. // tell the property page to do whatever now that we are back on the
  312. // main thread
  313. //pServerProp->OnPropertyChange(TRUE, &changeMask);
  314. //pServerProp->AcknowledgeNotify();
  315. if (changeMask)
  316. pNode->ChangeNode(changeMask);
  317. return hrOK;
  318. }
  319. /*---------------------------------------------------------------------------
  320. CFilterHandler::OnExpand
  321. Handles enumeration of a scope item
  322. Author: NSun
  323. ---------------------------------------------------------------------------*/
  324. HRESULT
  325. CFilterHandler::OnExpand
  326. (
  327. ITFSNode * pNode,
  328. LPDATAOBJECT pDataObject,
  329. DWORD dwType,
  330. LPARAM arg,
  331. LPARAM param
  332. )
  333. {
  334. HRESULT hr = hrOK;
  335. if (m_bExpanded)
  336. return hr;
  337. // do the default handling
  338. CORg (CIpsmHandler::OnExpand(pNode, pDataObject, dwType, arg, param));
  339. Error:
  340. return hr;
  341. }
  342. /*!--------------------------------------------------------------------------
  343. CFilterHandler::OnResultSelect
  344. Handles the MMCN_SELECT notifcation
  345. Author: NSun
  346. ---------------------------------------------------------------------------*/
  347. HRESULT
  348. CFilterHandler::OnResultSelect
  349. (
  350. ITFSComponent * pComponent,
  351. LPDATAOBJECT pDataObject,
  352. MMC_COOKIE cookie,
  353. LPARAM arg,
  354. LPARAM lParam
  355. )
  356. {
  357. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  358. HRESULT hr = hrOK;
  359. SPINTERNAL spInternal;
  360. SPIConsole spConsole;
  361. SPIConsoleVerb spConsoleVerb;
  362. SPITFSNode spNode;
  363. BOOL bStates[ARRAYLEN(g_ConsoleVerbs)];
  364. int i;
  365. LONG_PTR dwNodeType;
  366. BOOL fSelect = HIWORD(arg);
  367. // virtual listbox notifications come to the handler of the node that is selected.
  368. // check to see if this notification is for a virtual listbox item or the active
  369. // registrations node itself.
  370. CORg (pComponent->GetConsoleVerb(&spConsoleVerb));
  371. m_verbDefault = MMC_VERB_OPEN;
  372. if (!fSelect)
  373. {
  374. return hr;
  375. }
  376. if (m_spSpdInfo)
  377. {
  378. DWORD dwInitInfo;
  379. dwInitInfo=m_spSpdInfo->GetInitInfo();
  380. if (!(dwInitInfo & MON_QM_FILTER)) {
  381. CORg(m_spSpdInfo->EnumQmFilters());
  382. m_spSpdInfo->SetInitInfo(dwInitInfo | MON_QM_FILTER);
  383. m_spSpdInfo->SetInitInfo(dwInitInfo | MON_QM_SP_FILTER);
  384. }
  385. m_spSpdInfo->SetActiveInfo(MON_QM_FILTER);
  386. // Get the current count
  387. i = m_spSpdInfo->GetQmFilterCountOfCurrentViewType();
  388. // now notify the virtual listbox
  389. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  390. CORg ( spConsole->UpdateAllViews(pDataObject, i, RESULT_PANE_SET_VIRTUAL_LB_SIZE) );
  391. }
  392. // now update the verbs...
  393. spInternal = ExtractInternalFormat(pDataObject);
  394. Assert(spInternal);
  395. if (spInternal->HasVirtualIndex())
  396. {
  397. //TODO add to here if we want to have some result console verbs
  398. // we gotta do special stuff for the virtual index items
  399. dwNodeType = IPSECMON_FILTER_ITEM;
  400. for (i = 0; i < ARRAYLEN(g_ConsoleVerbs); bStates[i++] = FALSE);
  401. //enable the "properties" menu
  402. bStates[MMC_VERB_PROPERTIES & 0x000F] = TRUE;
  403. m_verbDefault = MMC_VERB_PROPERTIES;
  404. }
  405. else
  406. {
  407. // enable/disable delete depending if the node supports it
  408. CORg (m_spNodeMgr->FindNode(cookie, &spNode));
  409. dwNodeType = spNode->GetData(TFS_DATA_TYPE);
  410. for (i = 0; i < ARRAYLEN(g_ConsoleVerbs); bStates[i++] = TRUE);
  411. //hide "delete" context menu
  412. bStates[MMC_VERB_DELETE & 0x000F] = FALSE;
  413. bStates[MMC_VERB_REFRESH & 0x000F] = TRUE;
  414. }
  415. EnableVerbs(spConsoleVerb, g_ConsoleVerbStates[dwNodeType], bStates);
  416. COM_PROTECT_ERROR_LABEL;
  417. return hr;
  418. }
  419. /*!--------------------------------------------------------------------------
  420. CFilterHandler::OnDelete
  421. The base handler calls this when MMC sends a MMCN_DELETE for a
  422. scope pane item. We just call our delete command handler.
  423. Author: NSun
  424. ---------------------------------------------------------------------------*/
  425. HRESULT
  426. CFilterHandler::OnDelete
  427. (
  428. ITFSNode * pNode,
  429. LPARAM arg,
  430. LPARAM lParam
  431. )
  432. {
  433. return S_FALSE;
  434. }
  435. /*!--------------------------------------------------------------------------
  436. CFilterHandler::HasPropertyPages
  437. Handle the result notification
  438. Author: NSun
  439. ---------------------------------------------------------------------------*/
  440. STDMETHODIMP
  441. CFilterHandler::HasPropertyPages(
  442. ITFSComponent *pComponent,
  443. MMC_COOKIE cookie,
  444. LPDATAOBJECT pDataObject)
  445. {
  446. return hrOK;
  447. }
  448. /*!--------------------------------------------------------------------------
  449. CFilterHandler::HasPropertyPages
  450. Handle the result notification. Create the filter property sheet
  451. Author: NSun
  452. ---------------------------------------------------------------------------*/
  453. STDMETHODIMP CFilterHandler::CreatePropertyPages
  454. (
  455. ITFSComponent * pComponent,
  456. MMC_COOKIE cookie,
  457. LPPROPERTYSHEETCALLBACK lpProvider,
  458. LPDATAOBJECT pDataObject,
  459. LONG_PTR handle
  460. )
  461. {
  462. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  463. HRESULT hr = hrOK;
  464. SPINTERNAL spInternal;
  465. SPITFSNode spNode;
  466. int nIndex;
  467. SPIComponentData spComponentData;
  468. CFilterInfo FltrInfo;
  469. CFilterProperties * pFilterProp;
  470. Assert(m_spNodeMgr);
  471. CORg( m_spNodeMgr->FindNode(cookie, &spNode) );
  472. CORg( m_spNodeMgr->GetComponentData(&spComponentData) );
  473. spInternal = ExtractInternalFormat(pDataObject);
  474. // virtual listbox notifications come to the handler of the node that is selected.
  475. // assert that this notification is for a virtual listbox item
  476. Assert(spInternal);
  477. if (!spInternal->HasVirtualIndex())
  478. return hr;
  479. nIndex = spInternal->GetVirtualIndex();
  480. CORg(m_spSpdInfo->GetFilterInfo(nIndex, &FltrInfo));
  481. pFilterProp = new CFilterProperties(
  482. spNode,
  483. spComponentData,
  484. m_spTFSCompData,
  485. &FltrInfo,
  486. m_spSpdInfo,
  487. NULL);
  488. hr = pFilterProp->CreateModelessSheet(lpProvider, handle);
  489. COM_PROTECT_ERROR_LABEL;
  490. return hr;
  491. }
  492. /*---------------------------------------------------------------------------
  493. CFilterHandler::OnGetResultViewType
  494. Return the result view that this node is going to support
  495. Author: NSun
  496. ---------------------------------------------------------------------------*/
  497. HRESULT
  498. CFilterHandler::OnGetResultViewType
  499. (
  500. ITFSComponent * pComponent,
  501. MMC_COOKIE cookie,
  502. LPOLESTR * ppViewType,
  503. long * pViewOptions
  504. )
  505. {
  506. if (cookie != NULL)
  507. {
  508. *pViewOptions = MMC_VIEW_OPTIONS_OWNERDATALIST;
  509. }
  510. return S_FALSE;
  511. }
  512. /*---------------------------------------------------------------------------
  513. CFilterHandler::GetVirtualImage
  514. Returns the image index for virtual listbox items
  515. Author: NSun
  516. ---------------------------------------------------------------------------*/
  517. int
  518. CFilterHandler::GetVirtualImage
  519. (
  520. int nIndex
  521. )
  522. {
  523. return ICON_IDX_FILTER;
  524. }
  525. /*---------------------------------------------------------------------------
  526. CFilterHandler::GetVirtualString
  527. returns a pointer to the string for virtual listbox items
  528. Author: NSun
  529. ---------------------------------------------------------------------------*/
  530. LPCWSTR
  531. CFilterHandler::GetVirtualString
  532. (
  533. int nIndex,
  534. int nCol
  535. )
  536. {
  537. HRESULT hr = S_OK;
  538. static CString strTemp;
  539. strTemp.Empty();
  540. if (nCol >= DimensionOf(aColumns[IPSECMON_FILTER]))
  541. return NULL;
  542. CFilterInfo filter;
  543. CORg(m_spSpdInfo->GetFilterInfo(nIndex, &filter));
  544. switch (aColumns[IPSECMON_FILTER][nCol])
  545. {
  546. case IDS_COL_FLTR_NAME:
  547. strTemp = filter.m_stName;
  548. return strTemp;
  549. break;
  550. case IDS_COL_FLTR_SRC:
  551. AddressToString(filter.m_SrcAddr, &strTemp);
  552. return strTemp;
  553. break;
  554. case IDS_COL_FLTR_DEST:
  555. AddressToString(filter.m_DesAddr, &strTemp);
  556. return strTemp;
  557. break;
  558. case IDS_COL_FLTR_SRC_PORT:
  559. PortToString(filter.m_SrcPort, &strTemp);
  560. return strTemp;
  561. break;
  562. case IDS_COL_FLTR_DEST_PORT:
  563. PortToString(filter.m_DesPort, &strTemp);
  564. return strTemp;
  565. break;
  566. case IDS_COL_FLTR_SRC_TNL:
  567. TnlEpToString(filter.m_FilterType,
  568. filter.m_MyTnlAddr,
  569. &strTemp
  570. );
  571. return strTemp;
  572. break;
  573. case IDS_COL_FLTR_DEST_TNL:
  574. TnlEpToString(filter.m_FilterType,
  575. filter.m_PeerTnlAddr,
  576. &strTemp
  577. );
  578. return strTemp;
  579. break;
  580. case IDS_COL_FLTR_PROT:
  581. ProtocolToString(filter.m_Protocol, &strTemp);
  582. return strTemp;
  583. break;
  584. case IDS_COL_QM_POLICY:
  585. strTemp = filter.m_stPolicyName;
  586. return strTemp;
  587. break;
  588. case IDS_COL_IF_TYPE:
  589. InterfaceTypeToString(filter.m_InterfaceType, &strTemp);
  590. return strTemp;
  591. break;
  592. case IDS_COL_FLTR_OUT_FLAG:
  593. FilterFlagToString(filter.m_OutboundFilterFlag, &strTemp);
  594. return strTemp;
  595. break;
  596. case IDS_COL_FLTR_IN_FLAG:
  597. FilterFlagToString(filter.m_InboundFilterFlag, &strTemp);
  598. return strTemp;
  599. break;
  600. default:
  601. Panic0("CFilterHandler::GetVirtualString - Unknown column!\n");
  602. break;
  603. }
  604. COM_PROTECT_ERROR_LABEL;
  605. return NULL;
  606. }
  607. /*---------------------------------------------------------------------------
  608. CFilterHandler::CacheHint
  609. MMC tells us which items it will need before it requests things
  610. Author: NSun
  611. ---------------------------------------------------------------------------*/
  612. STDMETHODIMP
  613. CFilterHandler::CacheHint
  614. (
  615. int nStartIndex,
  616. int nEndIndex
  617. )
  618. {
  619. HRESULT hr = hrOK;;
  620. Trace2("CacheHint - Start %d, End %d\n", nStartIndex, nEndIndex);
  621. return hr;
  622. }
  623. /*---------------------------------------------------------------------------
  624. CFilterHandler::SortItems
  625. We are responsible for sorting of virtual listbox items
  626. Author: NSun
  627. ---------------------------------------------------------------------------*/
  628. STDMETHODIMP
  629. CFilterHandler::SortItems
  630. (
  631. int nColumn,
  632. DWORD dwSortOptions,
  633. LPARAM lUserParam
  634. )
  635. {
  636. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  637. HRESULT hr = S_OK;
  638. if (nColumn >= DimensionOf(aColumns[IPSECMON_FILTER]))
  639. return E_INVALIDARG;
  640. BEGIN_WAIT_CURSOR
  641. DWORD dwIndexType = aColumns[IPSECMON_FILTER][nColumn];
  642. hr = m_spSpdInfo->SortFilters(dwIndexType, dwSortOptions);
  643. END_WAIT_CURSOR
  644. return hr;
  645. }
  646. /*!--------------------------------------------------------------------------
  647. CFilterHandler::OnResultUpdateView
  648. Implementation of ITFSResultHandler::OnResultUpdateView
  649. Author: NSun
  650. ---------------------------------------------------------------------------*/
  651. HRESULT CFilterHandler::OnResultUpdateView
  652. (
  653. ITFSComponent *pComponent,
  654. LPDATAOBJECT pDataObject,
  655. LPARAM data,
  656. LONG_PTR hint
  657. )
  658. {
  659. HRESULT hr = hrOK;
  660. SPITFSNode spSelectedNode;
  661. pComponent->GetSelectedNode(&spSelectedNode);
  662. if (spSelectedNode == NULL)
  663. return S_OK; // no selection for our IComponentData
  664. if ( hint == IPSECMON_UPDATE_STATUS )
  665. {
  666. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  667. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  668. SPITFSNode spSelectedNode;
  669. pComponent->GetSelectedNode(&spSelectedNode);
  670. if (pNode == spSelectedNode)
  671. {
  672. // if we are the selected node, then we need to update
  673. SPIResultData spResultData;
  674. CORg (pComponent->GetResultData(&spResultData));
  675. CORg (spResultData->SetItemCount((int) data, MMCLV_UPDATE_NOSCROLL));
  676. }
  677. }
  678. else
  679. {
  680. // we don't handle this message, let the base class do it.
  681. return CIpsmHandler::OnResultUpdateView(pComponent, pDataObject, data, hint);
  682. }
  683. COM_PROTECT_ERROR_LABEL;
  684. return hr;
  685. }
  686. /*!--------------------------------------------------------------------------
  687. CFilterHandler::LoadColumns
  688. Set the correct column header and then call the base class
  689. Author: NSun
  690. ---------------------------------------------------------------------------*/
  691. HRESULT
  692. CFilterHandler::LoadColumns
  693. (
  694. ITFSComponent * pComponent,
  695. MMC_COOKIE cookie,
  696. LPARAM arg,
  697. LPARAM lParam
  698. )
  699. {
  700. //set column info
  701. return CIpsmHandler::LoadColumns(pComponent, cookie, arg, lParam);
  702. }
  703. /*---------------------------------------------------------------------------
  704. Command handlers
  705. ---------------------------------------------------------------------------*/
  706. /*---------------------------------------------------------------------------
  707. CFilterHandler::OnDelete
  708. Removes a service SA
  709. Author: NSun
  710. ---------------------------------------------------------------------------*/
  711. HRESULT
  712. CFilterHandler::OnDelete
  713. (
  714. ITFSNode * pNode
  715. )
  716. {
  717. HRESULT hr = S_FALSE;
  718. return hr;
  719. }
  720. /*---------------------------------------------------------------------------
  721. CFilterHandler::UpdateStatus
  722. -
  723. Author: NSun
  724. ---------------------------------------------------------------------------*/
  725. HRESULT
  726. CFilterHandler::UpdateStatus
  727. (
  728. ITFSNode * pNode
  729. )
  730. {
  731. HRESULT hr = hrOK;
  732. SPIComponentData spComponentData;
  733. SPIConsole spConsole;
  734. IDataObject * pDataObject;
  735. SPIDataObject spDataObject;
  736. int i = 0;
  737. Trace0("CFilterHandler::UpdateStatus - Updating status for Filter");
  738. // force the listbox to update. We do this by setting the count and
  739. // telling it to invalidate the data
  740. CORg(m_spNodeMgr->GetComponentData(&spComponentData));
  741. CORg(m_spNodeMgr->GetConsole(&spConsole));
  742. // grab a data object to use
  743. CORg(spComponentData->QueryDataObject((MMC_COOKIE) pNode, CCT_RESULT, &pDataObject) );
  744. spDataObject = pDataObject;
  745. i = m_spSpdInfo->GetQmFilterCountOfCurrentViewType();
  746. CORg(spConsole->UpdateAllViews(pDataObject, i, IPSECMON_UPDATE_STATUS));
  747. COM_PROTECT_ERROR_LABEL;
  748. return hr;
  749. }
  750. /*---------------------------------------------------------------------------
  751. Misc functions
  752. ---------------------------------------------------------------------------*/
  753. /*---------------------------------------------------------------------------
  754. CFilterHandler::InitData
  755. Initializes data for this node
  756. Author: NSun
  757. ---------------------------------------------------------------------------*/
  758. HRESULT
  759. CFilterHandler::InitData
  760. (
  761. ISpdInfo * pSpdInfo
  762. )
  763. {
  764. m_spSpdInfo.Set(pSpdInfo);
  765. return hrOK;
  766. }
  767. HRESULT
  768. CFilterHandler::UpdateViewType(ITFSNode * pNode, FILTER_TYPE NewFltrType)
  769. {
  770. // clear the listbox then set the size
  771. HRESULT hr = hrOK;
  772. SPIComponentData spCompData;
  773. SPIConsole spConsole;
  774. IDataObject* pDataObject;
  775. SPIDataObject spDataObject;
  776. LONG_PTR command;
  777. int i;
  778. COM_PROTECT_TRY
  779. {
  780. m_FltrType = NewFltrType;
  781. //tell the spddb to update its index manager for QM filter
  782. m_spSpdInfo->ChangeQmFilterViewType(m_FltrType);
  783. i = m_spSpdInfo->GetQmFilterCountOfCurrentViewType();
  784. m_spNodeMgr->GetComponentData(&spCompData);
  785. CORg ( spCompData->QueryDataObject((MMC_COOKIE) pNode, CCT_RESULT, &pDataObject) );
  786. spDataObject = pDataObject;
  787. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  788. //update the result pane virtual list
  789. CORg ( spConsole->UpdateAllViews(spDataObject, i, RESULT_PANE_CLEAR_VIRTUAL_LB) );
  790. COM_PROTECT_ERROR_LABEL;
  791. }
  792. COM_PROTECT_CATCH
  793. return hr;
  794. }