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.

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