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.

807 lines
21 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. IPXAdmin
  7. Interface node information
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "util.h"
  12. #include "reg.h" // registry utilities
  13. #include "rtrutil.h"
  14. #include "service.h" // for TFS service APIs
  15. #include "ipxstrm.h" // for IPXAdminConfigStream
  16. #include "ipxconn.h"
  17. #include "summary.h"
  18. #include "nbview.h"
  19. #include "srview.h"
  20. #include "ssview.h"
  21. #include "snview.h"
  22. #include "rtrui.h"
  23. #include "sumprop.h" // IP Summary property page
  24. #include "format.h" // FormatNumber function
  25. DEBUG_DECLARE_INSTANCE_COUNTER(IPXAdminNodeHandler)
  26. STDMETHODIMP IPXAdminNodeHandler::QueryInterface(REFIID riid, LPVOID *ppv)
  27. {
  28. // Is the pointer bad?
  29. if (ppv == NULL)
  30. return E_INVALIDARG;
  31. // Place NULL in *ppv in case of failure
  32. *ppv = NULL;
  33. // This is the non-delegating IUnknown implementation
  34. if (riid == IID_IUnknown)
  35. *ppv = (LPVOID) this;
  36. else if (riid == IID_IRtrAdviseSink)
  37. *ppv = &m_IRtrAdviseSink;
  38. else
  39. return BaseRouterHandler::QueryInterface(riid, ppv);
  40. // If we're going to return an interface, AddRef it first
  41. if (*ppv)
  42. {
  43. ((LPUNKNOWN) *ppv)->AddRef();
  44. return hrOK;
  45. }
  46. else
  47. return E_NOINTERFACE;
  48. }
  49. /*---------------------------------------------------------------------------
  50. NodeHandler implementation
  51. ---------------------------------------------------------------------------*/
  52. IPXAdminNodeHandler::IPXAdminNodeHandler(ITFSComponentData *pCompData)
  53. : BaseRouterHandler(pCompData),
  54. m_bExpanded(FALSE),
  55. m_pConfigStream(NULL),
  56. m_ulStatsConnId(0),
  57. m_ulConnId(0)
  58. {
  59. DEBUG_INCREMENT_INSTANCE_COUNTER(IPXAdminNodeHandler)
  60. m_rgButtonState[MMC_VERB_PROPERTIES_INDEX] = ENABLED;
  61. m_bState[MMC_VERB_PROPERTIES_INDEX] = TRUE;
  62. };
  63. /*!--------------------------------------------------------------------------
  64. IPXAdminNodeHandler::Init
  65. -
  66. Author: KennT
  67. ---------------------------------------------------------------------------*/
  68. HRESULT IPXAdminNodeHandler::Init(IRouterInfo *pRouterInfo, IPXAdminConfigStream *pConfigStream)
  69. {
  70. HRESULT hr = hrOK;
  71. Assert(pRouterInfo);
  72. SPIRouterRefresh spRefresh;
  73. m_spRouterInfo.Set(pRouterInfo);
  74. CORg( m_spRouterInfo->FindRtrMgr(PID_IPX, &m_spRtrMgrInfo) );
  75. m_pConfigStream = pConfigStream;
  76. if (m_spRtrMgrInfo == NULL)
  77. return E_FAIL;
  78. m_IpxStats.SetConfigInfo(pConfigStream, IPXSTRM_STATS_IPX);
  79. m_IpxRoutingStats.SetConfigInfo(pConfigStream, IPXSTRM_STATS_ROUTING);
  80. m_IpxServiceStats.SetConfigInfo(pConfigStream, IPXSTRM_STATS_SERVICE);
  81. m_IpxRoutingStats.SetRouterInfo(m_spRouterInfo);
  82. m_IpxServiceStats.SetRouterInfo(m_spRouterInfo);
  83. if (m_spRouterInfo)
  84. m_spRouterInfo->GetRefreshObject(&spRefresh);
  85. if (m_ulConnId == 0)
  86. m_spRtrMgrInfo->RtrAdvise(&m_IRtrAdviseSink, &m_ulConnId, 0);
  87. if (m_ulStatsConnId == 0)
  88. spRefresh->AdviseRefresh(&m_IRtrAdviseSink, &m_ulStatsConnId, 0);
  89. Error:
  90. return hr;
  91. }
  92. /*!--------------------------------------------------------------------------
  93. IPXAdminNodeHandler::DestroyHandler
  94. Implementation of ITFSNodeHandler::DestroyHandler
  95. Author: KennT
  96. ---------------------------------------------------------------------------*/
  97. STDMETHODIMP IPXAdminNodeHandler::DestroyHandler(ITFSNode *pNode)
  98. {
  99. IPXConnection * pIPXConn;
  100. pIPXConn = GET_IPXADMIN_NODEDATA(pNode);
  101. pIPXConn->Release();
  102. if (m_ulConnId)
  103. {
  104. m_spRtrMgrInfo->RtrUnadvise(m_ulConnId);
  105. }
  106. m_ulConnId = 0;
  107. if (m_ulStatsConnId)
  108. {
  109. SPIRouterRefresh spRefresh;
  110. if (m_spRouterInfo)
  111. m_spRouterInfo->GetRefreshObject(&spRefresh);
  112. if (spRefresh)
  113. spRefresh->UnadviseRefresh(m_ulStatsConnId);
  114. }
  115. m_ulStatsConnId = 0;
  116. WaitForStatisticsWindow(&m_IpxStats);
  117. WaitForStatisticsWindow(&m_IpxRoutingStats);
  118. WaitForStatisticsWindow(&m_IpxServiceStats);
  119. m_spRtrMgrInfo.Release();
  120. m_spRouterInfo.Release();
  121. return hrOK;
  122. }
  123. /*!--------------------------------------------------------------------------
  124. IPXAdminNodeHandler::OnCommand
  125. Implementation of ITFSNodeHandler::OnCommand
  126. Author: KennT
  127. ---------------------------------------------------------------------------*/
  128. STDMETHODIMP IPXAdminNodeHandler::OnCommand(ITFSNode *pNode, long nCommandId,
  129. DATA_OBJECT_TYPES type,
  130. LPDATAOBJECT pDataObject,
  131. DWORD dwType)
  132. {
  133. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  134. HRESULT hr = S_OK;
  135. COM_PROTECT_TRY
  136. {
  137. switch (nCommandId)
  138. {
  139. case IDS_MENU_SYNC:
  140. RefreshInterfaces(pNode);
  141. break;
  142. case IDS_MENU_IPXSUM_NEW_PROTOCOL:
  143. hr = OnNewProtocol();
  144. if (!FHrSucceeded(hr))
  145. DisplayErrorMessage(NULL, hr);
  146. break;
  147. case IDS_MENU_IPXSUM_TASK_IPX_INFO:
  148. CreateNewStatisticsWindow(&m_IpxStats,
  149. ::FindMMCMainWindow(),
  150. IDD_STATS_NARROW);
  151. break;
  152. case IDS_MENU_IPXSUM_TASK_ROUTING_TABLE:
  153. CreateNewStatisticsWindow(&m_IpxRoutingStats,
  154. ::FindMMCMainWindow(),
  155. IDD_STATS_NARROW);
  156. break;
  157. case IDS_MENU_IPXSUM_TASK_SERVICE_TABLE:
  158. CreateNewStatisticsWindow(&m_IpxServiceStats,
  159. ::FindMMCMainWindow(),
  160. IDD_STATS);
  161. default:
  162. break;
  163. }
  164. }
  165. COM_PROTECT_CATCH;
  166. return hr;
  167. }
  168. /*!--------------------------------------------------------------------------
  169. IPXAdminNodeHandler::GetString
  170. Implementation of ITFSNodeHandler::GetString
  171. Author: KennT
  172. ---------------------------------------------------------------------------*/
  173. STDMETHODIMP_(LPCTSTR) IPXAdminNodeHandler::GetString(ITFSNode *pNode, int nCol)
  174. {
  175. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  176. HRESULT hr = hrOK;
  177. COM_PROTECT_TRY
  178. {
  179. if (m_stTitle.IsEmpty())
  180. m_stTitle.LoadString(IDS_IPXADMIN_TITLE);
  181. }
  182. COM_PROTECT_CATCH;
  183. return m_stTitle;
  184. }
  185. /*!--------------------------------------------------------------------------
  186. IPXAdminNodeHandler::OnCreateDataObject
  187. Implementation of ITFSNodeHandler::OnCreateDataObject
  188. Author: KennT
  189. ---------------------------------------------------------------------------*/
  190. STDMETHODIMP IPXAdminNodeHandler::OnCreateDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  191. {
  192. HRESULT hr = hrOK;
  193. COM_PROTECT_TRY
  194. {
  195. CORg( CreateDataObjectFromRtrMgrInfo(m_spRtrMgrInfo,
  196. type, cookie, m_spTFSCompData,
  197. ppDataObject, &m_dynExtensions) );
  198. COM_PROTECT_ERROR_LABEL;
  199. }
  200. COM_PROTECT_CATCH;
  201. return hr;
  202. }
  203. /*!--------------------------------------------------------------------------
  204. IPXAdminNodeHandler::OnExpand
  205. -
  206. Author: KennT
  207. ---------------------------------------------------------------------------*/
  208. HRESULT IPXAdminNodeHandler::OnExpand(ITFSNode *pNode,
  209. LPDATAOBJECT pDataObject,
  210. DWORD dwType,
  211. LPARAM arg,
  212. LPARAM lParam)
  213. {
  214. HRESULT hr = hrOK;
  215. SPITFSNodeHandler spHandler;
  216. SPITFSNode spNode;
  217. IPXConnection * pIPXConn;
  218. IPXSummaryHandler * pHandler;
  219. IpxNBHandler * pNBHandler;
  220. IpxSRHandler * pSRHandler;
  221. IpxSSHandler * pSSHandler;
  222. IpxSNHandler * pSNHandler;
  223. if (m_bExpanded)
  224. return hrOK;
  225. pIPXConn = GET_IPXADMIN_NODEDATA(pNode);
  226. // Add the General node
  227. pHandler = new IPXSummaryHandler(m_spTFSCompData);
  228. CORg( pHandler->Init(m_spRtrMgrInfo, m_pConfigStream) );
  229. spHandler = pHandler;
  230. CreateContainerTFSNode(&spNode,
  231. &GUID_IPXSummaryNodeType,
  232. (ITFSNodeHandler *) pHandler,
  233. (ITFSResultHandler *) pHandler,
  234. m_spNodeMgr);
  235. // Call to the node handler to init the node data
  236. pHandler->ConstructNode(spNode, NULL, pIPXConn);
  237. // Make the node immediately visible
  238. spNode->SetVisibilityState(TFS_VIS_SHOW);
  239. pNode->AddChild(spNode);
  240. spHandler.Release();
  241. spNode.Release();
  242. // Add the NetBIOS Broadcasts node
  243. pNBHandler = new IpxNBHandler(m_spTFSCompData);
  244. CORg( pNBHandler->Init(m_spRtrMgrInfo, m_pConfigStream) );
  245. spHandler = pNBHandler;
  246. CreateContainerTFSNode(&spNode,
  247. &GUID_IPXSummaryNodeType,
  248. (ITFSNodeHandler *) pNBHandler,
  249. (ITFSResultHandler *) pNBHandler,
  250. m_spNodeMgr);
  251. // Call to the node handler to init the node data
  252. pNBHandler->ConstructNode(spNode, NULL, pIPXConn);
  253. // Make the node immediately visible
  254. spNode->SetVisibilityState(TFS_VIS_SHOW);
  255. pNode->AddChild(spNode);
  256. spHandler.Release();
  257. spNode.Release();
  258. // Add the Static Routes node
  259. pSRHandler = new IpxSRHandler(m_spTFSCompData);
  260. CORg( pSRHandler->Init(m_spRtrMgrInfo, m_pConfigStream) );
  261. spHandler = pSRHandler;
  262. CreateContainerTFSNode(&spNode,
  263. &GUID_IPXSummaryNodeType,
  264. (ITFSNodeHandler *) pSRHandler,
  265. (ITFSResultHandler *) pSRHandler,
  266. m_spNodeMgr);
  267. // Call to the node handler to init the node data
  268. pSRHandler->ConstructNode(spNode, NULL, pIPXConn);
  269. // Make the node immediately visible
  270. spNode->SetVisibilityState(TFS_VIS_SHOW);
  271. pNode->AddChild(spNode);
  272. spHandler.Release();
  273. spNode.Release();
  274. // Add the Static Services node
  275. pSSHandler = new IpxSSHandler(m_spTFSCompData);
  276. CORg( pSSHandler->Init(m_spRtrMgrInfo, m_pConfigStream) );
  277. spHandler = pSSHandler;
  278. CreateContainerTFSNode(&spNode,
  279. &GUID_IPXSummaryNodeType,
  280. (ITFSNodeHandler *) pSSHandler,
  281. (ITFSResultHandler *) pSSHandler,
  282. m_spNodeMgr);
  283. // Call to the node handler to init the node data
  284. pSSHandler->ConstructNode(spNode, NULL, pIPXConn);
  285. // Make the node immediately visible
  286. spNode->SetVisibilityState(TFS_VIS_SHOW);
  287. pNode->AddChild(spNode);
  288. spHandler.Release();
  289. spNode.Release();
  290. // Add the Static NetBIOS Names node
  291. pSNHandler = new IpxSNHandler(m_spTFSCompData);
  292. CORg( pSNHandler->Init(m_spRtrMgrInfo, m_pConfigStream) );
  293. spHandler = pSNHandler;
  294. CreateContainerTFSNode(&spNode,
  295. &GUID_IPXSummaryNodeType,
  296. (ITFSNodeHandler *) pSNHandler,
  297. (ITFSResultHandler *) pSNHandler,
  298. m_spNodeMgr);
  299. // Call to the node handler to init the node data
  300. pSNHandler->ConstructNode(spNode, NULL, pIPXConn);
  301. // Make the node immediately visible
  302. spNode->SetVisibilityState(TFS_VIS_SHOW);
  303. pNode->AddChild(spNode);
  304. spHandler.Release();
  305. spNode.Release();
  306. m_bExpanded = TRUE;
  307. AddDynamicNamespaceExtensions(pNode);
  308. Error:
  309. return hr;
  310. }
  311. /*!--------------------------------------------------------------------------
  312. IPXAdminNodeHandler::ConstructNode
  313. Initializes the Domain node (sets it up).
  314. Author: KennT
  315. ---------------------------------------------------------------------------*/
  316. HRESULT IPXAdminNodeHandler::ConstructNode(ITFSNode *pNode, BOOL fAddedAsLocal)
  317. {
  318. HRESULT hr = hrOK;
  319. IPXConnection * pIPXConn = NULL;
  320. if (pNode == NULL)
  321. return hrOK;
  322. COM_PROTECT_TRY
  323. {
  324. // Need to initialize the data for the Domain node
  325. pNode->SetData(TFS_DATA_IMAGEINDEX, IMAGE_IDX_INTERFACES);
  326. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, IMAGE_IDX_INTERFACES);
  327. pNode->SetData(TFS_DATA_SCOPEID, 0);
  328. m_cookie = reinterpret_cast<DWORD_PTR>(pNode);
  329. pNode->SetData(TFS_DATA_COOKIE, m_cookie);
  330. pNode->SetNodeType(&GUID_IPXNodeType);
  331. pIPXConn = new IPXConnection;
  332. pIPXConn->SetMachineName(m_spRouterInfo->GetMachineName());
  333. pIPXConn->SetComputerAddedAsLocal(fAddedAsLocal);
  334. SET_IPXADMIN_NODEDATA(pNode, pIPXConn);
  335. m_IpxStats.SetConnectionData(pIPXConn);
  336. m_IpxRoutingStats.SetConnectionData(pIPXConn);
  337. m_IpxServiceStats.SetConnectionData(pIPXConn);
  338. EnumDynamicExtensions(pNode);
  339. }
  340. COM_PROTECT_CATCH
  341. if (!FHrSucceeded(hr))
  342. {
  343. SET_IPXADMIN_NODEDATA(pNode, NULL);
  344. if (pIPXConn)
  345. pIPXConn->Release();
  346. }
  347. return hr;
  348. }
  349. /*!--------------------------------------------------------------------------
  350. IPXAdminNodeHandler::RefreshInterfaces
  351. -
  352. Author: KennT
  353. ---------------------------------------------------------------------------*/
  354. HRESULT IPXAdminNodeHandler::RefreshInterfaces(ITFSNode *pThisNode)
  355. {
  356. return hrOK;
  357. }
  358. ImplementEmbeddedUnknown(IPXAdminNodeHandler, IRtrAdviseSink)
  359. STDMETHODIMP IPXAdminNodeHandler::EIRtrAdviseSink::OnChange(LONG_PTR ulConn,
  360. DWORD dwChangeType, DWORD dwObjectType, LPARAM lUserParam, LPARAM lParam)
  361. {
  362. InitPThis(IPXAdminNodeHandler, IRtrAdviseSink);
  363. HRESULT hr = hrOK;
  364. if (dwChangeType == ROUTER_REFRESH)
  365. {
  366. if (ulConn == pThis->m_ulStatsConnId)
  367. {
  368. pThis->m_IpxStats.PostRefresh();
  369. pThis->m_IpxRoutingStats.PostRefresh();
  370. pThis->m_IpxServiceStats.PostRefresh();
  371. }
  372. }
  373. else if (dwChangeType == ROUTER_DO_DISCONNECT)
  374. {
  375. SPITFSNode spThisNode;
  376. IPXConnection * pIPXConn = NULL;
  377. pThis->m_spNodeMgr->FindNode(pThis->m_cookie, &spThisNode);
  378. pIPXConn = GET_IPXADMIN_NODEDATA(spThisNode);
  379. pIPXConn->DisconnectAll();
  380. }
  381. return hr;
  382. }
  383. /*!--------------------------------------------------------------------------
  384. CreateDataObjectFromRouterInfo
  385. -
  386. Author: KennT
  387. ---------------------------------------------------------------------------*/
  388. HRESULT CreateDataObjectFromRouterInfo(IRouterInfo *pInfo,
  389. DATA_OBJECT_TYPES type,
  390. MMC_COOKIE cookie,
  391. ITFSComponentData *pTFSCompData,
  392. IDataObject **ppDataObject,
  393. CDynamicExtensions * pDynExt)
  394. {
  395. Assert(ppDataObject);
  396. CDataObject * pdo = NULL;
  397. HRESULT hr = hrOK;
  398. SPIUnknown spunk;
  399. SPIDataObject spDataObject;
  400. pdo = new CDataObject;
  401. spDataObject = pdo;
  402. CORg( CreateRouterInfoAggregation(pInfo, pdo, &spunk) );
  403. pdo->SetInnerIUnknown(spunk);
  404. // Save cookie and type for delayed rendering
  405. pdo->SetType(type);
  406. pdo->SetCookie(cookie);
  407. // Store the coclass with the data object
  408. pdo->SetClsid(*(pTFSCompData->GetCoClassID()));
  409. pdo->SetTFSComponentData(pTFSCompData);
  410. pdo->SetDynExt(pDynExt);
  411. *ppDataObject = spDataObject.Transfer();
  412. Error:
  413. return hr;
  414. }
  415. /*!--------------------------------------------------------------------------
  416. CreateDataObjectFromRtrMgrInfo
  417. -
  418. Author: KennT
  419. ---------------------------------------------------------------------------*/
  420. HRESULT CreateDataObjectFromRtrMgrInfo(IRtrMgrInfo *pInfo,
  421. DATA_OBJECT_TYPES type,
  422. MMC_COOKIE cookie,
  423. ITFSComponentData *pTFSCompData,
  424. IDataObject **ppDataObject,
  425. CDynamicExtensions * pDynExt)
  426. {
  427. Assert(ppDataObject);
  428. CDataObject * pdo = NULL;
  429. HRESULT hr = hrOK;
  430. SPIUnknown spunk;
  431. SPIDataObject spDataObject;
  432. pdo = new CDataObject;
  433. spDataObject = pdo;
  434. CORg( CreateRtrMgrInfoAggregation(pInfo, pdo, &spunk) );
  435. pdo->SetInnerIUnknown(spunk);
  436. // Save cookie and type for delayed rendering
  437. pdo->SetType(type);
  438. pdo->SetCookie(cookie);
  439. // Store the coclass with the data object
  440. pdo->SetClsid(*(pTFSCompData->GetCoClassID()));
  441. pdo->SetTFSComponentData(pTFSCompData);
  442. pdo->SetDynExt(pDynExt);
  443. *ppDataObject = spDataObject.Transfer();
  444. Error:
  445. return hr;
  446. }
  447. /*!--------------------------------------------------------------------------
  448. CreateDataObjectFromRtrMgrProtocolInfo
  449. -
  450. Author: KennT
  451. ---------------------------------------------------------------------------*/
  452. HRESULT CreateDataObjectFromRtrMgrProtocolInfo(IRtrMgrProtocolInfo *pInfo,
  453. DATA_OBJECT_TYPES type,
  454. MMC_COOKIE cookie,
  455. ITFSComponentData *pTFSCompData,
  456. IDataObject **ppDataObject)
  457. {
  458. Assert(ppDataObject);
  459. CDataObject * pdo = NULL;
  460. HRESULT hr = hrOK;
  461. SPIUnknown spunk;
  462. SPIDataObject spDataObject;
  463. pdo = new CDataObject;
  464. spDataObject = pdo;
  465. CORg( CreateRtrMgrProtocolInfoAggregation(pInfo, pdo, &spunk) );
  466. pdo->SetInnerIUnknown(spunk);
  467. // Save cookie and type for delayed rendering
  468. pdo->SetType(type);
  469. pdo->SetCookie(cookie);
  470. // Store the coclass with the data object
  471. pdo->SetClsid(*(pTFSCompData->GetCoClassID()));
  472. pdo->SetTFSComponentData(pTFSCompData);
  473. *ppDataObject = spDataObject.Transfer();
  474. Error:
  475. return hr;
  476. }
  477. /*!--------------------------------------------------------------------------
  478. CreateDataObjectFromInterfaceInfo
  479. -
  480. Author: KennT
  481. ---------------------------------------------------------------------------*/
  482. HRESULT CreateDataObjectFromInterfaceInfo(IInterfaceInfo *pInfo,
  483. DATA_OBJECT_TYPES type,
  484. MMC_COOKIE cookie,
  485. ITFSComponentData *pTFSCompData,
  486. IDataObject **ppDataObject)
  487. {
  488. Assert(ppDataObject);
  489. CDataObject * pdo = NULL;
  490. HRESULT hr = hrOK;
  491. SPIUnknown spunk;
  492. SPIDataObject spDataObject;
  493. pdo = new CDataObject;
  494. spDataObject = pdo;
  495. CORg( CreateInterfaceInfoAggregation(pInfo, pdo, &spunk) );
  496. pdo->SetInnerIUnknown(spunk);
  497. // Save cookie and type for delayed rendering
  498. pdo->SetType(type);
  499. pdo->SetCookie(cookie);
  500. // Store the coclass with the data object
  501. pdo->SetClsid(*(pTFSCompData->GetCoClassID()));
  502. pdo->SetTFSComponentData(pTFSCompData);
  503. *ppDataObject = spDataObject.Transfer();
  504. Error:
  505. return hr;
  506. }
  507. static const SRouterNodeMenu s_rgIfGeneralMenu[] =
  508. {
  509. { IDS_MENU_IPXSUM_NEW_PROTOCOL, 0,
  510. CCM_INSERTIONPOINTID_PRIMARY_TOP },
  511. { IDS_MENU_SEPARATOR, 0,
  512. CCM_INSERTIONPOINTID_PRIMARY_TOP },
  513. { IDS_MENU_IPXSUM_TASK_IPX_INFO, 0,
  514. CCM_INSERTIONPOINTID_PRIMARY_TOP },
  515. { IDS_MENU_IPXSUM_TASK_ROUTING_TABLE, 0,
  516. CCM_INSERTIONPOINTID_PRIMARY_TOP },
  517. { IDS_MENU_IPXSUM_TASK_SERVICE_TABLE, 0,
  518. CCM_INSERTIONPOINTID_PRIMARY_TOP },
  519. { IDS_MENU_SEPARATOR, 0,
  520. CCM_INSERTIONPOINTID_PRIMARY_TOP }
  521. };
  522. /*!--------------------------------------------------------------------------
  523. IPXRootHandler::OnAddMenuItems
  524. Implementation of ITFSNodeHandler::OnAddMenuItems
  525. Author: DeonB
  526. ---------------------------------------------------------------------------*/
  527. STDMETHODIMP IPXAdminNodeHandler::OnAddMenuItems(
  528. ITFSNode *pNode,
  529. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  530. LPDATAOBJECT lpDataObject,
  531. DATA_OBJECT_TYPES type,
  532. DWORD dwType,
  533. long *pInsertionAllowed)
  534. {
  535. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  536. HRESULT hr = S_OK;
  537. IPXAdminNodeHandler::SMenuData menuData;
  538. COM_PROTECT_TRY
  539. {
  540. menuData.m_spNode.Set(pNode);
  541. hr = AddArrayOfMenuItems(pNode, s_rgIfGeneralMenu,
  542. DimensionOf(s_rgIfGeneralMenu),
  543. pContextMenuCallback,
  544. *pInsertionAllowed,
  545. reinterpret_cast<INT_PTR>(&menuData));
  546. }
  547. COM_PROTECT_CATCH;
  548. return hr;
  549. }
  550. /*!--------------------------------------------------------------------------
  551. IPXSummaryHandler::OnNewProtocol
  552. This function will install new protocols. It will look for
  553. conflicts with existing protocols (and ask the user if they
  554. would like to remove the existing protocol).
  555. We will have to figure out how to get the protocol UI installed
  556. (this implies that we have to know if the protocol UI is
  557. installed or not).
  558. Author: KennT
  559. ---------------------------------------------------------------------------*/
  560. HRESULT IPXAdminNodeHandler::OnNewProtocol()
  561. {
  562. HRESULT hr = hrOK;
  563. SPIRtrMgrProtocolInfo spRmProt;
  564. // Display the protocol prompt
  565. if (AddProtocolPrompt(m_spRouterInfo, m_spRtrMgrInfo, &spRmProt, NULL)
  566. != IDOK)
  567. {
  568. // The most likely case for this is that the user cancelled
  569. // out of the dialog, just return hrOK
  570. return hrOK;
  571. }
  572. // At this point, we now have a protocol that can be added (we
  573. // will also have removed any conflicting protocols, although
  574. // another user may have added a protocol already).
  575. // Add the new protocol
  576. CORg( AddRoutingProtocol(m_spRtrMgrInfo, spRmProt, ::FindMMCMainWindow()) );
  577. // Ok, at this point we have successfully added the protocol
  578. // to the router. Now we need to make sure that we can add
  579. // the correct admin UI.
  580. // Have MMC dynamically add the protocol (if necessary)
  581. ForceGlobalRefresh(m_spRouterInfo);
  582. Error:
  583. return hr;
  584. }
  585. /*!--------------------------------------------------------------------------
  586. IPXAdminNodeHandler::HasPropertyPages
  587. Implementation of ITFSNodeHandler::HasPropertyPages
  588. NOTE: the root node handler has to over-ride this function to
  589. handle the snapin manager property page (wizard) case!!!
  590. Author: DeonB
  591. ---------------------------------------------------------------------------*/
  592. STDMETHODIMP
  593. IPXAdminNodeHandler::HasPropertyPages
  594. (
  595. ITFSNode * pNode,
  596. LPDATAOBJECT pDataObject,
  597. DATA_OBJECT_TYPES type,
  598. DWORD dwType
  599. )
  600. {
  601. return hrOK;
  602. }
  603. /*!--------------------------------------------------------------------------
  604. IPXAdminNodeHandler::CreatePropertyPages
  605. -
  606. Author: DeonB
  607. ---------------------------------------------------------------------------*/
  608. STDMETHODIMP
  609. IPXAdminNodeHandler::CreatePropertyPages
  610. (
  611. ITFSNode * pNode,
  612. LPPROPERTYSHEETCALLBACK lpProvider,
  613. LPDATAOBJECT pDataObject,
  614. LONG_PTR handle,
  615. DWORD dwType
  616. )
  617. {
  618. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  619. HRESULT hr = hrOK;
  620. IPXSummaryProperties * pProperties = NULL;
  621. SPIComponentData spComponentData;
  622. CString stTitle;
  623. CORg( m_spNodeMgr->GetComponentData(&spComponentData) );
  624. stTitle.Format(IDS_IPXSUMMARY_PAGE_TITLE);
  625. pProperties = new IPXSummaryProperties(pNode, spComponentData,
  626. m_spTFSCompData, stTitle);
  627. CORg( pProperties->Init(m_spRtrMgrInfo) );
  628. if (lpProvider)
  629. hr = pProperties->CreateModelessSheet(lpProvider, handle);
  630. else
  631. hr = pProperties->DoModelessSheet();
  632. Error:
  633. return hr;
  634. }