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.

1487 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 "atlkprop.h"
  11. #include "atlkview.h"
  12. #include "atlkstrm.h" //
  13. #include "atlkenv.h"
  14. #include "coldlg.h" // columndlg
  15. #include "column.h" // ComponentConfigStream
  16. #include "rtrui.h"
  17. #include "globals.h" // IP CB defaults
  18. #include "infoi.h" // InterfaceInfo
  19. #include "cfgmgr32.h" // for CM_ calls
  20. static const GUID GUID_DevClass_Net = {0x4D36E972,0xE325,0x11CE,{0xBF,0xC1,0x08,0x00,0x2B,0xE1,0x03,0x18}};
  21. /*---------------------------------------------------------------------------
  22. Keep this in sync with the column ids in ATLKview.h
  23. ---------------------------------------------------------------------------*/
  24. extern const ContainerColumnInfo s_rgATLKViewColumnInfo[];
  25. const ContainerColumnInfo s_rgATLKViewColumnInfo[] =
  26. {
  27. { IDS_ATLK_COL_ADAPTERS, CON_SORT_BY_STRING, TRUE, COL_IF_NAME },
  28. { IDS_ATLK_COL_STATUS, CON_SORT_BY_STRING, TRUE, COL_STATUS },
  29. { IDS_ATLK_COL_NETRANGE, CON_SORT_BY_STRING, TRUE, COL_SMALL_NUM},
  30. };
  31. /*---------------------------------------------------------------------------
  32. ATLKNodeHandler implementation
  33. ---------------------------------------------------------------------------*/
  34. ATLKNodeHandler::ATLKNodeHandler(ITFSComponentData *pCompData)
  35. : BaseContainerHandler(pCompData, ATLK_COLUMNS, s_rgATLKViewColumnInfo),
  36. m_ulConnId(0),
  37. m_ulRefreshConnId(0),
  38. m_ulStatsConnId(0),
  39. m_hDevInfo(INVALID_HANDLE_VALUE)
  40. {
  41. // Setup the verb states
  42. m_rgButtonState[MMC_VERB_REFRESH_INDEX] = ENABLED;
  43. m_bState[MMC_VERB_REFRESH_INDEX] = TRUE;
  44. m_nTaskPadDisplayNameId = IDS_ATLK_DISPLAY_NAME;
  45. }
  46. ATLKNodeHandler::~ATLKNodeHandler()
  47. {
  48. if (m_hDevInfo != INVALID_HANDLE_VALUE)
  49. {
  50. SetupDiDestroyDeviceInfoList(m_hDevInfo);
  51. m_hDevInfo = INVALID_HANDLE_VALUE;
  52. }
  53. }
  54. STDMETHODIMP ATLKNodeHandler::QueryInterface(REFIID riid, LPVOID *ppv)
  55. {
  56. // Is the pointer bad?
  57. if ( ppv == NULL )
  58. return E_INVALIDARG;
  59. // Place NULL in *ppv in case of failure
  60. *ppv = NULL;
  61. // This is the non-delegating IUnknown implementation
  62. if ( riid == IID_IUnknown )
  63. *ppv = (LPVOID) this;
  64. else if ( riid == IID_IRtrAdviseSink )
  65. *ppv = &m_IRtrAdviseSink;
  66. else
  67. return BaseContainerHandler::QueryInterface(riid, ppv);
  68. // If we're going to return an interface, AddRef it first
  69. if ( *ppv )
  70. {
  71. ((LPUNKNOWN) *ppv)->AddRef();
  72. return hrOK;
  73. }
  74. else
  75. return E_NOINTERFACE;
  76. }
  77. /*!--------------------------------------------------------------------------
  78. ATLKNodeHandler::DestroyHandler
  79. Implementation of ITFSNodeHandler::DestroyHandler
  80. Author: KennT
  81. ---------------------------------------------------------------------------*/
  82. STDMETHODIMP ATLKNodeHandler::DestroyHandler(ITFSNode *pNode)
  83. {
  84. if ( m_ulRefreshConnId )
  85. {
  86. SPIRouterRefresh spRefresh;
  87. if ( m_spRouterInfo )
  88. m_spRouterInfo->GetRefreshObject(&spRefresh);
  89. if ( spRefresh )
  90. spRefresh->UnadviseRefresh(m_ulRefreshConnId);
  91. }
  92. m_ulRefreshConnId = 0;
  93. if ( m_ulStatsConnId )
  94. {
  95. SPIRouterRefresh spRefresh;
  96. if ( m_spRouterInfo )
  97. m_spRouterInfo->GetRefreshObject(&spRefresh);
  98. if ( spRefresh )
  99. spRefresh->UnadviseRefresh(m_ulStatsConnId);
  100. }
  101. m_ulStatsConnId = 0;
  102. if ( m_ulConnId )
  103. m_spRmProt->RtrUnadvise(m_ulConnId);
  104. m_ulConnId = 0;
  105. m_spRmProt.Release();
  106. m_spRm.Release();
  107. m_spRouterInfo.Release();
  108. if (m_hDevInfo != INVALID_HANDLE_VALUE)
  109. {
  110. SetupDiDestroyDeviceInfoList(m_hDevInfo);
  111. m_hDevInfo = INVALID_HANDLE_VALUE;
  112. }
  113. return hrOK;
  114. }
  115. /*!--------------------------------------------------------------------------
  116. ATLKNodeHandler::HasPropertyPages
  117. Implementation of ITFSNodeHandler::HasPropertyPages
  118. NOTE: the root node handler has to over-ride this function to
  119. handle the snapin manager property page (wizard) case!!!
  120. Author: KennT
  121. ---------------------------------------------------------------------------*/
  122. STDMETHODIMP
  123. ATLKNodeHandler::HasPropertyPages
  124. (
  125. ITFSNode * pNode,
  126. LPDATAOBJECT pDataObject,
  127. DATA_OBJECT_TYPES type,
  128. DWORD dwType
  129. )
  130. {
  131. return hrOK;
  132. }
  133. /*!--------------------------------------------------------------------------
  134. ATLKNodeHandler::CreatePropertyPages
  135. -
  136. Author: KennT
  137. ---------------------------------------------------------------------------*/
  138. STDMETHODIMP
  139. ATLKNodeHandler::CreatePropertyPages
  140. (
  141. ITFSNode * pNode,
  142. LPPROPERTYSHEETCALLBACK lpProvider,
  143. LPDATAOBJECT pDataObject,
  144. LONG_PTR handle,
  145. DWORD dwType
  146. )
  147. {
  148. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  149. HRESULT hr = hrOK;
  150. return hr;
  151. }
  152. /*---------------------------------------------------------------------------
  153. Menu data structure for our menus
  154. ---------------------------------------------------------------------------*/
  155. static const SRouterNodeMenu s_rgIfNodeMenu[] =
  156. {
  157. // Add items that go on the top menu here
  158. { IDS_MENU_ATLK_ENABLE, ATLKNodeHandler::ATLKEnableFlags,
  159. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  160. {IDS_MENU_ATLK_DISABLE, ATLKNodeHandler::ATLKEnableFlags,
  161. CCM_INSERTIONPOINTID_PRIMARY_TOP},
  162. };
  163. bool IfATLKRoutingEnabled()
  164. {
  165. RegKey regkey;
  166. DWORD dw=0;
  167. if ( ERROR_SUCCESS == regkey.Open(HKEY_LOCAL_MACHINE,c_szAppleTalkService) )
  168. regkey.QueryValue(c_szEnableRouter, dw);
  169. return (dw!=0) ? true : false;
  170. };
  171. ULONG ATLKNodeHandler::ATLKEnableFlags(const SRouterNodeMenu *pMenuData,
  172. INT_PTR pUserData)
  173. {
  174. ULONG uStatus = MF_GRAYED;
  175. BOOL fATLKEnabled = ::IfATLKRoutingEnabled();
  176. if(IDS_MENU_ATLK_ENABLE == pMenuData->m_sidMenu)
  177. uStatus = fATLKEnabled ? MF_GRAYED : MF_ENABLED;
  178. else if(IDS_MENU_ATLK_DISABLE == pMenuData->m_sidMenu)
  179. uStatus = fATLKEnabled ? MF_ENABLED : MF_GRAYED;
  180. return uStatus;
  181. }
  182. /*!--------------------------------------------------------------------------
  183. ATLKNodeHandler::OnAddMenuItems
  184. Implementation of ITFSNodeHandler::OnAddMenuItems
  185. Author: KennT
  186. ---------------------------------------------------------------------------*/
  187. STDMETHODIMP ATLKNodeHandler::OnAddMenuItems(
  188. ITFSNode *pNode,
  189. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  190. LPDATAOBJECT lpDataObject,
  191. DATA_OBJECT_TYPES type,
  192. DWORD dwType,
  193. long *pInsertionAllowed)
  194. {
  195. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  196. HRESULT hr = S_OK;
  197. ATLKNodeHandler::SMenuData menuData;
  198. COM_PROTECT_TRY
  199. {
  200. menuData.m_spNode.Set(pNode);
  201. hr = AddArrayOfMenuItems(pNode, s_rgIfNodeMenu,
  202. DimensionOf(s_rgIfNodeMenu),
  203. pContextMenuCallback,
  204. *pInsertionAllowed,
  205. reinterpret_cast<INT_PTR>(&menuData));
  206. }
  207. COM_PROTECT_CATCH;
  208. return hr;
  209. }
  210. /*!--------------------------------------------------------------------------
  211. ATLKNodeHandler::OnCommand
  212. Implementation of ITFSNodeHandler::OnCommand
  213. Author: KennT
  214. ---------------------------------------------------------------------------*/
  215. STDMETHODIMP ATLKNodeHandler::OnCommand(ITFSNode *pNode, long nCommandId,
  216. DATA_OBJECT_TYPES type,
  217. LPDATAOBJECT pDataObject,
  218. DWORD dwType)
  219. {
  220. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  221. HRESULT hr = S_OK;
  222. RegKey regkey;
  223. COM_PROTECT_TRY
  224. {
  225. switch ( nCommandId )
  226. {
  227. case IDS_MENU_ATLK_ENABLE:
  228. case IDS_MENU_ATLK_DISABLE:
  229. if ( ERROR_SUCCESS == regkey.Open(HKEY_LOCAL_MACHINE,c_szAppleTalkService) )
  230. {
  231. CStop_StartAppleTalkPrint MacPrint;
  232. DWORD dw = (IDS_MENU_ATLK_ENABLE == nCommandId) ? 1 : 0;
  233. regkey.SetValue(c_szEnableRouter, dw);
  234. if (FHrFailed(CATLKEnv::HrAtlkPnPSwithRouting()))
  235. {
  236. AfxMessageBox(IDS_ERR_ATLK_CONFIG);
  237. }
  238. SynchronizeNodeData(pNode);
  239. }
  240. break;
  241. case IDS_MENU_REFRESH:
  242. hr = ForceGlobalRefresh(m_spRouterInfo);
  243. break;
  244. }
  245. }
  246. COM_PROTECT_CATCH;
  247. return hr;
  248. }
  249. HRESULT ATLKNodeHandler::OnVerbRefresh(ITFSNode *pNode,LPARAM arg,LPARAM lParam)
  250. {
  251. // Now that we have all of the nodes, update the data for
  252. // all of the nodes
  253. return ForceGlobalRefresh(m_spRouterInfo);
  254. }
  255. HRESULT ATLKNodeHandler::OnResultRefresh(ITFSComponent * pComponent,
  256. LPDATAOBJECT pDataObject,
  257. MMC_COOKIE cookie,
  258. LPARAM arg,
  259. LPARAM lParam)
  260. {
  261. return ForceGlobalRefresh(m_spRouterInfo);
  262. }
  263. /*!--------------------------------------------------------------------------
  264. ATLKNodeHandler::OnExpand
  265. -
  266. Author: KennT
  267. ---------------------------------------------------------------------------*/
  268. HRESULT ATLKNodeHandler::OnExpand(ITFSNode *pNode,
  269. LPDATAOBJECT pDataObject,
  270. DWORD dwType,
  271. LPARAM arg,
  272. LPARAM lParam)
  273. {
  274. HRESULT hr = hrOK;
  275. SPIInterfaceInfo spIf;
  276. ATLKList adapterList;
  277. ATLKListEntry * pAtlkEntry = NULL;
  278. if ( m_bExpanded )
  279. return hrOK;
  280. COM_PROTECT_TRY
  281. {
  282. SynchronizeNodeData(pNode);
  283. }
  284. COM_PROTECT_CATCH;
  285. // cleanup
  286. // ----------------------------------------------------------------
  287. while (!adapterList.IsEmpty())
  288. delete adapterList.RemoveHead();
  289. m_bExpanded = TRUE;
  290. return hr;
  291. }
  292. /*!--------------------------------------------------------------------------
  293. ATLKNodeHandler::GetString
  294. Implementation of ITFSNodeHandler::GetString
  295. We don't need to do anything, since our root node is an extension
  296. only and thus can't do anything to the node text.
  297. Author: KennT
  298. ---------------------------------------------------------------------------*/
  299. STDMETHODIMP_(LPCTSTR) ATLKNodeHandler::GetString(ITFSNode *pNode, int nCol)
  300. {
  301. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  302. HRESULT hr = hrOK;
  303. COM_PROTECT_TRY
  304. {
  305. if ( m_stTitle.IsEmpty() )
  306. m_stTitle.LoadString(IDS_ATLK_TITLE);
  307. }
  308. COM_PROTECT_CATCH;
  309. return m_stTitle;
  310. }
  311. /*!--------------------------------------------------------------------------
  312. ATLKNodeHandler::OnCreateDataObject
  313. -
  314. Author: KennT
  315. ---------------------------------------------------------------------------*/
  316. STDMETHODIMP ATLKNodeHandler::OnCreateDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  317. {
  318. HRESULT hr = hrOK;
  319. COM_PROTECT_TRY
  320. {
  321. SPIDataObject spdo;
  322. CDataObject* pdo = NULL;
  323. pdo= new CDataObject;
  324. spdo = pdo;
  325. // Save cookie and type for delayed rendering
  326. pdo->SetType(type);
  327. pdo->SetCookie(cookie);
  328. // Store the coclass with the data object
  329. pdo->SetClsid(*(m_spTFSCompData->GetCoClassID()));
  330. pdo->SetTFSComponentData(m_spTFSCompData);
  331. *ppDataObject = spdo.Transfer();
  332. }
  333. COM_PROTECT_CATCH;
  334. return hr;
  335. }
  336. /*!--------------------------------------------------------------------------
  337. ATLKNodeHandler::Init
  338. -
  339. Author: KennT
  340. ---------------------------------------------------------------------------*/
  341. HRESULT ATLKNodeHandler::Init(IRouterInfo *pRouter, ATLKConfigStream *pConfigStream)
  342. {
  343. HRESULT hr=S_OK;
  344. RegKey regkey;
  345. m_spRouterInfo.Set(pRouter);
  346. m_pConfigStream = pConfigStream;
  347. return hrOK;
  348. }
  349. /*!--------------------------------------------------------------------------
  350. ATLKNodeHandler::ConstructNode
  351. Initializes the root node (sets it up).
  352. Author: KennT
  353. ---------------------------------------------------------------------------*/
  354. HRESULT ATLKNodeHandler::ConstructNode(ITFSNode *pNode)
  355. {
  356. HRESULT hr = hrOK;
  357. if ( pNode == NULL )
  358. return hrOK;
  359. COM_PROTECT_TRY
  360. {
  361. // Need to initialize the data for the root node
  362. pNode->SetData(TFS_DATA_IMAGEINDEX, IMAGE_IDX_INTERFACES);
  363. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, IMAGE_IDX_INTERFACES);
  364. pNode->SetData(TFS_DATA_SCOPEID, 0);
  365. // This is a leaf node in the scope pane
  366. pNode->SetData(TFS_DATA_SCOPE_LEAF_NODE, TRUE);
  367. m_cookie = reinterpret_cast<MMC_COOKIE>(pNode);
  368. pNode->SetData(TFS_DATA_COOKIE, m_cookie);
  369. pNode->SetNodeType(&GUID_ATLKNodeType);
  370. }
  371. COM_PROTECT_CATCH;
  372. return hr;
  373. }
  374. /*!--------------------------------------------------------------------------
  375. ATLKNodeHandler::AddInterfaceNode
  376. -
  377. Author: KennT
  378. ---------------------------------------------------------------------------*/
  379. HRESULT ATLKNodeHandler::AddInterfaceNode(ITFSNode *pParent, IInterfaceInfo *pIf, IInfoBase *pInfoBase, ITFSNode **ppNewNode)
  380. {
  381. HRESULT hr = hrOK;
  382. Assert(pParent);
  383. Assert(pIf);
  384. ATLKInterfaceHandler * pHandler;
  385. SPITFSResultHandler spHandler;
  386. SPITFSNode spNode;
  387. InterfaceNodeData* pData;
  388. // Create the handler for this node
  389. pHandler = new ATLKInterfaceHandler(m_spTFSCompData);
  390. spHandler = pHandler;
  391. CORg( pHandler->Init(pIf, pParent, m_pConfigStream) );
  392. // Create a result item node (or a leaf node)
  393. CORg( CreateLeafTFSNode(&spNode,
  394. NULL,
  395. static_cast<ITFSNodeHandler *>(pHandler),
  396. static_cast<ITFSResultHandler *>(pHandler),
  397. m_spNodeMgr) );
  398. CORg( pHandler->ConstructNode(spNode, pIf) );
  399. pData = GET_INTERFACENODEDATA(spNode);
  400. Assert(pData);
  401. pData->m_rgData[ATLK_SI_ADAPTER].m_stData = pIf->GetTitle();
  402. // If we don't have a pic, it means that we have just added
  403. // the protocol to the interface (and am not picking up a refresh).
  404. // The properties dialog will make the node visible.
  405. // Make the node immediately visible
  406. CORg( spNode->SetVisibilityState(TFS_VIS_SHOW) );
  407. CORg( spNode->Show() );
  408. CORg( pParent->AddChild(spNode) );
  409. if (ppNewNode)
  410. *ppNewNode = spNode.Transfer();
  411. Error:
  412. return hr;
  413. }
  414. /*!--------------------------------------------------------------------------
  415. ATLKNodeHandler::AddMenuItems
  416. Implementation of ITFSResultHandler::AddMenuItems
  417. Use this to add commands to the context menu of the blank areas
  418. of the result pane.
  419. Author: KennT
  420. ---------------------------------------------------------------------------*/
  421. STDMETHODIMP ATLKNodeHandler::AddMenuItems(ITFSComponent *pComponent,
  422. MMC_COOKIE cookie,
  423. LPDATAOBJECT pDataObject,
  424. LPCONTEXTMENUCALLBACK pCallback,
  425. long *pInsertionAllowed)
  426. {
  427. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  428. HRESULT hr = S_OK;
  429. ATLKNodeHandler::SMenuData menuData;
  430. SPITFSNode spNode;
  431. COM_PROTECT_TRY
  432. {
  433. m_spNodeMgr->FindNode(cookie, &spNode);
  434. menuData.m_spNode.Set(spNode);
  435. hr = AddArrayOfMenuItems(spNode, s_rgIfNodeMenu,
  436. DimensionOf(s_rgIfNodeMenu),
  437. pCallback,
  438. *pInsertionAllowed,
  439. reinterpret_cast<INT_PTR>(&menuData));
  440. }
  441. COM_PROTECT_CATCH;
  442. return hr;
  443. }
  444. /*!--------------------------------------------------------------------------
  445. ATLKNodeHandler::Command
  446. -
  447. Author: KennT
  448. ---------------------------------------------------------------------------*/
  449. STDMETHODIMP ATLKNodeHandler::Command(ITFSComponent *pComponent,
  450. MMC_COOKIE cookie,
  451. int nCommandID,
  452. LPDATAOBJECT pDataObject)
  453. {
  454. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  455. HRESULT hr = hrOK;
  456. SPITFSNode spNode;
  457. Assert( m_spNodeMgr );
  458. CORg( m_spNodeMgr->FindNode(cookie, &spNode) );
  459. hr = OnCommand(spNode, nCommandID, CCT_RESULT,
  460. pDataObject, 0);
  461. Error:
  462. return hr;
  463. }
  464. ImplementEmbeddedUnknown(ATLKNodeHandler, IRtrAdviseSink)
  465. STDMETHODIMP ATLKNodeHandler::EIRtrAdviseSink::OnChange(LONG_PTR ulConn,
  466. DWORD dwChangeType, DWORD dwObjectType, LPARAM lUserParam, LPARAM lParam)
  467. {
  468. InitPThis(ATLKNodeHandler, IRtrAdviseSink);
  469. SPITFSNode spThisNode;
  470. SPITFSNode spNode;
  471. SPITFSNodeEnum spEnumNode;
  472. SPIEnumInterfaceInfo spEnumIf;
  473. SPIInterfaceInfo spIf;
  474. SPIRtrMgrInterfaceInfo spRmIf;
  475. SPIInfoBase spInfoBase;
  476. BOOL fPleaseAdd;
  477. BOOL fFound;
  478. InterfaceNodeData * pData;
  479. HRESULT hr = hrOK;
  480. pThis->m_spNodeMgr->FindNode(pThis->m_cookie, &spThisNode);
  481. if ( dwObjectType == ROUTER_OBJ_RmProtIf )
  482. {
  483. }
  484. else if ( dwChangeType == ROUTER_REFRESH )
  485. {
  486. if (ulConn == pThis->m_ulRefreshConnId)
  487. pThis->SynchronizeNodeData(spThisNode);
  488. }
  489. return hr;
  490. }
  491. /*!--------------------------------------------------------------------------
  492. ATLKNodeHandler::SynchronizeNodeData
  493. -
  494. Author: KennT
  495. ---------------------------------------------------------------------------*/
  496. HRESULT ATLKNodeHandler::SynchronizeNodeData(ITFSNode *pThisNode)
  497. {
  498. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  499. HRESULT hr = hrOK;
  500. SPITFSNodeEnum spNodeEnum;
  501. SPITFSNode spNode;
  502. CStringList ifidList;
  503. InterfaceNodeData * pNodeData;
  504. int i;
  505. POSITION pos;
  506. CString szBuf;
  507. BOOL bBoundToAtlk;
  508. // prepare AppleTalk Env information
  509. CATLKEnv atlkEnv;
  510. // find the AppleTalk interface object
  511. RegKey regkey;
  512. DWORD dwEnableAtlkRouting =0;
  513. COM_PROTECT_TRY
  514. {
  515. if ( ERROR_SUCCESS == regkey.Open(HKEY_LOCAL_MACHINE,
  516. c_szAppleTalkService) )
  517. regkey.QueryValue(c_szEnableRouter, dwEnableAtlkRouting);
  518. // winsock on adapter only
  519. atlkEnv.SetFlags(CATLKEnv::ATLK_ONLY_ONADAPTER);
  520. // load up container of adapters names
  521. atlkEnv.FetchRegInit();
  522. // Mark all of the nodes
  523. pThisNode->GetEnum(&spNodeEnum);
  524. UnmarkAllNodes(pThisNode, spNodeEnum);
  525. // Iterate through the nodes, looking for the
  526. // data associated with the node
  527. spNodeEnum->Reset();
  528. for ( ; spNodeEnum->Next(1, &spNode, NULL) == hrOK; spNode.Release() )
  529. {
  530. CAdapterInfo * pAdapterInfo = NULL;
  531. CString stIfName;
  532. pNodeData = GET_INTERFACENODEDATA(spNode);
  533. Assert(pNodeData);
  534. stIfName = pNodeData->spIf->GetId();
  535. bBoundToAtlk = FALSE;
  536. // Check to see that the adapter is bound to Appletalk.
  537. // ----------------------------------------------------
  538. if (!FHrOK(CATLKEnv::IsAdapterBoundToAtlk((LPWSTR) (LPCWSTR) stIfName, &bBoundToAtlk)))
  539. continue;
  540. // If it's not bound to Appletalk, we're not interested
  541. // in the adapter.
  542. // ----------------------------------------------------
  543. if (!bBoundToAtlk)
  544. continue;
  545. // Need to check to see if this is a valid
  546. // netcard. We may have a GUID, but it may not
  547. // be working.
  548. // ----------------------------------------------------
  549. if (!FIsFunctioningNetcard(stIfName))
  550. continue;
  551. // Search for this ID in the atlkEnv
  552. pAdapterInfo = atlkEnv.FindAdapter(stIfName);
  553. // Initialize the strings for this node.
  554. // pNodeData->m_rgData[ATLK_SI_ADAPTER].m_stData = stIfName;
  555. pNodeData->m_rgData[ATLK_SI_STATUS].m_stData = _T("-");
  556. pNodeData->m_rgData[ATLK_SI_STATUS].m_dwData = 0;
  557. pNodeData->m_rgData[ATLK_SI_NETRANGE].m_stData = _T("-");
  558. pNodeData->m_rgData[ATLK_SI_NETRANGE].m_dwData = 0;
  559. // If we can't find the adapter, skip it, it will get
  560. // removed.
  561. if (pAdapterInfo == NULL)
  562. {
  563. TRACE1("The adapter GUID %s was not found in appletalk\\parameters\\adapters key", stIfName);
  564. continue;
  565. }
  566. // Ok, this node exists, mark the node
  567. pNodeData->dwMark = TRUE;
  568. pAdapterInfo->m_fAlreadyShown = true;
  569. // Reload some of the adapter-specific information
  570. {
  571. CWaitCursor wait;
  572. hr = atlkEnv.ReloadAdapter(pAdapterInfo, false);
  573. }
  574. if(hr != S_OK)
  575. {
  576. DisplayTFSErrorMessage(NULL);
  577. // we are not removing it, since a later refresh
  578. // may have the information avaible
  579. // remove the adaptor from the list
  580. // pThisNode->RemoveChild(spNode);
  581. continue;
  582. }
  583. SetAdapterData(spNode, pAdapterInfo, dwEnableAtlkRouting);
  584. // Redraw the node
  585. spNode->ChangeNode(RESULT_PANE_CHANGE_ITEM_DATA);
  586. }
  587. spNode.Release();
  588. // Now remove all unmarked nodes
  589. RemoveAllUnmarkedNodes(pThisNode, spNodeEnum);
  590. // Now go through the list of adapters and find the ones
  591. // that need to be added into the list.
  592. // ------------------------------------------------------------
  593. CATLKEnv::AI p;
  594. CAdapterInfo* pAI=NULL;
  595. for ( p= atlkEnv.m_adapterinfolist.begin();
  596. p!= atlkEnv.m_adapterinfolist.end() ;
  597. p++ )
  598. {
  599. pAI = *p;
  600. if (!pAI->m_fAlreadyShown)
  601. {
  602. SPIInterfaceInfo spIf;
  603. CString stKey(pAI->m_regInfo.m_szAdapter);
  604. SPITFSNode spNewNode;
  605. SPSZ spszTitle;
  606. bBoundToAtlk = FALSE;
  607. // Check to see that the adapter is bound to Appletalk.
  608. // ----------------------------------------------------
  609. if (!FHrOK(CATLKEnv::IsAdapterBoundToAtlk((LPWSTR) (LPCWSTR) stKey, &bBoundToAtlk)))
  610. continue;
  611. // If it's not bound to Appletalk, we're not interested
  612. // in the adapter.
  613. // ----------------------------------------------------
  614. if (!bBoundToAtlk)
  615. continue;
  616. // Need to check to see if this is a valid
  617. // netcard. We may have a GUID, but it may not
  618. // be working.
  619. // ----------------------------------------------------
  620. if (!FIsFunctioningNetcard(stKey))
  621. continue;
  622. if (!FHrOK(m_spRouterInfo->FindInterface(stKey, &spIf)))
  623. {
  624. // We didn't find the IInterfaceInfo, we will
  625. // have to create one ourselves.
  626. // ------------------------------------------------
  627. CreateInterfaceInfo(&spIf,
  628. stKey,
  629. ROUTER_IF_TYPE_DEDICATED);
  630. if (FHrOK(InterfaceInfo::FindInterfaceTitle(NULL,
  631. stKey,
  632. &spszTitle)))
  633. spIf->SetTitle(spszTitle);
  634. else
  635. spIf->SetTitle(spIf->GetId());
  636. }
  637. AddInterfaceNode(pThisNode, spIf, NULL, &spNewNode);
  638. {
  639. CWaitCursor wait;
  640. hr = atlkEnv.ReloadAdapter(pAI, false);
  641. }
  642. SetAdapterData(spNewNode, pAI, dwEnableAtlkRouting);
  643. // Redraw the node
  644. spNewNode->ChangeNode(RESULT_PANE_CHANGE_ITEM_DATA);
  645. }
  646. }
  647. }
  648. COM_PROTECT_CATCH;
  649. return hr;
  650. }
  651. /*!--------------------------------------------------------------------------
  652. ATLKNodeHandler::OnResultShow
  653. -
  654. Author: KennT
  655. ---------------------------------------------------------------------------*/
  656. HRESULT ATLKNodeHandler::OnResultShow(ITFSComponent *pTFSComponent, MMC_COOKIE cookie, LPARAM arg, LPARAM lParam)
  657. {
  658. BOOL bSelect = (BOOL) arg;
  659. HRESULT hr = hrOK;
  660. SPIRouterRefresh spRefresh;
  661. SPITFSNode spNode;
  662. BaseContainerHandler::OnResultShow(pTFSComponent, cookie, arg, lParam);
  663. /* WeiJiang : only do reload data on Expand and Refresh
  664. if ( bSelect )
  665. {
  666. // Call synchronize on this node
  667. m_spNodeMgr->FindNode(cookie, &spNode);
  668. if ( spNode )
  669. SynchronizeNodeData(spNode);
  670. }
  671. */
  672. // Un/Register for refresh advises
  673. if ( m_spRouterInfo )
  674. m_spRouterInfo->GetRefreshObject(&spRefresh);
  675. if ( spRefresh )
  676. {
  677. if ( bSelect )
  678. {
  679. if ( m_ulRefreshConnId == 0 )
  680. spRefresh->AdviseRefresh(&m_IRtrAdviseSink, &m_ulRefreshConnId, 0);
  681. if ( m_ulStatsConnId == 0 )
  682. spRefresh->AdviseRefresh(&m_IRtrAdviseSink, &m_ulStatsConnId, 0);
  683. }
  684. else
  685. {
  686. if ( m_ulRefreshConnId )
  687. spRefresh->UnadviseRefresh(m_ulRefreshConnId);
  688. m_ulRefreshConnId = 0;
  689. }
  690. }
  691. return hr;
  692. }
  693. /*!--------------------------------------------------------------------------
  694. ATLKNodeHandler::CompareItems
  695. -
  696. Author: KennT
  697. ---------------------------------------------------------------------------*/
  698. STDMETHODIMP_(int) ATLKNodeHandler::CompareItems(
  699. ITFSComponent * pComponent,
  700. MMC_COOKIE cookieA,
  701. MMC_COOKIE cookieB,
  702. int nCol)
  703. {
  704. // Get the strings from the nodes and use that as a basis for
  705. // comparison.
  706. SPITFSNode spNode;
  707. SPITFSResultHandler spResult;
  708. m_spNodeMgr->FindNode(cookieA, &spNode);
  709. spNode->GetResultHandler(&spResult);
  710. return spResult->CompareItems(pComponent, cookieA, cookieB, nCol);
  711. }
  712. /*!--------------------------------------------------------------------------
  713. ATLKNodeHandler::FIsFunctioningNetcard
  714. Takes a GUID and checks to see if the netcard is functioning.
  715. By default, we return FALSE if any call in this fails.
  716. This code is modeled off of the netcfg code.
  717. Author: KennT
  718. ---------------------------------------------------------------------------*/
  719. BOOL ATLKNodeHandler::FIsFunctioningNetcard(LPCTSTR pszGuid)
  720. {
  721. CString stMachine;
  722. CONFIGRET cfgRet;
  723. SP_DEVINFO_DATA DevInfo;
  724. RegKey rkNet;
  725. RegKey rkNetcard;
  726. HRESULT hr = hrOK;
  727. BOOL fReturn = FALSE;
  728. CString stPnpInstanceId;
  729. ULONG ulProblem, ulStatus;
  730. DWORD dwErr = ERROR_SUCCESS;
  731. Assert(IsLocalMachine(m_spRouterInfo->GetMachineName()));
  732. if (m_hDevInfo == INVALID_HANDLE_VALUE)
  733. {
  734. stMachine = m_spRouterInfo->GetMachineName();
  735. if (IsLocalMachine(stMachine))
  736. {
  737. m_hDevInfo = SetupDiCreateDeviceInfoList(
  738. (LPGUID) &GUID_DevClass_Net,
  739. NULL);
  740. }
  741. else
  742. {
  743. // Append on the "\\\\" if needed
  744. if (StrniCmp((LPCTSTR) stMachine, _T("\\\\"), 2) != 0)
  745. {
  746. stMachine = _T("\\\\");
  747. stMachine += m_spRouterInfo->GetMachineName();
  748. }
  749. m_hDevInfo = SetupDiCreateDeviceInfoListEx(
  750. (LPGUID) &GUID_DevClass_Net,
  751. NULL,
  752. (LPCTSTR) stMachine,
  753. 0);
  754. }
  755. }
  756. Assert(m_hDevInfo != INVALID_HANDLE_VALUE);
  757. // If m_hDevInfo is still invalid, then return a
  758. // functioning device.
  759. // ----------------------------------------------------------------
  760. if (m_hDevInfo == INVALID_HANDLE_VALUE)
  761. return fReturn;
  762. // Get the PnpInstanceID
  763. // ----------------------------------------------------------------
  764. CWRg( rkNet.Open(HKEY_LOCAL_MACHINE, c_szNetworkCardsNT5Key, KEY_READ,
  765. m_spRouterInfo->GetMachineName()) );
  766. CWRg( rkNetcard.Open(rkNet, pszGuid, KEY_READ) );
  767. dwErr = rkNetcard.QueryValue(c_szPnpInstanceID, stPnpInstanceId);
  768. // Windows NT Bug : 273284
  769. // This is a result of the new Bindings Engine
  770. // some of the registry keys were moved around
  771. // ----------------------------------------------------------------
  772. if (dwErr != ERROR_SUCCESS)
  773. {
  774. RegKey rkConnection;
  775. // Need to open another key to get this info.
  776. CWRg( rkConnection.Open(rkNetcard, c_szRegKeyConnection, KEY_READ) );
  777. CWRg( rkConnection.QueryValue(c_szPnpInstanceID, stPnpInstanceId) );
  778. }
  779. // Now get the info for this device
  780. // ----------------------------------------------------------------
  781. ::ZeroMemory(&DevInfo, sizeof(DevInfo));
  782. DevInfo.cbSize = sizeof(DevInfo);
  783. if (!SetupDiOpenDeviceInfo(m_hDevInfo,
  784. (LPCTSTR) stPnpInstanceId,
  785. NULL,
  786. 0,
  787. &DevInfo))
  788. {
  789. CWRg( GetLastError() );
  790. }
  791. cfgRet = CM_Get_DevNode_Status_Ex(&ulStatus, &ulProblem,
  792. DevInfo.DevInst, 0, NULL);;
  793. if (CR_SUCCESS == cfgRet)
  794. {
  795. // ulProblem is returned by calling CM_Get_DevNode_Status_Ex
  796. //
  797. // "Functioning" means the device is enabled and started
  798. // with no problem codes, or it is disabled and stopped with
  799. // no problem codes.
  800. fReturn = ( (ulProblem == 0) || (ulProblem == CM_PROB_DISABLED));
  801. }
  802. Error:
  803. return fReturn;
  804. }
  805. /*!--------------------------------------------------------------------------
  806. ATLKNodeHandler::UnmarkAllNodes
  807. -
  808. Author: KennT
  809. ---------------------------------------------------------------------------*/
  810. HRESULT ATLKNodeHandler::UnmarkAllNodes(ITFSNode *pNode, ITFSNodeEnum *pEnum)
  811. {
  812. SPITFSNode spChildNode;
  813. InterfaceNodeData * pNodeData;
  814. pEnum->Reset();
  815. for ( ;pEnum->Next(1, &spChildNode, NULL) == hrOK; spChildNode.Release())
  816. {
  817. pNodeData = GET_INTERFACENODEDATA(spChildNode);
  818. Assert(pNodeData);
  819. pNodeData->dwMark = FALSE;
  820. }
  821. return hrOK;
  822. }
  823. /*!--------------------------------------------------------------------------
  824. ATLKNodeHandler::RemoveAllUnmarkedNodes
  825. -
  826. Author: KennT
  827. ---------------------------------------------------------------------------*/
  828. HRESULT ATLKNodeHandler::RemoveAllUnmarkedNodes(ITFSNode *pNode, ITFSNodeEnum *pEnum)
  829. {
  830. HRESULT hr = hrOK;
  831. SPITFSNode spChildNode;
  832. InterfaceNodeData * pNodeData;
  833. pEnum->Reset();
  834. for ( ;pEnum->Next(1, &spChildNode, NULL) == hrOK; spChildNode.Release())
  835. {
  836. pNodeData = GET_INTERFACENODEDATA(spChildNode);
  837. Assert(pNodeData);
  838. if (pNodeData->dwMark == FALSE)
  839. {
  840. pNode->RemoveChild(spChildNode);
  841. spChildNode->Destroy();
  842. }
  843. }
  844. return hr;
  845. }
  846. /*!--------------------------------------------------------------------------
  847. ATLKNodeHandler::SetAdapterData
  848. -
  849. Author: KennT
  850. ---------------------------------------------------------------------------*/
  851. HRESULT ATLKNodeHandler::SetAdapterData(ITFSNode *pNode,
  852. CAdapterInfo *pAdapter,
  853. DWORD dwEnableAtlkRouting)
  854. {
  855. InterfaceNodeData * pNodeData;
  856. pNodeData = GET_INTERFACENODEDATA(pNode);
  857. Assert(pNodeData);
  858. // if the adapter is the default
  859. UINT ids = 0;
  860. INT lRange, uRange;
  861. if(pAdapter->m_regInfo.m_fDefAdapter)
  862. {
  863. if (dwEnableAtlkRouting)
  864. {
  865. if (pAdapter->m_regInfo.m_dwSeedingNetwork)
  866. ids = IDS_ATLK_COL_STATUS_SEEDROUTING_DEF;
  867. else
  868. ids = IDS_ATLK_COL_STATUS_ROUTING_DEF;
  869. }
  870. else
  871. ids = IDS_ATLK_COL_STATUS_NONROUTING_DEF;
  872. }
  873. else
  874. {
  875. if (dwEnableAtlkRouting)
  876. {
  877. if (pAdapter->m_regInfo.m_dwSeedingNetwork)
  878. ids = IDS_ATLK_COL_STATUS_SEEDROUTING;
  879. else
  880. ids = IDS_ATLK_COL_STATUS_ROUTING;
  881. }
  882. else
  883. ids = IDS_ATLK_COL_STATUS_NONROUTING;
  884. }
  885. // range column
  886. if (pAdapter->m_regInfo.m_dwSeedingNetwork)
  887. {
  888. lRange = pAdapter->m_regInfo.m_dwRangeLower;
  889. uRange = pAdapter->m_regInfo.m_dwRangeUpper;
  890. }
  891. else
  892. {
  893. lRange = pAdapter->m_dynInfo.m_dwRangeLower;
  894. uRange = pAdapter->m_dynInfo.m_dwRangeUpper;
  895. }
  896. // write data
  897. if(uRange == 0 && lRange == 0 &&
  898. !dwEnableAtlkRouting &&
  899. !pAdapter->m_regInfo.m_dwSeedingNetwork)
  900. ids = IDS_ATLK_COL_STATUS_NETWORKNOTSEEDED;
  901. pNodeData->m_rgData[ATLK_SI_STATUS].m_stData.LoadString(ids);
  902. pNodeData->m_rgData[ATLK_SI_STATUS].m_dwData = 0;
  903. if(uRange == 0 && lRange == 0)
  904. pNodeData->m_rgData[ATLK_SI_NETRANGE].m_stData.Format(_T("-"));
  905. else
  906. pNodeData->m_rgData[ATLK_SI_NETRANGE].m_stData.Format(_T("%-d-%-d"),
  907. lRange, uRange);
  908. pNodeData->m_rgData[ATLK_SI_NETRANGE].m_dwData = 0;
  909. return hrOK;
  910. }
  911. /*---------------------------------------------------------------------------
  912. Class: ATLKInterfaceHandler
  913. ---------------------------------------------------------------------------*/
  914. ATLKInterfaceHandler::ATLKInterfaceHandler(ITFSComponentData *pCompData)
  915. : BaseResultHandler(pCompData, ATLK_COLUMNS)
  916. {
  917. m_rgButtonState[MMC_VERB_PROPERTIES_INDEX] = ENABLED;
  918. m_bState[MMC_VERB_PROPERTIES_INDEX] = TRUE;
  919. m_verbDefault = MMC_VERB_PROPERTIES;
  920. }
  921. static const DWORD s_rgInterfaceImageMap[] =
  922. {
  923. ROUTER_IF_TYPE_HOME_ROUTER, IMAGE_IDX_WAN_CARD,
  924. ROUTER_IF_TYPE_FULL_ROUTER, IMAGE_IDX_WAN_CARD,
  925. ROUTER_IF_TYPE_CLIENT, IMAGE_IDX_WAN_CARD,
  926. ROUTER_IF_TYPE_DEDICATED, IMAGE_IDX_LAN_CARD,
  927. ROUTER_IF_TYPE_INTERNAL, IMAGE_IDX_LAN_CARD,
  928. ROUTER_IF_TYPE_LOOPBACK, IMAGE_IDX_LAN_CARD,
  929. -1, IMAGE_IDX_WAN_CARD, // sentinel value
  930. };
  931. /*!--------------------------------------------------------------------------
  932. ATLKInterfaceHandler::ConstructNode
  933. Initializes the Domain node (sets it up).
  934. Author: KennT
  935. ---------------------------------------------------------------------------*/
  936. HRESULT ATLKInterfaceHandler::ConstructNode(ITFSNode *pNode, IInterfaceInfo *pIfInfo)
  937. {
  938. HRESULT hr = hrOK;
  939. int i;
  940. if ( pNode == NULL )
  941. return hrOK;
  942. COM_PROTECT_TRY
  943. {
  944. // Need to initialize the data for the Domain node
  945. // Find the right image index for this type of node
  946. for ( i=0; i<DimensionOf(s_rgInterfaceImageMap); i+=2 )
  947. {
  948. if ( (pIfInfo->GetInterfaceType() == s_rgInterfaceImageMap[i]) ||
  949. (-1 == s_rgInterfaceImageMap[i]) )
  950. break;
  951. }
  952. if ( pIfInfo->GetInterfaceType() == ROUTER_IF_TYPE_INTERNAL ||
  953. pIfInfo->GetInterfaceType() == ROUTER_IF_TYPE_HOME_ROUTER )
  954. {
  955. m_rgButtonState[MMC_VERB_PROPERTIES_INDEX] = HIDDEN;
  956. m_bState[MMC_VERB_PROPERTIES_INDEX] = FALSE;
  957. m_rgButtonState[MMC_VERB_DELETE_INDEX] = HIDDEN;
  958. m_bState[MMC_VERB_DELETE_INDEX] = FALSE;
  959. }
  960. pNode->SetData(TFS_DATA_IMAGEINDEX, s_rgInterfaceImageMap[i+1]);
  961. pNode->SetData(TFS_DATA_OPENIMAGEINDEX, s_rgInterfaceImageMap[i+1]);
  962. pNode->SetData(TFS_DATA_SCOPEID, 0);
  963. pNode->SetData(TFS_DATA_COOKIE, reinterpret_cast<ULONG_PTR>(pNode));
  964. //$ Review: kennt, what are the different type of interfaces
  965. // do we distinguish based on the same list as above? (i.e. the
  966. // one for image indexes).
  967. pNode->SetNodeType(&GUID_ATLKInterfaceNodeType);
  968. // m_ATLKInterfaceStats.SetConnectionData(pIPConn);
  969. InterfaceNodeData::Init(pNode, pIfInfo);
  970. }
  971. COM_PROTECT_CATCH
  972. return hr;
  973. }
  974. /*!--------------------------------------------------------------------------
  975. ATLKInterfaceHandler::OnCreateDataObject
  976. -
  977. Author: KennT
  978. ---------------------------------------------------------------------------*/
  979. STDMETHODIMP ATLKInterfaceHandler::OnCreateDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  980. {
  981. HRESULT hr = hrOK;
  982. COM_PROTECT_TRY
  983. {
  984. CORg( CreateDataObjectFromInterfaceInfo(m_spInterfaceInfo,
  985. type, cookie, m_spTFSCompData,
  986. ppDataObject) );
  987. COM_PROTECT_ERROR_LABEL;
  988. }
  989. COM_PROTECT_CATCH;
  990. return hr;
  991. }
  992. /*!--------------------------------------------------------------------------
  993. ATLKInterfaceHandler::OnCreateDataObject
  994. Implementation of ITFSResultHandler::OnCreateDataObject
  995. Author: KennT
  996. ---------------------------------------------------------------------------*/
  997. STDMETHODIMP ATLKInterfaceHandler::OnCreateDataObject(ITFSComponent *pComp, MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  998. {
  999. HRESULT hr = hrOK;
  1000. COM_PROTECT_TRY
  1001. {
  1002. CORg( CreateDataObjectFromInterfaceInfo(m_spInterfaceInfo,
  1003. type, cookie, m_spTFSCompData,
  1004. ppDataObject) );
  1005. COM_PROTECT_ERROR_LABEL;
  1006. }
  1007. COM_PROTECT_CATCH;
  1008. return hr;
  1009. }
  1010. /*!--------------------------------------------------------------------------
  1011. ATLKInterfaceHandler::RefreshInterface
  1012. -
  1013. Author: KennT
  1014. ---------------------------------------------------------------------------*/
  1015. void ATLKInterfaceHandler::RefreshInterface(MMC_COOKIE cookie)
  1016. {
  1017. SPITFSNode spNode;
  1018. SPITFSNode spParent;
  1019. SPITFSNodeHandler spHandler;
  1020. m_spNodeMgr->FindNode(cookie, &spNode);
  1021. // Can't do it for a single node at this time, just refresh the
  1022. // whole thing.
  1023. spNode->GetParent(&spParent);
  1024. spParent->GetHandler(&spHandler);
  1025. spHandler->OnCommand(spParent,
  1026. IDS_MENU_REFRESH,
  1027. CCT_RESULT, NULL, 0);
  1028. }
  1029. /*!--------------------------------------------------------------------------
  1030. ATLKInterfaceHandler::Init
  1031. -
  1032. Author: KennT
  1033. ---------------------------------------------------------------------------*/
  1034. HRESULT ATLKInterfaceHandler::Init(IInterfaceInfo *pIfInfo, ITFSNode *pParent, ATLKConfigStream *pConfigStream)
  1035. {
  1036. Assert(pIfInfo);
  1037. m_spInterfaceInfo.Set(pIfInfo);
  1038. // m_ATLKInterfaceStats.SetConfigInfo(pConfigStream, ATLKSTRM_IFSTATS_ATLKNBR);
  1039. BaseResultHandler::Init(pIfInfo, pParent);
  1040. return hrOK;
  1041. }
  1042. /*!--------------------------------------------------------------------------
  1043. ATLKInterfaceHandler::DestroyResultHandler
  1044. -
  1045. Author: KennT
  1046. ---------------------------------------------------------------------------*/
  1047. STDMETHODIMP ATLKInterfaceHandler::DestroyResultHandler(MMC_COOKIE cookie)
  1048. {
  1049. // WaitForStatisticsWindow(&m_ATLKInterfaceStats);
  1050. m_spInterfaceInfo.Release();
  1051. BaseResultHandler::DestroyResultHandler(cookie);
  1052. return hrOK;
  1053. }
  1054. /*---------------------------------------------------------------------------
  1055. This is the list of commands that will show up for the result pane
  1056. nodes.
  1057. ---------------------------------------------------------------------------*/
  1058. struct SIPInterfaceNodeMenu
  1059. {
  1060. ULONG m_sidMenu; // string/command id for this menu item
  1061. ULONG (ATLKInterfaceHandler:: *m_pfnGetMenuFlags)(ATLKInterfaceHandler::SMenuData *);
  1062. ULONG m_ulPosition;
  1063. };
  1064. /*!--------------------------------------------------------------------------
  1065. ATLKInterfaceHandler::AddMenuItems
  1066. Implementation of ITFSResultHandler::AddMenuItems
  1067. Author: KennT
  1068. ---------------------------------------------------------------------------*/
  1069. STDMETHODIMP ATLKInterfaceHandler::AddMenuItems(
  1070. ITFSComponent *pComponent,
  1071. MMC_COOKIE cookie,
  1072. LPDATAOBJECT lpDataObject,
  1073. LPCONTEXTMENUCALLBACK pContextMenuCallback,
  1074. long *pInsertionAllowed)
  1075. {
  1076. return hrOK;
  1077. }
  1078. /*!--------------------------------------------------------------------------
  1079. ATLKInterfaceHandler::Command
  1080. -
  1081. Author: KennT
  1082. ---------------------------------------------------------------------------*/
  1083. STDMETHODIMP ATLKInterfaceHandler::Command(ITFSComponent *pComponent,
  1084. MMC_COOKIE cookie,
  1085. int nCommandID,
  1086. LPDATAOBJECT pDataObject)
  1087. {
  1088. return hrOK;
  1089. }
  1090. /*!--------------------------------------------------------------------------
  1091. ATLKInterfaceHandler::HasPropertyPages
  1092. -
  1093. Author: KennT
  1094. ---------------------------------------------------------------------------*/
  1095. STDMETHODIMP ATLKInterfaceHandler::HasPropertyPages
  1096. (
  1097. ITFSNode * pNode,
  1098. LPDATAOBJECT pDataObject,
  1099. DATA_OBJECT_TYPES type,
  1100. DWORD dwType
  1101. )
  1102. {
  1103. return hrTrue;
  1104. }
  1105. /*!--------------------------------------------------------------------------
  1106. ATLKInterfaceHandler::CreatePropertyPages
  1107. -
  1108. Author: KennT
  1109. ---------------------------------------------------------------------------*/
  1110. STDMETHODIMP ATLKInterfaceHandler::CreatePropertyPages
  1111. (
  1112. ITFSNode * pNode,
  1113. LPPROPERTYSHEETCALLBACK lpProvider,
  1114. LPDATAOBJECT pDataObject,
  1115. LONG_PTR handle,
  1116. DWORD dwType)
  1117. {
  1118. HRESULT hr = hrOK;
  1119. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1120. CATLKPropertySheet * pProperties = NULL;
  1121. SPIComponentData spComponentData;
  1122. CString stTitle;
  1123. SPIRouterInfo spRouter;
  1124. SPIRtrMgrInfo spRm;
  1125. CORg( m_spNodeMgr->GetComponentData(&spComponentData) );
  1126. stTitle.Format(IDS_ATLK_PROPPAGE_TITLE,
  1127. m_spInterfaceInfo->GetTitle());
  1128. pProperties = new CATLKPropertySheet (pNode, spComponentData,
  1129. m_spTFSCompData, stTitle);
  1130. // CORg( m_spInterfaceInfo->GetParentRouterInfo(&spRouter) );
  1131. // CORg( spRouter->FindRtrMgr(PID_IP, &spRm) );
  1132. CORg( pProperties->Init(m_spInterfaceInfo) );
  1133. if ( lpProvider )
  1134. hr = pProperties->CreateModelessSheet(lpProvider, handle);
  1135. else
  1136. hr = pProperties->DoModelessSheet();
  1137. Error:
  1138. // Is this the right way to destroy the sheet?
  1139. if ( !FHrSucceeded(hr) )
  1140. delete pProperties;
  1141. return hr;
  1142. }
  1143. /*!--------------------------------------------------------------------------
  1144. ATLKInterfaceHandler::CreatePropertyPages
  1145. Implementation of ResultHandler::CreatePropertyPages
  1146. Author: KennT
  1147. ---------------------------------------------------------------------------*/
  1148. STDMETHODIMP ATLKInterfaceHandler::CreatePropertyPages
  1149. (
  1150. ITFSComponent * pComponent,
  1151. MMC_COOKIE cookie,
  1152. LPPROPERTYSHEETCALLBACK lpProvider,
  1153. LPDATAOBJECT pDataObject,
  1154. LONG_PTR handle
  1155. )
  1156. {
  1157. // Forward this call onto the NodeHandler::CreatePropertyPages
  1158. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1159. HRESULT hr = hrOK;
  1160. SPITFSNode spNode;
  1161. Assert( m_spNodeMgr );
  1162. CORg( m_spNodeMgr->FindNode(cookie, &spNode) );
  1163. // Call the ITFSNodeHandler::CreatePropertyPages
  1164. hr = CreatePropertyPages(spNode, lpProvider, pDataObject, handle, 0);
  1165. Error:
  1166. return hr;
  1167. }
  1168. /*!--------------------------------------------------------------------------
  1169. ATLKInterfaceHandler::OnResultDelete
  1170. -
  1171. Author: KennT
  1172. ---------------------------------------------------------------------------*/
  1173. HRESULT ATLKInterfaceHandler::OnResultDelete(ITFSComponent *pComponent,
  1174. LPDATAOBJECT pDataObject,
  1175. MMC_COOKIE cookie,
  1176. LPARAM arg,
  1177. LPARAM param)
  1178. {
  1179. SPITFSNode spNode;
  1180. m_spNodeMgr->FindNode(cookie, &spNode);
  1181. return OnRemoveInterface(spNode);
  1182. }
  1183. /*!--------------------------------------------------------------------------
  1184. ATLKInterfaceHandler::OnRemoveInterface
  1185. -
  1186. Author: KennT
  1187. ---------------------------------------------------------------------------*/
  1188. HRESULT ATLKInterfaceHandler::OnRemoveInterface(ITFSNode *pNode)
  1189. {
  1190. return hrOK;
  1191. }