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.

1541 lines
47 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. ATLKview.cpp
  7. FILE HISTORY:
  8. */
  9. #include "stdafx.h"
  10. #include "coldlg.h" // columndlg
  11. #include "column.h" // ComponentConfigStream
  12. #include "rtrui.h"
  13. #include "globals.h" // IP CB defaults
  14. #include "resource.h"
  15. #include "machine.h"
  16. #include "mstatus.h"
  17. #include "rrasqry.h"
  18. #include "dvsview.h"
  19. #include "cservice.h"
  20. #include "rrasqry.h"
  21. #include "rtrres.h"
  22. #include "rtrutilp.h"
  23. #include "refresh.h"
  24. /*---------------------------------------------------------------------------
  25. Keep this in sync with the column ids in ATLKview.h
  26. ---------------------------------------------------------------------------*/
  27. extern const ContainerColumnInfo s_rgDVSViewColumnInfo[];
  28. const ContainerColumnInfo s_rgDVSViewColumnInfo[] =
  29. {
  30. { IDS_DMV_COL_SERVERNAME, CON_SORT_BY_STRING, TRUE, COL_MACHINE_NAME},
  31. { IDS_DMV_COL_SERVERTYPE, CON_SORT_BY_STRING, TRUE, COL_BIG_STRING},
  32. { IDS_DMV_COL_BUILDNO, CON_SORT_BY_STRING, FALSE, COL_SMALL_NUM },
  33. { IDS_DMV_COL_STATE, CON_SORT_BY_STRING, TRUE, COL_STRING },
  34. { IDS_DMV_COL_PORTSINUSE, CON_SORT_BY_DWORD, TRUE, COL_SMALL_NUM},
  35. { IDS_DMV_COL_PORTSTOTAL, CON_SORT_BY_DWORD, TRUE, COL_SMALL_NUM},
  36. { IDS_DMV_COL_UPTIME, CON_SORT_BY_DWORD, TRUE, COL_DURATION },
  37. };
  38. DMVNodeData::DMVNodeData()
  39. {
  40. #ifdef DEBUG
  41. StrCpyA(m_szDebug, "DMVNodeData");
  42. #endif
  43. }
  44. DMVNodeData::~DMVNodeData()
  45. {
  46. // This will actually call Release();
  47. m_spMachineData.Free();
  48. }
  49. HRESULT DMVNodeData::MergeMachineNodeData(MachineNodeData* pData)
  50. {
  51. if((MachineNodeData*)m_spMachineData)
  52. m_spMachineData->Merge(*pData);
  53. return S_OK;
  54. }
  55. void FillInNumberData(DMVNodeData *pNodeData, UINT iIndex,DWORD dwData)
  56. {
  57. TCHAR szNumber[32];
  58. FormatNumber(dwData, szNumber, DimensionOf(szNumber), FALSE);
  59. pNodeData->m_rgData[iIndex].m_stData = szNumber;
  60. pNodeData->m_rgData[iIndex].m_dwData = dwData;
  61. }
  62. /*!--------------------------------------------------------------------------
  63. DMVNodeData::InitNodeData
  64. -
  65. Author: KennT
  66. ---------------------------------------------------------------------------*/
  67. HRESULT DMVNodeData::InitDMVNodeData(ITFSNode *pNode, MachineNodeData *pMachineData)
  68. {
  69. HRESULT hr = hrOK;
  70. DMVNodeData * pData = NULL;
  71. pData = new DMVNodeData;
  72. Assert(pData);
  73. pData->m_spMachineData.Free();
  74. pData->m_spMachineData = pMachineData;
  75. pMachineData->AddRef();
  76. SET_DMVNODEDATA(pNode, pData);
  77. return hr;
  78. }
  79. /*!--------------------------------------------------------------------------
  80. DMVNodeData::FreeAdminNodeData
  81. -
  82. Author: KennT
  83. ---------------------------------------------------------------------------*/
  84. HRESULT DMVNodeData::FreeDMVNodeData(ITFSNode *pNode)
  85. {
  86. DMVNodeData * pData = GET_DMVNODEDATA(pNode);
  87. delete pData;
  88. SET_DMVNODEDATA(pNode, NULL);
  89. return hrOK;
  90. }
  91. /*---------------------------------------------------------------------------
  92. DomainStatusHandler implementation
  93. ---------------------------------------------------------------------------*/
  94. DomainStatusHandler::DomainStatusHandler(ITFSComponentData *pCompData)
  95. : BaseContainerHandler(pCompData, DM_COLUMNS_DVSUM,s_rgDVSViewColumnInfo),
  96. // m_ulConnId(0),
  97. m_ulRefreshConnId(0),
  98. m_ulStatsConnId(0)
  99. {
  100. m_rgButtonState[MMC_VERB_REFRESH_INDEX] = ENABLED;
  101. m_bState[MMC_VERB_REFRESH_INDEX] = TRUE;
  102. m_pQData=NULL;
  103. }
  104. DomainStatusHandler::~DomainStatusHandler()
  105. {
  106. }
  107. STDMETHODIMP DomainStatusHandler::QueryInterface(REFIID riid, LPVOID *ppv)
  108. {
  109. // Is the pointer bad?
  110. if ( ppv == NULL )
  111. return E_INVALIDARG;
  112. // Place NULL in *ppv in case of failure
  113. *ppv = NULL;
  114. // This is the non-delegating IUnknown implementation
  115. if ( riid == IID_IUnknown )
  116. *ppv = (LPVOID) this;
  117. else if ( riid == IID_IRtrAdviseSink )
  118. *ppv = &m_IRtrAdviseSink;
  119. else
  120. return BaseContainerHandler::QueryInterface(riid, ppv);
  121. // If we're going to return an interface, AddRef it first
  122. if ( *ppv )
  123. {
  124. ((LPUNKNOWN) *ppv)->AddRef();
  125. return hrOK;
  126. }
  127. else
  128. return E_NOINTERFACE;
  129. }
  130. // assign auto refresh object from root handler
  131. HRESULT DomainStatusHandler::SetExternalRefreshObject(RouterRefreshObject *pRefresh)
  132. {
  133. Assert(!m_spRefreshObject);
  134. m_spRefreshObject = pRefresh;
  135. if(pRefresh)
  136. pRefresh->AddRef();
  137. return S_OK;
  138. };
  139. /*!--------------------------------------------------------------------------
  140. DomainStatusHandler::DestroyHandler
  141. Implementation of ITFSNodeHandler::DestroyHandler
  142. Author: KennT
  143. ---------------------------------------------------------------------------*/
  144. STDMETHODIMP DomainStatusHandler::DestroyHandler(ITFSNode *pNode)
  145. {
  146. if ( m_ulRefreshConnId )
  147. {
  148. if ( (RouterRefreshObject*)m_spRefreshObject )
  149. m_spRefreshObject->UnadviseRefresh(m_ulRefreshConnId);
  150. }
  151. m_ulRefreshConnId = 0;
  152. if ( m_ulStatsConnId )
  153. {
  154. if ( (RouterRefreshObject*)m_spRefreshObject )
  155. m_spRefreshObject->UnadviseRefresh(m_ulStatsConnId);
  156. }
  157. m_ulStatsConnId = 0;
  158. return hrOK;
  159. }
  160. /*!--------------------------------------------------------------------------
  161. DomainStatusHandler::HasPropertyPages
  162. Implementation of ITFSNodeHandler::HasPropertyPages
  163. NOTE: the root node handler has to over-ride this function to
  164. handle the snapin manager property page (wizard) case!!!
  165. Author: KennT
  166. ---------------------------------------------------------------------------*/
  167. STDMETHODIMP
  168. DomainStatusHandler::HasPropertyPages
  169. (
  170. ITFSNode * pNode,
  171. LPDATAOBJECT pDataObject,
  172. DATA_OBJECT_TYPES type,
  173. DWORD dwType
  174. )
  175. {
  176. return hrOK;
  177. }
  178. /*!--------------------------------------------------------------------------
  179. DomainStatusHandler::CreatePropertyPages
  180. -
  181. Author: KennT
  182. ---------------------------------------------------------------------------*/
  183. STDMETHODIMP
  184. DomainStatusHandler::CreatePropertyPages
  185. (
  186. ITFSNode * pNode,
  187. LPPROPERTYSHEETCALLBACK lpProvider,
  188. LPDATAOBJECT pDataObject,
  189. LONG_PTR handle,
  190. DWORD dwType
  191. )
  192. {
  193. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  194. HRESULT hr = hrOK;
  195. return hr;
  196. }
  197. /*---------------------------------------------------------------------------
  198. Menu data structure for our menus
  199. ---------------------------------------------------------------------------*/
  200. ULONG DomainStatusHandler::RebuildServerFlags(const SRouterNodeMenu *pMenuData,
  201. INT_PTR pUserData)
  202. {
  203. SMenuData * pData = reinterpret_cast<SMenuData *>(pUserData);
  204. Assert(pData);
  205. DWORD dw = pData->m_pConfigStream->m_RQPersist.m_v_pQData.size();
  206. return (dw > 1) ? MF_ENABLED : MF_GRAYED;
  207. }
  208. static const SRouterNodeMenu s_rgDVSNodeMenu[] =
  209. {
  210. // Add items that go on the top menu here
  211. { IDS_DMV_MENU_ADDSVR, 0,
  212. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  213. { IDS_DMV_MENU_REBUILDSVRLIST, DomainStatusHandler::RebuildServerFlags,
  214. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  215. };
  216. /*!--------------------------------------------------------------------------
  217. DomainStatusHandler::OnAddMenuItems
  218. Implementation of ITFSNodeHandler::OnAddMenuItems
  219. Author: KennT
  220. ---------------------------------------------------------------------------*/
  221. STDMETHODIMP DomainStatusHandler::OnAddMenuItems(
  222. ITFSNode *pNode,
  223. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  224. LPDATAOBJECT lpDataObject,
  225. DATA_OBJECT_TYPES type,
  226. DWORD dwType,
  227. long *pInsertionAllowed)
  228. {
  229. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  230. HRESULT hr = S_OK;
  231. DomainStatusHandler::SMenuData menuData;
  232. COM_PROTECT_TRY
  233. {
  234. menuData.m_spNode.Set(pNode);
  235. menuData.m_pConfigStream = m_pConfigStream;
  236. hr = AddArrayOfMenuItems(pNode, s_rgDVSNodeMenu,
  237. DimensionOf(s_rgDVSNodeMenu),
  238. pContextMenuCallback,
  239. *pInsertionAllowed,
  240. reinterpret_cast<INT_PTR>(&menuData));
  241. }
  242. COM_PROTECT_CATCH;
  243. return hr;
  244. }
  245. /*!--------------------------------------------------------------------------
  246. DomainStatusHandler::OnCommand
  247. Implementation of ITFSNodeHandler::OnCommand
  248. Author: KennT
  249. ---------------------------------------------------------------------------*/
  250. STDMETHODIMP DomainStatusHandler::OnCommand(ITFSNode *pNode, long nCommandId,
  251. DATA_OBJECT_TYPES type,
  252. LPDATAOBJECT pDataObject,
  253. DWORD dwType)
  254. {
  255. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  256. HRESULT hr = S_OK;
  257. RegKey regkey;
  258. SPITFSNode spParent;
  259. SPITFSNodeHandler spHandler;
  260. Assert(pNode);
  261. COM_PROTECT_TRY
  262. {
  263. switch ( nCommandId )
  264. {
  265. case IDS_DMV_MENU_ADDSVR:
  266. case IDS_DMV_MENU_REBUILDSVRLIST:
  267. pNode->GetParent(&spParent);
  268. spParent->GetHandler(&spHandler);
  269. spHandler->OnCommand(spParent,nCommandId,CCT_RESULT, NULL, 0);
  270. break;
  271. case IDS_MENU_REFRESH:
  272. // do it in background thread
  273. if ((RouterRefreshObject*)m_spRefreshObject )
  274. m_spRefreshObject->Refresh();
  275. break;
  276. }
  277. }
  278. COM_PROTECT_CATCH;
  279. return hr;
  280. }
  281. /*!--------------------------------------------------------------------------
  282. DomainStatusHandler::OnExpand
  283. -
  284. Author: KennT
  285. ---------------------------------------------------------------------------*/
  286. HRESULT DomainStatusHandler::OnExpand(ITFSNode *pNode,LPDATAOBJECT pDataObject, DWORD dwType, LPARAM arg,LPARAM lParam)
  287. {
  288. HRESULT hr = hrOK;
  289. SPIEnumInterfaceInfo spEnumIf;
  290. SPIInterfaceInfo spIf;
  291. SPIRtrMgrInterfaceInfo spRmIf;
  292. SPIInfoBase spInfoBase;
  293. Assert(m_pServerList);
  294. COM_PROTECT_TRY
  295. {
  296. list< MachineNodeData * >::iterator it;
  297. //iterate the lazy list for server nodes to add server handlers
  298. for (it=m_pServerList->m_listServerHandlersToExpand.begin();
  299. it!= m_pServerList->m_listServerHandlersToExpand.end() ; it++ )
  300. {
  301. AddServerNode(pNode, *it);
  302. m_bExpanded=false;
  303. }
  304. // Refresh the entire status node in background thread
  305. if((RouterRefreshObject*)m_spRefreshObject)
  306. {
  307. UpdateUIItems(pNode);
  308. m_spRefreshObject->Refresh();
  309. }
  310. else // if no refresh object, refresh it in main thread
  311. SynchronizeNode(pNode);
  312. // clear the lazy list
  313. m_pServerList->RemoveAllServerHandlers();
  314. }
  315. COM_PROTECT_CATCH;
  316. m_bExpanded = TRUE;
  317. return hr;
  318. }
  319. /*!--------------------------------------------------------------------------
  320. DomainStatusHandler::GetString
  321. Implementation of ITFSNodeHandler::GetString
  322. We don't need to do anything, since our root node is an extension
  323. only and thus can't do anything to the node text.
  324. Author: KennT
  325. ---------------------------------------------------------------------------*/
  326. STDMETHODIMP_(LPCTSTR) DomainStatusHandler::GetString(ITFSNode *pNode, int nCol)
  327. {
  328. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  329. HRESULT hr = hrOK;
  330. COM_PROTECT_TRY
  331. {
  332. if ( m_stTitle.IsEmpty() )
  333. m_stTitle.LoadString(IDS_DVS_SUMMARYNODE);
  334. }
  335. COM_PROTECT_CATCH;
  336. return m_stTitle;
  337. }
  338. /*!--------------------------------------------------------------------------
  339. DomainStatusHandler::OnCreateDataObject
  340. -
  341. Author: KennT
  342. ---------------------------------------------------------------------------*/
  343. STDMETHODIMP DomainStatusHandler::OnCreateDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  344. {
  345. HRESULT hr = hrOK;
  346. COM_PROTECT_TRY
  347. {
  348. SPIDataObject spdo;
  349. CDataObject* pdo = NULL;
  350. pdo= new CDataObject;
  351. spdo = pdo;
  352. // Save cookie and type for delayed rendering
  353. pdo->SetType(type);
  354. pdo->SetCookie(cookie);
  355. // Store the coclass with the data object
  356. pdo->SetClsid(*(m_spTFSCompData->GetCoClassID()));
  357. pdo->SetTFSComponentData(m_spTFSCompData);
  358. *ppDataObject = spdo.Transfer();
  359. }
  360. COM_PROTECT_CATCH;
  361. return hr;
  362. }
  363. /*!--------------------------------------------------------------------------
  364. DomainStatusHandler::Init
  365. -
  366. Author: KennT
  367. ---------------------------------------------------------------------------*/
  368. HRESULT DomainStatusHandler::Init(DMVConfigStream *pConfigStream, CServerList* pSList)
  369. {
  370. HRESULT hr=S_OK;
  371. m_pConfigStream = pConfigStream;
  372. Assert(pSList);
  373. m_pServerList=pSList;
  374. m_bExpanded=FALSE;
  375. return hrOK;
  376. }
  377. /*!--------------------------------------------------------------------------
  378. DomainStatusHandler::ConstructNode
  379. Initializes the root node (sets it up).
  380. Author: KennT
  381. ---------------------------------------------------------------------------*/
  382. HRESULT DomainStatusHandler::ConstructNode(ITFSNode *pNode)
  383. {
  384. HRESULT hr = hrOK;
  385. if ( pNode == NULL )
  386. return hrOK;
  387. COM_PROTECT_TRY
  388. {
  389. // Need to initialize the data for the root node
  390. pNode->SetData(TFS_DATA_IMAGEINDEX, IMAGE_IDX_DOMAIN);
  391. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, IMAGE_IDX_DOMAIN);
  392. pNode->SetData(TFS_DATA_SCOPEID, 0);
  393. // This is a leaf node in the scope pane
  394. pNode->SetData(TFS_DATA_SCOPE_LEAF_NODE, TRUE);
  395. m_cookie = reinterpret_cast<LONG_PTR>(pNode);
  396. pNode->SetData(TFS_DATA_COOKIE, m_cookie);
  397. pNode->SetNodeType(&GUID_DomainStatusNodeType);
  398. }
  399. COM_PROTECT_CATCH;
  400. return hr;
  401. }
  402. /*!--------------------------------------------------------------------------
  403. DomainStatusHandler::AddServerNode
  404. -
  405. Author: KennT
  406. ---------------------------------------------------------------------------*/
  407. HRESULT DomainStatusHandler::AddServerNode(ITFSNode *pParent, MachineNodeData* pMachineData)
  408. {
  409. HRESULT hr = hrOK;
  410. Assert(pParent);
  411. Assert(pMachineData);
  412. DomainStatusServerHandler * pHandler;
  413. SPITFSResultHandler spHandler;
  414. SPITFSNode spNode;
  415. // Create the handler for this node
  416. pHandler = new DomainStatusServerHandler(m_spTFSCompData);
  417. spHandler = pHandler;
  418. CORg( pHandler->Init(pParent, m_pConfigStream) );
  419. // Create a result item node (or a leaf node)
  420. CORg( CreateLeafTFSNode(&spNode,
  421. NULL,
  422. static_cast<ITFSNodeHandler *>(pHandler),
  423. static_cast<ITFSResultHandler *>(pHandler),
  424. m_spNodeMgr) );
  425. CORg( pHandler->ConstructNode(spNode, pMachineData) );
  426. // set information for auto refresh
  427. if(m_spRefreshObject)
  428. {
  429. pHandler->SetExternalRefreshObject(m_spRefreshObject);
  430. m_spRefreshObject->AddStatusNode(this, spNode);
  431. }
  432. // The data for this node will be set by the SynchronizeNode() call
  433. // in the code that calls this function.
  434. CORg( spNode->SetVisibilityState(TFS_VIS_SHOW) );
  435. CORg( spNode->Show() );
  436. CORg( pParent->AddChild(spNode) );
  437. Error:
  438. return hr;
  439. }
  440. /*!--------------------------------------------------------------------------
  441. DomainStatusHandler::AddMenuItems
  442. Implementation of ITFSResultHandler::AddMenuItems
  443. Use this to add commands to the context menu of the blank areas
  444. of the result pane.
  445. Author: KennT
  446. ---------------------------------------------------------------------------*/
  447. STDMETHODIMP DomainStatusHandler::AddMenuItems(ITFSComponent *pComponent,
  448. MMC_COOKIE cookie,
  449. LPDATAOBJECT pDataObject,
  450. LPCONTEXTMENUCALLBACK pCallback,
  451. long *pInsertionAllowed)
  452. {
  453. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  454. HRESULT hr = hrOK;
  455. SPITFSNode spNode;
  456. m_spNodeMgr->FindNode(cookie, &spNode);
  457. // Call through to the regular OnAddMenuItems
  458. hr = OnAddMenuItems(spNode,
  459. pCallback,
  460. pDataObject,
  461. CCT_RESULT,
  462. TFS_COMPDATA_CHILD_CONTEXTMENU,
  463. pInsertionAllowed);
  464. return hr;
  465. }
  466. /*!--------------------------------------------------------------------------
  467. DomainStatusHandler::Command
  468. -
  469. Author: KennT
  470. ---------------------------------------------------------------------------*/
  471. STDMETHODIMP DomainStatusHandler::Command(ITFSComponent *pComponent,
  472. MMC_COOKIE cookie,
  473. int nCommandID,
  474. LPDATAOBJECT pDataObject)
  475. {
  476. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  477. SPITFSNode spNode;
  478. HRESULT hr = hrOK;
  479. m_spNodeMgr->FindNode(cookie, &spNode);
  480. hr = OnCommand(spNode,
  481. nCommandID,
  482. CCT_RESULT,
  483. pDataObject,
  484. TFS_COMPDATA_CHILD_CONTEXTMENU);
  485. return hr;
  486. }
  487. ImplementEmbeddedUnknown(DomainStatusHandler, IRtrAdviseSink)
  488. STDMETHODIMP DomainStatusHandler::EIRtrAdviseSink::OnChange(LONG_PTR ulConn,
  489. DWORD dwChangeType, DWORD dwObjectType, LPARAM lUserParam, LPARAM lParam)
  490. {
  491. InitPThis(DomainStatusHandler, IRtrAdviseSink);
  492. SPITFSNode spThisNode;
  493. SPITFSNode spRootNode;
  494. SPITFSNodeEnum spEnumNode;
  495. SPIEnumInterfaceInfo spEnumIf;
  496. SPIInterfaceInfo spIf;
  497. SPIRtrMgrInterfaceInfo spRmIf;
  498. SPIInfoBase spInfoBase;
  499. BOOL fPleaseAdd;
  500. BOOL fFound;
  501. InterfaceNodeData * pData;
  502. HRESULT hr = hrOK;
  503. pThis->m_spNodeMgr->FindNode(pThis->m_cookie, &spThisNode);
  504. if ( dwObjectType == ROUTER_OBJ_RmProtIf )
  505. {
  506. }
  507. else
  508. if ( dwChangeType == ROUTER_REFRESH )
  509. {
  510. if ( ulConn == pThis->m_ulStatsConnId )
  511. {
  512. // pThis->m_ATLKGroupStats.PostRefresh();
  513. }
  514. else
  515. // pThis->SynchronizeNode(spThisNode);
  516. ;
  517. }
  518. // update all the machine node icons
  519. spThisNode->GetParent(&spRootNode);
  520. hr = DMVRootHandler::UpdateAllMachineIcons(spRootNode);
  521. //Error:
  522. return hr;
  523. }
  524. /*!--------------------------------------------------------------------------
  525. DomainStatusHandler::GetServerInfo
  526. Gets the information for the specified summary node.
  527. Author: FlorinT
  528. ---------------------------------------------------------------------------*/
  529. HRESULT DomainStatusHandler::GetServerInfo(ITFSNode *pNode)
  530. {
  531. HRESULT hr=S_OK;
  532. DMVNodeData *pData;
  533. MachineNodeData *pMachineData;
  534. pData = GET_DMVNODEDATA(pNode);
  535. Assert(pData);
  536. pMachineData = pData->m_spMachineData;
  537. Assert(pMachineData);
  538. // Do a refresh of the data in the machine node data.
  539. pMachineData->Load();
  540. return hrOK;
  541. }
  542. /*!--------------------------------------------------------------------------
  543. DomainStatusHandler::SynchronizeIcon
  544. -
  545. Author: FlorinT
  546. ----------------------------------------------------------------------------*/
  547. HRESULT DomainStatusHandler::SynchronizeIcon(ITFSNode *pNode)
  548. {
  549. HRESULT hr = hrOK;
  550. DMVNodeData *pData;
  551. MachineNodeData *pMachineData;
  552. DomainStatusServerHandler::SMenuData menuData;
  553. LPARAM imageIndex;
  554. pData = GET_DMVNODEDATA(pNode);
  555. Assert(pData);
  556. pMachineData = pData->m_spMachineData;
  557. Assert(pMachineData);
  558. imageIndex = pMachineData->GetServiceImageIndex();
  559. pNode->SetData(TFS_DATA_IMAGEINDEX, imageIndex);
  560. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, imageIndex);
  561. return hr;
  562. }
  563. /*!--------------------------------------------------------------------------
  564. DomainStatusHandler::SynchronizeData
  565. -
  566. Author: FlorinT
  567. ----------------------------------------------------------------------------*/
  568. HRESULT DomainStatusHandler::SynchronizeData(ITFSNode *pNode)
  569. {
  570. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  571. HRESULT hr = hrOK;
  572. DMVNodeData *pData;
  573. MachineNodeData *pMachineData;
  574. pData = GET_DMVNODEDATA(pNode);
  575. Assert(pData);
  576. pMachineData = pData->m_spMachineData;
  577. Assert(pMachineData);
  578. if(pMachineData->m_stMachineName.GetLength() == 0)
  579. pData->m_rgData[DVS_SI_SERVERNAME].m_stData = GetLocalMachineName();
  580. else
  581. pData->m_rgData[DVS_SI_SERVERNAME].m_stData = pMachineData->m_stMachineName;
  582. pData->m_rgData[DVS_SI_SERVERTYPE].m_stData = pMachineData->m_stServerType;
  583. pData->m_rgData[DVS_SI_BUILDNO].m_stData = pMachineData->m_stBuildNo;
  584. pData->m_rgData[DVS_SI_STATE].m_stData = pMachineData->m_stState;
  585. if (pMachineData->m_fStatsRetrieved)
  586. {
  587. FillInNumberData(pData, DVS_SI_PORTSINUSE, pMachineData->m_dwPortsInUse);
  588. FillInNumberData(pData, DVS_SI_PORTSTOTAL, pMachineData->m_dwPortsTotal);
  589. if (pMachineData->m_routerType == ServerType_Rras)
  590. {
  591. FormatDuration(pMachineData->m_dwUpTime,
  592. pData->m_rgData[DVS_SI_UPTIME].m_stData,
  593. 1,
  594. FDFLAG_DAYS | FDFLAG_HOURS | FDFLAG_MINUTES);
  595. pData->m_rgData[DVS_SI_UPTIME].m_dwData = pMachineData->m_dwUpTime;
  596. }
  597. else
  598. {
  599. // This is a non-steelhead RAS server, so we don't
  600. // have the uptime information.
  601. pData->m_rgData[DVS_SI_UPTIME].m_stData.LoadString(IDS_NOT_AVAILABLE);
  602. pData->m_rgData[DVS_SI_UPTIME].m_dwData = 0;
  603. }
  604. }
  605. else
  606. {
  607. pData->m_rgData[DVS_SI_PORTSINUSE].m_stData = c_szDash;
  608. pData->m_rgData[DVS_SI_PORTSINUSE].m_dwData = 0;
  609. pData->m_rgData[DVS_SI_PORTSTOTAL].m_stData = c_szDash;
  610. pData->m_rgData[DVS_SI_PORTSTOTAL].m_dwData = 0;
  611. pData->m_rgData[DVS_SI_UPTIME].m_stData = c_szDash;
  612. pData->m_rgData[DVS_SI_UPTIME].m_dwData = 0;
  613. }
  614. return hr;
  615. }
  616. /*!--------------------------------------------------------------------------
  617. DomainStatusHandler::UpdateSubItemUI
  618. -
  619. Author: WeiJiang
  620. ---------------------------------------------------------------------------*/
  621. HRESULT DomainStatusHandler::SynchronizeSubItem(ITFSNode *pNode)
  622. {
  623. HRESULT hr = hrOK;
  624. hr = GetServerInfo(pNode);
  625. if (hr == hrOK)
  626. hr = UpdateSubItemUI(pNode);
  627. return hr;
  628. }
  629. /*!--------------------------------------------------------------------------
  630. DomainStatusHandler::UpdateSubItemUI
  631. -
  632. Author: WeiJiang
  633. ---------------------------------------------------------------------------*/
  634. HRESULT DomainStatusHandler::UpdateSubItemUI(ITFSNode *pNode)
  635. {
  636. HRESULT hr = hrOK;
  637. hr = SynchronizeData(pNode);
  638. if (hr == hrOK)
  639. hr = SynchronizeIcon(pNode);
  640. {// update the corresponding machine node
  641. }
  642. pNode->ChangeNode(RESULT_PANE_CHANGE_ITEM);
  643. return hr;
  644. }
  645. /*!--------------------------------------------------------------------------
  646. DomainStatusHandler::UpdateUIItems
  647. -
  648. Author: KennT
  649. ---------------------------------------------------------------------------*/
  650. HRESULT DomainStatusHandler::UpdateUIItems(ITFSNode *pThisNode)
  651. {
  652. HRESULT hr = hrOK;
  653. SPITFSNodeEnum spNodeEnum;
  654. SPITFSNode spNode;
  655. CWaitCursor cw;
  656. COM_PROTECT_TRY
  657. {
  658. pThisNode->GetEnum(&spNodeEnum);
  659. while(spNodeEnum->Next(1, &spNode, NULL) == hrOK)
  660. {
  661. hr = UpdateSubItemUI(spNode);
  662. spNode.Release();
  663. }
  664. }
  665. COM_PROTECT_CATCH;
  666. return hr;
  667. }
  668. /*!--------------------------------------------------------------------------
  669. DomainStatusHandler::SynchronizeNode
  670. -
  671. Author: KennT
  672. ---------------------------------------------------------------------------*/
  673. HRESULT DomainStatusHandler::SynchronizeNode(ITFSNode *pThisNode)
  674. {
  675. HRESULT hr = hrOK;
  676. SPITFSNodeEnum spNodeEnum;
  677. SPITFSNode spNode;
  678. CWaitCursor cw;
  679. COM_PROTECT_TRY
  680. {
  681. pThisNode->GetEnum(&spNodeEnum);
  682. while(spNodeEnum->Next(1, &spNode, NULL) == hrOK)
  683. {
  684. hr = SynchronizeSubItem(spNode);
  685. if (hr == hrOK)
  686. spNode->ChangeNode(RESULT_PANE_CHANGE_ITEM);
  687. spNode.Release();
  688. }
  689. }
  690. COM_PROTECT_CATCH;
  691. return hr;
  692. }
  693. /*!--------------------------------------------------------------------------
  694. DomainStatusHandler::GetDVSData
  695. -
  696. Author: KennT
  697. ---------------------------------------------------------------------------*/
  698. HRESULT DomainStatusHandler::GetDVServerData(ITFSNode *pThisNode)
  699. {
  700. return hrOK;
  701. }
  702. /*!--------------------------------------------------------------------------
  703. DomainStatusHandler::OnResultShow
  704. -
  705. Author: KennT
  706. ---------------------------------------------------------------------------*/
  707. HRESULT DomainStatusHandler::OnResultShow(ITFSComponent *pTFSComponent,
  708. MMC_COOKIE cookie,
  709. LPARAM arg,
  710. LPARAM lParam)
  711. {
  712. BOOL bSelect = (BOOL) arg;
  713. HRESULT hr = hrOK;
  714. SPIRouterRefresh spRefresh;
  715. SPITFSNode spNode;
  716. BaseContainerHandler::OnResultShow(pTFSComponent, cookie, arg, lParam);
  717. if ( bSelect )
  718. {
  719. hr = OnResultRefresh(pTFSComponent, NULL, cookie, arg, lParam);
  720. }
  721. // Un/Register for refresh advises
  722. if ((RouterRefreshObject*)m_spRefreshObject )
  723. {
  724. if ( bSelect )
  725. {
  726. if ( m_ulRefreshConnId == 0 )
  727. m_spRefreshObject->AdviseRefresh(&m_IRtrAdviseSink, &m_ulRefreshConnId, 0);
  728. if ( m_ulStatsConnId == 0 )
  729. m_spRefreshObject->AdviseRefresh(&m_IRtrAdviseSink, &m_ulStatsConnId, 0);
  730. }
  731. else
  732. {
  733. if ( m_ulRefreshConnId )
  734. m_spRefreshObject->UnadviseRefresh(m_ulRefreshConnId);
  735. m_ulRefreshConnId = 0;
  736. }
  737. }
  738. return hr;
  739. }
  740. /*!--------------------------------------------------------------------------
  741. DomainStatusHandler::OnResultRefresh
  742. -
  743. Author: KennT
  744. ---------------------------------------------------------------------------*/
  745. HRESULT DomainStatusHandler::OnResultRefresh(ITFSComponent * pComponent,
  746. LPDATAOBJECT pDataObject,
  747. MMC_COOKIE cookie,
  748. LPARAM arg,
  749. LPARAM lParam)
  750. {
  751. SPITFSNode spThisNode;
  752. CWaitCursor cw;
  753. m_spResultNodeMgr->FindNode(cookie, &spThisNode);
  754. return OnCommand(spThisNode, IDS_MENU_REFRESH, CCT_RESULT, NULL, 0);
  755. }
  756. /*!--------------------------------------------------------------------------
  757. DomainStatusHandler::CompareItems
  758. -
  759. Author: KennT
  760. ---------------------------------------------------------------------------*/
  761. STDMETHODIMP_(int) DomainStatusHandler::CompareItems(
  762. ITFSComponent * pComponent,
  763. MMC_COOKIE cookieA,
  764. MMC_COOKIE cookieB,
  765. int nCol)
  766. {
  767. // Get the strings from the nodes and use that as a basis for
  768. // comparison.
  769. SPITFSNode spNode;
  770. SPITFSResultHandler spResult;
  771. m_spNodeMgr->FindNode(cookieA, &spNode);
  772. spNode->GetResultHandler(&spResult);
  773. return spResult->CompareItems(pComponent, cookieA, cookieB, nCol);
  774. }
  775. /*---------------------------------------------------------------------------
  776. Class: DomainStatusServerHandler
  777. ---------------------------------------------------------------------------*/
  778. DomainStatusServerHandler::DomainStatusServerHandler(ITFSComponentData *pCompData)
  779. : BaseResultHandler(pCompData, DM_COLUMNS_DVSUM)
  780. {
  781. m_rgButtonState[MMC_VERB_DELETE_INDEX] = ENABLED;
  782. m_bState[MMC_VERB_DELETE_INDEX] = TRUE;
  783. // m_verbDefault = MMC_VERB_PROPERTIES;
  784. }
  785. DomainStatusServerHandler::~DomainStatusServerHandler()
  786. {
  787. }
  788. /*!--------------------------------------------------------------------------
  789. DomainStatusServerHandler::ConstructNode
  790. Initializes the Domain node (sets it up).
  791. Author: KennT
  792. ---------------------------------------------------------------------------*/
  793. HRESULT DomainStatusServerHandler::ConstructNode(ITFSNode *pNode, MachineNodeData *pMachineData)
  794. {
  795. HRESULT hr = hrOK;
  796. int i;
  797. if ( pNode == NULL )
  798. return hrOK;
  799. COM_PROTECT_TRY
  800. {
  801. pNode->SetData(TFS_DATA_SCOPEID, 0);
  802. pNode->SetData(TFS_DATA_COOKIE, reinterpret_cast<LONG_PTR>(pNode));
  803. pNode->SetNodeType(&GUID_DVSServerNodeType);
  804. DMVNodeData::InitDMVNodeData(pNode, pMachineData);
  805. }
  806. COM_PROTECT_CATCH
  807. return hr;
  808. }
  809. HRESULT DomainStatusServerHandler::SetExternalRefreshObject(RouterRefreshObject *pRefresh)
  810. {
  811. Assert(!m_spRefreshObject); // set twice is not allowed
  812. Assert(pRefresh);
  813. m_spRefreshObject = pRefresh;
  814. if(m_spRefreshObject)
  815. m_spRefreshObject->AddRef();
  816. return S_OK;
  817. };
  818. /*!--------------------------------------------------------------------------
  819. DomainStatusServerHandler::GetString
  820. -
  821. Author: KennT
  822. ---------------------------------------------------------------------------*/
  823. STDMETHODIMP_(LPCTSTR) DomainStatusServerHandler::GetString(ITFSComponent * pComponent,
  824. MMC_COOKIE cookie,
  825. int nCol)
  826. {
  827. Assert(m_spNodeMgr);
  828. SPITFSNode spNode;
  829. DMVNodeData *pData;
  830. ConfigStream * pConfig;
  831. m_spNodeMgr->FindNode(cookie, &spNode);
  832. Assert(spNode);
  833. pData = GET_DMVNODEDATA(spNode);
  834. Assert(pData);
  835. pComponent->GetUserData((LONG_PTR *) &pConfig);
  836. Assert(pConfig);
  837. return pData->m_rgData[pConfig->MapColumnToSubitem(DM_COLUMNS_DVSUM, nCol)].m_stData;
  838. }
  839. /*!--------------------------------------------------------------------------
  840. DomainStatusServerHandler::OnCreateDataObject
  841. -
  842. Author: KennT
  843. ---------------------------------------------------------------------------*/
  844. STDMETHODIMP DomainStatusServerHandler::OnCreateDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  845. {
  846. HRESULT hr = hrOK;
  847. COM_PROTECT_TRY
  848. {
  849. SPIDataObject spdo;
  850. CDataObject* pdo = NULL;
  851. pdo= new CDataObject;
  852. spdo = pdo;
  853. // Save cookie and type for delayed rendering
  854. pdo->SetType(type);
  855. pdo->SetCookie(cookie);
  856. // Store the coclass with the data object
  857. pdo->SetClsid(*(m_spTFSCompData->GetCoClassID()));
  858. pdo->SetTFSComponentData(m_spTFSCompData);
  859. *ppDataObject = spdo.Transfer();
  860. }
  861. COM_PROTECT_CATCH;
  862. return hr;
  863. }
  864. /*!--------------------------------------------------------------------------
  865. DomainStatusServerHandler::OnCreateDataObject
  866. Implementation of ITFSResultHandler::OnCreateDataObject
  867. Author: KennT
  868. ---------------------------------------------------------------------------*/
  869. STDMETHODIMP DomainStatusServerHandler::OnCreateDataObject(ITFSComponent *pComp,
  870. MMC_COOKIE cookie,
  871. DATA_OBJECT_TYPES type,
  872. IDataObject **ppDataObject)
  873. {
  874. HRESULT hr = hrOK;
  875. COM_PROTECT_TRY
  876. {
  877. SPIDataObject spdo;
  878. CDataObject* pdo = NULL;
  879. pdo= new CDataObject;
  880. spdo = pdo;
  881. // Save cookie and type for delayed rendering
  882. pdo->SetType(type);
  883. pdo->SetCookie(cookie);
  884. // Store the coclass with the data object
  885. pdo->SetClsid(*(m_spTFSCompData->GetCoClassID()));
  886. pdo->SetTFSComponentData(m_spTFSCompData);
  887. *ppDataObject = spdo.Transfer();
  888. }
  889. COM_PROTECT_CATCH;
  890. return hr;
  891. }
  892. /*!--------------------------------------------------------------------------
  893. DomainStatusServerHandler::RefreshInterface
  894. -
  895. Author: KennT
  896. ---------------------------------------------------------------------------*/
  897. void DomainStatusServerHandler::RefreshInterface(MMC_COOKIE cookie)
  898. {
  899. SPITFSNode spNode;
  900. SPITFSNode spParent;
  901. SPITFSNodeHandler spHandler;
  902. m_spNodeMgr->FindNode(cookie, &spNode);
  903. // Can't do it for a single node at this time, just refresh the
  904. // whole thing.
  905. spNode->GetParent(&spParent);
  906. spParent->GetHandler(&spHandler);
  907. spHandler->OnCommand(spParent,
  908. IDS_MENU_REFRESH,
  909. CCT_RESULT, NULL, 0);
  910. }
  911. /*!--------------------------------------------------------------------------
  912. DomainStatusServerHandler::Init
  913. -
  914. Author: KennT
  915. ---------------------------------------------------------------------------*/
  916. HRESULT DomainStatusServerHandler::Init(ITFSNode *pParent, DMVConfigStream *pConfigStream)
  917. {
  918. BaseResultHandler::Init(NULL, pParent);
  919. return hrOK;
  920. }
  921. /*!--------------------------------------------------------------------------
  922. DomainStatusServerHandler::DestroyResultHandler
  923. -
  924. Author: KennT
  925. ---------------------------------------------------------------------------*/
  926. STDMETHODIMP DomainStatusServerHandler::DestroyResultHandler(MMC_COOKIE cookie)
  927. {
  928. SPITFSNode spNode;
  929. m_spNodeMgr->FindNode(cookie, &spNode);
  930. if((RouterRefreshObject*)m_spRefreshObject)
  931. {
  932. m_spRefreshObject->RemoveStatusNode(spNode);
  933. }
  934. DMVNodeData::FreeDMVNodeData(spNode);
  935. CHandler::DestroyResultHandler(cookie);
  936. return hrOK;
  937. }
  938. /*---------------------------------------------------------------------------
  939. This is the list of commands that will show up for the result pane
  940. nodes.
  941. ---------------------------------------------------------------------------*/
  942. struct SIPServerNodeMenu
  943. {
  944. ULONG m_sidMenu; // string/command id for this menu item
  945. ULONG (DomainStatusServerHandler:: *m_pfnGetMenuFlags)(DomainStatusServerHandler::SMenuData *);
  946. ULONG m_ulPosition;
  947. };
  948. static const SRouterNodeMenu s_rgServerMenu[] =
  949. {
  950. // Add items that go at the top here
  951. { IDS_MENU_RTRWIZ, DomainStatusServerHandler::QueryService,
  952. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  953. { IDS_DMV_MENU_REMOVESERVICE, DomainStatusServerHandler::QueryService,
  954. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  955. { IDS_DMV_MENU_REFRESH, 0,
  956. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  957. { IDS_DMV_MENU_REBUILDSVRLIST, 0,
  958. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  959. { IDS_DMV_MENU_REMOVEFROMDIR, 0,
  960. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  961. { IDS_DMV_MENU_START, DomainStatusServerHandler::QueryService,
  962. CCM_INSERTIONPOINTID_PRIMARY_TASK},
  963. { IDS_DMV_MENU_STOP, DomainStatusServerHandler::QueryService,
  964. CCM_INSERTIONPOINTID_PRIMARY_TASK},
  965. { IDS_MENU_PAUSE_SERVICE, MachineHandler::GetPauseFlags,
  966. CCM_INSERTIONPOINTID_PRIMARY_TASK },
  967. { IDS_MENU_RESUME_SERVICE, MachineHandler::GetPauseFlags,
  968. CCM_INSERTIONPOINTID_PRIMARY_TASK },
  969. { IDS_MENU_RESTART_SERVICE, MachineHandler::QueryService,
  970. CCM_INSERTIONPOINTID_PRIMARY_TASK }
  971. };
  972. /*---------------------------------------------------------------------------
  973. Use this menu for servers which we cannot connect to.
  974. ---------------------------------------------------------------------------*/
  975. static const SRouterNodeMenu s_rgBadConnectionServerMenu[] =
  976. {
  977. // Add items that go at the top here
  978. { IDS_DMV_MENU_REFRESH, 0,
  979. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  980. { IDS_DMV_MENU_REBUILDSVRLIST, 0,
  981. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  982. };
  983. ULONG DomainStatusServerHandler::QueryService(const SRouterNodeMenu *pMenuData,
  984. INT_PTR pUserData)
  985. {
  986. // This relies on the fact that the DomainStatusServerHandler::SMenuData
  987. // is derived from the MachineHandler::SMenuData
  988. return MachineHandler::GetServiceFlags(pMenuData, pUserData);
  989. }
  990. ULONG DomainStatusServerHandler::GetPauseFlags(const SRouterNodeMenu *pMenuData,
  991. INT_PTR pUserData)
  992. {
  993. // This relies on the fact that the DomainStatusServerHandler::SMenuData
  994. // is derived from the MachineHandler::SMenuData
  995. return MachineHandler::GetPauseFlags(pMenuData, pUserData);
  996. }
  997. /*!--------------------------------------------------------------------------
  998. DomainStatusServerHandler::AddMenuItems
  999. Implementation of ITFSResultHandler::AddMenuItems
  1000. Author: KennT
  1001. ---------------------------------------------------------------------------*/
  1002. STDMETHODIMP DomainStatusServerHandler::AddMenuItems(
  1003. ITFSComponent *pComponent,
  1004. MMC_COOKIE cookie,
  1005. LPDATAOBJECT lpDataObject,
  1006. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  1007. long *pInsertionAllowed)
  1008. {
  1009. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1010. HRESULT hr = S_OK;
  1011. SPITFSNode spNode;
  1012. DomainStatusServerHandler::SMenuData menuData;
  1013. DMVNodeData *pData;
  1014. MachineNodeData * pMachineData;
  1015. SRouterNodeMenu * prgMenu;
  1016. DWORD cMenu;
  1017. COM_PROTECT_TRY
  1018. {
  1019. m_spNodeMgr->FindNode(cookie, &spNode);
  1020. pData = GET_DMVNODEDATA(spNode);
  1021. Assert(pData);
  1022. pMachineData = pData->m_spMachineData;
  1023. Assert(pMachineData);
  1024. if (pMachineData->m_machineState != machine_connected)
  1025. {
  1026. prgMenu = (SRouterNodeMenu *) s_rgBadConnectionServerMenu;
  1027. cMenu = DimensionOf(s_rgBadConnectionServerMenu);
  1028. }
  1029. else
  1030. {
  1031. prgMenu = (SRouterNodeMenu *) s_rgServerMenu;
  1032. cMenu = DimensionOf(s_rgServerMenu);
  1033. }
  1034. // Now go through and add our menu items
  1035. menuData.m_spNode.Set(spNode);
  1036. menuData.m_pMachineConfig = &(pMachineData->m_MachineConfig);
  1037. hr = AddArrayOfMenuItems(spNode,
  1038. prgMenu,
  1039. cMenu,
  1040. pContextMenuCallback,
  1041. *pInsertionAllowed,
  1042. (INT_PTR) &menuData);
  1043. }
  1044. COM_PROTECT_CATCH;
  1045. return hr;
  1046. }
  1047. /*!--------------------------------------------------------------------------
  1048. DomainStatusServerHandler::Command
  1049. -
  1050. Author: KennT
  1051. ---------------------------------------------------------------------------*/
  1052. STDMETHODIMP DomainStatusServerHandler::Command(ITFSComponent *pComponent,
  1053. MMC_COOKIE cookie,
  1054. int nCommandID,
  1055. LPDATAOBJECT pDataObject)
  1056. {
  1057. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1058. SPITFSNode spNode;
  1059. SPITFSNode spNodeMach;
  1060. SPITFSNode spParent;
  1061. SPITFSResultHandler spResult;
  1062. SPITFSNodeHandler spHandler;
  1063. HRESULT hr = hrOK;
  1064. DMVNodeData *pData;
  1065. MachineNodeData * pMachineData;
  1066. m_spNodeMgr->FindNode(cookie, &spNode);
  1067. switch ( nCommandID )
  1068. {
  1069. case IDS_DMV_MENU_REFRESH:
  1070. hr = DomainStatusHandler::SynchronizeSubItem(spNode);
  1071. case IDS_MENU_RTRWIZ:
  1072. case IDS_DMV_MENU_START:
  1073. case IDS_DMV_MENU_STOP:
  1074. case IDS_DMV_MENU_REMOVESERVICE:
  1075. case IDS_MENU_PAUSE_SERVICE:
  1076. case IDS_MENU_RESUME_SERVICE:
  1077. case IDS_MENU_RESTART_SERVICE:
  1078. pData = GET_DMVNODEDATA(spNode);
  1079. Assert(pData);
  1080. pMachineData = pData->m_spMachineData;
  1081. Assert(pMachineData);
  1082. m_spNodeMgr->FindNode(pMachineData->m_cookie, &spNodeMach);
  1083. spNodeMach->GetHandler(&spHandler);
  1084. hr = spHandler->OnCommand(spNodeMach,nCommandID,CCT_RESULT,NULL, 0);
  1085. break;
  1086. case IDS_DMV_MENU_REBUILDSVRLIST:
  1087. // Forward the refresh request to the parent node
  1088. //$ todo : is this really needed? This should check to see what
  1089. // node has the selection.
  1090. spParent.Release();
  1091. spHandler.Release();
  1092. spNode->GetParent(&spParent);
  1093. spParent->GetHandler(&spHandler);
  1094. spHandler->OnCommand(spParent,nCommandID,CCT_RESULT, NULL, 0);
  1095. break;
  1096. case IDS_DMV_MENU_REMOVEFROMDIR:
  1097. pData = GET_DMVNODEDATA(spNode);
  1098. Assert(pData);
  1099. pMachineData = pData->m_spMachineData;
  1100. Assert(pMachineData);
  1101. hr = RRASDelRouterIdObj( pMachineData->m_stMachineName );
  1102. break;
  1103. default:
  1104. break;
  1105. }
  1106. return hr;
  1107. }
  1108. /*!--------------------------------------------------------------------------
  1109. DomainStatusServerHandler::HasPropertyPages
  1110. -
  1111. Author: KennT
  1112. ---------------------------------------------------------------------------*/
  1113. STDMETHODIMP DomainStatusServerHandler::HasPropertyPages
  1114. (
  1115. ITFSNode * pNode,
  1116. LPDATAOBJECT pDataObject,
  1117. DATA_OBJECT_TYPES type,
  1118. DWORD dwType
  1119. )
  1120. {
  1121. return hrFalse;
  1122. }
  1123. /*!--------------------------------------------------------------------------
  1124. DomainStatusServerHandler::CreatePropertyPages
  1125. -
  1126. Author: KennT
  1127. ---------------------------------------------------------------------------*/
  1128. STDMETHODIMP DomainStatusServerHandler::CreatePropertyPages
  1129. (
  1130. ITFSNode * pNode,
  1131. LPPROPERTYSHEETCALLBACK lpProvider,
  1132. LPDATAOBJECT pDataObject,
  1133. LONG_PTR handle,
  1134. DWORD dwType)
  1135. {
  1136. HRESULT hr = hrOK;
  1137. return hr;
  1138. }
  1139. /*!--------------------------------------------------------------------------
  1140. DomainStatusServerHandler::CreatePropertyPages
  1141. Implementation of ResultHandler::CreatePropertyPages
  1142. Author: KennT
  1143. ---------------------------------------------------------------------------*/
  1144. STDMETHODIMP DomainStatusServerHandler::CreatePropertyPages
  1145. (
  1146. ITFSComponent * pComponent,
  1147. MMC_COOKIE cookie,
  1148. LPPROPERTYSHEETCALLBACK lpProvider,
  1149. LPDATAOBJECT pDataObject,
  1150. LONG_PTR handle
  1151. )
  1152. {
  1153. // Forward this call onto the NodeHandler::CreatePropertyPages
  1154. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1155. HRESULT hr = hrOK;
  1156. SPITFSNode spNode;
  1157. Assert( m_spNodeMgr );
  1158. CORg( m_spNodeMgr->FindNode(cookie, &spNode) );
  1159. // Call the ITFSNodeHandler::CreatePropertyPages
  1160. hr = CreatePropertyPages(spNode, lpProvider, pDataObject, handle, 0);
  1161. Error:
  1162. return hr;
  1163. }
  1164. /*!--------------------------------------------------------------------------
  1165. DomainStatusServerHandler::OnResultDelete
  1166. -
  1167. Author: KennT
  1168. ---------------------------------------------------------------------------*/
  1169. HRESULT DomainStatusServerHandler::OnResultDelete(ITFSComponent *pComponent,
  1170. LPDATAOBJECT pDataObject,
  1171. MMC_COOKIE cookie,
  1172. LPARAM arg,
  1173. LPARAM param)
  1174. {
  1175. SPITFSNode spNode;
  1176. m_spNodeMgr->FindNode(cookie, &spNode);
  1177. return OnRemoveServer(spNode);
  1178. }
  1179. /*!--------------------------------------------------------------------------
  1180. DomainStatusServerHandler::OnRemoveServer
  1181. -
  1182. Author: KennT
  1183. ---------------------------------------------------------------------------*/
  1184. HRESULT DomainStatusServerHandler::OnRemoveServer(ITFSNode *pNode)
  1185. {
  1186. SPITFSNodeHandler spHoldHandler;
  1187. SPITFSNode spParent;
  1188. SPITFSNode spGrandParent;
  1189. SPITFSNode spthis;
  1190. SPITFSNode spMachineNode;
  1191. DMVNodeData* pData;
  1192. MachineNodeData * pMachineData;
  1193. Assert(pNode);
  1194. pNode->GetParent( &spParent );
  1195. Assert( spParent );
  1196. // Addref this node so that it won't get deleted before we're out
  1197. // of this function
  1198. spHoldHandler.Set( this );
  1199. spthis.Set( pNode );
  1200. // Look for the machine node
  1201. pData = GET_DMVNODEDATA( pNode );
  1202. Assert( pData );
  1203. pMachineData = pData->m_spMachineData;
  1204. m_spNodeMgr->FindNode(pMachineData->m_cookie, &spMachineNode);
  1205. // delete the machine node (the node in the scope pane)
  1206. spParent->GetParent( &spGrandParent );
  1207. Assert( spGrandParent );
  1208. spGrandParent->RemoveChild( spMachineNode );
  1209. // fetch & delete server node (the node in the result pane)
  1210. spParent->RemoveChild( pNode );
  1211. return hrOK;
  1212. }
  1213. STDMETHODIMP_(int) DomainStatusServerHandler::CompareItems(ITFSComponent * pComponent,
  1214. MMC_COOKIE cookieA,
  1215. MMC_COOKIE cookieB,
  1216. int nCol)
  1217. {
  1218. ConfigStream * pConfig;
  1219. pComponent->GetUserData((LONG_PTR *) &pConfig);
  1220. Assert(pConfig);
  1221. int nSubItem = pConfig->MapColumnToSubitem(m_ulColumnId, nCol);
  1222. if (pConfig->GetSortCriteria(m_ulColumnId, nCol) == CON_SORT_BY_DWORD)
  1223. {
  1224. SPITFSNode spNodeA, spNodeB;
  1225. DMVNodeData * pNodeDataA = NULL;
  1226. DMVNodeData * pNodeDataB = NULL;
  1227. m_spNodeMgr->FindNode(cookieA, &spNodeA);
  1228. m_spNodeMgr->FindNode(cookieB, &spNodeB);
  1229. pNodeDataA = GET_DMVNODEDATA(spNodeA);
  1230. Assert(pNodeDataA);
  1231. pNodeDataB = GET_DMVNODEDATA(spNodeB);
  1232. Assert(pNodeDataB);
  1233. // Note: if the values are both zero, we need to do
  1234. // a string comparison (to distinuguish true zero
  1235. // from a NULL data).
  1236. // e.g. "0" vs. "-"
  1237. if ((pNodeDataA->m_rgData[nSubItem].m_dwData == 0 ) &&
  1238. (pNodeDataB->m_rgData[nSubItem].m_dwData == 0))
  1239. {
  1240. return StriCmpW(GetString(pComponent, cookieA, nCol),
  1241. GetString(pComponent, cookieB, nCol));
  1242. }
  1243. else
  1244. return pNodeDataA->m_rgData[nSubItem].m_dwData -
  1245. pNodeDataB->m_rgData[nSubItem].m_dwData;
  1246. }
  1247. else
  1248. return StriCmpW(GetString(pComponent, cookieA, nCol),
  1249. GetString(pComponent, cookieB, nCol));
  1250. }