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.

206 lines
5.5 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. pgtunnel.h
  7. Definition of CPgNetworking -- property page to edit
  8. profile attributes related to tunneling
  9. FILE HISTORY:
  10. */
  11. // PgTunnel.cpp : implementation file
  12. //
  13. #include "stdafx.h"
  14. #include "rasuser.h"
  15. #include "resource.h"
  16. #include "PgTunnel.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CPgTunneling property page
  24. #ifdef _TUNNEL
  25. IMPLEMENT_DYNCREATE(CPgTunneling, CPropertyPage)
  26. CPgTunneling::CPgTunneling(CRASProfile* profile)
  27. : CManagedPage(CPgTunneling::IDD),
  28. m_pProfile(profile)
  29. {
  30. //{{AFX_DATA_INIT(CPgTunneling)
  31. m_bTunnel = FALSE;
  32. //}}AFX_DATA_INIT
  33. m_pTunnelTypeBox = new CStrBox<CComboBox>(this, IDC_COMBOTYPE, CRASProfile::m_TunnelTypes);
  34. m_pTunnelMediumTypeBox = new CStrBox<CComboBox>(this, IDC_COMBOMEDIA, CRASProfile::m_TunnelMediumTypes);
  35. m_bTunnel = (m_pProfile->m_dwTunnelType != 0);
  36. SetHelpTable(IDD_TUNNELING_HelpTable);
  37. m_bInited = false;
  38. }
  39. CPgTunneling::~CPgTunneling()
  40. {
  41. delete m_pTunnelTypeBox;
  42. delete m_pTunnelMediumTypeBox;
  43. }
  44. void CPgTunneling::DoDataExchange(CDataExchange* pDX)
  45. {
  46. ASSERT(m_pProfile);
  47. CPropertyPage::DoDataExchange(pDX);
  48. //{{AFX_DATA_MAP(CPgTunneling)
  49. DDX_Check(pDX, IDC_CHECKREQUIREVPN, m_bTunnel);
  50. //}}AFX_DATA_MAP
  51. DDX_Text(pDX, IDC_EDITPRIVATEGROUPID, m_pProfile->m_strTunnelPrivateGroupId);
  52. DDX_Text(pDX, IDC_EDITSERVER, m_pProfile->m_strTunnelServerEndpoint);
  53. }
  54. BEGIN_MESSAGE_MAP(CPgTunneling, CPropertyPage)
  55. //{{AFX_MSG_MAP(CPgTunneling)
  56. ON_BN_CLICKED(IDC_CHECKREQUIREVPN, OnCheckrequirevpn)
  57. ON_CBN_SELCHANGE(IDC_COMBOMEDIA, OnSelchangeCombomedia)
  58. ON_CBN_SELCHANGE(IDC_COMBOTYPE, OnSelchangeCombotype)
  59. ON_EN_CHANGE(IDC_EDITSERVER, OnChangeEditserver)
  60. ON_EN_CHANGE(IDC_EDITPRIVATEGROUPID, OnChangeEditprivategroupid)
  61. ON_WM_HELPINFO()
  62. ON_WM_CONTEXTMENU()
  63. //}}AFX_MSG_MAP
  64. END_MESSAGE_MAP()
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CPgTunneling message handlers
  67. BOOL CPgTunneling::OnInitDialog()
  68. {
  69. CPropertyPage::OnInitDialog();
  70. // tunnel type box
  71. m_pTunnelTypeBox->Fill();
  72. if(m_pProfile->m_dwTunnelType)
  73. {
  74. for(int i = 0; i < CRASProfile::m_TunnelTypeIds.GetSize(); i++)
  75. {
  76. if(CRASProfile::m_TunnelTypeIds[i] == (int)m_pProfile->m_dwTunnelType)
  77. break;
  78. }
  79. if(i < CRASProfile::m_TunnelTypeIds.GetSize())
  80. m_pTunnelTypeBox->Select(i);
  81. }
  82. // tunnel medium type box
  83. m_pTunnelMediumTypeBox->Fill();
  84. if(m_pProfile->m_dwTunnelMediumType)
  85. {
  86. for(int i = 0; i < CRASProfile::m_TunnelMediumTypeIds.GetSize(); i++)
  87. {
  88. if(CRASProfile::m_TunnelMediumTypeIds[i] == (int)m_pProfile->m_dwTunnelMediumType)
  89. break;
  90. }
  91. if(i < CRASProfile::m_TunnelMediumTypeIds.GetSize())
  92. m_pTunnelMediumTypeBox->Select(i);
  93. }
  94. EnableSettings();
  95. m_bInited = true;
  96. return TRUE; // return TRUE unless you set the focus to a control
  97. // EXCEPTION: OCX Property Pages should return FALSE
  98. }
  99. void CPgTunneling::OnCheckrequirevpn()
  100. {
  101. EnableSettings();
  102. if(m_bInited) SetModified();
  103. }
  104. void CPgTunneling::OnSelchangeCombomedia()
  105. {
  106. if(m_bInited) SetModified();
  107. }
  108. void CPgTunneling::OnSelchangeCombotype()
  109. {
  110. if(m_bInited) SetModified();
  111. }
  112. void CPgTunneling::OnChangeEditserver()
  113. {
  114. // TODO: If this is a RICHEDIT control, the control will not
  115. // send this notification unless you override the CPropertyPage::OnInitDialog()
  116. // function to send the EM_SETEVENTMASK message to the control
  117. // with the ENM_CHANGE flag ORed into the lParam mask.
  118. if(m_bInited) SetModified();
  119. }
  120. void CPgTunneling::OnChangeEditprivategroupid()
  121. {
  122. // TODO: If this is a RICHEDIT control, the control will not
  123. // send this notification unless you override the CPropertyPage::OnInitDialog()
  124. // function to send the EM_SETEVENTMASK message to the control
  125. // with the ENM_CHANGE flag ORed into the lParam mask.
  126. if(m_bInited) SetModified();
  127. }
  128. void CPgTunneling::EnableSettings()
  129. {
  130. BOOL b = ((CButton*)GetDlgItem(IDC_CHECKREQUIREVPN))->GetCheck();
  131. m_pTunnelTypeBox->Enable(b);
  132. m_pTunnelMediumTypeBox->Enable(b);
  133. GetDlgItem(IDC_EDITSERVER)->EnableWindow(b);
  134. GetDlgItem(IDC_EDITPRIVATEGROUPID)->EnableWindow(b);
  135. }
  136. BOOL CPgTunneling::OnApply()
  137. {
  138. if (!GetModified()) return TRUE;
  139. if(!m_bTunnel) // no tunel is defined
  140. {
  141. m_pProfile->m_dwTunnelMediumType = 0;
  142. m_pProfile->m_dwTunnelType = 0;
  143. m_pProfile->m_strTunnelPrivateGroupId.Empty();
  144. m_pProfile->m_strTunnelServerEndpoint.Empty();
  145. }
  146. else // get tunnel type and media type
  147. {
  148. int i = m_pTunnelTypeBox->GetSelected();
  149. if(i != -1)
  150. m_pProfile->m_dwTunnelType = CRASProfile::m_TunnelTypeIds[i];
  151. else
  152. m_pProfile->m_dwTunnelType = 0;
  153. i = m_pTunnelMediumTypeBox->GetSelected();
  154. if(i != -1)
  155. m_pProfile->m_dwTunnelMediumType = CRASProfile::m_TunnelMediumTypeIds[i];
  156. else
  157. m_pProfile->m_dwTunnelMediumType = 0;
  158. }
  159. return CManagedPage::OnApply();
  160. }
  161. BOOL CPgTunneling::OnHelpInfo(HELPINFO* pHelpInfo)
  162. {
  163. return CManagedPage::OnHelpInfo(pHelpInfo);
  164. }
  165. void CPgTunneling::OnContextMenu(CWnd* pWnd, CPoint point)
  166. {
  167. CManagedPage::OnContextMenu(pWnd, point);
  168. }
  169. #endif