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.

289 lines
8.2 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2001.
  5. //
  6. // File: ssidpage.cpp
  7. //
  8. // Contents: WiF Policy Snapin : General Properties of each PS.(Non 8021x)
  9. //
  10. //
  11. // History: TaroonM
  12. // 10/30/01
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "stdafx.h"
  16. #include "sprpage.h"
  17. #include "ssidpage.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CSSIDPage property page
  25. IMPLEMENT_DYNCREATE(CSSIDPage, CWirelessBasePage)
  26. //CSSIDPage::CSSIDPage() : CWirelessBasePage(CSSIDPage::IDD)
  27. CSSIDPage::CSSIDPage(UINT nIDTemplate) : CWirelessBasePage(nIDTemplate)
  28. {
  29. //{{AFX_DATA_INIT(CSSIDPage)
  30. // NOTE: the ClassWizard will add member initialization here
  31. //}}AFX_DATA_INIT
  32. m_dlgIDD = nIDTemplate;
  33. m_bNameChanged = FALSE;
  34. m_bNetworkTypeChanged = FALSE;
  35. m_bPageInitialized = FALSE;
  36. m_dwWepEnabled = TRUE;
  37. m_dwNetworkAuthentication = FALSE;
  38. m_dwAutomaticKeyProvision = FALSE;
  39. m_dwNetworkType = FALSE;
  40. m_pWirelessPolicyData = NULL;
  41. m_bReadOnly = FALSE;
  42. }
  43. CSSIDPage::~CSSIDPage()
  44. {
  45. }
  46. void CSSIDPage::DoDataExchange(CDataExchange* pDX)
  47. {
  48. CWirelessBasePage::DoDataExchange(pDX);
  49. //{{AFX_DATA_MAP(CSSIDPage)
  50. DDX_Control(pDX, IDC_SSID_NAME, m_edSSID);
  51. DDX_Control(pDX, IDC_PS_DESCRIPTION, m_edPSDescription);
  52. DDX_Check(pDX, IDC_WEP_ENABLED, m_dwWepEnabled);
  53. DDX_Check(pDX, IDC_NETWORK_AUTHENTICATION, m_dwNetworkAuthentication);
  54. DDX_Check(pDX, IDC_AUTOMATIC_KEY_PROVISION, m_dwAutomaticKeyProvision);
  55. DDX_Check(pDX, IDC_NETWORK_TYPE, m_dwNetworkType);
  56. //}}AFX_DATA_MAP
  57. }
  58. BEGIN_MESSAGE_MAP(CSSIDPage, CWirelessBasePage)
  59. //{{AFX_MSG_MAP(CSSIDPage)
  60. ON_WM_HELPINFO()
  61. ON_EN_CHANGE(IDC_SSID_NAME, OnChangedSSID)
  62. ON_EN_CHANGE(IDC_PS_DESCRIPTION, OnChangedPSDescription)
  63. ON_BN_CLICKED(IDC_WEP_ENABLED, OnChangedOtherParams)
  64. ON_BN_CLICKED(IDC_NETWORK_AUTHENTICATION, OnChangedOtherParams)
  65. ON_BN_CLICKED(IDC_AUTOMATIC_KEY_PROVISION, OnChangedOtherParams)
  66. ON_BN_CLICKED(IDC_NETWORK_TYPE, OnChangedOtherParams)
  67. ON_BN_CLICKED(IDC_NETWORK_TYPE, OnChangedNetworkType)
  68. //}}AFX_MSG_MAP
  69. END_MESSAGE_MAP()
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CSSIDPage message handlers
  72. BOOL CSSIDPage::OnInitDialog()
  73. {
  74. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  75. if (m_pWirelessPolicyData->dwFlags & WLSTORE_READONLY) {
  76. m_bReadOnly = TRUE;
  77. }
  78. // call base class init
  79. CWirelessBasePage::OnInitDialog();
  80. m_bPageInitialized = TRUE;
  81. // show the wait cursor in case there is a huge description being accessed
  82. CWaitCursor waitCursor;
  83. pWirelessPSData = WirelessPS();
  84. m_edSSID.SetLimitText(c_nMaxSSIDLen);
  85. m_edPSDescription.SetLimitText(c_nMaxDescriptionLen);
  86. // initialize our edit controls
  87. ASSERT(pWirelessPSData);
  88. m_edSSID.SetWindowText(pWirelessPSData->pszWirelessSSID);
  89. m_oldSSIDName = CString(pWirelessPSData->pszWirelessSSID,pWirelessPSData->dwWirelessSSIDLen);
  90. if (pWirelessPSData->pszDescription) {
  91. m_edPSDescription.SetWindowText (pWirelessPSData->pszDescription);
  92. }
  93. m_dwWepEnabled =
  94. (pWirelessPSData->dwWepEnabled) ? TRUE : FALSE;
  95. m_dwNetworkAuthentication =
  96. (pWirelessPSData->dwNetworkAuthentication) ? TRUE : FALSE;
  97. m_dwAutomaticKeyProvision =
  98. (pWirelessPSData->dwAutomaticKeyProvision) ? TRUE : FALSE;
  99. m_dwNetworkType =
  100. (pWirelessPSData->dwNetworkType == WIRELESS_NETWORK_TYPE_ADHOC) ? TRUE : FALSE;
  101. if (m_bReadOnly) {
  102. DisableControls();
  103. }
  104. UpdateData (FALSE);
  105. // OK, we can start paying attention to modifications made via dlg controls now.
  106. // This should be the last call before returning from OnInitDialog.
  107. OnFinishInitDialog();
  108. return TRUE; // return TRUE unless you set the focus to a control
  109. // EXCEPTION: OCX Property Pages should return FALSE
  110. }
  111. BOOL CSSIDPage::OnApply()
  112. {
  113. CString strName;
  114. CString strDescription;
  115. LPWSTR SSID = NULL;
  116. LPWSTR pszDescription = NULL;
  117. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  118. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  119. pWirelessPSData = WirelessPS();
  120. // pull our data out of the controls and into the object
  121. if (!UpdateData (TRUE))
  122. // Data was not valid, return for user to correct it.
  123. return CancelApply();
  124. ASSERT(pWirelessPSData);
  125. pWirelessPolicyData = m_pWirelessPolicyData;
  126. ASSERT(pWirelessPolicyData);
  127. DWORD dwNetworkType = 0;
  128. if (m_dwNetworkType)
  129. dwNetworkType = WIRELESS_NETWORK_TYPE_ADHOC;
  130. else
  131. dwNetworkType = WIRELESS_NETWORK_TYPE_AP;
  132. m_edSSID.GetWindowText (strName);
  133. if(m_bNameChanged || m_bNetworkTypeChanged)
  134. {
  135. if (m_bNameChanged) {
  136. if (strName.IsEmpty()) {
  137. ReportError(IDS_OPERATION_FAILED_NULL_SSID, 0);
  138. m_edSSID.SetWindowText(pWirelessPSData->pszWirelessSSID);
  139. return CancelApply();
  140. }
  141. }
  142. DWORD dwId = pWirelessPSData->dwId;
  143. if(IsDuplicateSSID(strName, dwNetworkType, pWirelessPolicyData, dwId)) {
  144. ReportError(IDS_OPERATION_FAILED_DUP_SSID,0);
  145. m_edSSID.SetWindowText(pWirelessPSData->pszWirelessSSID);
  146. return CancelApply();
  147. }
  148. }
  149. m_bNameChanged = FALSE;
  150. m_bNetworkTypeChanged = FALSE;
  151. if (m_dwWepEnabled)
  152. pWirelessPSData->dwWepEnabled = 1;
  153. else
  154. pWirelessPSData->dwWepEnabled = 0;
  155. if (m_dwNetworkAuthentication)
  156. pWirelessPSData->dwNetworkAuthentication = 1;
  157. else
  158. pWirelessPSData->dwNetworkAuthentication = 0;
  159. if (m_dwAutomaticKeyProvision)
  160. pWirelessPSData->dwAutomaticKeyProvision = 1;
  161. else
  162. pWirelessPSData->dwAutomaticKeyProvision = 0;
  163. if (m_dwNetworkType)
  164. pWirelessPSData->dwNetworkType = WIRELESS_NETWORK_TYPE_ADHOC;
  165. else
  166. pWirelessPSData->dwNetworkType = WIRELESS_NETWORK_TYPE_AP;
  167. SSIDDupString(pWirelessPSData->pszWirelessSSID, strName);
  168. m_edPSDescription.GetWindowText (strDescription);
  169. FreeAndThenDupString(&pWirelessPSData->pszDescription, strDescription);
  170. UpdateWirelessPSData(pWirelessPSData);
  171. return CWirelessBasePage::OnApply();
  172. }
  173. void
  174. CSSIDPage::Initialize (
  175. PWIRELESS_PS_DATA pWirelessPSData,
  176. CComponentDataImpl* pComponentDataImpl,
  177. PWIRELESS_POLICY_DATA pWirelessPolicyData
  178. )
  179. {
  180. m_pWirelessPolicyData = pWirelessPolicyData;
  181. CWirelessBasePage::Initialize(pWirelessPSData, pComponentDataImpl);
  182. }
  183. BOOL CSSIDPage::OnHelpInfo(HELPINFO* pHelpInfo)
  184. {
  185. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  186. {
  187. DWORD* pdwHelp = (DWORD*) &g_aHelpIDs_IDD_SSID[0];
  188. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  189. c_szWlsnpHelpFile,
  190. HELP_WM_HELP,
  191. (DWORD_PTR)(LPVOID)pdwHelp);
  192. }
  193. return CWirelessBasePage::OnHelpInfo(pHelpInfo);
  194. }
  195. void CSSIDPage::OnChangedSSID()
  196. {
  197. m_bNameChanged = TRUE;
  198. SetModified();
  199. }
  200. void CSSIDPage::OnChangedPSDescription()
  201. {
  202. SetModified();
  203. }
  204. void CSSIDPage::OnChangedNetworkType()
  205. {
  206. m_bNetworkTypeChanged = TRUE;
  207. SetModified();
  208. }
  209. void CSSIDPage::OnChangedOtherParams()
  210. {
  211. SetModified();
  212. }
  213. void CSSIDPage::DisableControls()
  214. {
  215. SAFE_ENABLEWINDOW(IDC_SSID_NAME, FALSE);
  216. SAFE_ENABLEWINDOW(IDC_PS_DESCRIPTION, FALSE);
  217. SAFE_ENABLEWINDOW(IDC_WEP_ENABLED, FALSE);
  218. SAFE_ENABLEWINDOW(IDC_NETWORK_AUTHENTICATION, FALSE);
  219. SAFE_ENABLEWINDOW(IDC_AUTOMATIC_KEY_PROVISION, FALSE);
  220. SAFE_ENABLEWINDOW(IDC_NETWORK_TYPE, FALSE);
  221. return;
  222. }