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.

1180 lines
30 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. sumprop.cpp
  7. IPX summary node property sheet and property pages
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "rtrutil.h" // smart MPR handle pointers
  12. #include "format.h" // FormatNumber function
  13. #include "sumprop.h"
  14. #include "summary.h"
  15. #include "ipxrtdef.h"
  16. #include "mprerror.h"
  17. #include "mprfltr.h"
  18. #include "rtrerr.h"
  19. #include "remras.h"
  20. #include "rrasutil.h"
  21. #include "ipxutil.h"
  22. #include "rtrcomn.h"
  23. extern "C"
  24. {
  25. #include "routprot.h"
  26. };
  27. IPXSummaryInterfaceProperties::IPXSummaryInterfaceProperties(ITFSNode *pNode,
  28. IComponentData *pComponentData,
  29. ITFSComponentData *pTFSCompData,
  30. LPCTSTR pszSheetName,
  31. CWnd *pParent,
  32. UINT iPage,
  33. BOOL fScopePane)
  34. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  35. pszSheetName, pParent, iPage, fScopePane),
  36. m_pageConfig(IDD_IPX_IF_CONFIG_PAGE),
  37. m_pageGeneral(IDD_IPX_IF_GENERAL_PAGE),
  38. m_bNewInterface(FALSE),
  39. m_pIPXConn(NULL)
  40. {
  41. m_spNode.Set(pNode);
  42. }
  43. /*!--------------------------------------------------------------------------
  44. IPXSummaryInterfaceProperties::Init
  45. Initialize the property sheets. The general action here will be
  46. to initialize/add the various pages.
  47. Author: KennT
  48. ---------------------------------------------------------------------------*/
  49. HRESULT IPXSummaryInterfaceProperties::Init(IRtrMgrInfo *pRm,
  50. IInterfaceInfo *pIfInfo)
  51. {
  52. HRESULT hr = hrOK;
  53. IPXConnection * pIPXConn;
  54. BaseIPXResultNodeData * pData;
  55. SPIRouterInfo spRouter;
  56. RouterVersionInfo routerVersion;
  57. pData = GET_BASEIPXRESULT_NODEDATA(m_spNode);
  58. ASSERT_BASEIPXRESULT_NODEDATA(pData);
  59. pIPXConn = pData->m_pIPXConnection;
  60. m_spRm.Set(pRm);
  61. m_spIf.Set(pIfInfo);
  62. m_spRm->GetParentRouterInfo(&spRouter);
  63. // The pages are embedded members of the class
  64. // do not delete them.
  65. m_bAutoDeletePages = FALSE;
  66. // Initialize the infobase
  67. // Do this here, because the init is called in the context
  68. // of the main thread
  69. CORg( LoadInfoBase(pIPXConn) );
  70. m_pageGeneral.Init(m_spIf, pIPXConn, this);
  71. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  72. // Windows NT Bug : 208724
  73. // Only show the IPX configuration page for the internal interface
  74. if (m_spIf && (m_spIf->GetInterfaceType() == ROUTER_IF_TYPE_INTERNAL))
  75. {
  76. // Only allow config page for NT5 and up (there is no
  77. // configuration object for NT4).
  78. spRouter->GetRouterVersionInfo(&routerVersion);
  79. if (routerVersion.dwRouterVersion >= 5)
  80. {
  81. HRESULT hrPage;
  82. hrPage = m_pageConfig.Init(m_spIf, pIPXConn, this);
  83. if (FHrOK(hrPage))
  84. AddPageToList((CPropertyPageBase*) &m_pageConfig);
  85. else if (!FHrSucceeded(hrPage))
  86. DisplayTFSErrorMessage(NULL);
  87. }
  88. }
  89. Error:
  90. return hr;
  91. }
  92. IPXSummaryInterfaceProperties::~IPXSummaryInterfaceProperties()
  93. {
  94. if (m_pIPXConn)
  95. {
  96. m_pIPXConn->Release();
  97. m_pIPXConn = NULL;
  98. }
  99. }
  100. /*!--------------------------------------------------------------------------
  101. IPXSummaryInterfaceProperties::LoadInfoBase
  102. -
  103. Author: KennT
  104. ---------------------------------------------------------------------------*/
  105. HRESULT IPXSummaryInterfaceProperties::LoadInfoBase(IPXConnection *pIPXConn)
  106. {
  107. Assert(pIPXConn);
  108. HRESULT hr = hrOK;
  109. HANDLE hTransport = NULL;
  110. LPCOLESTR pszInterfaceId = NULL;
  111. SPIInfoBase spInfoBase;
  112. BYTE * pDefault;
  113. int cBlocks = 0;
  114. m_pIPXConn = pIPXConn;
  115. pIPXConn->AddRef();
  116. // If configuring the client-interface, load the client-interface info,
  117. // otherwise, retrieve the interface being configured and load
  118. // its info.
  119. // The client interface doesn't have an ID
  120. if (m_spIf)
  121. pszInterfaceId = m_spIf->GetId();
  122. if ((pszInterfaceId == NULL) || (StrLenW(pszInterfaceId) == 0))
  123. {
  124. #ifdef DEBUG
  125. // Check to see that this is really an client node
  126. {
  127. BaseIPXResultNodeData * pResultData = NULL;
  128. pResultData = GET_BASEIPXRESULT_NODEDATA(m_spNode);
  129. Assert(pResultData);
  130. ASSERT_BASEIPXRESULT_NODEDATA(pResultData);
  131. Assert(pResultData->m_fClient);
  132. }
  133. #endif
  134. // Get the transport handle
  135. CWRg( ::MprConfigTransportGetHandle(pIPXConn->GetConfigHandle(),
  136. PID_IPX,
  137. &hTransport) );
  138. // Load the client interface info
  139. CORg( m_spRm->GetInfoBase(pIPXConn->GetConfigHandle(),
  140. hTransport,
  141. NULL,
  142. &spInfoBase) );
  143. m_bClientInfoBase = TRUE;
  144. }
  145. else
  146. {
  147. m_spRmIf.Release();
  148. CORg( m_spIf->FindRtrMgrInterface(PID_IPX,
  149. &m_spRmIf) );
  150. //
  151. //$ Opt: This should be made into a sync call rather
  152. // than a Load.
  153. //
  154. // Reload the information for this router-manager interface
  155. // This call could fail for valid reasons (if we are creating
  156. // a new interface, for example).
  157. //
  158. m_spRmIf->Load(m_spIf->GetMachineName(), NULL, NULL, NULL);
  159. //
  160. // The parameters are all NULL so that we can use the
  161. // default RPC handles.
  162. //
  163. m_spRmIf->GetInfoBase(NULL, NULL, NULL, &spInfoBase);
  164. m_bClientInfoBase = FALSE;
  165. }
  166. if (!spInfoBase)
  167. {
  168. // No info was found for the inteface
  169. // allocate a new InfoBase instead
  170. CORg( CreateInfoBase(&spInfoBase) );
  171. }
  172. //
  173. // Check that there is a block for interface-status in the info,
  174. // and insert the default block if none is found.
  175. //
  176. if (spInfoBase->BlockExists(IPX_INTERFACE_INFO_TYPE) == hrFalse)
  177. {
  178. // If it didn't have the general interface info, assume that
  179. // we're adding IPX to this interface
  180. m_bNewInterface = TRUE;
  181. }
  182. CORg( AddIpxPerInterfaceBlocks(m_spIf, spInfoBase) );
  183. m_spInfoBase = spInfoBase.Transfer();
  184. Error:
  185. return hr;
  186. }
  187. /*!--------------------------------------------------------------------------
  188. IPXSummaryInterfaceProperties::GetInfoBase
  189. -
  190. Author: KennT
  191. ---------------------------------------------------------------------------*/
  192. HRESULT IPXSummaryInterfaceProperties::GetInfoBase(IInfoBase **ppInfoBase)
  193. {
  194. Assert(ppInfoBase);
  195. *ppInfoBase = m_spInfoBase;
  196. m_spInfoBase->AddRef();
  197. return hrOK;
  198. }
  199. /*!--------------------------------------------------------------------------
  200. IPXSummaryInterfaceProperties::SaveSheetData
  201. This is performed on the main thread. This will save sheet-wide
  202. data (rather than page data).
  203. Author: KennT
  204. ---------------------------------------------------------------------------*/
  205. BOOL IPXSummaryInterfaceProperties::SaveSheetData()
  206. {
  207. HRESULT hr = hrOK;
  208. SPITFSNodeHandler spHandler;
  209. HANDLE hTransport = NULL, hInterface = NULL;
  210. DWORD dwErr;
  211. SPITFSNode spParent;
  212. // By this time each page should have written its information out
  213. // to the infobase
  214. if (m_spInfoBase)
  215. {
  216. if (m_bClientInfoBase)
  217. {
  218. Assert(m_spRm);
  219. CORg( m_spRm->Save(m_spRm->GetMachineName(), 0, 0, NULL,
  220. m_spInfoBase, 0));
  221. }
  222. else
  223. {
  224. // For IPX, we need to have the protocol information in the
  225. // infobase, BEFORE we add the interface to the running router.
  226. Assert(m_spRmIf);
  227. //
  228. // Need to set the infobase back to the registry
  229. //
  230. m_pIPXConn->DisconnectFromConfigServer();
  231. CWRg( ::MprConfigInterfaceGetHandle(
  232. m_pIPXConn->GetConfigHandle(),
  233. (LPTSTR) m_spRmIf->GetInterfaceId(),
  234. &hInterface) );
  235. // Get the transport handle
  236. dwErr = ::MprConfigInterfaceTransportGetHandle(
  237. m_pIPXConn->GetConfigHandle(),
  238. hInterface,// need hInterface
  239. PID_IPX,
  240. &hTransport);
  241. if (dwErr != ERROR_SUCCESS)
  242. {
  243. RtrMgrInterfaceCB rmIfCB;
  244. m_spRmIf->CopyCB(&rmIfCB);
  245. dwErr = ::MprConfigInterfaceTransportAdd(
  246. m_pIPXConn->GetConfigHandle(),
  247. hInterface,
  248. m_spRmIf->GetTransportId(),
  249. rmIfCB.szId,
  250. NULL, 0, &hTransport);
  251. }
  252. CWRg( dwErr );
  253. m_spRmIf->SetInfoBase(NULL, hInterface, hTransport, m_spInfoBase);
  254. //
  255. // Now, we notify that the interface is being added
  256. // This gives the protocols a chance to add on their information
  257. //
  258. if (m_bNewInterface)
  259. m_spRm->RtrNotify(ROUTER_CHILD_PREADD, ROUTER_OBJ_RmIf, 0);
  260. //
  261. // Reload the infobase (to get the new data before calling
  262. // the final save).
  263. //
  264. m_spInfoBase.Release();
  265. m_spRmIf->GetInfoBase(NULL, hInterface, hTransport, &m_spInfoBase);
  266. //
  267. // Perform the final save (since we are passing in a non-NULL
  268. // infobase pointer) this will commit the information back
  269. // to the running router.
  270. //
  271. CORg( m_spRmIf->Save(m_spIf->GetMachineName(),
  272. NULL, hInterface, hTransport, m_spInfoBase, 0));
  273. }
  274. if (m_bNewInterface)
  275. m_spRm->RtrNotify(ROUTER_CHILD_ADD, ROUTER_OBJ_RmIf, 0);
  276. }
  277. if (m_bNewInterface)
  278. {
  279. SPITFSNodeHandler spHandler;
  280. SPITFSNode spParent;
  281. m_spNode->SetVisibilityState(TFS_VIS_SHOW);
  282. m_spNode->Show();
  283. // Force the node to do a resync
  284. m_spNode->GetParent(&spParent);
  285. spParent->GetHandler(&spHandler);
  286. spHandler->OnCommand(spParent, IDS_MENU_SYNC, CCT_RESULT,
  287. NULL, 0);
  288. // Windows NT Bugs : 133891, we have added this to the UI
  289. // we no longer consider this a new interface
  290. m_bNewInterface = FALSE;
  291. }
  292. Error:
  293. if (!FHrSucceeded(hr))
  294. {
  295. // Panic1("The Save failed %08lx", hr);
  296. CancelSheetData();
  297. return FALSE;
  298. }
  299. // Force the node to do a resync
  300. m_spNode->GetParent(&spParent);
  301. spParent->GetHandler(&spHandler);
  302. spHandler->OnCommand(spParent, IDS_MENU_SYNC, CCT_RESULT,
  303. NULL, 0);
  304. return TRUE;
  305. }
  306. /*!--------------------------------------------------------------------------
  307. IPXSummaryInterfaceProperties::CancelSheetData
  308. -
  309. Author: KennT
  310. ---------------------------------------------------------------------------*/
  311. void IPXSummaryInterfaceProperties::CancelSheetData()
  312. {
  313. if (m_bNewInterface)
  314. {
  315. m_spNode->SetVisibilityState(TFS_VIS_DELETE);
  316. if (m_spIf)
  317. m_spIf->DeleteRtrMgrInterface(PID_IPX, TRUE);
  318. else
  319. {
  320. // This was the client interface, just don't save the
  321. // infobase back
  322. }
  323. }
  324. }
  325. /*---------------------------------------------------------------------------
  326. IPXSummaryIfPageGeneral
  327. ---------------------------------------------------------------------------*/
  328. IPXSummaryIfPageGeneral::~IPXSummaryIfPageGeneral()
  329. {
  330. if (m_pIPXConn)
  331. {
  332. m_pIPXConn->Release();
  333. m_pIPXConn = NULL;
  334. }
  335. }
  336. BEGIN_MESSAGE_MAP(IPXSummaryIfPageGeneral, RtrPropertyPage)
  337. //{{AFX_MSG_MAP(IPXSummaryIfPageGeneral)
  338. ON_BN_CLICKED(IDC_IIG_BTN_INPUT_FILTERS, OnInputFilters)
  339. ON_BN_CLICKED(IDC_IIG_BTN_OUTPUT_FILTERS, OnOutputFilters)
  340. ON_BN_CLICKED(IDC_IIG_BTN_ADMIN_STATE, OnChangeAdminButton)
  341. ON_BN_CLICKED(IDC_IIG_BTN_IPX_CP, OnChangeButton)
  342. ON_BN_CLICKED(IDC_IIG_BTN_IPX_WAN, OnChangeButton)
  343. //}}AFX_MSG_MAP
  344. END_MESSAGE_MAP()
  345. void IPXSummaryIfPageGeneral::OnChangeAdminButton()
  346. {
  347. BOOL bSelected = IsDlgButtonChecked(IDC_IIG_BTN_ADMIN_STATE);
  348. DWORD dwIfType = m_spIf ? m_spIf->GetInterfaceType() : ROUTER_IF_TYPE_CLIENT;
  349. if (ROUTER_IF_TYPE_CLIENT != dwIfType)
  350. {
  351. GetDlgItem(IDC_IIG_BTN_INPUT_FILTERS)->EnableWindow(bSelected);
  352. GetDlgItem(IDC_IIG_BTN_OUTPUT_FILTERS)->EnableWindow(bSelected);
  353. }
  354. // Only if dwIfType == ROUTER_IF_TYPE_FULL_ROUTER can IDC_IIG_BTN_IPX_CP || IDC_IIG_BTN_IPX_WAN be changed
  355. if (ROUTER_IF_TYPE_FULL_ROUTER == dwIfType)
  356. {
  357. GetDlgItem(IDC_IIG_GRP_CONTROL_PROTOCOL)->EnableWindow(bSelected);
  358. GetDlgItem(IDC_IIG_BTN_IPX_CP)->EnableWindow(bSelected);
  359. GetDlgItem(IDC_IIG_BTN_IPX_WAN)->EnableWindow(bSelected);
  360. }
  361. OnChangeButton();
  362. }
  363. void IPXSummaryIfPageGeneral::OnChangeButton()
  364. {
  365. SetDirty(TRUE);
  366. SetModified();
  367. }
  368. void IPXSummaryIfPageGeneral::OnInputFilters()
  369. {
  370. OnFiltersConfig(FILTER_INBOUND);
  371. }
  372. void IPXSummaryIfPageGeneral::OnOutputFilters()
  373. {
  374. OnFiltersConfig(FILTER_OUTBOUND);
  375. }
  376. /*!--------------------------------------------------------------------------
  377. IPXSummaryIfPageGeneral::Init
  378. -
  379. Author: KennT
  380. ---------------------------------------------------------------------------*/
  381. HRESULT IPXSummaryIfPageGeneral::Init(IInterfaceInfo *pIfInfo,
  382. IPXConnection *pIPXConn,
  383. IPXSummaryInterfaceProperties *pPropSheet)
  384. {
  385. m_spIf.Set(pIfInfo);
  386. m_pIPXConn = pIPXConn;
  387. pIPXConn->AddRef();
  388. m_pIPXPropSheet = pPropSheet;
  389. return hrOK;
  390. }
  391. /*!--------------------------------------------------------------------------
  392. IPXSummaryIfPageGeneral::OnInitDialog
  393. -
  394. Author: KennT
  395. ---------------------------------------------------------------------------*/
  396. BOOL IPXSummaryIfPageGeneral::OnInitDialog()
  397. {
  398. HRESULT hr = hrOK;
  399. PBYTE pData;
  400. SPIInfoBase spInfoBase;
  401. IPX_IF_INFO * pIpxIf = NULL;
  402. IPXWAN_IF_INFO *pIpxWanIf = NULL;
  403. DWORD dwIfType;
  404. BOOL fEnable;
  405. // create the error info object
  406. CreateTFSErrorInfo(0);
  407. RtrPropertyPage::OnInitDialog();
  408. //
  409. // The page is now initialized. Load the current configuration
  410. // for the interface being configured, and display its settings.
  411. //
  412. // Get the infobase from the property sheet.
  413. //
  414. CORg( m_pIPXPropSheet->GetInfoBase(&spInfoBase) );
  415. //
  416. // Retrieve the interface-status block configured
  417. //
  418. CORg( spInfoBase->GetData(IPX_INTERFACE_INFO_TYPE, 0, (BYTE **) &pIpxIf) );
  419. CheckDlgButton(IDC_IIG_BTN_ADMIN_STATE, pIpxIf->AdminState == ADMIN_STATE_ENABLED);
  420. GetDlgItem(IDC_IIG_GRP_CONTROL_PROTOCOL)->EnableWindow(pIpxIf->AdminState == ADMIN_STATE_ENABLED);
  421. GetDlgItem(IDC_IIG_BTN_INPUT_FILTERS)->EnableWindow(pIpxIf->AdminState == ADMIN_STATE_ENABLED);
  422. GetDlgItem(IDC_IIG_BTN_OUTPUT_FILTERS)->EnableWindow(pIpxIf->AdminState == ADMIN_STATE_ENABLED);
  423. dwIfType = m_spIf ? m_spIf->GetInterfaceType() : ROUTER_IF_TYPE_CLIENT;
  424. if (dwIfType == ROUTER_IF_TYPE_FULL_ROUTER)
  425. {
  426. CORg( spInfoBase->GetData(IPXWAN_INTERFACE_INFO_TYPE, 0,
  427. (LPBYTE *) &pIpxWanIf) );
  428. if (pIpxWanIf->AdminState == ADMIN_STATE_ENABLED)
  429. CheckDlgButton(IDC_IIG_BTN_IPX_WAN, ENABLED);
  430. else
  431. CheckDlgButton(IDC_IIG_BTN_IPX_CP, ENABLED);
  432. fEnable = TRUE;
  433. }
  434. else if (dwIfType == ROUTER_IF_TYPE_CLIENT)
  435. {
  436. CheckDlgButton(IDC_IIG_BTN_IPX_CP, ENABLED);
  437. fEnable = FALSE;
  438. }
  439. else
  440. {
  441. fEnable = FALSE;
  442. }
  443. // by default the controls are enabled, so do this call only
  444. // if we need to disable them
  445. if (fEnable == FALSE)
  446. {
  447. GetDlgItem(IDC_IIG_GRP_CONTROL_PROTOCOL)->EnableWindow(FALSE);
  448. GetDlgItem(IDC_IIG_BTN_IPX_CP)->EnableWindow(FALSE);
  449. GetDlgItem(IDC_IIG_BTN_IPX_WAN)->EnableWindow(FALSE);
  450. }
  451. if (dwIfType == ROUTER_IF_TYPE_CLIENT)
  452. {
  453. GetDlgItem(IDC_IIG_BTN_INPUT_FILTERS)->EnableWindow(FALSE);
  454. GetDlgItem(IDC_IIG_BTN_OUTPUT_FILTERS)->EnableWindow(FALSE);
  455. }
  456. SetDirty(m_pIPXPropSheet->m_bNewInterface ? TRUE : FALSE);
  457. Error:
  458. if (!FHrSucceeded(hr))
  459. Cancel();
  460. return FHrSucceeded(hr) ? TRUE : FALSE;
  461. }
  462. /*!--------------------------------------------------------------------------
  463. IPXSummaryIfPageGeneral::DoDataExchange
  464. -
  465. Author: KennT
  466. ---------------------------------------------------------------------------*/
  467. void IPXSummaryIfPageGeneral::DoDataExchange(CDataExchange *pDX)
  468. {
  469. RtrPropertyPage::DoDataExchange(pDX);
  470. //{{AFX_DATA_MAP(IPXSummaryIfPageGeneral)
  471. //}}AFX_DATA_MAP
  472. }
  473. BOOL IPXSummaryIfPageGeneral::OnApply()
  474. {
  475. INT i;
  476. SPIInfoBase spInfoBase;
  477. IPX_IF_INFO * pIpxIf = NULL;
  478. IPXWAN_IF_INFO *pIpxWanIf = NULL;
  479. BOOL fReturn;
  480. HRESULT hr = hrOK;
  481. DWORD dwIfType;
  482. if ( m_pIPXPropSheet->IsCancel() )
  483. {
  484. CancelApply();
  485. return TRUE;
  486. }
  487. //
  488. // Retrieve the interface-status block configured
  489. //
  490. m_pIPXPropSheet->GetInfoBase(&spInfoBase);
  491. CORg( spInfoBase->GetData(IPX_INTERFACE_INFO_TYPE, 0, (BYTE **) &pIpxIf) );
  492. pIpxIf->AdminState = IsDlgButtonChecked(IDC_IIG_BTN_ADMIN_STATE) ?
  493. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  494. dwIfType = m_spIf ? m_spIf->GetInterfaceType() : ROUTER_IF_TYPE_CLIENT;
  495. if ((dwIfType == ROUTER_IF_TYPE_FULL_ROUTER) ||
  496. (dwIfType == ROUTER_IF_TYPE_CLIENT))
  497. {
  498. CORg( spInfoBase->GetData(IPXWAN_INTERFACE_INFO_TYPE, 0, (LPBYTE *) &pIpxWanIf) );
  499. pIpxWanIf->AdminState = IsDlgButtonChecked(IDC_IIG_BTN_IPX_WAN) ?
  500. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  501. }
  502. fReturn = RtrPropertyPage::OnApply();
  503. Error:
  504. return fReturn;
  505. }
  506. //----------------------------------------------------------------------------
  507. // Function: CIpxIfGeneral::OnFiltersConfig
  508. //
  509. // does the actual call to MprUIFilterConfig for filter configuration.
  510. //----------------------------------------------------------------------------
  511. void IPXSummaryIfPageGeneral::OnFiltersConfig(
  512. DWORD dwFilterDirection
  513. )
  514. {
  515. CWaitCursor wait;
  516. SPIInfoBase spInfoBase;
  517. m_pIPXPropSheet->GetInfoBase(&spInfoBase);
  518. if (FHrOK(MprUIFilterConfigInfoBase(this->GetSafeHwnd(),
  519. spInfoBase,
  520. NULL,
  521. PID_IPX,
  522. dwFilterDirection)))
  523. {
  524. SetDirty(TRUE);
  525. SetModified();
  526. }
  527. }
  528. /*---------------------------------------------------------------------------
  529. IPXSummaryIfPageConfig
  530. ---------------------------------------------------------------------------*/
  531. IPXSummaryIfPageConfig::~IPXSummaryIfPageConfig()
  532. {
  533. if (m_pIPXConn)
  534. {
  535. m_pIPXConn->Release();
  536. m_pIPXConn = NULL;
  537. }
  538. }
  539. BEGIN_MESSAGE_MAP(IPXSummaryIfPageConfig, RtrPropertyPage)
  540. //{{AFX_MSG_MAP(IPXSummaryIfPageConfig)
  541. ON_EN_CHANGE(IDC_IIC_EDIT_NETNUMBER, OnChangeEdit)
  542. //}}AFX_MSG_MAP
  543. END_MESSAGE_MAP()
  544. /*!--------------------------------------------------------------------------
  545. IPXSummaryIfPageConfig::Init
  546. -
  547. Author: KennT
  548. ---------------------------------------------------------------------------*/
  549. HRESULT IPXSummaryIfPageConfig::Init(IInterfaceInfo *pIfInfo,
  550. IPXConnection *pIPXConn,
  551. IPXSummaryInterfaceProperties *pPropSheet)
  552. {
  553. // create the error info object
  554. CreateTFSErrorInfo(0);
  555. m_spIf.Set(pIfInfo);
  556. m_pIPXConn = pIPXConn;
  557. pIPXConn->AddRef();
  558. m_pIPXPropSheet = pPropSheet;
  559. m_fNetNumberChanged = FALSE;
  560. HRESULT hr = hrOK;
  561. SPIRemoteRouterConfig spRemote;
  562. SPIRouterInfo spRouter;
  563. COSERVERINFO csi;
  564. COAUTHINFO cai;
  565. COAUTHIDENTITY caid;
  566. ZeroMemory(&csi, sizeof(csi));
  567. ZeroMemory(&cai, sizeof(cai));
  568. ZeroMemory(&caid, sizeof(caid));
  569. csi.pAuthInfo = &cai;
  570. cai.pAuthIdentityData = &caid;
  571. // If there's no interface (such as for dial-in clients) don't
  572. // add the config page
  573. if (!m_spIf)
  574. return S_FALSE;
  575. m_spIf->GetParentRouterInfo(&spRouter);
  576. // Now try to cocreate the object
  577. if (m_spRemote == NULL)
  578. {
  579. LPCOLESTR pszMachine = m_spIf->GetMachineName();
  580. IUnknown * punk = NULL;
  581. hr = CoCreateRouterConfig(pszMachine,
  582. spRouter,
  583. &csi,
  584. IID_IRemoteRouterConfig,
  585. &punk);
  586. spRemote = (IRemoteRouterConfig *) punk;
  587. }
  588. if (FHrSucceeded(hr))
  589. {
  590. DWORD dwNet;
  591. m_spRemote = spRemote.Transfer();
  592. hr = m_spRemote->GetIpxVirtualNetworkNumber(&dwNet);
  593. m_dwNetNumber = dwNet;
  594. }
  595. if (!HandleIRemoteRouterConfigErrors(hr, m_spIf->GetMachineName()))
  596. {
  597. // other misc errors
  598. AddSystemErrorMessage(hr);
  599. AddHighLevelErrorStringId(IDS_ERR_IPXCONFIG_CANNOT_SHOW);
  600. }
  601. if (csi.pAuthInfo)
  602. delete csi.pAuthInfo->pAuthIdentityData->Password;
  603. return hr;
  604. }
  605. BOOL IPXSummaryIfPageConfig::OnPropertyChange(BOOL bScopePane, LONG_PTR *pChangeMask)
  606. {
  607. BOOL fReturn = TRUE;
  608. m_hrRemote = hrOK;
  609. if ( m_pIPXPropSheet->IsCancel() )
  610. {
  611. RtrPropertyPage::OnPropertyChange(bScopePane, pChangeMask);
  612. return FALSE;
  613. }
  614. if (m_fNetNumberChanged)
  615. {
  616. Assert(m_spRemote);
  617. m_hrRemote = m_spRemote->SetIpxVirtualNetworkNumber(m_dwNetNumber);
  618. fReturn = FHrSucceeded(m_hrRemote);
  619. }
  620. BOOL fPageReturn = RtrPropertyPage::OnPropertyChange(bScopePane, pChangeMask);
  621. // Only if both calls succeeded, do we return TRUE
  622. return fPageReturn && fReturn;
  623. }
  624. /*!--------------------------------------------------------------------------
  625. IPXSummaryIfPageConfig::OnInitDialog
  626. -
  627. Author: KennT
  628. ---------------------------------------------------------------------------*/
  629. BOOL IPXSummaryIfPageConfig::OnInitDialog()
  630. {
  631. HRESULT hr = hrOK;
  632. TCHAR szNetNumber[64];
  633. RtrPropertyPage::OnInitDialog();
  634. wsprintf(szNetNumber, _T("%08lx"), m_dwNetNumber);
  635. SetDlgItemText(IDC_IIC_EDIT_NETNUMBER, szNetNumber);
  636. SetDirty(m_pIPXPropSheet->m_bNewInterface ? TRUE : FALSE);
  637. //Error:
  638. if (!FHrSucceeded(hr))
  639. Cancel();
  640. return FHrSucceeded(hr) ? TRUE : FALSE;
  641. }
  642. /*!--------------------------------------------------------------------------
  643. IPXSummaryIfPageConfig::DoDataExchange
  644. -
  645. Author: KennT
  646. ---------------------------------------------------------------------------*/
  647. void IPXSummaryIfPageConfig::DoDataExchange(CDataExchange *pDX)
  648. {
  649. RtrPropertyPage::DoDataExchange(pDX);
  650. //{{AFX_DATA_MAP(IPXSummaryIfPageConfig)
  651. //}}AFX_DATA_MAP
  652. }
  653. /*!--------------------------------------------------------------------------
  654. IPXSummaryIfPageConfig::OnApply
  655. -
  656. Author: KennT
  657. ---------------------------------------------------------------------------*/
  658. BOOL IPXSummaryIfPageConfig::OnApply()
  659. {
  660. BOOL fReturn;
  661. DWORD dwNetNumber;
  662. CString stNetNumber;
  663. HRESULT hr = hrOK;
  664. if ( m_pIPXPropSheet->IsCancel() )
  665. {
  666. CancelApply();
  667. return TRUE;
  668. }
  669. // Get the value from the edit control
  670. // ----------------------------------------------------------------
  671. GetDlgItemText(IDC_IIC_EDIT_NETNUMBER, stNetNumber);
  672. // Convert this text string into a hex number
  673. // ----------------------------------------------------------------
  674. dwNetNumber = _tcstoul(stNetNumber, NULL, 16);
  675. // Only attempt to write if the value actually changd.
  676. // ----------------------------------------------------------------
  677. if (m_spRemote && (dwNetNumber != m_dwNetNumber))
  678. {
  679. m_dwNetNumber = dwNetNumber;
  680. m_fNetNumberChanged = TRUE;
  681. }
  682. fReturn = RtrPropertyPage::OnApply();
  683. // If this fails warn the user
  684. // ----------------------------------------------------------------
  685. if (!FHrSucceeded(hr))
  686. {
  687. DisplayErrorMessage(GetSafeHwnd(), hr);
  688. }
  689. else if (!FHrSucceeded(m_hrRemote))
  690. {
  691. // Return to this page
  692. // ------------------------------------------------------------
  693. GetParent()->PostMessage(PSM_SETCURSEL, 0, (LPARAM) GetSafeHwnd());
  694. AddHighLevelErrorStringId(IDS_ERR_CANNOT_SAVE_IPXCONFIG);
  695. AddSystemErrorMessage(m_hrRemote);
  696. DisplayTFSErrorMessage(NULL);
  697. fReturn = FALSE;
  698. }
  699. return fReturn;
  700. }
  701. void IPXSummaryIfPageConfig::OnChangeEdit()
  702. {
  703. SetDirty(TRUE);
  704. SetModified();
  705. }
  706. /*---------------------------------------------------------------------------
  707. IPXSummaryPageGeneral
  708. ---------------------------------------------------------------------------*/
  709. BEGIN_MESSAGE_MAP(IPXSummaryPageGeneral, RtrPropertyPage)
  710. //{{AFX_MSG_MAP(IPXSummaryPageGeneral)
  711. ON_BN_CLICKED(IDC_IGG_BTN_LOG_ERRORS, OnButtonClicked)
  712. ON_BN_CLICKED(IDC_IGG_BTN_LOG_INFO, OnButtonClicked)
  713. ON_BN_CLICKED(IDC_IGG_BTN_LOG_NONE, OnButtonClicked)
  714. ON_BN_CLICKED(IDC_IGG_BTN_LOG_WARNINGS, OnButtonClicked)
  715. //}}AFX_MSG_MAP
  716. END_MESSAGE_MAP()
  717. void IPXSummaryPageGeneral::OnButtonClicked()
  718. {
  719. SetDirty(TRUE);
  720. SetModified();
  721. }
  722. /*!--------------------------------------------------------------------------
  723. IPXSummaryPageGeneral::Init
  724. -
  725. Author: KennT
  726. ---------------------------------------------------------------------------*/
  727. HRESULT IPXSummaryPageGeneral::Init(IPXSummaryProperties *pPropSheet)
  728. {
  729. m_pIPXPropSheet = pPropSheet;
  730. return hrOK;
  731. }
  732. /*!--------------------------------------------------------------------------
  733. IPXSummaryPageGeneral::OnInitDialog
  734. -
  735. Author: KennT
  736. ---------------------------------------------------------------------------*/
  737. BOOL IPXSummaryPageGeneral::OnInitDialog()
  738. {
  739. HRESULT hr= hrOK;
  740. SPIInfoBase spInfoBase;
  741. PIPX_GLOBAL_INFO pGlobalInfo = NULL;
  742. RtrPropertyPage::OnInitDialog();
  743. //
  744. // Load the existing global-config
  745. //
  746. CORg( m_pIPXPropSheet->GetInfoBase(&spInfoBase) );
  747. //
  748. // Retrieve the global-info, to set the 'Enable filtering' checkbox
  749. // and the logging levels.
  750. //
  751. CORg( spInfoBase->GetData(IPX_GLOBAL_INFO_TYPE,
  752. 0,
  753. (BYTE **) &pGlobalInfo) );
  754. // Initialize the logging-level buttons
  755. //
  756. SetLogLevelButtons(pGlobalInfo->EventLogMask);
  757. SetDirty(FALSE);
  758. Error:
  759. if (!FHrSucceeded(hr))
  760. Cancel();
  761. return FHrSucceeded(hr) ? TRUE : FALSE;
  762. }
  763. /*!--------------------------------------------------------------------------
  764. IPXSummaryPageGeneral::DoDataExchange
  765. -
  766. Author: KennT
  767. ---------------------------------------------------------------------------*/
  768. void IPXSummaryPageGeneral::DoDataExchange(CDataExchange *pDX)
  769. {
  770. RtrPropertyPage::DoDataExchange(pDX);
  771. //{{AFX_DATA_MAP(IPXSummaryPageGeneral)
  772. //}}AFX_DATA_MAP
  773. }
  774. BOOL IPXSummaryPageGeneral::OnApply()
  775. {
  776. SPIInfoBase spInfoBase;
  777. BOOL fReturn;
  778. HRESULT hr = hrOK;
  779. PIPX_GLOBAL_INFO pgi;
  780. if ( m_pIPXPropSheet->IsCancel() )
  781. {
  782. CancelApply();
  783. return TRUE;
  784. }
  785. //
  786. // Save the 'Enable filtering' setting
  787. //
  788. CORg( m_pIPXPropSheet->GetInfoBase(&spInfoBase) );
  789. CORg( spInfoBase->GetData(IPX_GLOBAL_INFO_TYPE, 0, (BYTE **) &pgi) );
  790. pgi->EventLogMask = QueryLogLevelButtons();
  791. fReturn = RtrPropertyPage::OnApply();
  792. Error:
  793. if (!FHrSucceeded(hr))
  794. fReturn = FALSE;
  795. return fReturn;
  796. }
  797. /*!--------------------------------------------------------------------------
  798. IPXSummaryPageGeneral::SetLogLevelButtons
  799. -
  800. Author: KennT
  801. ---------------------------------------------------------------------------*/
  802. void IPXSummaryPageGeneral::SetLogLevelButtons(DWORD dwLogLevel)
  803. {
  804. switch (dwLogLevel)
  805. {
  806. case 0:
  807. CheckDlgButton(IDC_IGG_BTN_LOG_NONE, TRUE);
  808. break;
  809. case EVENTLOG_ERROR_TYPE:
  810. CheckDlgButton(IDC_IGG_BTN_LOG_ERRORS, TRUE);
  811. break;
  812. case EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE:
  813. CheckDlgButton(IDC_IGG_BTN_LOG_WARNINGS, TRUE);
  814. break;
  815. case EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE:
  816. default:
  817. CheckDlgButton(IDC_IGG_BTN_LOG_INFO, TRUE);
  818. break;
  819. }
  820. }
  821. /*!--------------------------------------------------------------------------
  822. IPXSummaryPageGeneral::QueryLogLevelButtons
  823. Called to get the value set by the 'Logging level' radio-buttons.
  824. Author: KennT
  825. ---------------------------------------------------------------------------*/
  826. DWORD IPXSummaryPageGeneral::QueryLogLevelButtons()
  827. {
  828. if (IsDlgButtonChecked(IDC_IGG_BTN_LOG_INFO))
  829. return EVENTLOG_INFORMATION_TYPE |
  830. EVENTLOG_WARNING_TYPE |
  831. EVENTLOG_ERROR_TYPE;
  832. else if (IsDlgButtonChecked(IDC_IGG_BTN_LOG_WARNINGS))
  833. return EVENTLOG_WARNING_TYPE |
  834. EVENTLOG_ERROR_TYPE;
  835. else if (IsDlgButtonChecked(IDC_IGG_BTN_LOG_ERRORS))
  836. return EVENTLOG_ERROR_TYPE;
  837. else
  838. return 0;
  839. }
  840. /*---------------------------------------------------------------------------
  841. IPXSummaryProperties implementation
  842. ---------------------------------------------------------------------------*/
  843. IPXSummaryProperties::IPXSummaryProperties(ITFSNode *pNode,
  844. IComponentData *pComponentData,
  845. ITFSComponentData *pTFSCompData,
  846. LPCTSTR pszSheetName,
  847. CWnd *pParent,
  848. UINT iPage,
  849. BOOL fScopePane)
  850. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  851. pszSheetName, pParent, iPage, fScopePane),
  852. m_pageGeneral(IDD_IPX_GLOBAL_GENERAL_PAGE)
  853. {
  854. m_spNode.Set(pNode);
  855. }
  856. /*!--------------------------------------------------------------------------
  857. IPXSummaryProperties::Init
  858. Initialize the property sheets. The general action here will be
  859. to initialize/add the various pages.
  860. Author: KennT
  861. ---------------------------------------------------------------------------*/
  862. HRESULT IPXSummaryProperties::Init(IRtrMgrInfo *pRm)
  863. {
  864. HRESULT hr = hrOK;
  865. IPXConnection * pIPXConn;
  866. BaseIPXResultNodeData * pData;
  867. SPIRouterInfo spRouter;
  868. m_spRm.Set(pRm);
  869. pIPXConn = GET_IPXSUMMARY_NODEDATA(m_spNode);
  870. // The pages are embedded members of the class
  871. // do not delete them.
  872. m_bAutoDeletePages = FALSE;
  873. // Get the router info
  874. CORg( pRm->GetParentRouterInfo(&spRouter) );
  875. // Initialize the infobase
  876. // Do this here, because the init is called in the context
  877. // of the main thread
  878. CORg( LoadInfoBase(pIPXConn) );
  879. m_pageGeneral.Init(this);
  880. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  881. Error:
  882. return hr;
  883. }
  884. /*!--------------------------------------------------------------------------
  885. IPXSummaryProperties::LoadInfoBase
  886. -
  887. Author: KennT
  888. ---------------------------------------------------------------------------*/
  889. HRESULT IPXSummaryProperties::LoadInfoBase(IPXConnection *pIPXConn)
  890. {
  891. Assert(pIPXConn);
  892. HRESULT hr = hrOK;
  893. HANDLE hTransport = NULL;
  894. LPCOLESTR pszInterfaceId;
  895. SPIInfoBase spInfoBase;
  896. BYTE * pDefault;
  897. Assert(m_spRm);
  898. // Get the transport handle
  899. CWRg( ::MprConfigTransportGetHandle(pIPXConn->GetConfigHandle(),
  900. PID_IPX,
  901. &hTransport) );
  902. // Load the current IPX global info
  903. CORg( m_spRm->GetInfoBase(pIPXConn->GetConfigHandle(),
  904. hTransport,
  905. &spInfoBase,
  906. NULL) );
  907. // Ensure that the global info block for IPX exists, adding
  908. // the default block if none is found.
  909. if (!FHrOK(spInfoBase->BlockExists(IPX_GLOBAL_INFO_TYPE)))
  910. {
  911. IPX_GLOBAL_INFO ipxgl;
  912. ipxgl.RoutingTableHashSize = IPX_MEDIUM_ROUTING_TABLE_HASH_SIZE;
  913. ipxgl.EventLogMask = EVENTLOG_ERROR_TYPE |
  914. EVENTLOG_WARNING_TYPE;
  915. CORg( spInfoBase->AddBlock(IPX_GLOBAL_INFO_TYPE,
  916. sizeof(ipxgl),
  917. (PBYTE) &ipxgl,
  918. 1 /* dwCount */,
  919. 0 /* bRemoveFirst */) );
  920. }
  921. Error:
  922. if (!FHrSucceeded(hr))
  923. spInfoBase.Release();
  924. m_spInfoBase.Release();
  925. m_spInfoBase = spInfoBase.Transfer();
  926. return hr;
  927. }
  928. /*!--------------------------------------------------------------------------
  929. IPXSummaryProperties::GetInfoBase
  930. -
  931. Author: KennT
  932. ---------------------------------------------------------------------------*/
  933. HRESULT IPXSummaryProperties::GetInfoBase(IInfoBase **ppInfoBase)
  934. {
  935. Assert(ppInfoBase);
  936. *ppInfoBase = m_spInfoBase;
  937. m_spInfoBase->AddRef();
  938. return hrOK;
  939. }
  940. BOOL IPXSummaryProperties::SaveSheetData()
  941. {
  942. Assert(m_spRm);
  943. // Save the global info
  944. // We don't need to pass in the hMachine, hTransport since they
  945. // got set up in the Load call.
  946. m_spRm->Save(m_spRm->GetMachineName(), // pszMachine
  947. 0, // hMachine
  948. 0, // hTransport
  949. m_spInfoBase, // pGlobalInfo
  950. NULL, // pClientInfo
  951. 0); // dwDeleteProtocolId
  952. return TRUE;
  953. }