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.

823 lines
22 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. sapprop.cpp
  7. Dhcp Relay 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 "sapprop.h"
  14. #include "sapview.h"
  15. #include "ipxutil.h" // SapModeToCString
  16. #include "ipxconn.h"
  17. #include "svfltdlg.h"
  18. #include "globals.h" // IPX defaults
  19. extern "C"
  20. {
  21. #include "routprot.h"
  22. };
  23. /*---------------------------------------------------------------------------
  24. SapPageGeneral
  25. ---------------------------------------------------------------------------*/
  26. BEGIN_MESSAGE_MAP(SapPageGeneral, RtrPropertyPage)
  27. //{{AFX_MSG_MAP(SapPageGeneral)
  28. ON_BN_CLICKED(IDC_SGG_BTN_LOG_ERROR, OnButtonClicked)
  29. ON_BN_CLICKED(IDC_SGG_BTN_LOG_INFO, OnButtonClicked)
  30. ON_BN_CLICKED(IDC_SGG_BTN_LOG_NONE, OnButtonClicked)
  31. ON_BN_CLICKED(IDC_SGG_BTN_LOG_WARN, OnButtonClicked)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /*!--------------------------------------------------------------------------
  35. SapPageGeneral::Init
  36. -
  37. Author: KennT
  38. ---------------------------------------------------------------------------*/
  39. HRESULT SapPageGeneral::Init(SapProperties *pPropSheet)
  40. {
  41. m_pSapPropSheet = pPropSheet;
  42. return hrOK;
  43. }
  44. /*!--------------------------------------------------------------------------
  45. SapPageGeneral::OnInitDialog
  46. -
  47. Author: KennT
  48. ---------------------------------------------------------------------------*/
  49. BOOL SapPageGeneral::OnInitDialog()
  50. {
  51. HRESULT hr= hrOK;
  52. SPIInfoBase spInfoBase;
  53. SAP_GLOBAL_INFO* pGlobal;
  54. DWORD * pdw;
  55. int i;
  56. RtrPropertyPage::OnInitDialog();
  57. //
  58. // Load the existing global-config
  59. //
  60. CORg( m_pSapPropSheet->GetInfoBase(&spInfoBase) );
  61. //
  62. // Retrieve the IPSAP block from the global-config
  63. //
  64. CORg( spInfoBase->GetData(IPX_PROTOCOL_SAP, 0, (PBYTE *) &pGlobal) );
  65. //
  66. // Initialize the error-level buttons
  67. //
  68. SetErrorLevelButtons(pGlobal->EventLogMask);
  69. SetDirty(FALSE);
  70. Error:
  71. if (!FHrSucceeded(hr))
  72. Cancel();
  73. return FHrSucceeded(hr) ? TRUE : FALSE;
  74. }
  75. /*!--------------------------------------------------------------------------
  76. SapPageGeneral::DoDataExchange
  77. -
  78. Author: KennT
  79. ---------------------------------------------------------------------------*/
  80. void SapPageGeneral::DoDataExchange(CDataExchange *pDX)
  81. {
  82. RtrPropertyPage::DoDataExchange(pDX);
  83. //{{AFX_DATA_MAP(SapPageGeneral)
  84. //}}AFX_DATA_MAP
  85. }
  86. /*!--------------------------------------------------------------------------
  87. SapPageGeneral::OnApply
  88. -
  89. Author: KennT
  90. ---------------------------------------------------------------------------*/
  91. BOOL SapPageGeneral::OnApply()
  92. {
  93. BOOL fReturn;
  94. HRESULT hr = hrOK;
  95. SAP_GLOBAL_INFO * prgi;
  96. SPIInfoBase spInfoBase;
  97. if ( m_pSapPropSheet->IsCancel() )
  98. {
  99. CancelApply();
  100. return TRUE;
  101. }
  102. m_pSapPropSheet->GetInfoBase(&spInfoBase);
  103. // Retrieve the existing IPSAP block from the global-config
  104. CORg( spInfoBase->GetData(IPX_PROTOCOL_SAP, 0, (BYTE **) &prgi) );
  105. // Save the error level
  106. prgi->EventLogMask = QueryErrorLevelButtons();
  107. fReturn = RtrPropertyPage::OnApply();
  108. Error:
  109. if (!FHrSucceeded(hr))
  110. fReturn = FALSE;
  111. return fReturn;
  112. }
  113. void SapPageGeneral::SetErrorLevelButtons(DWORD dwErrorLevel)
  114. {
  115. switch (dwErrorLevel)
  116. {
  117. case 0:
  118. CheckDlgButton(IDC_SGG_BTN_LOG_NONE, TRUE);
  119. break;
  120. case EVENTLOG_ERROR_TYPE:
  121. CheckDlgButton(IDC_SGG_BTN_LOG_ERROR, TRUE);
  122. break;
  123. case EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE:
  124. CheckDlgButton(IDC_SGG_BTN_LOG_WARN, TRUE);
  125. break;
  126. case EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE:
  127. default:
  128. CheckDlgButton(IDC_SGG_BTN_LOG_INFO, TRUE);
  129. break;
  130. }
  131. }
  132. DWORD SapPageGeneral::QueryErrorLevelButtons()
  133. {
  134. if (IsDlgButtonChecked(IDC_SGG_BTN_LOG_INFO))
  135. return EVENTLOG_INFORMATION_TYPE |
  136. EVENTLOG_WARNING_TYPE |
  137. EVENTLOG_ERROR_TYPE;
  138. else if (IsDlgButtonChecked(IDC_SGG_BTN_LOG_WARN))
  139. return EVENTLOG_WARNING_TYPE |
  140. EVENTLOG_ERROR_TYPE;
  141. else if (IsDlgButtonChecked(IDC_SGG_BTN_LOG_ERROR))
  142. return EVENTLOG_ERROR_TYPE;
  143. else
  144. return 0;
  145. }
  146. void SapPageGeneral::OnButtonClicked()
  147. {
  148. SetDirty(TRUE);
  149. SetModified();
  150. }
  151. /*---------------------------------------------------------------------------
  152. SapProperties implementation
  153. ---------------------------------------------------------------------------*/
  154. SapProperties::SapProperties(ITFSNode *pNode,
  155. IComponentData *pComponentData,
  156. ITFSComponentData *pTFSCompData,
  157. LPCTSTR pszSheetName,
  158. CWnd *pParent,
  159. UINT iPage,
  160. BOOL fScopePane)
  161. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  162. pszSheetName, pParent, iPage, fScopePane),
  163. m_pageGeneral(IDD_SAP_GLOBAL_GENERAL_PAGE)
  164. {
  165. m_spNode.Set(pNode);
  166. }
  167. /*!--------------------------------------------------------------------------
  168. SapProperties::Init
  169. Initialize the property sheets. The general action here will be
  170. to initialize/add the various pages.
  171. Author: KennT
  172. ---------------------------------------------------------------------------*/
  173. HRESULT SapProperties::Init(IRtrMgrInfo *pRm)
  174. {
  175. Assert(pRm);
  176. HRESULT hr = hrOK;
  177. IPXConnection * pIPXConn;
  178. m_spRm.Set(pRm);
  179. pIPXConn = GET_SAP_NODEDATA(m_spNode);
  180. // The pages are embedded members of the class
  181. // do not delete them.
  182. m_bAutoDeletePages = FALSE;
  183. // Do this here, because the init is called in the context
  184. // of the main thread
  185. CORg( LoadInfoBase(pIPXConn) );
  186. m_pageGeneral.Init(this);
  187. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  188. Error:
  189. return hr;
  190. }
  191. /*!--------------------------------------------------------------------------
  192. SapProperties::SaveSheetData
  193. -
  194. Author: KennT
  195. ---------------------------------------------------------------------------*/
  196. BOOL SapProperties::SaveSheetData()
  197. {
  198. Assert(m_spRm);
  199. SPITFSNodeHandler spHandler;
  200. SPITFSNode spParent;
  201. // Save the global info
  202. // We don't need to pass in the hMachine, hTransport since they
  203. // got set up in the Load call.
  204. m_spRm->Save(m_spRm->GetMachineName(),
  205. 0, 0, m_spInfoBase, NULL, 0);
  206. // Force the node to do a resync
  207. m_spNode->GetParent(&spParent);
  208. spParent->GetHandler(&spHandler);
  209. spHandler->OnCommand(spParent, IDS_MENU_SYNC, CCT_RESULT,
  210. NULL, 0);
  211. return TRUE;
  212. }
  213. /*!--------------------------------------------------------------------------
  214. SapProperties::LoadInfoBase
  215. -
  216. Author: KennT
  217. ---------------------------------------------------------------------------*/
  218. HRESULT SapProperties::LoadInfoBase(IPXConnection *pIPXConn)
  219. {
  220. Assert(pIPXConn);
  221. HRESULT hr = hrOK;
  222. HANDLE hTransport = NULL;
  223. SPIInfoBase spInfoBase;
  224. // Get the transport handle
  225. CWRg( ::MprConfigTransportGetHandle(pIPXConn->GetConfigHandle(),
  226. PID_IPX,
  227. &hTransport) );
  228. CORg( m_spRm->GetInfoBase(pIPXConn->GetConfigHandle(),
  229. hTransport, &spInfoBase, NULL) );
  230. Assert(spInfoBase);
  231. // Retrieve the current block for IP_SAP
  232. // Adding the default block if none is found.
  233. if (!FHrOK(spInfoBase->ProtocolExists(IPX_PROTOCOL_SAP)))
  234. {
  235. SAP_GLOBAL_INFO rgi;
  236. rgi.EventLogMask = EVENTLOG_ERROR_TYPE;
  237. CORg( spInfoBase->AddBlock(IPX_PROTOCOL_SAP,
  238. sizeof(rgi),
  239. (PBYTE) &rgi, 1, TRUE) );
  240. }
  241. m_spInfoBase = spInfoBase.Transfer();
  242. Error:
  243. return hr;
  244. }
  245. /*!--------------------------------------------------------------------------
  246. SapProperties::GetInfoBase
  247. -
  248. Author: KennT
  249. ---------------------------------------------------------------------------*/
  250. HRESULT SapProperties::GetInfoBase(IInfoBase **ppGlobalInfo)
  251. {
  252. *ppGlobalInfo = m_spInfoBase;
  253. if (*ppGlobalInfo)
  254. (*ppGlobalInfo)->AddRef();
  255. return hrOK;
  256. }
  257. /*---------------------------------------------------------------------------
  258. SapInterfacePageGeneral
  259. ---------------------------------------------------------------------------*/
  260. BEGIN_MESSAGE_MAP(SapInterfacePageGeneral, RtrPropertyPage)
  261. //{{AFX_MSG_MAP(SapInterfacePageGeneral)
  262. ON_BN_CLICKED(IDC_SIG_BTN_ADMIN_STATE, OnButtonClicked)
  263. ON_BN_CLICKED(IDC_SIG_BTN_ADVERTISE_SERVICES, OnButtonClicked)
  264. ON_BN_CLICKED(IDC_SIG_BTN_ACCEPT_SERVICE_ADS, OnButtonClicked)
  265. ON_BN_CLICKED(IDC_SIG_BTN_REPLY_GNS_REQUESTS, OnButtonClicked)
  266. ON_BN_CLICKED(IDC_SIG_BTN_UPDATE_MODE_STANDARD, OnUpdateButtonClicked)
  267. ON_BN_CLICKED(IDC_SIG_BTN_UPDATE_MODE_NONE, OnUpdateButtonClicked)
  268. ON_BN_CLICKED(IDC_SIG_BTN_UPDATE_MODE_AUTOSTATIC, OnUpdateButtonClicked)
  269. ON_BN_CLICKED(IDC_SIG_BTN_INPUT_FILTERS, OnInputFilter)
  270. ON_BN_CLICKED(IDC_SIG_BTN_OUTPUT_FILTERS, OnOutputFilter)
  271. ON_EN_CHANGE(IDC_SIG_EDIT_INTERVAL, OnChangeEdit)
  272. ON_EN_CHANGE(IDC_SIG_EDIT_MULTIPLIER, OnChangeEdit)
  273. //}}AFX_MSG_MAP
  274. END_MESSAGE_MAP()
  275. void SapInterfacePageGeneral::DoDataExchange(CDataExchange *pDX)
  276. {
  277. RtrPropertyPage::DoDataExchange(pDX);
  278. //{{AFX_DATA_MAP(SapInterfacePageGeneral)
  279. DDX_Control(pDX, IDC_SIG_SPIN_INTERVAL, m_spinInterval);
  280. DDX_Control(pDX, IDC_SIG_SPIN_MULTIPLIER, m_spinMultiplier);
  281. //}}AFX_DATA_MAP
  282. }
  283. /*!--------------------------------------------------------------------------
  284. SapInterfacePageGeneral::Init
  285. -
  286. Author: KennT
  287. ---------------------------------------------------------------------------*/
  288. HRESULT SapInterfacePageGeneral::Init(SapInterfaceProperties *pPropSheet,
  289. IInterfaceInfo *pIf)
  290. {
  291. m_pSapIfPropSheet = pPropSheet;
  292. m_spIf.Set(pIf);
  293. return hrOK;
  294. }
  295. /*!--------------------------------------------------------------------------
  296. SapInterfacePageGeneral::OnInitDialog
  297. -
  298. Author: KennT
  299. ---------------------------------------------------------------------------*/
  300. BOOL SapInterfacePageGeneral::OnInitDialog()
  301. {
  302. HRESULT hr= hrOK;
  303. SPIInfoBase spInfoBase;
  304. SAP_IF_CONFIG* pIfConfig;
  305. int i, count, item;
  306. CString sItem;
  307. RtrPropertyPage::OnInitDialog();
  308. //
  309. // Initialize controls
  310. //
  311. m_spinInterval.SetRange(0, 32767);
  312. m_spinInterval.SetBuddy(GetDlgItem(IDC_SIG_EDIT_INTERVAL));
  313. m_spinMultiplier.SetRange(0, 32767);
  314. m_spinMultiplier.SetBuddy(GetDlgItem(IDC_SIG_EDIT_MULTIPLIER));
  315. //
  316. // Load the existing global-config
  317. //
  318. CORg( m_pSapIfPropSheet->GetInfoBase(&spInfoBase) );
  319. //
  320. // Retrieve the IPSAP block from the global-config
  321. //
  322. CORg( spInfoBase->GetData(IPX_PROTOCOL_SAP, 0, (PBYTE *) &pIfConfig) );
  323. //
  324. // Set the spin-controls
  325. //
  326. m_spinInterval.SetPos(pIfConfig->SapIfInfo.PeriodicUpdateInterval);
  327. m_spinMultiplier.SetPos(pIfConfig->SapIfInfo.AgeIntervalMultiplier);
  328. CheckDlgButton(IDC_SIG_BTN_ADMIN_STATE,
  329. pIfConfig->SapIfInfo.AdminState == ADMIN_STATE_ENABLED);
  330. CheckDlgButton(IDC_SIG_BTN_ADVERTISE_SERVICES,
  331. pIfConfig->SapIfInfo.Supply == ADMIN_STATE_ENABLED);
  332. CheckDlgButton(IDC_SIG_BTN_ACCEPT_SERVICE_ADS,
  333. pIfConfig->SapIfInfo.Listen == ADMIN_STATE_ENABLED);
  334. CheckDlgButton(IDC_SIG_BTN_REPLY_GNS_REQUESTS,
  335. pIfConfig->SapIfInfo.GetNearestServerReply == ADMIN_STATE_ENABLED);
  336. switch (pIfConfig->SapIfInfo.UpdateMode)
  337. {
  338. case IPX_STANDARD_UPDATE:
  339. CheckDlgButton(IDC_SIG_BTN_UPDATE_MODE_STANDARD, TRUE);
  340. break;
  341. case IPX_NO_UPDATE:
  342. CheckDlgButton(IDC_SIG_BTN_UPDATE_MODE_NONE, TRUE);
  343. break;
  344. case IPX_AUTO_STATIC_UPDATE:
  345. CheckDlgButton(IDC_SIG_BTN_UPDATE_MODE_AUTOSTATIC, TRUE);
  346. break;
  347. default:
  348. break;
  349. }
  350. OnUpdateButtonClicked();
  351. // If this is a new interface, we need to force the change
  352. // through if the user hits ok.
  353. SetDirty(m_pSapIfPropSheet->m_bNewInterface ? TRUE : FALSE);
  354. Error:
  355. if (!FHrSucceeded(hr))
  356. Cancel();
  357. return FHrSucceeded(hr) ? TRUE : FALSE;
  358. }
  359. void SapInterfacePageGeneral::OnButtonClicked()
  360. {
  361. SetDirty(TRUE);
  362. SetModified();
  363. }
  364. void SapInterfacePageGeneral::OnUpdateButtonClicked()
  365. {
  366. BOOL fStandard = IsDlgButtonChecked(IDC_SIG_BTN_UPDATE_MODE_STANDARD);
  367. if (fStandard &&
  368. (m_spinInterval.GetPos() == 0) &&
  369. (m_spinMultiplier.GetPos() == 0))
  370. {
  371. m_spinInterval.SetPos(IPX_UPDATE_INTERVAL_DEFVAL);
  372. m_spinMultiplier.SetPos(3);
  373. }
  374. MultiEnableWindow(GetSafeHwnd(),
  375. fStandard,
  376. IDC_SIG_TEXT_INTERVAL,
  377. IDC_SIG_SPIN_INTERVAL,
  378. IDC_SIG_EDIT_INTERVAL,
  379. IDC_SIG_TEXT_MULTIPLIER,
  380. IDC_SIG_SPIN_MULTIPLIER,
  381. IDC_SIG_EDIT_MULTIPLIER,
  382. 0);
  383. SetDirty(TRUE);
  384. SetModified();
  385. }
  386. void SapInterfacePageGeneral::OnChangeEdit()
  387. {
  388. SetDirty(TRUE);
  389. SetModified();
  390. }
  391. void SapInterfacePageGeneral::ShowFilter(BOOL fOutputFilter)
  392. {
  393. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  394. SPIInfoBase spInfoBase;
  395. SAP_IF_CONFIG * pic;
  396. HRESULT hr = hrOK;
  397. m_pSapIfPropSheet->GetInfoBase(&spInfoBase);
  398. CServiceFltDlg dlgFlt (fOutputFilter /* bOutputDlg */, spInfoBase, this);
  399. // Need to grab the Sap IF config struct out of the
  400. // infobase
  401. if (m_spIf)
  402. dlgFlt.m_sIfName = m_spIf->GetTitle();
  403. else
  404. dlgFlt.m_sIfName.LoadString(IDS_IPX_DIAL_IN_CLIENTS);
  405. try {
  406. if (dlgFlt.DoModal () == IDOK)
  407. {
  408. SetDirty(TRUE);
  409. SetModified();
  410. }
  411. }
  412. catch (CException *ex) {
  413. ex->ReportError ();
  414. ex->Delete ();
  415. }
  416. return;
  417. }
  418. void SapInterfacePageGeneral::OnInputFilter()
  419. {
  420. ShowFilter(FALSE);
  421. }
  422. void SapInterfacePageGeneral::OnOutputFilter()
  423. {
  424. ShowFilter(TRUE);
  425. }
  426. /*!--------------------------------------------------------------------------
  427. SapInterfacePageGeneral::OnApply
  428. -
  429. Author: KennT
  430. ---------------------------------------------------------------------------*/
  431. BOOL SapInterfacePageGeneral::OnApply()
  432. {
  433. BOOL fReturn;
  434. HRESULT hr = hrOK;
  435. INT i, item;
  436. SAP_IF_CONFIG * pic;
  437. SPIInfoBase spInfoBase;
  438. if ( m_pSapIfPropSheet->IsCancel() )
  439. {
  440. CancelApply();
  441. return TRUE;
  442. }
  443. m_pSapIfPropSheet->GetInfoBase(&spInfoBase);
  444. CORg( spInfoBase->GetData(IPX_PROTOCOL_SAP, 0, (PBYTE *) &pic) );
  445. // Save the admin state
  446. pic->SapIfInfo.AdminState = IsDlgButtonChecked(IDC_SIG_BTN_ADMIN_STATE) ?
  447. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  448. // Save the advertise SERVICEs
  449. pic->SapIfInfo.Supply = IsDlgButtonChecked(IDC_SIG_BTN_ADVERTISE_SERVICES) ?
  450. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  451. // Save the accept SERVICE ads
  452. pic->SapIfInfo.Listen = IsDlgButtonChecked(IDC_SIG_BTN_ACCEPT_SERVICE_ADS) ?
  453. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  454. // Save the GSNR
  455. pic->SapIfInfo.GetNearestServerReply = IsDlgButtonChecked(IDC_SIG_BTN_REPLY_GNS_REQUESTS) ?
  456. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  457. // Save the update mode
  458. if (IsDlgButtonChecked(IDC_SIG_BTN_UPDATE_MODE_STANDARD))
  459. {
  460. pic->SapIfInfo.UpdateMode = IPX_STANDARD_UPDATE;
  461. }
  462. else if (IsDlgButtonChecked(IDC_SIG_BTN_UPDATE_MODE_NONE))
  463. {
  464. pic->SapIfInfo.UpdateMode = IPX_NO_UPDATE;
  465. }
  466. else
  467. pic->SapIfInfo.UpdateMode = IPX_AUTO_STATIC_UPDATE;
  468. // Save the interval and multiplier
  469. pic->SapIfInfo.PeriodicUpdateInterval = m_spinInterval.GetPos();
  470. pic->SapIfInfo.AgeIntervalMultiplier = m_spinMultiplier.GetPos();
  471. fReturn = RtrPropertyPage::OnApply();
  472. Error:
  473. if (!FHrSucceeded(hr))
  474. fReturn = FALSE;
  475. return fReturn;
  476. }
  477. /*---------------------------------------------------------------------------
  478. SapInterfaceProperties implementation
  479. ---------------------------------------------------------------------------*/
  480. SapInterfaceProperties::SapInterfaceProperties(ITFSNode *pNode,
  481. IComponentData *pComponentData,
  482. ITFSComponentData *pTFSCompData,
  483. LPCTSTR pszSheetName,
  484. CWnd *pParent,
  485. UINT iPage,
  486. BOOL fScopePane)
  487. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  488. pszSheetName, pParent, iPage, fScopePane),
  489. m_pageGeneral(IDD_SAP_INTERFACE_GENERAL_PAGE),
  490. m_bNewInterface(FALSE)
  491. {
  492. m_spNode.Set(pNode);
  493. }
  494. /*!--------------------------------------------------------------------------
  495. SapInterfaceProperties::Init
  496. Initialize the property sheets. The general action here will be
  497. to initialize/add the various pages.
  498. Author: KennT
  499. ---------------------------------------------------------------------------*/
  500. HRESULT SapInterfaceProperties::Init(IInterfaceInfo *pIf,
  501. IRtrMgrInfo *pRm)
  502. {
  503. Assert(pRm);
  504. HRESULT hr = hrOK;
  505. IPXConnection * pIPXConn;
  506. SPITFSNode spParent;
  507. m_spRm.Set(pRm);
  508. m_spIf.Set(pIf);
  509. if (pIf)
  510. CORg( pIf->FindRtrMgrInterface(PID_IPX, &m_spRmIf) );
  511. m_spNode->GetParent(&spParent);
  512. Assert(spParent);
  513. // The pages are embedded members of the class
  514. // do not delete them.
  515. m_bAutoDeletePages = FALSE;
  516. // Do this here, because the init is called in the context
  517. // of the main thread
  518. pIPXConn = GET_SAP_NODEDATA(spParent);
  519. CORg( LoadInfoBase(pIPXConn) );
  520. m_pageGeneral.Init(this, m_spIf);
  521. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  522. Error:
  523. return hr;
  524. }
  525. /*!--------------------------------------------------------------------------
  526. SapInterfaceProperties::SaveSheetData
  527. -
  528. Author: KennT
  529. ---------------------------------------------------------------------------*/
  530. BOOL SapInterfaceProperties::SaveSheetData()
  531. {
  532. Assert(m_spRm);
  533. BaseIPXResultNodeData * pNodeData;
  534. SAP_IF_CONFIG * pic;
  535. SPITFSNodeHandler spHandler;
  536. SPITFSNode spParent;
  537. if (m_spInfoBase)
  538. {
  539. if (m_bClientInfoBase)
  540. {
  541. Assert(m_spRm);
  542. m_spRm->Save(m_spRm->GetMachineName(), 0, 0, NULL,
  543. m_spInfoBase, 0);
  544. }
  545. else
  546. {
  547. Assert(m_spRmIf);
  548. m_spRmIf->Save(m_spIf->GetMachineName(),
  549. NULL, NULL, NULL, m_spInfoBase, 0);
  550. }
  551. }
  552. if (m_bNewInterface)
  553. {
  554. m_spNode->SetVisibilityState(TFS_VIS_SHOW);
  555. m_spNode->Show();
  556. // Windows NT Bugs : 133891, we have added this to the UI
  557. // we no longer consider this a new interface
  558. m_bNewInterface = FALSE;
  559. }
  560. // Force the node to do a resync
  561. m_spNode->GetParent(&spParent);
  562. spParent->GetHandler(&spHandler);
  563. spHandler->OnCommand(spParent, IDS_MENU_SYNC, CCT_RESULT,
  564. NULL, 0);
  565. return TRUE;
  566. }
  567. /*!--------------------------------------------------------------------------
  568. SapInterfaceProperties::CancelSheetData
  569. -
  570. Author: KennT
  571. ---------------------------------------------------------------------------*/
  572. void SapInterfaceProperties::CancelSheetData()
  573. {
  574. if (m_bNewInterface && m_bClientInfoBase)
  575. {
  576. m_spNode->SetVisibilityState(TFS_VIS_DELETE);
  577. m_spRmIf->DeleteRtrMgrProtocolInterface(IPX_PROTOCOL_SAP, TRUE);
  578. }
  579. }
  580. /*!--------------------------------------------------------------------------
  581. SapInterfaceProperties::LoadInfoBase
  582. -
  583. Author: KennT
  584. ---------------------------------------------------------------------------*/
  585. HRESULT SapInterfaceProperties::LoadInfoBase(IPXConnection *pIPXConn)
  586. {
  587. Assert(pIPXConn);
  588. HRESULT hr = hrOK;
  589. HANDLE hTransport = NULL;
  590. LPCOLESTR pszInterfaceId = NULL;
  591. SPIInfoBase spInfoBase;
  592. BYTE * pDefault;
  593. // If configuring the client-interface, load the client-interface info,
  594. // otherwise, retrieve the interface being configured and load
  595. // its info.
  596. // The client interface doesn't have an ID
  597. if (m_spIf)
  598. pszInterfaceId = m_spIf->GetId();
  599. if (StrLenW(pszInterfaceId) == 0)
  600. {
  601. Assert(m_spRm);
  602. // Get the transport handle
  603. CWRg( ::MprConfigTransportGetHandle(pIPXConn->GetConfigHandle(),
  604. PID_IPX,
  605. &hTransport) );
  606. // Load the client interface info
  607. CORg( m_spRm->GetInfoBase(pIPXConn->GetConfigHandle(),
  608. hTransport,
  609. NULL,
  610. &spInfoBase) );
  611. m_bClientInfoBase = TRUE;
  612. }
  613. else
  614. {
  615. Assert(m_spRmIf);
  616. //
  617. // The parameters are all NULL so that we can use the
  618. // default RPC handles.
  619. //
  620. m_spRmIf->GetInfoBase(NULL, NULL, NULL, &spInfoBase);
  621. m_bClientInfoBase = FALSE;
  622. }
  623. if (!spInfoBase)
  624. {
  625. // No info was found for the inteface
  626. // allocate a new InfoBase instead
  627. CORg( CreateInfoBase(&spInfoBase) );
  628. }
  629. //
  630. // Check that there is a block for interface-status in the info,
  631. // and insert the default block if none is found.
  632. //
  633. if (spInfoBase->ProtocolExists(IPX_PROTOCOL_SAP) == hrFalse)
  634. {
  635. SAP_IF_CONFIG ric;
  636. // Setup the defaults for an interface
  637. if (m_spIf &&
  638. (m_spIf->GetInterfaceType() == ROUTER_IF_TYPE_DEDICATED))
  639. pDefault = g_pIpxSapLanInterfaceDefault;
  640. else
  641. pDefault = g_pIpxSapInterfaceDefault;
  642. CORg( spInfoBase->AddBlock(IPX_PROTOCOL_SAP,
  643. sizeof(SAP_IF_CONFIG),
  644. pDefault,
  645. 1 /* count */,
  646. TRUE /* bRemoveFirst */) );
  647. m_bNewInterface = TRUE;
  648. }
  649. m_spInfoBase.Set(spInfoBase);
  650. Error:
  651. return hr;
  652. }
  653. /*!--------------------------------------------------------------------------
  654. SapInterfaceProperties::GetInfoBase
  655. -
  656. Author: KennT
  657. ---------------------------------------------------------------------------*/
  658. HRESULT SapInterfaceProperties::GetInfoBase(IInfoBase **ppGlobalInfo)
  659. {
  660. *ppGlobalInfo = m_spInfoBase;
  661. if (*ppGlobalInfo)
  662. (*ppGlobalInfo)->AddRef();
  663. return hrOK;
  664. }