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.

331 lines
8.3 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. pgmulnk.cpp
  7. Definition of CPgMultilink -- property page to edit
  8. profile attributes related to multiple connections
  9. FILE HISTORY:
  10. */
  11. // PgMulnk.cpp : implementation file
  12. //
  13. #include "stdafx.h"
  14. #include "resource.h"
  15. #include "PgMulnk.h"
  16. #include "hlptable.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CPgMultilinkMerge property page
  24. IMPLEMENT_DYNCREATE(CPgMultilinkMerge, CPropertyPage)
  25. CPgMultilinkMerge::CPgMultilinkMerge(CRASProfileMerge* profile)
  26. : CManagedPage(CPgMultilinkMerge::IDD),
  27. m_pProfile(profile)
  28. {
  29. //{{AFX_DATA_INIT(CPgMultilinkMerge)
  30. m_nTime = 0;
  31. m_Unit = -1;
  32. m_bRequireBAP = FALSE;
  33. m_nMultilinkPolicy = -1;
  34. //}}AFX_DATA_INIT
  35. if(m_pProfile->m_dwBapRequired == RAS_BAP_REQUIRE)
  36. m_bRequireBAP = TRUE;
  37. m_nTime = m_pProfile->m_dwBapLineDnTime;
  38. if(!(m_nTime % 60)) // can user min to represent
  39. {
  40. m_nTime /= 60;
  41. m_Unit = 1;
  42. }
  43. else
  44. m_Unit = 0;
  45. if(!(m_pProfile->m_dwAttributeFlags & PABF_msRADIUSPortLimit))
  46. {
  47. m_nMultilinkPolicy = 0; // value not set
  48. }
  49. else if(m_pProfile->m_dwPortLimit == 1)
  50. {
  51. m_nMultilinkPolicy = 1; // multilink not allowed
  52. }
  53. else
  54. {
  55. m_nMultilinkPolicy = 2; // multilink
  56. }
  57. SetHelpTable(g_aHelpIDs_IDD_MULTILINK_MERGE);
  58. m_bInited = false;
  59. }
  60. CPgMultilinkMerge::~CPgMultilinkMerge()
  61. {
  62. }
  63. void CPgMultilinkMerge::DoDataExchange(CDataExchange* pDX)
  64. {
  65. ASSERT(m_pProfile);
  66. CPropertyPage::DoDataExchange(pDX);
  67. //{{AFX_DATA_MAP(CPgMultilinkMerge)
  68. DDX_Control(pDX, IDC_CHECKREQUIREBAP, m_CheckRequireBAP);
  69. DDX_Control(pDX, IDC_EDITTIME, m_EditTime);
  70. DDX_Control(pDX, IDC_EDITMAXPORTS, m_EditPorts);
  71. DDX_Control(pDX, IDC_EDITPERCENT, m_EditPercent);
  72. DDX_Control(pDX, IDC_SPINTIME, m_SpinTime);
  73. DDX_Control(pDX, IDC_SPINPERCENT, m_SpinPercent);
  74. DDX_Control(pDX, IDC_SPINMAXPORTS, m_SpinMaxPorts);
  75. DDX_Control(pDX, IDC_COMBOUNIT, m_CBUnit);
  76. DDX_CBIndex(pDX, IDC_COMBOUNIT, m_Unit);
  77. DDX_Check(pDX, IDC_CHECKREQUIREBAP, m_bRequireBAP);
  78. DDX_Radio(pDX, IDC_RADIO_MULNK_NOTDEFINED, m_nMultilinkPolicy);
  79. DDX_Text(pDX, IDC_EDITTIME, m_nTime);
  80. if(m_nMultilinkPolicy != 1)
  81. DDV_MinMaxUInt(pDX, m_nTime, 1, MAX_TIME);
  82. //}}AFX_DATA_MAP
  83. DDX_Text(pDX, IDC_EDITPERCENT, m_pProfile->m_dwBapLineDnLimit);
  84. if(m_nMultilinkPolicy != 1)
  85. DDV_MinMaxUInt(pDX, m_pProfile->m_dwBapLineDnLimit, 1, 100);
  86. DDX_Text(pDX, IDC_EDITMAXPORTS, m_pProfile->m_dwPortLimit);
  87. if(m_nMultilinkPolicy == 2)
  88. DDV_MinMaxUInt(pDX, m_pProfile->m_dwPortLimit, 2, MAX_PORTLIMIT);
  89. }
  90. BEGIN_MESSAGE_MAP(CPgMultilinkMerge, CPropertyPage)
  91. //{{AFX_MSG_MAP(CPgMultilinkMerge)
  92. ON_EN_CHANGE(IDC_EDITMAXPORTS, OnChangeEditmaxports)
  93. ON_EN_CHANGE(IDC_EDITPERCENT, OnChangeEditpercent)
  94. ON_EN_CHANGE(IDC_EDITTIME, OnChangeEdittime)
  95. ON_WM_HELPINFO()
  96. ON_WM_CONTEXTMENU()
  97. ON_CBN_SELCHANGE(IDC_COMBOUNIT, OnSelchangeCombounit)
  98. ON_BN_CLICKED(IDC_CHECKREQUIREBAP, OnCheckrequirebap)
  99. ON_BN_CLICKED(IDC_RADIO_MULNK_MULTI, OnRadioMulnkMulti)
  100. ON_BN_CLICKED(IDC_RADIO_MULNK_NOTDEFINED, OnRadioMulnkNotdefined)
  101. ON_BN_CLICKED(IDC_RADIO_MULNK_SINGLE, OnRadioMulnkSingle)
  102. //}}AFX_MSG_MAP
  103. END_MESSAGE_MAP()
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CPgMultilinkMerge message handlers
  106. BOOL CPgMultilinkMerge::OnApply()
  107. {
  108. if(!GetModified()) return TRUE;
  109. // # of ports
  110. switch (m_nMultilinkPolicy)
  111. {
  112. case 0: // remove attribute
  113. m_pProfile->m_dwAttributeFlags &= (~PABF_msRADIUSPortLimit);
  114. break;
  115. case 1: // 1
  116. m_pProfile->m_dwAttributeFlags |= PABF_msRADIUSPortLimit;
  117. m_pProfile->m_dwPortLimit = 1;
  118. break;
  119. case 2: // port limits
  120. m_pProfile->m_dwAttributeFlags |= PABF_msRADIUSPortLimit;
  121. break;
  122. };
  123. if(m_nMultilinkPolicy == 1) // single link
  124. // remove all the bap attributes
  125. {
  126. m_pProfile->m_dwAttributeFlags &= ~PABF_msRASBapRequired;
  127. m_pProfile->m_dwAttributeFlags &= ~PABF_msRASBapLinednLimit;
  128. m_pProfile->m_dwAttributeFlags &= ~PABF_msRASBapLinednTime;
  129. }
  130. else
  131. {
  132. m_pProfile->m_dwAttributeFlags |= PABF_msRASBapLinednLimit;
  133. m_pProfile->m_dwAttributeFlags |= PABF_msRASBapLinednTime;
  134. if(m_Unit == 1) // minutes is selected as the unit
  135. m_pProfile->m_dwBapLineDnTime = m_nTime * 60; // change to second
  136. else
  137. m_pProfile->m_dwBapLineDnTime = m_nTime;
  138. if(m_bRequireBAP)
  139. {
  140. m_pProfile->m_dwAttributeFlags |= PABF_msRASBapRequired;
  141. m_pProfile->m_dwBapRequired = RAS_BAP_REQUIRE;
  142. }
  143. else // remove the attribute from the data store
  144. {
  145. m_pProfile->m_dwAttributeFlags &= (~PABF_msRASBapRequired);
  146. m_pProfile->m_dwBapRequired = RAS_DEF_BAPREQUIRED;
  147. }
  148. }
  149. return CManagedPage::OnApply();
  150. }
  151. BOOL CPgMultilinkMerge::OnInitDialog()
  152. {
  153. // populate the units
  154. CString str;
  155. CPropertyPage::OnInitDialog();
  156. str.LoadString(IDS_SEC);
  157. m_CBUnit.InsertString(0, str);
  158. str.LoadString(IDS_MIN);
  159. m_CBUnit.InsertString(1, str);
  160. UpdateData(FALSE);
  161. // set spin range
  162. m_SpinMaxPorts.SetRange(2, MAX_PORTLIMIT);
  163. m_SpinPercent.SetRange(1, MAX_PERCENT);
  164. m_SpinTime.SetRange(1, MAX_TIME);
  165. // settings -- d
  166. EnableSettings();
  167. m_bInited = true;
  168. return TRUE; // return TRUE unless you set the focus to a control
  169. // EXCEPTION: OCX Property Pages should return FALSE
  170. }
  171. void CPgMultilinkMerge::OnChangeEditmaxports()
  172. {
  173. // TODO: If this is a RICHEDIT control, the control will not
  174. // send this notification unless you override the CPropertyPage::OnInitDialog()
  175. // function to send the EM_SETEVENTMASK message to the control
  176. // with the ENM_CHANGE flag ORed into the lParam mask.
  177. if (m_bInited)
  178. {
  179. SetModified();
  180. m_pProfile->m_dwAttributeFlags |= PABF_msRADIUSPortLimit;
  181. };
  182. }
  183. void CPgMultilinkMerge::OnChangeEditpercent()
  184. {
  185. // TODO: If this is a RICHEDIT control, the control will not
  186. // send this notification unless you override the CPropertyPage::OnInitDialog()
  187. // function to send the EM_SETEVENTMASK message to the control
  188. // with the ENM_CHANGE flag ORed into the lParam mask.
  189. // TODO: Add your control notification handler code here
  190. if (m_bInited)
  191. {
  192. SetModified();
  193. m_pProfile->m_dwAttributeFlags |= PABF_msRASBapLinednLimit;
  194. };
  195. }
  196. void CPgMultilinkMerge::OnChangeEdittime()
  197. {
  198. // TODO: If this is a RICHEDIT control, the control will not
  199. // send this notification unless you override the CPropertyPage::OnInitDialog()
  200. // function to send the EM_SETEVENTMASK message to the control
  201. // with the ENM_CHANGE flag ORed into the lParam mask.
  202. // TODO: Add your control notification handler code here
  203. if (m_bInited)
  204. {
  205. SetModified();
  206. m_pProfile->m_dwAttributeFlags |= PABF_msRASBapLinednTime;
  207. };
  208. }
  209. void CPgMultilinkMerge::EnableSettings()
  210. {
  211. EnablePorts();
  212. EnableBAP();
  213. }
  214. void CPgMultilinkMerge::EnableBAP()
  215. {
  216. CButton *pBtn = (CButton*)GetDlgItem(IDC_RADIO_MULNK_SINGLE);
  217. ASSERT(pBtn);
  218. BOOL b = (pBtn->GetCheck() == 0); // only enable when Single is not selected
  219. m_CheckRequireBAP.EnableWindow(b);
  220. // the other BAP info is not affected by the state of the check box
  221. m_EditPercent.EnableWindow(b);
  222. m_SpinPercent.EnableWindow(b);
  223. m_EditTime.EnableWindow(b);
  224. m_SpinTime.EnableWindow(b);
  225. GetDlgItem(IDC_COMBOUNIT)->EnableWindow(b);
  226. }
  227. void CPgMultilinkMerge::EnablePorts()
  228. {
  229. CButton *pBtn = (CButton*)GetDlgItem(IDC_RADIO_MULNK_MULTI);
  230. ASSERT(pBtn);
  231. BOOL b = pBtn->GetCheck();
  232. m_EditPorts.EnableWindow(b);
  233. m_SpinMaxPorts.EnableWindow(b);
  234. }
  235. BOOL CPgMultilinkMerge::OnHelpInfo(HELPINFO* pHelpInfo)
  236. {
  237. return CManagedPage::OnHelpInfo(pHelpInfo);
  238. }
  239. void CPgMultilinkMerge::OnContextMenu(CWnd* pWnd, CPoint point)
  240. {
  241. CManagedPage::OnContextMenu(pWnd, point);
  242. }
  243. void CPgMultilinkMerge::OnSelchangeCombounit()
  244. {
  245. SetModified();
  246. m_pProfile->m_dwAttributeFlags |= PABF_msRASBapLinednTime;
  247. }
  248. void CPgMultilinkMerge::OnCheckrequirebap()
  249. {
  250. SetModified();
  251. }
  252. void CPgMultilinkMerge::OnRadioMulnkMulti()
  253. {
  254. SetModified();
  255. EnablePorts();
  256. EnableBAP();
  257. if(m_pProfile->m_dwPortLimit == 1)
  258. {
  259. m_pProfile->m_dwPortLimit =2;
  260. CString str = _T("2");
  261. m_EditPorts.SetWindowText(str);
  262. }
  263. }
  264. void CPgMultilinkMerge::OnRadioMulnkNotdefined()
  265. {
  266. SetModified();
  267. EnablePorts();
  268. EnableBAP();
  269. }
  270. void CPgMultilinkMerge::OnRadioMulnkSingle()
  271. {
  272. SetModified();
  273. EnablePorts();
  274. EnableBAP();
  275. }