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.

862 lines
19 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. atlkprop.cpp
  7. FILE HISTORY:
  8. */
  9. #include "stdafx.h"
  10. #include "atlkprop.h"
  11. #include "atlkview.h"
  12. #include "globals.h"
  13. BEGIN_MESSAGE_MAP(CATLKGeneralPage, RtrPropertyPage)
  14. //{{AFX_MSG_MAP(CATLKGeneralPage)
  15. ON_BN_CLICKED(IDC_RTR_ATLK_SEEDNETWORK, OnSeedNetwork) // Checkbox
  16. ON_BN_CLICKED(IDC_BTN_ATLK_ZONEADD, OnZoneAdd)
  17. ON_BN_CLICKED(IDC_BTN_ATLK_ZONEREMOVE, OnZoneRemove)
  18. ON_BN_CLICKED(IDC_BTN_ATLK_GETZONES, OnZoneGetZones)
  19. ON_BN_CLICKED(IDC_ATLK_BTN_SET_DEFAULT, OnSetAsDefault)
  20. ON_EN_CHANGE(IDC_RTR_ATLK_FROM, OnRangeLowerChange)
  21. ON_EN_CHANGE(IDC_RTR_ATLK_TO, OnRangeUpperChange)
  22. ON_CBN_SELCHANGE(IDC_RTR_ATLK_LB_DEFZONES, OnSelChangeZones)
  23. // ON_CBN_SELCHANGE(IDC_CMB_ATLK_ZONEDEF, OnSelchangeCmbAtlkZonedef)
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. HRESULT CATLKGeneralPage::Init(CATLKPropertySheet *pPropSheet, CAdapterInfo* pAdapterInfo)
  27. {
  28. m_pAdapterInfo=pAdapterInfo;
  29. m_pATLKPropSheet = pPropSheet;
  30. m_fDynFetch=false;
  31. return hrOK;
  32. }
  33. CATLKGeneralPage::~CATLKGeneralPage()
  34. {
  35. }
  36. void CATLKGeneralPage::DoDataExchange(CDataExchange* pDX)
  37. {
  38. RtrPropertyPage::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CATLKGeneralPage)
  40. // DDX_Control(pDX, IDC_CMB_ATLK_ZONEDEF, m_cmbZoneDef);
  41. DDX_Text(pDX, IDC_RTR_ATLK_DEFAULTZONE_DISPLAY, m_szZoneDef);
  42. DDX_Control(pDX, IDC_RTR_ATLK_FROM, m_RangeLower);
  43. DDX_Text(pDX, IDC_RTR_ATLK_FROM, m_iRangeLower);
  44. DDX_Control(pDX, IDC_RTR_ATLK_TO, m_RangeUpper);
  45. DDX_Text(pDX, IDC_RTR_ATLK_TO, m_iRangeUpper);
  46. DDX_Control(pDX, IDC_RTR_ATLK_LB_DEFZONES, m_zones);
  47. DDX_Control(pDX, IDC_ATLK_SPIN_FROM, m_spinFrom);
  48. DDX_Control(pDX, IDC_ATLK_SPIN_TO, m_spinTo);
  49. //}}AFX_DATA_MAP
  50. }
  51. BOOL CATLKGeneralPage::OnInitDialog()
  52. {
  53. HRESULT hr= hrOK;
  54. DWORD * pdw;
  55. int i;
  56. // check if router is enabled, if not then disable all the controls on the page
  57. if(!IfATLKRoutingEnabled())
  58. EnableChildControls(GetSafeHwnd(), PROPPAGE_CHILD_DISABLE);
  59. Assert(m_pAdapterInfo);
  60. RtrPropertyPage::OnInitDialog();
  61. CheckDlgButton(IDC_RTR_ATLK_SEEDNETWORK, m_pAdapterInfo->m_regInfo.m_dwSeedingNetwork );
  62. if (m_pAdapterInfo->m_regInfo.m_dwSeedingNetwork)
  63. {
  64. TCHAR buf[11];
  65. m_RangeLower.SetWindowText( _ltot(m_pAdapterInfo->m_regInfo.m_dwRangeLower,buf,10) );
  66. m_RangeUpper.SetWindowText( _ltot(m_pAdapterInfo->m_regInfo.m_dwRangeUpper,buf,10) );
  67. }
  68. else
  69. { //non-seeded
  70. TCHAR buf[11];
  71. m_RangeLower.SetWindowText( _ltot(1,buf,10) );
  72. m_RangeUpper.SetWindowText( _ltot(1,buf,10) );
  73. hr = LoadDynForAdapter();
  74. if(!FAILED(hr))
  75. {
  76. m_RangeLower.SetWindowText( _ltot(m_pAdapterInfo->m_dynInfo.m_dwRangeLower,buf,10) );
  77. m_RangeUpper.SetWindowText( _ltot(m_pAdapterInfo->m_dynInfo.m_dwRangeUpper,buf,10) );
  78. }
  79. }
  80. SetZones();
  81. if(IfATLKRoutingEnabled())
  82. EnableSeedCtrls ( m_pAdapterInfo->m_regInfo.m_dwSeedingNetwork!=0 );
  83. m_spinFrom.SetRange(0, 8192);
  84. m_spinTo.SetRange(0, 8192);
  85. m_spinFrom.SetBuddy(GetDlgItem(IDC_RTR_ATLK_FROM));
  86. m_spinTo.SetBuddy(GetDlgItem(IDC_RTR_ATLK_TO));
  87. // disable upper range on local talk
  88. if(m_pAdapterInfo->m_regInfo.m_dwMediaType == MEDIATYPE_LOCALTALK)
  89. m_RangeUpper.EnableWindow(FALSE);
  90. m_dwDefID=GetDefID();
  91. SetDirty(FALSE);
  92. SetModified();
  93. return TRUE;
  94. }
  95. HRESULT CATLKGeneralPage::LoadDynForAdapter(bool fForce/*=false*/)
  96. {
  97. CWaitCursor wait;
  98. HRESULT hr = S_OK;
  99. if (fForce || !m_fDynFetch)
  100. {
  101. if ( !FHrSucceeded(hr = m_pATLKPropSheet->m_atlkEnv.ReloadAdapter(m_pAdapterInfo, true)) )
  102. {
  103. DisplayIdErrorMessage2(NULL, IDS_ERR_ARAP_NOADAPTINFO, hr);
  104. return hr;
  105. }
  106. m_fDynFetch=true;
  107. }
  108. return hr;
  109. }
  110. void CATLKGeneralPage::OnZoneGetZones()
  111. {
  112. CWaitCursor wait;
  113. Assert(m_pATLKPropSheet);
  114. //forced fetch on dynamic zones for this adapter
  115. HRESULT hr = LoadDynForAdapter(true);
  116. if(FAILED(hr))
  117. {
  118. //XX EnableWindow(FALSE);
  119. return;
  120. }
  121. //load the controls with dynamic zones
  122. SetZones(true);
  123. //load new winsock netranges also
  124. TCHAR buf[11];
  125. m_RangeLower.SetWindowText( _ltot(m_pAdapterInfo->m_dynInfo.m_dwRangeLower,buf,10) );
  126. m_RangeUpper.SetWindowText( _ltot(m_pAdapterInfo->m_dynInfo.m_dwRangeUpper,buf,10) );
  127. if (m_pAdapterInfo->m_dynInfo.m_listZones.GetCount()==0)
  128. {
  129. AfxMessageBox(IDS_ATLK_NOZONES);
  130. }
  131. SetDirty(TRUE);
  132. SetModified();
  133. }
  134. void CATLKGeneralPage::OnRangeLowerChange()
  135. {
  136. // update upper range automaticcaly on local talk
  137. if(m_pAdapterInfo->m_regInfo.m_dwMediaType == MEDIATYPE_LOCALTALK)
  138. {
  139. CString str;
  140. m_RangeLower.GetWindowText(str);
  141. m_RangeUpper.SetWindowText(str);
  142. m_RangeUpper.UpdateWindow();
  143. }
  144. SetDirty(TRUE);
  145. SetModified();
  146. }
  147. void CATLKGeneralPage::OnRangeUpperChange()
  148. {
  149. SetDirty(TRUE);
  150. SetModified();
  151. }
  152. void CATLKGeneralPage::OnSetAsDefault()
  153. {
  154. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  155. UpdateData(TRUE);
  156. int i;
  157. if ( (i = m_zones.GetCurSel()) == LB_ERR )
  158. return;
  159. CString sz;
  160. m_zones.GetText(i, sz);
  161. m_szZoneDef = sz;
  162. SetDirty(TRUE);
  163. SetModified();
  164. GetDlgItem(IDC_ATLK_BTN_SET_DEFAULT)->EnableWindow(false);
  165. UpdateData(FALSE);
  166. }
  167. void CATLKGeneralPage::SetZones(bool fForceDyn/*=false*/)
  168. {
  169. POSITION pos;
  170. Assert(m_pAdapterInfo);
  171. HRESULT hr = S_OK;
  172. CString stDefZone;
  173. int iCmb;
  174. UpdateData(TRUE);
  175. Assert(m_zones.GetSafeHwnd());
  176. m_zones.ResetContent();
  177. // m_cmbZoneDef.ResetContent();
  178. CStringList* psl=NULL;
  179. if (fForceDyn || m_pAdapterInfo->m_regInfo.m_dwSeedingNetwork==0)
  180. { //non-seeded or forced uses network zones only
  181. hr = LoadDynForAdapter();
  182. if(FAILED(hr))
  183. {
  184. //XX EnableWindow(FALSE);
  185. goto Error;
  186. }
  187. stDefZone = m_pAdapterInfo->m_dynInfo.m_szDefaultZone;
  188. psl= &(m_pAdapterInfo->m_dynInfo.m_listZones);
  189. }
  190. else
  191. { //seeded uses registry settings
  192. if (m_pAdapterInfo->m_regInfo.m_szDefaultZone.IsEmpty())
  193. {
  194. hr = LoadDynForAdapter();
  195. if(FAILED(hr))
  196. {
  197. //XX EnableWindow(FALSE);
  198. goto Error;
  199. }
  200. stDefZone = m_pAdapterInfo->m_dynInfo.m_szDefaultZone;
  201. }
  202. else
  203. {
  204. stDefZone = m_pAdapterInfo->m_regInfo.m_szDefaultZone;
  205. }
  206. //seed rtr--fetch from reg if present; otherwize get winsock ones.
  207. if (m_pAdapterInfo->m_regInfo.m_listZones.GetCount()>0)
  208. psl= &(m_pAdapterInfo->m_regInfo.m_listZones);
  209. else
  210. {
  211. hr = LoadDynForAdapter();
  212. if(FAILED(hr))
  213. {
  214. //XX EnableWindow(FALSE);
  215. goto Error;
  216. }
  217. psl= &(m_pAdapterInfo->m_dynInfo.m_listZones);
  218. }
  219. }
  220. Assert(psl);
  221. pos = psl->GetHeadPosition();
  222. while ( pos )
  223. {
  224. CString& sz = psl->GetNext(pos);
  225. if ( sz!=_T("") )
  226. {
  227. m_zones.AddString(sz);
  228. // m_cmbZoneDef.AddString((LPCTSTR)sz);
  229. }
  230. }
  231. if ( m_zones.GetCount()>=1 )
  232. {
  233. m_zones.SetCurSel(0);
  234. OnSelChangeZones();
  235. }
  236. // if((iCmb = m_cmbZoneDef.FindStringExact(-1, (LPCTSTR)stDefZone)) != CB_ERR)
  237. // m_cmbZoneDef.SetCurSel( iCmb );
  238. m_szZoneDef = stDefZone;
  239. UpdateData(FALSE);
  240. if(IfATLKRoutingEnabled())
  241. EnableZoneCtrls();
  242. Error:
  243. ;
  244. }
  245. void CATLKGeneralPage::EnableZoneCtrls()
  246. {
  247. bool f= (m_zones.GetCount()>=1);
  248. GetDlgItem(IDC_BTN_ATLK_ZONEREMOVE)->EnableWindow(f);
  249. // Wei Jiang, BUG # 145767
  250. if(!f && (GetFocus() == GetDlgItem(IDC_BTN_ATLK_ZONEREMOVE)))
  251. GetDlgItem(IDC_RTR_ATLK_SEEDNETWORK)->SetFocus();
  252. DWORD i;
  253. if ( (i = m_zones.GetCurSel()) == LB_ERR )
  254. return;
  255. CString sz;
  256. m_zones.GetText(i, sz);
  257. if (sz == m_szZoneDef)
  258. GetDlgItem(IDC_ATLK_BTN_SET_DEFAULT)->EnableWindow(false);
  259. else
  260. GetDlgItem(IDC_ATLK_BTN_SET_DEFAULT)->EnableWindow(true);
  261. }
  262. BOOL CATLKGeneralPage::OnApply()
  263. {
  264. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  265. BOOL fReturn;
  266. HRESULT hr = hrOK;
  267. CString sz;
  268. int iCmb;
  269. Assert(m_pAdapterInfo);
  270. m_pAdapterInfo->m_fModified= !m_pATLKPropSheet->IsCancel();
  271. if ( m_pAdapterInfo->m_fModified )
  272. {
  273. m_pAdapterInfo->m_regInfo.m_dwSeedingNetwork = IsDlgButtonChecked(IDC_RTR_ATLK_SEEDNETWORK);
  274. if ( m_pAdapterInfo->m_regInfo.m_dwSeedingNetwork )
  275. {
  276. sz = m_szZoneDef;
  277. BOOL bDefaultZoneInZoneList = FALSE;
  278. CString szZoneString;
  279. for (int n = 0; n < m_zones.GetCount(); n++)
  280. {
  281. m_zones.GetText(n, szZoneString);
  282. if ( sz.CompareNoCase(szZoneString) == 0 )
  283. {
  284. bDefaultZoneInZoneList = TRUE;
  285. break;
  286. }
  287. }
  288. if ( sz.GetLength()>0 )
  289. {
  290. if (!bDefaultZoneInZoneList)
  291. {
  292. AfxMessageBox(IDS_WRN_ATLK_DELDEFZONE);
  293. return FALSE;
  294. }
  295. m_pAdapterInfo->m_regInfo.m_szDefaultZone=sz;
  296. }
  297. else
  298. {
  299. AfxMessageBox(IDS_WRN_ATLK_SEEDDEFZONE);
  300. return FALSE;
  301. }
  302. if ( !ValidateNetworkRange() )
  303. {
  304. return FALSE;
  305. }
  306. m_RangeLower.GetWindowText(sz);
  307. m_pAdapterInfo->m_regInfo.m_dwRangeLower = _ttol(sz);
  308. m_RangeUpper.GetWindowText(sz);
  309. m_pAdapterInfo->m_regInfo.m_dwRangeUpper = _ttol(sz);
  310. m_pAdapterInfo->m_regInfo.m_listZones.RemoveAll();
  311. for ( int i=0, c=m_zones.GetCount(); i<c ; i++ )
  312. {
  313. m_zones.GetText(i,sz);
  314. m_pAdapterInfo->m_regInfo.m_listZones.AddTail(sz);
  315. }
  316. m_pAdapterInfo->m_regInfo.m_listZones.AddTail( _T("") );
  317. }
  318. else
  319. { //for non-seeded network, remove all seeded values
  320. m_pAdapterInfo->m_regInfo.m_szDefaultZone=_T("");
  321. m_pAdapterInfo->m_regInfo.m_dwRangeLower=0;
  322. m_pAdapterInfo->m_regInfo.m_dwRangeUpper=0;
  323. m_pAdapterInfo->m_regInfo.m_listZones.RemoveAll();
  324. }
  325. }
  326. fReturn = RtrPropertyPage::OnApply();
  327. if ( !FHrSucceeded(hr) )
  328. fReturn = FALSE;
  329. return fReturn;
  330. }
  331. BOOL CATLKGeneralPage::ValidateNetworkRange()
  332. {
  333. CWaitCursor wait;
  334. CString szLower, szUpper;
  335. CATLKEnv::AI iter;
  336. Assert(m_pATLKPropSheet);
  337. Assert(m_pAdapterInfo);
  338. static bool fLoaded=false;
  339. if (!fLoaded)
  340. { //fetch all adapter's dynamic zone & range
  341. if (m_pATLKPropSheet->m_atlkEnv.m_adapterinfolist.size() <= 1)
  342. {
  343. if(FAILED(LoadDynForAdapter()))
  344. {
  345. //XX EnableWindow(FALSE);
  346. return FALSE;
  347. }
  348. }
  349. else
  350. {
  351. m_pATLKPropSheet->m_atlkEnv.GetAdapterInfo(false);
  352. }
  353. fLoaded=true;
  354. }
  355. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  356. CATLKEnv::AL& list = m_pATLKPropSheet->m_atlkEnv.m_adapterinfolist;
  357. m_RangeLower.GetWindowText(szLower);
  358. m_RangeUpper.GetWindowText(szUpper);
  359. DWORD dwValueLower = _ttol(szLower);
  360. DWORD dwValueUpper = _ttol(szUpper);
  361. BOOL bRetVal = TRUE;
  362. if ( (dwValueLower < MIN_RANGE_ALLOWED) || (dwValueLower > MAX_RANGE_ALLOWED) )
  363. {
  364. CString st;
  365. st.Format(IDS_ERR_ARAP_LOWERRANGE, MIN_RANGE_ALLOWED, MAX_RANGE_ALLOWED);
  366. AfxMessageBox((LPCTSTR)st);
  367. m_RangeLower.SetFocus();
  368. m_RangeLower.SetSel(0,-1);
  369. bRetVal = FALSE;
  370. goto END;
  371. }
  372. if ( (dwValueUpper < MIN_RANGE_ALLOWED) || (dwValueUpper > MAX_RANGE_ALLOWED) )
  373. {
  374. CString st;
  375. st.Format(IDS_ERR_ARAP_UPPERRANGE, MIN_RANGE_ALLOWED, MAX_RANGE_ALLOWED);
  376. AfxMessageBox((LPCTSTR)st);
  377. m_RangeUpper.SetFocus();
  378. m_RangeUpper.SetSel(0,-1);
  379. bRetVal = FALSE;
  380. goto END;
  381. }
  382. if ( dwValueLower > dwValueUpper )
  383. {
  384. AfxMessageBox(IDS_ERR_ARAP_RANGE);
  385. m_RangeLower.SetFocus();
  386. m_RangeLower.SetSel(0,-1);
  387. bRetVal = FALSE;
  388. goto END;
  389. }
  390. for ( iter = list.begin();iter != list.end(); iter++ )
  391. {
  392. ATLK_DYN_ADAPTER& adapt =(*iter)->m_dynInfo;
  393. if ( adapt.m_dwRangeLower==0 && adapt.m_dwRangeUpper==0 )
  394. continue;
  395. if ( (*iter)->m_regInfo.m_szAdapter==m_pAdapterInfo->m_regInfo.m_szAdapter )
  396. continue;
  397. if ( (dwValueLower >= adapt.m_dwRangeLower) && (dwValueLower <= adapt.m_dwRangeUpper) )
  398. {
  399. AfxMessageBox(IDS_ERR_ARAP_LOWERRANGE_OVERLAP);
  400. m_RangeLower.SetFocus();
  401. m_RangeLower.SetSel(0,-1);
  402. bRetVal = FALSE;
  403. goto END;
  404. }
  405. if ( (dwValueUpper >= adapt.m_dwRangeLower) && (dwValueUpper <= adapt.m_dwRangeUpper) )
  406. {
  407. AfxMessageBox(IDS_ERR_ARAP_UPPERRANGE_OVERLAP);
  408. m_RangeUpper.SetFocus();
  409. m_RangeUpper.SetSel(0,-1);
  410. bRetVal = FALSE;
  411. goto END;
  412. }
  413. if ( (dwValueLower <= adapt.m_dwRangeLower) && (dwValueUpper >= adapt.m_dwRangeUpper) )
  414. {
  415. AfxMessageBox(IDS_ERR_ARAP_RANGE_OVERLAP);
  416. m_RangeLower.SetFocus();
  417. m_RangeLower.SetSel(0,-1);
  418. bRetVal = FALSE;
  419. goto END;
  420. }
  421. }
  422. END:
  423. return bRetVal;
  424. }
  425. void CATLKGeneralPage::OnSeedNetwork()
  426. {
  427. EnableSeedCtrls(IsDlgButtonChecked(IDC_RTR_ATLK_SEEDNETWORK)!=0);
  428. SetDirty(TRUE);
  429. SetModified();
  430. }
  431. BOOL IsValidZoneName(CString& str)
  432. {
  433. if(str.GetLength() > 31 || str.GetLength() <= 0)
  434. return FALSE;
  435. if(str.FindOneOf(_T("*:=@")) != -1)
  436. return FALSE;
  437. int n = str.GetLength();
  438. while(--n)
  439. {
  440. int c = str.GetAt(n);
  441. if(c >= 128 || !_istprint((wint_t) c))
  442. return FALSE;
  443. }
  444. return TRUE;
  445. }
  446. void CATLKGeneralPage::OnZoneAdd()
  447. {
  448. CEditNewZoneDialog editNewZone(this);
  449. if( editNewZone.DoModal() == IDOK )
  450. {
  451. CString sz;
  452. editNewZone.GetZone(sz);
  453. if( sz.GetLength() <= 0 )
  454. return;
  455. sz.TrimLeft();
  456. sz.TrimRight();
  457. if (!IsValidZoneName(sz))
  458. {
  459. AfxMessageBox(IDS_ERR_ATLK_ZONE_NAME);
  460. return;
  461. }
  462. // Validate if the Zone name is valid
  463. if( LB_ERR != m_zones.FindStringExact(-1, (LPCTSTR)sz))
  464. {
  465. CString stDupZoneMsg;
  466. stDupZoneMsg.Format(IDS_ERR_ATLK_DUP_ZONE_NAME, (LPCTSTR)sz);
  467. AfxMessageBox(stDupZoneMsg);
  468. return;
  469. }
  470. m_zones.AddString(sz);
  471. m_zones.SelectString(-1,sz);
  472. // m_cmbZoneDef.AddString((LPCTSTR)sz);
  473. if (m_szZoneDef.IsEmpty())
  474. OnSetAsDefault();
  475. EnableZoneCtrls();
  476. SetDirty(TRUE);
  477. SetModified();
  478. }
  479. }
  480. void CATLKGeneralPage::OnZoneRemove()
  481. {
  482. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  483. int i;
  484. if ( (i = m_zones.GetCurSel()) == LB_ERR )
  485. return;
  486. CString sz;
  487. m_zones.GetText(i, sz);
  488. m_zones.DeleteString(i);
  489. EnableZoneCtrls();
  490. if ( sz.CompareNoCase(m_szZoneDef)==0 )
  491. {
  492. m_szZoneDef = _T("");
  493. AfxMessageBox(IDS_WRN_ATLK_DELDEFZONE);
  494. }
  495. m_zones.SetCurSel( (m_zones.GetCount() == i) ? i-1 : i );
  496. OnSelChangeZones();
  497. SetDirty(TRUE);
  498. SetModified();
  499. }
  500. void CATLKGeneralPage::OnSelChangeZones()
  501. {
  502. int i;
  503. if ( (i = m_zones.GetCurSel()) == LB_ERR )
  504. return;
  505. CString sz;
  506. m_zones.GetText(i, sz);
  507. if (sz == m_szZoneDef)
  508. GetDlgItem(IDC_ATLK_BTN_SET_DEFAULT)->EnableWindow(false);
  509. else
  510. if(IfATLKRoutingEnabled())
  511. GetDlgItem(IDC_ATLK_BTN_SET_DEFAULT)->EnableWindow(true);
  512. SetDirty(TRUE);
  513. SetModified();
  514. }
  515. void CATLKGeneralPage::OnSelchangeCmbAtlkZonedef()
  516. {
  517. SetDirty(TRUE);
  518. SetModified();
  519. }
  520. void CATLKGeneralPage::EnableSeedCtrls(bool fEnable)
  521. {
  522. GetDlgItem(IDC_RTR_ATLK_S_RANGE)->EnableWindow(fEnable);
  523. GetDlgItem(IDC_RTR_ATLK_S_LOWER)->EnableWindow(fEnable);
  524. GetDlgItem(IDC_RTR_ATLK_DEFAULTZONE_PROMPT)->EnableWindow(fEnable);
  525. GetDlgItem(IDC_RTR_ATLK_DEFAULTZONE_DISPLAY)->EnableWindow(fEnable);
  526. GetDlgItem(IDC_ATLK_SPIN_FROM)->EnableWindow(fEnable);
  527. GetDlgItem(IDC_ATLK_SPIN_TO)->EnableWindow(fEnable);
  528. m_RangeLower.EnableWindow(fEnable);
  529. GetDlgItem(IDC_RTR_ATLK_S_UPPER)->EnableWindow(fEnable);
  530. m_RangeUpper.EnableWindow(fEnable);
  531. // Windows NT Bug : 354771
  532. // disable upper range on local talk
  533. if(m_pAdapterInfo->m_regInfo.m_dwMediaType == MEDIATYPE_LOCALTALK)
  534. m_RangeUpper.EnableWindow(FALSE);
  535. m_zones.EnableWindow(fEnable);
  536. // m_cmbZoneDef.EnableWindow(fEnable);
  537. GetDlgItem(IDC_ATLK_BTN_SET_DEFAULT)->EnableWindow(fEnable);
  538. GetDlgItem(IDC_RTR_ATLK_S_DEF)->EnableWindow(fEnable);
  539. GetDlgItem(IDC_BTN_ATLK_ZONEADD)->EnableWindow(fEnable);
  540. GetDlgItem(IDC_BTN_ATLK_GETZONES)->EnableWindow(fEnable);
  541. if ( fEnable )
  542. EnableZoneCtrls();
  543. else
  544. {
  545. GetDlgItem(IDC_BTN_ATLK_ZONEREMOVE)->EnableWindow(false);
  546. }
  547. }
  548. //***********************************************************************
  549. // Apple talk property sheet
  550. //***********************************************************************
  551. CATLKPropertySheet::CATLKPropertySheet(ITFSNode *pNode,
  552. IComponentData *pComponentData,
  553. ITFSComponentData *pTFSCompData,
  554. LPCTSTR pszSheetName,
  555. CWnd *pParent,
  556. UINT iPage,
  557. BOOL fScopePane)
  558. : RtrPropertySheet(pNode, pComponentData, pTFSCompData,
  559. pszSheetName, pParent, iPage, fScopePane),
  560. m_pageGeneral(IDD_RTR_ATLK)
  561. {
  562. m_spNode.Set(pNode);
  563. }
  564. /*!--------------------------------------------------------------------------
  565. CATLKPropertySheet::Init
  566. Initialize the property sheets. The general action here will be
  567. to initialize/add the various pages.
  568. Author: KennT
  569. ---------------------------------------------------------------------------*/
  570. HRESULT CATLKPropertySheet::Init(IInterfaceInfo *pIf)
  571. {
  572. Assert(pIf);
  573. HRESULT hr = hrOK;
  574. m_spIf.Set(pIf);
  575. // The pages are embedded members of the class
  576. // do not delete them.
  577. m_bAutoDeletePages = FALSE;
  578. //winsock on adapter only
  579. m_atlkEnv.SetFlags(CATLKEnv::ATLK_ONLY_ONADAPTER);
  580. //load up container of adapters names
  581. m_atlkEnv.FetchRegInit();
  582. //find this adapterinfo in the container
  583. CString sz=m_spIf->GetId();
  584. CAdapterInfo* p = m_atlkEnv.FindAdapter(sz);
  585. Assert(p);
  586. if (p==NULL)
  587. {
  588. TRACE1("The adapter GUID %s was not found in appletalk\\parameters\\adapters key", sz);
  589. goto Error;
  590. }
  591. //add general appletalk page
  592. m_pageGeneral.Init(this, p);
  593. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  594. Error:
  595. return hr;
  596. }
  597. /*!--------------------------------------------------------------------------
  598. CATLKPropertySheet::SaveSheetData
  599. -
  600. Author: KennT
  601. ---------------------------------------------------------------------------*/
  602. BOOL CATLKPropertySheet::SaveSheetData()
  603. {
  604. Assert(m_spIf);
  605. HRESULT hr = m_atlkEnv.SetAdapterInfo();
  606. if ( FHrFailed(hr) )
  607. {
  608. DisplayIdErrorMessage2(NULL, IDS_ERR_ATLK_CONFIG, hr);
  609. }
  610. SPITFSNode spParent;
  611. SPITFSNodeHandler spHandler;
  612. m_spNode->GetParent(&spParent);
  613. spParent->GetHandler(&spHandler);
  614. spHandler->OnCommand(spParent,
  615. IDS_MENU_REFRESH,
  616. CCT_RESULT, NULL, 0);
  617. return TRUE; return TRUE;
  618. }
  619. /////////////////////////////////////////////////////////////////////////////
  620. // CEditNewZoneDialog dialog
  621. //
  622. // Author: NSun
  623. CEditNewZoneDialog::CEditNewZoneDialog(CWnd* pParent /*=NULL*/)
  624. : CDialog(CEditNewZoneDialog::IDD, pParent)
  625. {
  626. //{{AFX_DATA_INIT(CEditNewZoneDialog)
  627. // NOTE: the ClassWizard will add member initialization here
  628. //}}AFX_DATA_INIT
  629. }
  630. void CEditNewZoneDialog::DoDataExchange(CDataExchange* pDX)
  631. {
  632. CDialog::DoDataExchange(pDX);
  633. //{{AFX_DATA_MAP(CEditNewZoneDialog)
  634. DDX_Control(pDX, IDC_RTR_ATLK_NEWZONE_EDIT, m_editZone);
  635. //}}AFX_DATA_MAP
  636. }
  637. BEGIN_MESSAGE_MAP(CEditNewZoneDialog, CDialog)
  638. //{{AFX_MSG_MAP(CEditNewZoneDialog)
  639. // NOTE: the ClassWizard will add message map macros here
  640. //}}AFX_MSG_MAP
  641. END_MESSAGE_MAP()
  642. /*!----------------------------------------------------------------------------
  643. CEditNewZoneDialog::GetZone
  644. -
  645. Author: NSun
  646. ------------------------------------------------------------------------------*/
  647. void CEditNewZoneDialog::GetZone(OUT CString& stZone)
  648. {
  649. stZone = m_stZone;
  650. }
  651. BOOL CEditNewZoneDialog::OnInitDialog()
  652. {
  653. CDialog::OnInitDialog();
  654. m_editZone.SetFocus();
  655. return FALSE;
  656. }
  657. void CEditNewZoneDialog::OnOK()
  658. {
  659. CString st;
  660. m_editZone.GetWindowText(st);
  661. if(st.IsEmpty())
  662. {
  663. AfxMessageBox(IDS_ERR_ATLK_EMPTY_ZONE);
  664. return;
  665. }
  666. m_stZone = st;
  667. CDialog::OnOK();
  668. }
  669. void CEditNewZoneDialog::OnCancel()
  670. {
  671. CDialog::OnCancel();
  672. }