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.

1002 lines
27 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 2002 **/
  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. m_spSpdInfo->ChangeQmFilterViewType(m_FltrType);
  177. i = m_spSpdInfo->GetQmFilterCountOfCurrentViewType();
  178. // now notify the virtual listbox
  179. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  180. CORg ( spConsole->UpdateAllViews(pDataObject, i, RESULT_PANE_SET_VIRTUAL_LB_SIZE));
  181. Error:
  182. return hr;
  183. }
  184. /*---------------------------------------------------------------------------
  185. CFilterHandler::OnCommand
  186. Handles context menu commands for SA scope pane node
  187. Author: NSun
  188. ---------------------------------------------------------------------------*/
  189. STDMETHODIMP
  190. CFilterHandler::OnCommand
  191. (
  192. ITFSNode * pNode,
  193. long nCommandId,
  194. DATA_OBJECT_TYPES type,
  195. LPDATAOBJECT pDataObject,
  196. DWORD dwType
  197. )
  198. {
  199. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  200. //handle the scope context menu commands here
  201. return S_OK;
  202. }
  203. /*!--------------------------------------------------------------------------
  204. CFilterHandler::Command
  205. Handles context menu commands for virtual listbox items
  206. Author: NSun
  207. ---------------------------------------------------------------------------*/
  208. STDMETHODIMP
  209. CFilterHandler::Command
  210. (
  211. ITFSComponent * pComponent,
  212. MMC_COOKIE cookie,
  213. int nCommandID,
  214. LPDATAOBJECT pDataObject
  215. )
  216. {
  217. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  218. HRESULT hr = S_OK;
  219. SPITFSNode spNode;
  220. m_spResultNodeMgr->FindNode(cookie, &spNode);
  221. FILTER_TYPE NewFltrType = m_FltrType;
  222. // handle result context menu and view menus here
  223. switch (nCommandID)
  224. {
  225. case IDS_VIEW_ALL_FLTR:
  226. NewFltrType = FILTER_TYPE_ANY;
  227. break;
  228. case IDS_VIEW_TRANSPORT_FLTR:
  229. NewFltrType = FILTER_TYPE_TRANSPORT;
  230. break;
  231. case IDS_VIEW_TUNNEL_FLTR:
  232. NewFltrType = FILTER_TYPE_TUNNEL;
  233. break;
  234. default:
  235. break;
  236. }
  237. //Update the views if a different view is selected.
  238. if (NewFltrType != m_FltrType)
  239. {
  240. m_FltrType = NewFltrType;
  241. UpdateViewType(spNode, m_FltrType);
  242. }
  243. return hr;
  244. }
  245. /*!--------------------------------------------------------------------------
  246. CFilterHandler::HasPropertyPages
  247. Implementation of ITFSNodeHandler::HasPropertyPages
  248. NOTE: the root node handler has to over-ride this function to
  249. handle the snapin manager property page (wizard) case!!!
  250. Author: KennT
  251. ---------------------------------------------------------------------------*/
  252. STDMETHODIMP
  253. CFilterHandler::HasPropertyPages
  254. (
  255. ITFSNode * pNode,
  256. LPDATAOBJECT pDataObject,
  257. DATA_OBJECT_TYPES type,
  258. DWORD dwType
  259. )
  260. {
  261. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  262. return hrFalse;
  263. }
  264. /*---------------------------------------------------------------------------
  265. CFilterHandler::CreatePropertyPages
  266. Description
  267. Author: NSun
  268. ---------------------------------------------------------------------------*/
  269. STDMETHODIMP
  270. CFilterHandler::CreatePropertyPages
  271. (
  272. ITFSNode * pNode,
  273. LPPROPERTYSHEETCALLBACK lpSA,
  274. LPDATAOBJECT pDataObject,
  275. LONG_PTR handle,
  276. DWORD dwType
  277. )
  278. {
  279. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  280. DWORD dwError;
  281. DWORD dwDynDnsFlags;
  282. //
  283. // Create the property page
  284. //
  285. SPIComponentData spComponentData;
  286. m_spNodeMgr->GetComponentData(&spComponentData);
  287. //CServerProperties * pServerProp = new CServerProperties(pNode, spComponentData, m_spTFSCompData, NULL);
  288. //
  289. // Object gets deleted when the page is destroyed
  290. //
  291. Assert(lpSA != NULL);
  292. //return pServerProp->CreateModelessSheet(lpSA, handle);
  293. return hrFalse;
  294. }
  295. /*---------------------------------------------------------------------------
  296. CFilterHandler::OnPropertyChange
  297. Description
  298. Author: NSun
  299. ---------------------------------------------------------------------------*/
  300. HRESULT
  301. CFilterHandler::OnPropertyChange
  302. (
  303. ITFSNode * pNode,
  304. LPDATAOBJECT pDataobject,
  305. DWORD dwType,
  306. LPARAM arg,
  307. LPARAM lParam
  308. )
  309. {
  310. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  311. //CServerProperties * pServerProp = reinterpret_cast<CServerProperties *>(lParam);
  312. LONG_PTR changeMask = 0;
  313. // tell the property page to do whatever now that we are back on the
  314. // main thread
  315. //pServerProp->OnPropertyChange(TRUE, &changeMask);
  316. //pServerProp->AcknowledgeNotify();
  317. if (changeMask)
  318. pNode->ChangeNode(changeMask);
  319. return hrOK;
  320. }
  321. /*---------------------------------------------------------------------------
  322. CFilterHandler::OnExpand
  323. Handles enumeration of a scope item
  324. Author: NSun
  325. ---------------------------------------------------------------------------*/
  326. HRESULT
  327. CFilterHandler::OnExpand
  328. (
  329. ITFSNode * pNode,
  330. LPDATAOBJECT pDataObject,
  331. DWORD dwType,
  332. LPARAM arg,
  333. LPARAM param
  334. )
  335. {
  336. HRESULT hr = hrOK;
  337. if (m_bExpanded)
  338. return hr;
  339. // do the default handling
  340. CORg (CIpsmHandler::OnExpand(pNode, pDataObject, dwType, arg, param));
  341. Error:
  342. return hr;
  343. }
  344. /*!--------------------------------------------------------------------------
  345. CFilterHandler::OnResultSelect
  346. Handles the MMCN_SELECT notifcation
  347. Author: NSun
  348. ---------------------------------------------------------------------------*/
  349. HRESULT
  350. CFilterHandler::OnResultSelect
  351. (
  352. ITFSComponent * pComponent,
  353. LPDATAOBJECT pDataObject,
  354. MMC_COOKIE cookie,
  355. LPARAM arg,
  356. LPARAM lParam
  357. )
  358. {
  359. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  360. HRESULT hr = hrOK;
  361. SPINTERNAL spInternal;
  362. SPIConsole spConsole;
  363. SPIConsoleVerb spConsoleVerb;
  364. SPITFSNode spNode;
  365. BOOL bStates[ARRAYLEN(g_ConsoleVerbs)];
  366. int i;
  367. LONG_PTR dwNodeType;
  368. BOOL fSelect = HIWORD(arg);
  369. IConsole2 *pConsole2 = NULL;
  370. //get pConsole2 for writing to the status bar, if fails not to worry
  371. pComponent->GetConsole(&pConsole2);
  372. // virtual listbox notifications come to the handler of the node that is selected.
  373. // check to see if this notification is for a virtual listbox item or the active
  374. // registrations node itself.
  375. CORg (pComponent->GetConsoleVerb(&spConsoleVerb));
  376. m_verbDefault = MMC_VERB_OPEN;
  377. if (!fSelect)
  378. {
  379. if(pConsole2) {
  380. pConsole2->SetStatusText(_T(""));
  381. pConsole2->Release();
  382. }
  383. return hr;
  384. }
  385. if (m_spSpdInfo)
  386. {
  387. DWORD dwInitInfo;
  388. dwInitInfo=m_spSpdInfo->GetInitInfo();
  389. if (!(dwInitInfo & MON_QM_FILTER)) {
  390. CORg(m_spSpdInfo->EnumQmFilters());
  391. m_spSpdInfo->SetInitInfo(dwInitInfo | MON_QM_FILTER);
  392. //m_spSpdInfo->SetInitInfo(dwInitInfo | MON_QM_SP_FILTER);
  393. }
  394. m_spSpdInfo->SetActiveInfo(MON_QM_FILTER);
  395. // Get the current count
  396. i = m_spSpdInfo->GetQmFilterCountOfCurrentViewType();
  397. // now notify the virtual listbox
  398. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  399. CORg ( spConsole->UpdateAllViews(pDataObject, i, RESULT_PANE_SET_VIRTUAL_LB_SIZE) );
  400. if(pConsole2)
  401. {
  402. CString strTemp;
  403. WCHAR szTemp[20];
  404. wsprintf(szTemp, L"%d", i);
  405. AfxFormatString1(strTemp, IDS_STATUS_NUM_ITEMS, szTemp);
  406. pConsole2->SetStatusText((LPOLESTR) (LPCTSTR) strTemp);
  407. pConsole2->Release();
  408. }
  409. }
  410. // now update the verbs...
  411. spInternal = ExtractInternalFormat(pDataObject);
  412. Assert(spInternal);
  413. if (spInternal->HasVirtualIndex())
  414. {
  415. //TODO add to here if we want to have some result console verbs
  416. // we gotta do special stuff for the virtual index items
  417. dwNodeType = IPSECMON_FILTER_ITEM;
  418. for (i = 0; i < ARRAYLEN(g_ConsoleVerbs); bStates[i++] = FALSE);
  419. //enable the "properties" menu
  420. bStates[MMC_VERB_PROPERTIES & 0x000F] = TRUE;
  421. m_verbDefault = MMC_VERB_PROPERTIES;
  422. }
  423. else
  424. {
  425. // enable/disable delete depending if the node supports it
  426. CORg (m_spNodeMgr->FindNode(cookie, &spNode));
  427. dwNodeType = spNode->GetData(TFS_DATA_TYPE);
  428. for (i = 0; i < ARRAYLEN(g_ConsoleVerbs); bStates[i++] = TRUE);
  429. //hide "delete" context menu
  430. bStates[MMC_VERB_DELETE & 0x000F] = FALSE;
  431. bStates[MMC_VERB_REFRESH & 0x000F] = TRUE;
  432. }
  433. EnableVerbs(spConsoleVerb, g_ConsoleVerbStates[dwNodeType], bStates);
  434. COM_PROTECT_ERROR_LABEL;
  435. return hr;
  436. }
  437. /*!--------------------------------------------------------------------------
  438. CFilterHandler::OnDelete
  439. The base handler calls this when MMC sends a MMCN_DELETE for a
  440. scope pane item. We just call our delete command handler.
  441. Author: NSun
  442. ---------------------------------------------------------------------------*/
  443. HRESULT
  444. CFilterHandler::OnDelete
  445. (
  446. ITFSNode * pNode,
  447. LPARAM arg,
  448. LPARAM lParam
  449. )
  450. {
  451. return S_FALSE;
  452. }
  453. /*!--------------------------------------------------------------------------
  454. CFilterHandler::HasPropertyPages
  455. Handle the result notification
  456. Author: NSun
  457. ---------------------------------------------------------------------------*/
  458. STDMETHODIMP
  459. CFilterHandler::HasPropertyPages(
  460. ITFSComponent *pComponent,
  461. MMC_COOKIE cookie,
  462. LPDATAOBJECT pDataObject)
  463. {
  464. return hrOK;
  465. }
  466. /*!--------------------------------------------------------------------------
  467. CFilterHandler::HasPropertyPages
  468. Handle the result notification. Create the filter property sheet
  469. Author: NSun
  470. ---------------------------------------------------------------------------*/
  471. STDMETHODIMP CFilterHandler::CreatePropertyPages
  472. (
  473. ITFSComponent * pComponent,
  474. MMC_COOKIE cookie,
  475. LPPROPERTYSHEETCALLBACK lpProvider,
  476. LPDATAOBJECT pDataObject,
  477. LONG_PTR handle
  478. )
  479. {
  480. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  481. HRESULT hr = hrOK;
  482. SPINTERNAL spInternal;
  483. SPITFSNode spNode;
  484. int nIndex;
  485. SPIComponentData spComponentData;
  486. CFilterInfo FltrInfo;
  487. CFilterProperties * pFilterProp;
  488. Assert(m_spNodeMgr);
  489. CORg( m_spNodeMgr->FindNode(cookie, &spNode) );
  490. CORg( m_spNodeMgr->GetComponentData(&spComponentData) );
  491. spInternal = ExtractInternalFormat(pDataObject);
  492. // virtual listbox notifications come to the handler of the node that is selected.
  493. // assert that this notification is for a virtual listbox item
  494. Assert(spInternal);
  495. if (!spInternal->HasVirtualIndex())
  496. return hr;
  497. nIndex = spInternal->GetVirtualIndex();
  498. CORg(m_spSpdInfo->GetFilterInfo(nIndex, &FltrInfo));
  499. pFilterProp = new CFilterProperties(
  500. spNode,
  501. spComponentData,
  502. m_spTFSCompData,
  503. &FltrInfo,
  504. m_spSpdInfo,
  505. NULL);
  506. hr = pFilterProp->CreateModelessSheet(lpProvider, handle);
  507. COM_PROTECT_ERROR_LABEL;
  508. return hr;
  509. }
  510. /*---------------------------------------------------------------------------
  511. CFilterHandler::OnGetResultViewType
  512. Return the result view that this node is going to support
  513. Author: NSun
  514. ---------------------------------------------------------------------------*/
  515. HRESULT
  516. CFilterHandler::OnGetResultViewType
  517. (
  518. ITFSComponent * pComponent,
  519. MMC_COOKIE cookie,
  520. LPOLESTR * ppViewType,
  521. long * pViewOptions
  522. )
  523. {
  524. if (cookie != NULL)
  525. {
  526. *pViewOptions = MMC_VIEW_OPTIONS_OWNERDATALIST;
  527. }
  528. return S_FALSE;
  529. }
  530. /*---------------------------------------------------------------------------
  531. CFilterHandler::GetVirtualImage
  532. Returns the image index for virtual listbox items
  533. Author: NSun
  534. ---------------------------------------------------------------------------*/
  535. int
  536. CFilterHandler::GetVirtualImage
  537. (
  538. int nIndex
  539. )
  540. {
  541. return ICON_IDX_FILTER;
  542. }
  543. /*---------------------------------------------------------------------------
  544. CFilterHandler::GetVirtualString
  545. returns a pointer to the string for virtual listbox items
  546. Author: NSun
  547. ---------------------------------------------------------------------------*/
  548. LPCWSTR
  549. CFilterHandler::GetVirtualString
  550. (
  551. int nIndex,
  552. int nCol
  553. )
  554. {
  555. HRESULT hr = S_OK;
  556. static CString strTemp;
  557. strTemp.Empty();
  558. if (nCol >= DimensionOf(aColumns[IPSECMON_FILTER]))
  559. return NULL;
  560. CFilterInfo filter;
  561. CORg(m_spSpdInfo->GetFilterInfo(nIndex, &filter));
  562. switch (aColumns[IPSECMON_FILTER][nCol])
  563. {
  564. case IDS_COL_FLTR_NAME:
  565. {
  566. strTemp = filter.m_stName;
  567. if( filter.m_dwFlags & IPSEC_QM_POLICY_DEFAULT_POLICY )
  568. {
  569. AfxFormatString1(strTemp, IDS_POL_DEFAULT_RESPONSE, (LPCTSTR) filter.m_stName);
  570. }
  571. return strTemp;
  572. break;
  573. }
  574. case IDS_COL_FLTR_SRC:
  575. AddressToString(filter.m_SrcAddr, &strTemp);
  576. return strTemp;
  577. break;
  578. case IDS_COL_FLTR_DEST:
  579. AddressToString(filter.m_DesAddr, &strTemp);
  580. return strTemp;
  581. break;
  582. case IDS_COL_FLTR_SRC_PORT:
  583. PortToString(filter.m_SrcPort, &strTemp);
  584. return strTemp;
  585. break;
  586. case IDS_COL_FLTR_DEST_PORT:
  587. PortToString(filter.m_DesPort, &strTemp);
  588. return strTemp;
  589. break;
  590. case IDS_COL_FLTR_SRC_TNL:
  591. TnlEpToString(filter.m_FilterType,
  592. filter.m_MyTnlAddr,
  593. &strTemp
  594. );
  595. return strTemp;
  596. break;
  597. case IDS_COL_FLTR_DEST_TNL:
  598. TnlEpToString(filter.m_FilterType,
  599. filter.m_PeerTnlAddr,
  600. &strTemp
  601. );
  602. return strTemp;
  603. break;
  604. case IDS_COL_FLTR_PROT:
  605. ProtocolToString(filter.m_Protocol, &strTemp);
  606. return strTemp;
  607. break;
  608. case IDS_COL_QM_POLICY:
  609. strTemp = filter.m_stPolicyName;
  610. return strTemp;
  611. break;
  612. case IDS_COL_IF_TYPE:
  613. InterfaceTypeToString(filter.m_InterfaceType, &strTemp);
  614. return strTemp;
  615. break;
  616. case IDS_COL_FLTR_OUT_FLAG:
  617. FilterFlagToString(filter.m_OutboundFilterAction, &strTemp);
  618. return strTemp;
  619. break;
  620. case IDS_COL_FLTR_IN_FLAG:
  621. FilterFlagToString(filter.m_InboundFilterAction, &strTemp);
  622. return strTemp;
  623. break;
  624. default:
  625. Panic0("CFilterHandler::GetVirtualString - Unknown column!\n");
  626. break;
  627. }
  628. COM_PROTECT_ERROR_LABEL;
  629. return NULL;
  630. }
  631. /*---------------------------------------------------------------------------
  632. CFilterHandler::CacheHint
  633. MMC tells us which items it will need before it requests things
  634. Author: NSun
  635. ---------------------------------------------------------------------------*/
  636. STDMETHODIMP
  637. CFilterHandler::CacheHint
  638. (
  639. int nStartIndex,
  640. int nEndIndex
  641. )
  642. {
  643. HRESULT hr = hrOK;;
  644. Trace2("CacheHint - Start %d, End %d\n", nStartIndex, nEndIndex);
  645. return hr;
  646. }
  647. /*---------------------------------------------------------------------------
  648. CFilterHandler::SortItems
  649. We are responsible for sorting of virtual listbox items
  650. Author: NSun
  651. ---------------------------------------------------------------------------*/
  652. STDMETHODIMP
  653. CFilterHandler::SortItems
  654. (
  655. int nColumn,
  656. DWORD dwSortOptions,
  657. LPARAM lUserParam
  658. )
  659. {
  660. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  661. HRESULT hr = S_OK;
  662. if (nColumn >= DimensionOf(aColumns[IPSECMON_FILTER]))
  663. return E_INVALIDARG;
  664. BEGIN_WAIT_CURSOR
  665. DWORD dwIndexType = aColumns[IPSECMON_FILTER][nColumn];
  666. hr = m_spSpdInfo->SortFilters(dwIndexType, dwSortOptions);
  667. END_WAIT_CURSOR
  668. return hr;
  669. }
  670. /*!--------------------------------------------------------------------------
  671. CFilterHandler::OnResultUpdateView
  672. Implementation of ITFSResultHandler::OnResultUpdateView
  673. Author: NSun
  674. ---------------------------------------------------------------------------*/
  675. HRESULT CFilterHandler::OnResultUpdateView
  676. (
  677. ITFSComponent *pComponent,
  678. LPDATAOBJECT pDataObject,
  679. LPARAM data,
  680. LONG_PTR hint
  681. )
  682. {
  683. HRESULT hr = hrOK;
  684. SPITFSNode spSelectedNode;
  685. pComponent->GetSelectedNode(&spSelectedNode);
  686. if (spSelectedNode == NULL)
  687. return S_OK; // no selection for our IComponentData
  688. if ( hint == IPSECMON_UPDATE_STATUS )
  689. {
  690. SPINTERNAL spInternal = ExtractInternalFormat(pDataObject);
  691. ITFSNode * pNode = reinterpret_cast<ITFSNode *>(spInternal->m_cookie);
  692. SPITFSNode spSelectedNode;
  693. pComponent->GetSelectedNode(&spSelectedNode);
  694. if (pNode == spSelectedNode)
  695. {
  696. // if we are the selected node, then we need to update
  697. SPIResultData spResultData;
  698. CORg (pComponent->GetResultData(&spResultData));
  699. CORg (spResultData->SetItemCount((int) data, MMCLV_UPDATE_NOSCROLL));
  700. }
  701. }
  702. else
  703. {
  704. // we don't handle this message, let the base class do it.
  705. return CIpsmHandler::OnResultUpdateView(pComponent, pDataObject, data, hint);
  706. }
  707. COM_PROTECT_ERROR_LABEL;
  708. return hr;
  709. }
  710. /*!--------------------------------------------------------------------------
  711. CFilterHandler::LoadColumns
  712. Set the correct column header and then call the base class
  713. Author: NSun
  714. ---------------------------------------------------------------------------*/
  715. HRESULT
  716. CFilterHandler::LoadColumns
  717. (
  718. ITFSComponent * pComponent,
  719. MMC_COOKIE cookie,
  720. LPARAM arg,
  721. LPARAM lParam
  722. )
  723. {
  724. //set column info
  725. return CIpsmHandler::LoadColumns(pComponent, cookie, arg, lParam);
  726. }
  727. /*---------------------------------------------------------------------------
  728. Command handlers
  729. ---------------------------------------------------------------------------*/
  730. /*---------------------------------------------------------------------------
  731. CFilterHandler::OnDelete
  732. Removes a service SA
  733. Author: NSun
  734. ---------------------------------------------------------------------------*/
  735. HRESULT
  736. CFilterHandler::OnDelete
  737. (
  738. ITFSNode * pNode
  739. )
  740. {
  741. HRESULT hr = S_FALSE;
  742. return hr;
  743. }
  744. /*---------------------------------------------------------------------------
  745. CFilterHandler::UpdateStatus
  746. -
  747. Author: NSun
  748. ---------------------------------------------------------------------------*/
  749. HRESULT
  750. CFilterHandler::UpdateStatus
  751. (
  752. ITFSNode * pNode
  753. )
  754. {
  755. HRESULT hr = hrOK;
  756. SPIComponentData spComponentData;
  757. SPIConsole spConsole;
  758. IDataObject * pDataObject;
  759. SPIDataObject spDataObject;
  760. int i = 0;
  761. Trace0("CFilterHandler::UpdateStatus - Updating status for Filter");
  762. // force the listbox to update. We do this by setting the count and
  763. // telling it to invalidate the data
  764. CORg(m_spNodeMgr->GetComponentData(&spComponentData));
  765. CORg(m_spNodeMgr->GetConsole(&spConsole));
  766. // grab a data object to use
  767. CORg(spComponentData->QueryDataObject((MMC_COOKIE) pNode, CCT_RESULT, &pDataObject) );
  768. spDataObject = pDataObject;
  769. m_spSpdInfo->ChangeQmFilterViewType(m_FltrType);
  770. i = m_spSpdInfo->GetQmFilterCountOfCurrentViewType();
  771. CORg(spConsole->UpdateAllViews(pDataObject, i, IPSECMON_UPDATE_STATUS));
  772. COM_PROTECT_ERROR_LABEL;
  773. return hr;
  774. }
  775. /*---------------------------------------------------------------------------
  776. Misc functions
  777. ---------------------------------------------------------------------------*/
  778. /*---------------------------------------------------------------------------
  779. CFilterHandler::InitData
  780. Initializes data for this node
  781. Author: NSun
  782. ---------------------------------------------------------------------------*/
  783. HRESULT
  784. CFilterHandler::InitData
  785. (
  786. ISpdInfo * pSpdInfo
  787. )
  788. {
  789. m_spSpdInfo.Set(pSpdInfo);
  790. return hrOK;
  791. }
  792. HRESULT
  793. CFilterHandler::UpdateViewType(ITFSNode * pNode, FILTER_TYPE NewFltrType)
  794. {
  795. // clear the listbox then set the size
  796. HRESULT hr = hrOK;
  797. SPIComponentData spCompData;
  798. SPIConsole spConsole;
  799. IDataObject* pDataObject;
  800. SPIDataObject spDataObject;
  801. LONG_PTR command;
  802. int i;
  803. COM_PROTECT_TRY
  804. {
  805. m_FltrType = NewFltrType;
  806. //tell the spddb to update its index manager for QM filter
  807. m_spSpdInfo->ChangeQmFilterViewType(m_FltrType);
  808. i = m_spSpdInfo->GetQmFilterCountOfCurrentViewType();
  809. m_spNodeMgr->GetComponentData(&spCompData);
  810. CORg ( spCompData->QueryDataObject((MMC_COOKIE) pNode, CCT_RESULT, &pDataObject) );
  811. spDataObject = pDataObject;
  812. CORg ( m_spNodeMgr->GetConsole(&spConsole) );
  813. //update the result pane virtual list
  814. CORg ( spConsole->UpdateAllViews(spDataObject, i, RESULT_PANE_CLEAR_VIRTUAL_LB) );
  815. COM_PROTECT_ERROR_LABEL;
  816. }
  817. COM_PROTECT_CATCH
  818. return hr;
  819. }