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.

293 lines
10 KiB

  1. //-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: Q O S D L G . C P P
  7. //
  8. // Contents: PVC Qos property pages message handler implementation
  9. //
  10. // Notes:
  11. //
  12. // Author: tongl 1 Mar, 1998
  13. //
  14. //-----------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "auniobj.h"
  18. #include "atmutil.h"
  19. #include "aunidlg.h"
  20. //#include "atmcommon.h"
  21. #include "ncatlui.h"
  22. #include "ncstl.h"
  23. //#include "ncui.h"
  24. const int MAX_QOS_SPEED = 6;
  25. const int MAX_QOS_SIZE = 5;
  26. const int MAX_DATA = 65535;
  27. //
  28. // CPvcQosPage
  29. //
  30. CPvcQosPage::CPvcQosPage(CPVCMainDialog * pParentDlg,
  31. CPvcInfo * pPvcInfo, const DWORD * adwHelpIDs )
  32. {
  33. Assert(pPvcInfo);
  34. Assert(pParentDlg);
  35. m_pParentDlg = pParentDlg;
  36. m_pPvcInfo = pPvcInfo;
  37. m_adwHelpIDs = adwHelpIDs;
  38. }
  39. CPvcQosPage::~CPvcQosPage()
  40. {
  41. }
  42. // Command handlers
  43. LRESULT CPvcQosPage::OnInitDialog(UINT uMsg, WPARAM wParam,
  44. LPARAM lParam, BOOL& bHandled)
  45. {
  46. // set length limit
  47. ::SendMessage(GetDlgItem(IDC_EDT_PVC_TRANS_PEAK), EM_SETLIMITTEXT, MAX_QOS_SPEED, 0);
  48. ::SendMessage(GetDlgItem(IDC_EDT_PVC_TRANS_AVG), EM_SETLIMITTEXT, MAX_QOS_SPEED, 0);
  49. ::SendMessage(GetDlgItem(IDC_EDT_PVC_RECEIVE_PEAK), EM_SETLIMITTEXT, MAX_QOS_SPEED, 0);
  50. ::SendMessage(GetDlgItem(IDC_EDT_PVC_RECEIVE_AVG), EM_SETLIMITTEXT, MAX_QOS_SPEED, 0);
  51. ::SendMessage(GetDlgItem(IDC_EDT_PVC_TRANS_BURST), EM_SETLIMITTEXT, MAX_QOS_SIZE, 0);
  52. ::SendMessage(GetDlgItem(IDC_EDT_PVC_TRANS_MAX_SIZE), EM_SETLIMITTEXT, MAX_QOS_SIZE, 0);
  53. ::SendMessage(GetDlgItem(IDC_EDT_PVC_RECEIVE_BURST), EM_SETLIMITTEXT, MAX_QOS_SIZE, 0);
  54. ::SendMessage(GetDlgItem(IDC_EDT_PVC_RECEIVE_MAX_SIZE), EM_SETLIMITTEXT, MAX_QOS_SIZE, 0);
  55. SetDwordEdtField(m_hWnd, m_pPvcInfo->m_dwTransmitPeakCellRate, IDC_EDT_PVC_TRANS_PEAK);
  56. SetDwordEdtField(m_hWnd, m_pPvcInfo->m_dwTransmitAvgCellRate, IDC_EDT_PVC_TRANS_AVG);
  57. SetDwordEdtField(m_hWnd, m_pPvcInfo->m_dwTransmitByteBurstLength, IDC_EDT_PVC_TRANS_BURST);
  58. SetDwordEdtField(m_hWnd, m_pPvcInfo->m_dwTransmitMaxSduSize, IDC_EDT_PVC_TRANS_MAX_SIZE);
  59. SetQosServiceCategory(m_pPvcInfo->m_dwTransmitServiceCategory, IDC_CMB_PVC_TRANS_SERVICE);
  60. SetDwordEdtField(m_hWnd, m_pPvcInfo->m_dwReceivePeakCellRate, IDC_EDT_PVC_RECEIVE_PEAK);
  61. SetDwordEdtField(m_hWnd, m_pPvcInfo->m_dwReceiveAvgCellRate, IDC_EDT_PVC_RECEIVE_AVG);
  62. SetDwordEdtField(m_hWnd, m_pPvcInfo->m_dwReceiveByteBurstLength, IDC_EDT_PVC_RECEIVE_BURST);
  63. SetDwordEdtField(m_hWnd, m_pPvcInfo->m_dwReceiveMaxSduSize, IDC_EDT_PVC_RECEIVE_MAX_SIZE);
  64. SetQosServiceCategory(m_pPvcInfo->m_dwReceiveServiceCategory, IDC_CMB_PVC_RECEIVE_SERVICE);
  65. // reset the "old" value so we know if anythign has changed
  66. m_pPvcInfo->m_dwOldTransmitPeakCellRate = m_pPvcInfo->m_dwTransmitPeakCellRate;
  67. m_pPvcInfo->m_dwOldTransmitAvgCellRate = m_pPvcInfo->m_dwTransmitAvgCellRate;
  68. m_pPvcInfo->m_dwOldTransmitByteBurstLength = m_pPvcInfo->m_dwTransmitByteBurstLength;
  69. m_pPvcInfo->m_dwOldTransmitMaxSduSize = m_pPvcInfo->m_dwTransmitMaxSduSize;
  70. m_pPvcInfo->m_dwOldTransmitServiceCategory = m_pPvcInfo->m_dwTransmitServiceCategory;
  71. m_pPvcInfo->m_dwOldReceivePeakCellRate = m_pPvcInfo->m_dwReceivePeakCellRate;
  72. m_pPvcInfo->m_dwOldReceiveAvgCellRate = m_pPvcInfo->m_dwReceiveAvgCellRate;
  73. m_pPvcInfo->m_dwOldReceiveByteBurstLength = m_pPvcInfo->m_dwReceiveByteBurstLength;
  74. m_pPvcInfo->m_dwOldReceiveMaxSduSize = m_pPvcInfo->m_dwReceiveMaxSduSize;
  75. m_pPvcInfo->m_dwOldReceiveServiceCategory = m_pPvcInfo->m_dwReceiveServiceCategory;
  76. return 0;
  77. }
  78. void CPvcQosPage::SetQosServiceCategory(ATM_SERVICE_CATEGORY dwServiceType, int nIDDlgItem)
  79. {
  80. // insert the selections
  81. SendDlgItemMessage(nIDDlgItem,
  82. CB_ADDSTRING, 0, (LPARAM)((PWSTR) SzLoadIds(IDS_PVC_CBR)));
  83. SendDlgItemMessage(nIDDlgItem,
  84. CB_ADDSTRING, 0, (LPARAM)((PWSTR) SzLoadIds(IDS_PVC_VBR)));
  85. SendDlgItemMessage(nIDDlgItem,
  86. CB_ADDSTRING, 0, (LPARAM)((PWSTR) SzLoadIds(IDS_PVC_UBR)));
  87. SendDlgItemMessage(nIDDlgItem,
  88. CB_ADDSTRING, 0, (LPARAM)((PWSTR) SzLoadIds(IDS_PVC_ABR)));
  89. // set the current selection
  90. int idx =0;
  91. switch(dwServiceType)
  92. {
  93. case ATM_SERVICE_CATEGORY_CBR:
  94. idx =0;
  95. break;
  96. case ATM_SERVICE_CATEGORY_VBR:
  97. idx =1;
  98. break;
  99. case ATM_SERVICE_CATEGORY_UBR:
  100. idx =2;
  101. break;
  102. case ATM_SERVICE_CATEGORY_ABR:
  103. idx =3;
  104. break;
  105. }
  106. SendDlgItemMessage(nIDDlgItem, CB_SETCURSEL, (LPARAM)(idx), 0);
  107. }
  108. LRESULT CPvcQosPage::OnContextMenu(UINT uMsg, WPARAM wParam,
  109. LPARAM lParam, BOOL& fHandled)
  110. {
  111. ShowContextHelp(m_hWnd, HELP_CONTEXTMENU, m_adwHelpIDs);
  112. return 0;
  113. }
  114. LRESULT CPvcQosPage::OnHelp(UINT uMsg, WPARAM wParam,
  115. LPARAM lParam, BOOL& fHandled)
  116. {
  117. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  118. Assert(lphi);
  119. if (HELPINFO_WINDOW == lphi->iContextType)
  120. {
  121. ShowContextHelp(static_cast<HWND>(lphi->hItemHandle), HELP_WM_HELP,
  122. m_adwHelpIDs);
  123. }
  124. return 0;
  125. }
  126. // notify handlers for the property page
  127. LRESULT CPvcQosPage::OnApply(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  128. {
  129. GetDwordEdtField(m_hWnd, &(m_pPvcInfo->m_dwTransmitPeakCellRate), IDC_EDT_PVC_TRANS_PEAK);
  130. GetDwordEdtField(m_hWnd, &(m_pPvcInfo->m_dwTransmitAvgCellRate), IDC_EDT_PVC_TRANS_AVG);
  131. GetDwordEdtField(m_hWnd, &(m_pPvcInfo->m_dwTransmitByteBurstLength), IDC_EDT_PVC_TRANS_BURST);
  132. GetDwordEdtField(m_hWnd, &(m_pPvcInfo->m_dwTransmitMaxSduSize), IDC_EDT_PVC_TRANS_MAX_SIZE);
  133. GetQosServiceCategory(&(m_pPvcInfo->m_dwTransmitServiceCategory), IDC_CMB_PVC_TRANS_SERVICE);
  134. GetDwordEdtField(m_hWnd, &(m_pPvcInfo->m_dwReceivePeakCellRate), IDC_EDT_PVC_RECEIVE_PEAK);
  135. GetDwordEdtField(m_hWnd, &(m_pPvcInfo->m_dwReceiveAvgCellRate), IDC_EDT_PVC_RECEIVE_AVG);
  136. GetDwordEdtField(m_hWnd, &(m_pPvcInfo->m_dwReceiveByteBurstLength), IDC_EDT_PVC_RECEIVE_BURST);
  137. GetDwordEdtField(m_hWnd, &(m_pPvcInfo->m_dwReceiveMaxSduSize), IDC_EDT_PVC_RECEIVE_MAX_SIZE);
  138. GetQosServiceCategory(&(m_pPvcInfo->m_dwReceiveServiceCategory), IDC_CMB_PVC_RECEIVE_SERVICE);
  139. m_pParentDlg->m_fPropShtOk = TRUE;
  140. // did any qos field change ?
  141. if ((m_pPvcInfo->m_dwTransmitPeakCellRate != m_pPvcInfo->m_dwOldTransmitPeakCellRate) ||
  142. (m_pPvcInfo->m_dwTransmitAvgCellRate != m_pPvcInfo->m_dwOldTransmitAvgCellRate) ||
  143. (m_pPvcInfo->m_dwTransmitByteBurstLength!= m_pPvcInfo->m_dwOldTransmitByteBurstLength) ||
  144. (m_pPvcInfo->m_dwTransmitMaxSduSize != m_pPvcInfo->m_dwOldTransmitMaxSduSize) ||
  145. (m_pPvcInfo->m_dwTransmitServiceCategory!= m_pPvcInfo->m_dwOldTransmitServiceCategory) ||
  146. (m_pPvcInfo->m_dwReceivePeakCellRate != m_pPvcInfo->m_dwOldReceivePeakCellRate) ||
  147. (m_pPvcInfo->m_dwReceiveAvgCellRate != m_pPvcInfo->m_dwOldReceiveAvgCellRate) ||
  148. (m_pPvcInfo->m_dwReceiveByteBurstLength != m_pPvcInfo->m_dwOldReceiveByteBurstLength) ||
  149. (m_pPvcInfo->m_dwReceiveMaxSduSize != m_pPvcInfo->m_dwOldReceiveMaxSduSize) ||
  150. (m_pPvcInfo->m_dwReceiveServiceCategory != m_pPvcInfo->m_dwOldReceiveServiceCategory)
  151. )
  152. m_pParentDlg->m_fPropShtModified = TRUE;
  153. return 0;
  154. }
  155. void CPvcQosPage::GetQosServiceCategory(ATM_SERVICE_CATEGORY * pdwServiceType, int nIDDlgItem)
  156. {
  157. // set the current selection
  158. int idx = (int)SendDlgItemMessage(nIDDlgItem, CB_GETCURSEL, (LPARAM)(0), 0);
  159. if (idx != CB_ERR)
  160. {
  161. switch(idx)
  162. {
  163. case 0:
  164. *pdwServiceType = ATM_SERVICE_CATEGORY_CBR;
  165. break;
  166. case 1:
  167. *pdwServiceType = ATM_SERVICE_CATEGORY_VBR;
  168. break;
  169. case 2:
  170. *pdwServiceType = ATM_SERVICE_CATEGORY_UBR;
  171. break;
  172. case 3:
  173. *pdwServiceType = ATM_SERVICE_CATEGORY_ABR;
  174. break;
  175. }
  176. }
  177. }
  178. LRESULT CPvcQosPage::OnKillActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  179. {
  180. BOOL err = FALSE; // Allow page to lose active status
  181. // (#293160): Max Burst lengths and Max Data Sizes are limited to 65535
  182. // disable all buttons on this dialog
  183. static const int nrgIdc[] = {IDC_EDT_PVC_TRANS_BURST,
  184. IDC_EDT_PVC_TRANS_MAX_SIZE,
  185. IDC_EDT_PVC_RECEIVE_BURST,
  186. IDC_EDT_PVC_RECEIVE_MAX_SIZE
  187. };
  188. int ccid = celems(nrgIdc);
  189. const INT* pId=nrgIdc;
  190. DWORD dwData;
  191. while (ccid--)
  192. {
  193. GetDwordEdtField(m_hWnd, &dwData, *pId);
  194. if ((dwData != FIELD_UNSET) && (dwData > MAX_DATA))
  195. {
  196. // we pop up a message box and set focus to the edit box
  197. NcMsgBox(m_hWnd, IDS_MSFT_UNI_TEXT, IDS_INVALID_QOS_VALUE,
  198. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  199. ::SetFocus(GetDlgItem(*pId));
  200. err = TRUE;
  201. break;
  202. }
  203. pId++;
  204. }
  205. ::SetWindowLongPtr(m_hWnd, DWLP_MSGRESULT, err);
  206. return err;
  207. }
  208. LRESULT CPvcQosPage::OnActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  209. {
  210. return 0;
  211. }
  212. LRESULT CPvcQosPage::OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  213. {
  214. return 0;
  215. }
  216. void SetDwordEdtField(HWND hDlg, DWORD dwData, int nIDDlgItem)
  217. {
  218. if (dwData != FIELD_UNSET)
  219. {
  220. WCHAR szBuf[MAX_PATH];
  221. wsprintfW(szBuf, c_szItoa, dwData);
  222. SetDlgItemText(hDlg, nIDDlgItem, szBuf);
  223. }
  224. }
  225. void GetDwordEdtField(HWND hDlg, DWORD * pdwData, int nIDDlgItem)
  226. {
  227. WCHAR szBuf[MAX_PATH];
  228. GetDlgItemText(hDlg, nIDDlgItem, szBuf, MAX_PATH);
  229. if (*szBuf ==0) // empty string
  230. {
  231. *pdwData = FIELD_UNSET;
  232. }
  233. else
  234. {
  235. *pdwData = _wtoi(szBuf);
  236. }
  237. }