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.

225 lines
6.6 KiB

  1. //-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: D L G R A S. C P P
  7. //
  8. // Contents: Implementation for CTcpRasPage
  9. //
  10. // Notes: CTcpRasPage is for setting PPP/SLIP specific parameters
  11. //
  12. // Author: tongl 10 Apr 1998
  13. //-----------------------------------------------------------------------
  14. #include "pch.h"
  15. #pragma hdrstop
  16. #include "tcpipobj.h"
  17. #include "ncstl.h"
  18. #include "resource.h"
  19. #include "tcpconst.h"
  20. #include "tcputil.h"
  21. #include "dlgras.h"
  22. #include "dlgaddr.h"
  23. //
  24. // CTcpRasPage
  25. //
  26. CTcpRasPage::CTcpRasPage( CTcpAddrPage * pTcpAddrPage,
  27. ADAPTER_INFO * pAdapterDlg,
  28. const DWORD * adwHelpIDs )
  29. {
  30. Assert(pTcpAddrPage);
  31. Assert(pAdapterDlg);
  32. m_pParentDlg = pTcpAddrPage;
  33. m_pAdapterInfo = pAdapterDlg;
  34. m_adwHelpIDs = adwHelpIDs;
  35. m_fModified = FALSE;
  36. }
  37. CTcpRasPage::~CTcpRasPage()
  38. {
  39. }
  40. LRESULT CTcpRasPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled)
  41. {
  42. AssertSz(((CONNECTION_RAS_PPP == m_pParentDlg->m_ConnType)||
  43. (CONNECTION_RAS_SLIP == m_pParentDlg->m_ConnType)||
  44. (CONNECTION_RAS_VPN == m_pParentDlg->m_ConnType)),
  45. "Why bring up the RAS property on a non-RAS connection?");
  46. // Fix bug 381870, If the interface is demand dial, then disable
  47. // the "Use default gateway on the remote network" checkbox
  48. if (m_pAdapterInfo->m_fIsDemandDialInterface)
  49. {
  50. ::EnableWindow(GetDlgItem(IDC_STATIC_REMOTE_GATEWAY), FALSE);
  51. ::EnableWindow(GetDlgItem(IDC_REMOTE_GATEWAY), FALSE);
  52. }
  53. // Set the "Use default gateway on the remote network" checkbox
  54. CheckDlgButton(IDC_REMOTE_GATEWAY, m_pAdapterInfo->m_fUseRemoteGateway);
  55. if (CONNECTION_RAS_PPP == m_pParentDlg->m_ConnType)
  56. {
  57. ::ShowWindow(GetDlgItem(IDC_GRP_SLIP), SW_HIDE);
  58. // if PPP connection, hide "Frame Size" control
  59. ::ShowWindow(GetDlgItem(IDC_CMB_FRAME_SIZE), SW_HIDE);
  60. ::ShowWindow(GetDlgItem(IDC_STATIC_FRAME_SIZE), SW_HIDE);
  61. }
  62. else if (CONNECTION_RAS_VPN == m_pParentDlg->m_ConnType)
  63. {
  64. //if VPN connection, hide the group box and the "Frame Size" control
  65. ::ShowWindow(GetDlgItem(IDC_GRP_PPP), SW_HIDE);
  66. ::ShowWindow(GetDlgItem(IDC_GRP_SLIP), SW_HIDE);
  67. ::ShowWindow(GetDlgItem(IDC_CHK_USE_COMPRESSION), SW_HIDE);
  68. ::ShowWindow(GetDlgItem(IDC_CMB_FRAME_SIZE), SW_HIDE);
  69. ::ShowWindow(GetDlgItem(IDC_STATIC_FRAME_SIZE), SW_HIDE);
  70. }
  71. else
  72. {
  73. ::ShowWindow(GetDlgItem(IDC_GRP_PPP), SW_HIDE);
  74. // initialize the combo box & show current selection
  75. int idx;
  76. idx = (int)SendDlgItemMessage(IDC_CMB_FRAME_SIZE, CB_ADDSTRING, 0,
  77. (LPARAM)(c_szFrameSize1006));
  78. if (idx != CB_ERR)
  79. {
  80. SendDlgItemMessage(IDC_CMB_FRAME_SIZE, CB_SETITEMDATA,
  81. idx, (LPARAM)c_dwFrameSize1006);
  82. if (1006 == m_pParentDlg->m_pAdapterInfo->m_dwFrameSize)
  83. SendDlgItemMessage(IDC_CMB_FRAME_SIZE, CB_SETCURSEL, idx, 0);
  84. }
  85. idx = (int)SendDlgItemMessage(IDC_CMB_FRAME_SIZE, CB_ADDSTRING, 0,
  86. (LPARAM)(c_szFrameSize1500));
  87. if (idx != CB_ERR)
  88. {
  89. SendDlgItemMessage(IDC_CMB_FRAME_SIZE, CB_SETITEMDATA,
  90. idx, (LPARAM)c_dwFrameSize1500);
  91. if (1500 == m_pParentDlg->m_pAdapterInfo->m_dwFrameSize)
  92. {
  93. SendDlgItemMessage(IDC_CMB_FRAME_SIZE, CB_SETCURSEL, idx, 0);
  94. }
  95. }
  96. }
  97. // initialize the checkbox
  98. CheckDlgButton(IDC_CHK_USE_COMPRESSION,
  99. m_pParentDlg->m_pAdapterInfo->m_fUseIPHeaderCompression);
  100. return 0;
  101. }
  102. LRESULT CTcpRasPage::OnContextMenu(UINT uMsg, WPARAM wParam,
  103. LPARAM lParam, BOOL& fHandled)
  104. {
  105. ShowContextHelp(m_hWnd, HELP_CONTEXTMENU, m_adwHelpIDs);
  106. return 0;
  107. }
  108. LRESULT CTcpRasPage::OnHelp(UINT uMsg, WPARAM wParam,
  109. LPARAM lParam, BOOL& fHandled)
  110. {
  111. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  112. Assert(lphi);
  113. if (HELPINFO_WINDOW == lphi->iContextType)
  114. {
  115. ShowContextHelp(static_cast<HWND>(lphi->hItemHandle), HELP_WM_HELP,
  116. m_adwHelpIDs);
  117. }
  118. return 0;
  119. }
  120. // notify handlers for the property page
  121. LRESULT CTcpRasPage::OnKillActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  122. {
  123. return 0;
  124. }
  125. LRESULT CTcpRasPage::OnActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  126. {
  127. return 0;
  128. }
  129. LRESULT CTcpRasPage::OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  130. {
  131. return 0;
  132. }
  133. LRESULT CTcpRasPage::OnApply(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  134. {
  135. BOOL nResult = PSNRET_NOERROR;
  136. // update value in second memory
  137. // Add remote gateway stuff
  138. BOOL fUseRemoteGateway = IsDlgButtonChecked(IDC_REMOTE_GATEWAY);
  139. if (fUseRemoteGateway != m_pAdapterInfo->m_fUseRemoteGateway)
  140. {
  141. m_pAdapterInfo->m_fUseRemoteGateway = fUseRemoteGateway;
  142. PageModified();
  143. }
  144. // header compression
  145. BOOL fUseHeaderCompression = IsDlgButtonChecked(IDC_CHK_USE_COMPRESSION);
  146. if (fUseHeaderCompression != m_pAdapterInfo->m_fUseIPHeaderCompression)
  147. {
  148. m_pAdapterInfo->m_fUseIPHeaderCompression = fUseHeaderCompression;
  149. PageModified();
  150. }
  151. // frame size
  152. if (CONNECTION_RAS_SLIP == m_pParentDlg->m_ConnType)
  153. {
  154. int idx = (int)SendDlgItemMessage(IDC_CMB_FRAME_SIZE, CB_GETCURSEL, 0L, 0L);
  155. if (idx != CB_ERR)
  156. {
  157. DWORD dwFrameSize = (DWORD)SendDlgItemMessage(IDC_CMB_FRAME_SIZE,
  158. CB_GETITEMDATA, idx, 0L);
  159. if ((dwFrameSize != CB_ERR) && (dwFrameSize != m_pAdapterInfo->m_dwFrameSize))
  160. {
  161. PageModified();
  162. m_pAdapterInfo->m_dwFrameSize = dwFrameSize;
  163. }
  164. }
  165. }
  166. if (!IsModified())
  167. {
  168. ::SetWindowLongPtr(m_hWnd, DWLP_MSGRESULT, nResult);
  169. return nResult;
  170. }
  171. // pass the info back to its parent dialog
  172. m_pParentDlg->m_fPropShtOk = TRUE;
  173. if(!m_pParentDlg->m_fPropShtModified)
  174. m_pParentDlg->m_fPropShtModified = IsModified();
  175. // reset status
  176. SetModifiedTo(FALSE); // this page is no longer modified
  177. ::SetWindowLongPtr(m_hWnd, DWLP_MSGRESULT, nResult);
  178. return nResult;
  179. }