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.

821 lines
21 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_SPIN_INTERVAL,
  377. IDC_SIG_EDIT_INTERVAL,
  378. IDC_SIG_SPIN_MULTIPLIER,
  379. IDC_SIG_EDIT_MULTIPLIER,
  380. 0);
  381. SetDirty(TRUE);
  382. SetModified();
  383. }
  384. void SapInterfacePageGeneral::OnChangeEdit()
  385. {
  386. SetDirty(TRUE);
  387. SetModified();
  388. }
  389. void SapInterfacePageGeneral::ShowFilter(BOOL fOutputFilter)
  390. {
  391. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  392. SPIInfoBase spInfoBase;
  393. SAP_IF_CONFIG * pic;
  394. HRESULT hr = hrOK;
  395. m_pSapIfPropSheet->GetInfoBase(&spInfoBase);
  396. CServiceFltDlg dlgFlt (fOutputFilter /* bOutputDlg */, spInfoBase, this);
  397. // Need to grab the Sap IF config struct out of the
  398. // infobase
  399. if (m_spIf)
  400. dlgFlt.m_sIfName = m_spIf->GetTitle();
  401. else
  402. dlgFlt.m_sIfName.LoadString(IDS_IPX_DIAL_IN_CLIENTS);
  403. try {
  404. if (dlgFlt.DoModal () == IDOK)
  405. {
  406. SetDirty(TRUE);
  407. SetModified();
  408. }
  409. }
  410. catch (CException *ex) {
  411. ex->ReportError ();
  412. ex->Delete ();
  413. }
  414. return;
  415. }
  416. void SapInterfacePageGeneral::OnInputFilter()
  417. {
  418. ShowFilter(FALSE);
  419. }
  420. void SapInterfacePageGeneral::OnOutputFilter()
  421. {
  422. ShowFilter(TRUE);
  423. }
  424. /*!--------------------------------------------------------------------------
  425. SapInterfacePageGeneral::OnApply
  426. -
  427. Author: KennT
  428. ---------------------------------------------------------------------------*/
  429. BOOL SapInterfacePageGeneral::OnApply()
  430. {
  431. BOOL fReturn;
  432. HRESULT hr = hrOK;
  433. INT i, item;
  434. SAP_IF_CONFIG * pic;
  435. SPIInfoBase spInfoBase;
  436. if ( m_pSapIfPropSheet->IsCancel() )
  437. {
  438. CancelApply();
  439. return TRUE;
  440. }
  441. m_pSapIfPropSheet->GetInfoBase(&spInfoBase);
  442. CORg( spInfoBase->GetData(IPX_PROTOCOL_SAP, 0, (PBYTE *) &pic) );
  443. // Save the admin state
  444. pic->SapIfInfo.AdminState = IsDlgButtonChecked(IDC_SIG_BTN_ADMIN_STATE) ?
  445. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  446. // Save the advertise SERVICEs
  447. pic->SapIfInfo.Supply = IsDlgButtonChecked(IDC_SIG_BTN_ADVERTISE_SERVICES) ?
  448. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  449. // Save the accept SERVICE ads
  450. pic->SapIfInfo.Listen = IsDlgButtonChecked(IDC_SIG_BTN_ACCEPT_SERVICE_ADS) ?
  451. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  452. // Save the GSNR
  453. pic->SapIfInfo.GetNearestServerReply = IsDlgButtonChecked(IDC_SIG_BTN_REPLY_GNS_REQUESTS) ?
  454. ADMIN_STATE_ENABLED : ADMIN_STATE_DISABLED;
  455. // Save the update mode
  456. if (IsDlgButtonChecked(IDC_SIG_BTN_UPDATE_MODE_STANDARD))
  457. {
  458. pic->SapIfInfo.UpdateMode = IPX_STANDARD_UPDATE;
  459. }
  460. else if (IsDlgButtonChecked(IDC_SIG_BTN_UPDATE_MODE_NONE))
  461. {
  462. pic->SapIfInfo.UpdateMode = IPX_NO_UPDATE;
  463. }
  464. else
  465. pic->SapIfInfo.UpdateMode = IPX_AUTO_STATIC_UPDATE;
  466. // Save the interval and multiplier
  467. pic->SapIfInfo.PeriodicUpdateInterval = m_spinInterval.GetPos();
  468. pic->SapIfInfo.AgeIntervalMultiplier = m_spinMultiplier.GetPos();
  469. fReturn = RtrPropertyPage::OnApply();
  470. Error:
  471. if (!FHrSucceeded(hr))
  472. fReturn = FALSE;
  473. return fReturn;
  474. }
  475. /*---------------------------------------------------------------------------
  476. SapInterfaceProperties implementation
  477. ---------------------------------------------------------------------------*/
  478. SapInterfaceProperties::SapInterfaceProperties(ITFSNode *pNode,
  479. IComponentData *pComponentData,
  480. ITFSComponentData *pTFSCompData,
  481. LPCTSTR pszSheetName,
  482. CWnd *pParent,
  483. UINT iPage,
  484. BOOL fScopePane)
  485. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  486. pszSheetName, pParent, iPage, fScopePane),
  487. m_pageGeneral(IDD_SAP_INTERFACE_GENERAL_PAGE),
  488. m_bNewInterface(FALSE)
  489. {
  490. m_spNode.Set(pNode);
  491. }
  492. /*!--------------------------------------------------------------------------
  493. SapInterfaceProperties::Init
  494. Initialize the property sheets. The general action here will be
  495. to initialize/add the various pages.
  496. Author: KennT
  497. ---------------------------------------------------------------------------*/
  498. HRESULT SapInterfaceProperties::Init(IInterfaceInfo *pIf,
  499. IRtrMgrInfo *pRm)
  500. {
  501. Assert(pRm);
  502. HRESULT hr = hrOK;
  503. IPXConnection * pIPXConn;
  504. SPITFSNode spParent;
  505. m_spRm.Set(pRm);
  506. m_spIf.Set(pIf);
  507. if (pIf)
  508. CORg( pIf->FindRtrMgrInterface(PID_IPX, &m_spRmIf) );
  509. m_spNode->GetParent(&spParent);
  510. Assert(spParent);
  511. // The pages are embedded members of the class
  512. // do not delete them.
  513. m_bAutoDeletePages = FALSE;
  514. // Do this here, because the init is called in the context
  515. // of the main thread
  516. pIPXConn = GET_SAP_NODEDATA(spParent);
  517. CORg( LoadInfoBase(pIPXConn) );
  518. m_pageGeneral.Init(this, m_spIf);
  519. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  520. Error:
  521. return hr;
  522. }
  523. /*!--------------------------------------------------------------------------
  524. SapInterfaceProperties::SaveSheetData
  525. -
  526. Author: KennT
  527. ---------------------------------------------------------------------------*/
  528. BOOL SapInterfaceProperties::SaveSheetData()
  529. {
  530. Assert(m_spRm);
  531. BaseIPXResultNodeData * pNodeData;
  532. SAP_IF_CONFIG * pic;
  533. SPITFSNodeHandler spHandler;
  534. SPITFSNode spParent;
  535. if (m_spInfoBase)
  536. {
  537. if (m_bClientInfoBase)
  538. {
  539. Assert(m_spRm);
  540. m_spRm->Save(m_spRm->GetMachineName(), 0, 0, NULL,
  541. m_spInfoBase, 0);
  542. }
  543. else
  544. {
  545. Assert(m_spRmIf);
  546. m_spRmIf->Save(m_spIf->GetMachineName(),
  547. NULL, NULL, NULL, m_spInfoBase, 0);
  548. }
  549. }
  550. if (m_bNewInterface)
  551. {
  552. m_spNode->SetVisibilityState(TFS_VIS_SHOW);
  553. m_spNode->Show();
  554. // Windows NT Bugs : 133891, we have added this to the UI
  555. // we no longer consider this a new interface
  556. m_bNewInterface = FALSE;
  557. }
  558. // Force the node to do a resync
  559. m_spNode->GetParent(&spParent);
  560. spParent->GetHandler(&spHandler);
  561. spHandler->OnCommand(spParent, IDS_MENU_SYNC, CCT_RESULT,
  562. NULL, 0);
  563. return TRUE;
  564. }
  565. /*!--------------------------------------------------------------------------
  566. SapInterfaceProperties::CancelSheetData
  567. -
  568. Author: KennT
  569. ---------------------------------------------------------------------------*/
  570. void SapInterfaceProperties::CancelSheetData()
  571. {
  572. if (m_bNewInterface && m_bClientInfoBase)
  573. {
  574. m_spNode->SetVisibilityState(TFS_VIS_DELETE);
  575. m_spRmIf->DeleteRtrMgrProtocolInterface(IPX_PROTOCOL_SAP, TRUE);
  576. }
  577. }
  578. /*!--------------------------------------------------------------------------
  579. SapInterfaceProperties::LoadInfoBase
  580. -
  581. Author: KennT
  582. ---------------------------------------------------------------------------*/
  583. HRESULT SapInterfaceProperties::LoadInfoBase(IPXConnection *pIPXConn)
  584. {
  585. Assert(pIPXConn);
  586. HRESULT hr = hrOK;
  587. HANDLE hTransport = NULL;
  588. LPCOLESTR pszInterfaceId = NULL;
  589. SPIInfoBase spInfoBase;
  590. BYTE * pDefault;
  591. // If configuring the client-interface, load the client-interface info,
  592. // otherwise, retrieve the interface being configured and load
  593. // its info.
  594. // The client interface doesn't have an ID
  595. if (m_spIf)
  596. pszInterfaceId = m_spIf->GetId();
  597. if (StrLenW(pszInterfaceId) == 0)
  598. {
  599. Assert(m_spRm);
  600. // Get the transport handle
  601. CWRg( ::MprConfigTransportGetHandle(pIPXConn->GetConfigHandle(),
  602. PID_IPX,
  603. &hTransport) );
  604. // Load the client interface info
  605. CORg( m_spRm->GetInfoBase(pIPXConn->GetConfigHandle(),
  606. hTransport,
  607. NULL,
  608. &spInfoBase) );
  609. m_bClientInfoBase = TRUE;
  610. }
  611. else
  612. {
  613. Assert(m_spRmIf);
  614. //
  615. // The parameters are all NULL so that we can use the
  616. // default RPC handles.
  617. //
  618. m_spRmIf->GetInfoBase(NULL, NULL, NULL, &spInfoBase);
  619. m_bClientInfoBase = FALSE;
  620. }
  621. if (!spInfoBase)
  622. {
  623. // No info was found for the inteface
  624. // allocate a new InfoBase instead
  625. CORg( CreateInfoBase(&spInfoBase) );
  626. }
  627. //
  628. // Check that there is a block for interface-status in the info,
  629. // and insert the default block if none is found.
  630. //
  631. if (spInfoBase->ProtocolExists(IPX_PROTOCOL_SAP) == hrFalse)
  632. {
  633. SAP_IF_CONFIG ric;
  634. // Setup the defaults for an interface
  635. if (m_spIf &&
  636. (m_spIf->GetInterfaceType() == ROUTER_IF_TYPE_DEDICATED))
  637. pDefault = g_pIpxSapLanInterfaceDefault;
  638. else
  639. pDefault = g_pIpxSapInterfaceDefault;
  640. CORg( spInfoBase->AddBlock(IPX_PROTOCOL_SAP,
  641. sizeof(SAP_IF_CONFIG),
  642. pDefault,
  643. 1 /* count */,
  644. TRUE /* bRemoveFirst */) );
  645. m_bNewInterface = TRUE;
  646. }
  647. m_spInfoBase.Set(spInfoBase);
  648. Error:
  649. return hr;
  650. }
  651. /*!--------------------------------------------------------------------------
  652. SapInterfaceProperties::GetInfoBase
  653. -
  654. Author: KennT
  655. ---------------------------------------------------------------------------*/
  656. HRESULT SapInterfaceProperties::GetInfoBase(IInfoBase **ppGlobalInfo)
  657. {
  658. *ppGlobalInfo = m_spInfoBase;
  659. if (*ppGlobalInfo)
  660. (*ppGlobalInfo)->AddRef();
  661. return hrOK;
  662. }