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.

287 lines
7.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: pglimit.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // pglimit.cpp : implementation file
  11. //
  12. #include "stdafx.h"
  13. #include "acsadmin.h"
  14. #include "acsdata.h"
  15. #include "pggen.h"
  16. #include "pglimit.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CPgSubLimit property page
  24. IMPLEMENT_DYNCREATE(CPgSubLimit, CACSDialog)
  25. CPgSubLimit::CPgSubLimit(CServiceLevelLimitsRecord* pRecord, int *pAvailTypes, CWnd* pParent) : CACSDialog(CPgSubLimit::IDD, pParent)
  26. {
  27. ASSERT(pRecord != NULL && pAvailTypes != NULL);
  28. m_pAvailTypes = pAvailTypes;
  29. m_pLimitsRecord = pRecord;
  30. DataInit();
  31. }
  32. void CPgSubLimit::DataInit()
  33. {
  34. //{{AFX_DATA_INIT(CPgSubLimit)
  35. // unlimit is the default choice
  36. m_nDataRateChoice = 0;
  37. m_nPeakRateChoice = 0;
  38. m_nTTDataRateChoice = 0;
  39. m_nTTPeakDataRateChoice = 0;
  40. m_uDataRate = 0;
  41. m_uPeakRate = 0;
  42. m_uTTDataRate = 0;
  43. m_uTTPeakRate = 0;
  44. m_bFlowDataChanged = FALSE;
  45. m_nServiceType = -1;
  46. //}}AFX_DATA_INIT
  47. }
  48. CPgSubLimit::CPgSubLimit() : CACSDialog(CPgSubLimit::IDD, NULL)
  49. {
  50. DataInit();
  51. }
  52. CPgSubLimit::~CPgSubLimit()
  53. {
  54. }
  55. void CPgSubLimit::DoDataExchange(CDataExchange* pDX)
  56. {
  57. CACSDialog::DoDataExchange(pDX);
  58. //{{AFX_DATA_MAP(CPgSubLimit)
  59. DDX_Control(pDX, IDC_COMBO_SUBNET_LIMIT_TYPES, m_comboTypes);
  60. DDX_Control(pDX, IDC_EDIT_GEN_TT_PEAKRATE, m_editTTPeakRate);
  61. DDX_Control(pDX, IDC_EDIT_GEN_TT_DATARATE, m_editTTDataRate);
  62. DDX_Control(pDX, IDC_EDIT_GEN_PF_PEAKRATE, m_editPeakRate);
  63. DDX_Control(pDX, IDC_EDIT_GEN_PF_DATARATE, m_editDataRate);
  64. DDX_Radio(pDX, IDC_SUBNET_TRAFFIC_DATARATE_UNLIMITED, m_nDataRateChoice);
  65. DDX_Radio(pDX, IDC_SUBNET_TRAFFIC_PEAKRATE_UNLIMITED, m_nPeakRateChoice);
  66. DDX_Radio(pDX, IDC_SUBNET_TRAFFIC_TTDATARATE_UNLIMITED, m_nTTDataRateChoice);
  67. DDX_Radio(pDX, IDC_SUBNET_TRAFFIC_TTPEAKRATE_UNLIMITED, m_nTTPeakDataRateChoice);
  68. //}}AFX_DATA_MAP
  69. DDX_Text(pDX, IDC_EDIT_GEN_PF_DATARATE, m_uDataRate);
  70. if(m_nDataRateChoice == 1)
  71. DDV_MinMaxUInt(pDX, m_uDataRate, 0, 4194300);
  72. DDX_Text(pDX, IDC_EDIT_GEN_PF_PEAKRATE, m_uPeakRate);
  73. if(m_nPeakRateChoice == 1)
  74. DDV_MinMaxUInt(pDX, m_uPeakRate, 0, 4194300);
  75. DDX_Text(pDX, IDC_EDIT_GEN_TT_DATARATE, m_uTTDataRate);
  76. if(m_nTTDataRateChoice == 1)
  77. DDV_MinMaxUInt(pDX, m_uTTDataRate, 0, 4194300);
  78. DDX_Text(pDX, IDC_EDIT_GEN_TT_PEAKRATE, m_uTTPeakRate);
  79. if(m_nTTPeakDataRateChoice == 1)
  80. DDV_MinMaxUInt(pDX, m_uTTPeakRate, 0, 4194300);
  81. }
  82. BEGIN_MESSAGE_MAP(CPgSubLimit, CACSDialog)
  83. //{{AFX_MSG_MAP(CPgSubLimit)
  84. ON_BN_CLICKED(IDC_SUBNET_TRAFFIC_DATARATE_LIMITED, OnSubnetTrafficDatarateLimited)
  85. ON_BN_CLICKED(IDC_SUBNET_TRAFFIC_DATARATE_UNLIMITED, OnSubnetTrafficDatarateUnlimited)
  86. ON_BN_CLICKED(IDC_SUBNET_TRAFFIC_PEAKRATE_LIMITED, OnSubnetTrafficPeakrateLimited)
  87. ON_BN_CLICKED(IDC_SUBNET_TRAFFIC_PEAKRATE_UNLIMITED, OnSubnetTrafficPeakrateUnlimited)
  88. ON_BN_CLICKED(IDC_SUBNET_TRAFFIC_TTDATARATE_LIMITED, OnSubnetTrafficTtdatarateLimited)
  89. ON_BN_CLICKED(IDC_SUBNET_TRAFFIC_TTDATARATE_UNLIMITED, OnSubnetTrafficTtdatarateUnlimited)
  90. ON_BN_CLICKED(IDC_SUBNET_TRAFFIC_TTPEAKRATE_LIMITED, OnSubnetTrafficTtpeakrateLimited)
  91. ON_BN_CLICKED(IDC_SUBNET_TRAFFIC_TTPEAKRATE_UNLIMITED, OnSubnetTrafficTtpeakrateUnlimited)
  92. //}}AFX_MSG_MAP
  93. END_MESSAGE_MAP()
  94. /////////////////////////////////////////////////////////////////////////////
  95. // CPgSubLimit message handlers
  96. BOOL CPgSubLimit::OnInitDialog()
  97. {
  98. CACSDialog::OnInitDialog();
  99. // populate the strings in combo box
  100. int* pTypes = m_pAvailTypes;
  101. CString str;
  102. UINT strId = 0;
  103. if(!pTypes) return FALSE;
  104. while (*pTypes != -1)
  105. {
  106. switch(*pTypes)
  107. {
  108. case ACS_SUBNET_LIMITS_SERVICETYPE_AGGREGATE:
  109. strId = IDS_AGGREGATEPOLICY;
  110. break;
  111. case ACS_SUBNET_LIMITS_SERVICETYPE_GUARANTEEDSERVICE:
  112. strId = IDS_GUARANTEEDSERVICE;
  113. break;
  114. case ACS_SUBNET_LIMITS_SERVICETYPE_CONTROLLEDLOAD:
  115. strId = IDS_CONTROLLEDLOAD;
  116. break;
  117. }
  118. str.LoadString(strId);
  119. int index = m_comboTypes.AddString(str);
  120. if(index != -1)
  121. m_comboTypes.SetItemData(index, *pTypes);
  122. pTypes++;
  123. }
  124. m_comboTypes.SetCurSel(0);
  125. EnableEverything();
  126. // TODO: Add extra initialization here
  127. return TRUE; // return TRUE unless you set the focus to a control
  128. // EXCEPTION: OCX Property Pages should return FALSE
  129. }
  130. void CPgSubLimit::OnSubnetTrafficDatarateLimited()
  131. {
  132. m_editDataRate.EnableWindow(TRUE);
  133. m_bFlowDataChanged = TRUE;
  134. }
  135. void CPgSubLimit::OnSubnetTrafficDatarateUnlimited()
  136. {
  137. m_editDataRate.EnableWindow(FALSE);
  138. m_bFlowDataChanged = TRUE;
  139. }
  140. void CPgSubLimit::OnSubnetTrafficPeakrateLimited()
  141. {
  142. m_editPeakRate.EnableWindow(TRUE);
  143. m_bFlowDataChanged = TRUE;
  144. }
  145. void CPgSubLimit::OnSubnetTrafficPeakrateUnlimited()
  146. {
  147. m_editPeakRate.EnableWindow(FALSE);
  148. m_bFlowDataChanged = TRUE;
  149. }
  150. void CPgSubLimit::OnSubnetTrafficTtdatarateLimited()
  151. {
  152. m_editTTDataRate.EnableWindow(TRUE);
  153. m_bFlowDataChanged = TRUE;
  154. }
  155. void CPgSubLimit::OnSubnetTrafficTtdatarateUnlimited()
  156. {
  157. m_editTTDataRate.EnableWindow(FALSE);
  158. m_bFlowDataChanged = TRUE;
  159. }
  160. void CPgSubLimit::OnSubnetTrafficTtpeakrateLimited()
  161. {
  162. m_editTTPeakRate.EnableWindow(TRUE);
  163. m_bFlowDataChanged = TRUE;
  164. }
  165. void CPgSubLimit::OnSubnetTrafficTtpeakrateUnlimited()
  166. {
  167. m_editTTPeakRate.EnableWindow(FALSE);
  168. m_bFlowDataChanged = TRUE;
  169. }
  170. void CPgSubLimit::EnableEverything()
  171. {
  172. UpdateData();
  173. m_editDataRate.EnableWindow(m_nDataRateChoice);
  174. m_editPeakRate.EnableWindow(m_nPeakRateChoice);
  175. m_editTTDataRate.EnableWindow(m_nTTDataRateChoice);
  176. m_editTTPeakRate.EnableWindow(m_nTTPeakDataRateChoice);
  177. if(m_nServiceType != -1) // being edited
  178. m_comboTypes.EnableWindow(FALSE);
  179. }
  180. void CPgSubLimit::OnOK()
  181. {
  182. // TODO: Add extra validation here
  183. UINT cId = 0;
  184. UINT mId = 0;
  185. if(m_nDataRateChoice && m_nPeakRateChoice && m_uDataRate > m_uPeakRate)
  186. {
  187. cId = IDC_EDIT_GEN_PF_PEAKRATE;
  188. mId = IDS_ERR_PEAKRATE_LESS_RATE;
  189. }
  190. if(!cId && m_nTTDataRateChoice && m_nDataRateChoice && m_uDataRate > m_uTTDataRate)
  191. {
  192. cId = IDC_EDIT_GEN_TT_DATARATE;
  193. mId = IDS_ERR_TOTALRATE_LESS_RATE;
  194. }
  195. #if 0 // 367760 1 a-leeb ACS: Snap-in performin incorrect boundary checking
  196. if(!cId && m_nTTDataRateChoice && m_nPeakRateChoice && m_uPeakRate > m_uTTDataRate)
  197. {
  198. cId = IDC_EDIT_GEN_TT_DATARATE;
  199. mId = IDS_ERR_TOTALRATE_LESS_PEAKRATE;
  200. }
  201. #endif
  202. if(!cId && m_nTTPeakDataRateChoice && m_nPeakRateChoice && m_uPeakRate > m_uTTPeakRate)
  203. {
  204. cId = IDC_EDIT_GEN_TT_PEAKRATE;
  205. mId = IDS_ERR_TOTALPEAK_LESS_PEAK;
  206. }
  207. if(!cId && m_nTTDataRateChoice && m_nTTPeakDataRateChoice && m_uTTDataRate > m_uTTPeakRate)
  208. {
  209. cId = IDC_EDIT_GEN_TT_PEAKRATE;
  210. mId = IDS_ERR_TOTALPEAK_LESS_TOTALRATE;
  211. }
  212. if(cId)
  213. {
  214. CWnd* pWnd = GetDlgItem(cId);
  215. ASSERT(pWnd);
  216. GotoDlgCtrl( pWnd );
  217. AfxMessageBox(mId);
  218. return ;
  219. }
  220. else
  221. {
  222. int index = m_comboTypes.GetCurSel();
  223. if( index != CB_ERR)
  224. {
  225. m_nServiceType = m_comboTypes.GetItemData(index);
  226. }
  227. CACSDialog::OnOK();
  228. }
  229. }