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.

1398 lines
39 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2001.
  5. //
  6. // File: sprpage.cpp
  7. //
  8. // Contents: WiF Policy Snapin: Policy Description/ Manager Page.
  9. //
  10. //
  11. // History: TaroonM
  12. // 10/30/01
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "stdafx.h"
  16. #include "sprpage.h"
  17. #include "nfaa.h"
  18. #include "ssidpage.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. typedef CTypedPtrList<CPtrList, PWIRELESS_PS_DATA> CSNPPSList;
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CSecPolRulesPage property page
  27. const TCHAR CSecPolRulesPage::STICKY_SETTING_USE_SEC_POLICY_WIZARD[] = _T("UseSecPolicyWizard");
  28. IMPLEMENT_DYNCREATE(CSecPolRulesPage, CSnapinPropPage)
  29. //Taroon:: Big change here.. check if it is correct
  30. CSecPolRulesPage::CSecPolRulesPage() : CSnapinPropPage(CSecPolRulesPage::IDD,FALSE)
  31. {
  32. //{{AFX_DATA_INIT(CSecPolRulesPage)
  33. // NOTE: the ClassWizard will add member initialization here
  34. //}}AFX_DATA_INIT
  35. m_iSortSubItem = 0;
  36. m_bSortOrder = TRUE;
  37. m_MMCthreadID = ::GetCurrentThreadId();
  38. m_pPrpSh = NULL;
  39. m_bHasWarnedPSCorruption = FALSE;
  40. m_currentWirelessPolicyData = NULL;
  41. m_bReadOnly = FALSE;
  42. }
  43. CSecPolRulesPage::~CSecPolRulesPage()
  44. {
  45. }
  46. void CSecPolRulesPage::DoDataExchange(CDataExchange* pDX)
  47. {
  48. CSnapinPropPage::DoDataExchange(pDX);
  49. //{{AFX_DATA_MAP(CSecPolRulesPage)
  50. DDX_Control(pDX, IDC_PS_LIST, m_lstActions);
  51. //}}AFX_DATA_MAP
  52. }
  53. BEGIN_MESSAGE_MAP(CSecPolRulesPage, CSnapinPropPage)
  54. //{{AFX_MSG_MAP(CSecPolRulesPage)
  55. ON_BN_CLICKED(IDC_ACTION_PS_ADD, OnActionAdd)
  56. ON_BN_CLICKED(IDC_ACTION_PS_EDIT, OnActionEdit)
  57. ON_BN_CLICKED(IDC_ACTION_PS_REMOVE, OnActionRemove)
  58. ON_BN_CLICKED(IDC_PS_UP, OnActionUp)
  59. ON_BN_CLICKED(IDC_PS_DOWN,OnActionDown)
  60. ON_NOTIFY(NM_DBLCLK, IDC_PS_LIST, OnDblclkActionslist)
  61. //ON_NOTIFY(LVN_COLUMNCLICK, IDC_ACTIONSLIST, OnColumnclickActionslist)
  62. //ON_NOTIFY(NM_CLICK, IDC_ACTIONSLIST, OnClickActionslist)
  63. ON_WM_HELPINFO()
  64. ON_NOTIFY(LVN_ITEMCHANGED, IDC_PS_LIST, OnItemchangedActionslist)
  65. ON_NOTIFY(LVN_KEYDOWN, IDC_PS_LIST, OnKeydownActionslist)
  66. ON_WM_DESTROY()
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CSecPolRulesPage message handlers
  71. BOOL CSecPolRulesPage::OnApply()
  72. {
  73. //if there is any sub dialog active, we cannot apply
  74. if (m_pPrpSh)
  75. {
  76. return FALSE;
  77. }
  78. // the rules page doesn't actually have any data on it that
  79. // the user might modify and then apply. in fact all changes
  80. // from this page actually happen directly on the dsObjects
  81. if( ERROR_SUCCESS != UpdateWlstore()) {
  82. PopulateListControl();
  83. return FALSE;
  84. }
  85. if (!m_bReadOnly) {
  86. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  87. pWirelessPolicyData = GetResultObject()->GetWirelessPolicy();
  88. UpdateWirelessPolicyData(
  89. pWirelessPolicyData,
  90. m_currentWirelessPolicyData
  91. );
  92. }
  93. return CSnapinPropPage::OnApply();
  94. }
  95. HRESULT CSecPolRulesPage::UpdateWlstore()
  96. {
  97. HRESULT hr = S_OK;
  98. HANDLE hPolicyStore = NULL;
  99. SNP_PS_LIST::iterator theIterator;
  100. BOOL dwModified = FALSE;
  101. CComObject<CSecPolItem>* pResultItem = NULL;
  102. PWIRELESS_POLICY_DATA pWirelessPolicyData;
  103. pResultItem = GetResultObject();
  104. hPolicyStore = pResultItem->m_pComponentDataImpl->GetPolicyStoreHandle();
  105. ASSERT(hPolicyStore);
  106. pWirelessPolicyData = pResultItem->GetWirelessPolicy();
  107. for(theIterator = m_NfaList.begin(); theIterator != m_NfaList.end(); theIterator++)
  108. {
  109. PSNP_PS_DATA pNfaData = (PSNP_PS_DATA) (*theIterator);
  110. PWIRELESS_PS_DATA pBWirelessPSData = pNfaData->pWirelessPSData;
  111. switch(pNfaData->status)
  112. {
  113. case NEW:
  114. {
  115. break;
  116. }
  117. case MODIFIED:
  118. {
  119. break;
  120. }
  121. case BEREMOVED:
  122. {
  123. break;
  124. }
  125. }//switch
  126. }//for
  127. return hr;
  128. }
  129. void CSecPolRulesPage::OnCancel()
  130. {
  131. //WirelessFreePolicyData(m_currentWirelessPolicyData);
  132. CSnapinPropPage::OnCancel();
  133. }
  134. BOOL CSecPolRulesPage::OnInitDialog()
  135. {
  136. CSnapinPropPage::OnInitDialog();
  137. DWORD dwError = 0;
  138. m_pPrpSh = NULL;
  139. // set headers on the list control
  140. m_lstActions.InsertColumn(0,ResourcedString(IDS_COLUMN_SSIDNAME), LVCFMT_CENTER, 120, 0);
  141. m_lstActions.InsertColumn(1,ResourcedString(IDS_COLUMN_AUTHMETHOD), LVCFMT_CENTER, 80, 1);
  142. m_lstActions.InsertColumn(2,ResourcedString(IDS_COLUMN_PRIVACY), LVCFMT_CENTER, 80, 2);
  143. //m_lstActions.InsertColumn(3,ResourcedString(IDS_COLUMN_ADAPTERTYPE), LVCFMT_LEFT, 90, 3);
  144. // set the image list
  145. CThemeContextActivator activator;
  146. m_imagelistChecks.Create(IDB_PSTYPE, 16, 1, RGB(0,255,0));
  147. // m_lstActions.SetImageList (&m_imagelistChecks, LVSIL_STATE);
  148. m_lstActions.SetImageList (CImageList::FromHandle(m_imagelistChecks), LVSIL_SMALL);
  149. // turn on entire row selection
  150. ListView_SetExtendedListViewStyle (m_lstActions.GetSafeHwnd(), LVS_EX_FULLROWSELECT);
  151. // Copy the Policy Data to the m_currentWirelessPolicyData
  152. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  153. pWirelessPolicyData = GetResultObject()->GetWirelessPolicy();
  154. dwError = CopyWirelessPolicyData(
  155. pWirelessPolicyData,
  156. &m_currentWirelessPolicyData
  157. );
  158. if(dwError) {
  159. ReportError(IDS_DISPLAY_ERROR, 0);
  160. BAIL_ON_WIN32_ERROR(dwError);
  161. }
  162. if (pWirelessPolicyData->dwFlags & WLSTORE_READONLY) {
  163. m_bReadOnly = TRUE;
  164. }
  165. if (m_bReadOnly) {
  166. DisableControls();
  167. }
  168. //store the rules data in m_NfaList linked list
  169. InitialzeNfaList(); //taroonm
  170. // fill the list control with the current PSs
  171. PopulateListControl(); //taroonm
  172. // Select the first list item
  173. if (m_lstActions.GetItemCount())
  174. {
  175. m_lstActions.SetItemState( 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  176. EnableDisableButtons ();
  177. }
  178. // OK, we can start paying attention to modifications made via dlg controls now.
  179. // This should be the last call before returning from OnInitDialog.
  180. OnFinishInitDialog();
  181. return TRUE; // return TRUE unless you set the focus to a control
  182. // EXCEPTION: OCX Property Pages should return FALSE
  183. error:
  184. return(FALSE);
  185. }
  186. void CSecPolRulesPage::InitialzeNfaList()
  187. {
  188. HRESULT hr;
  189. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  190. PWIRELESS_PS_DATA * ppWirelessPSData = NULL;
  191. PWIRELESS_PS_DATA pAWirelessPSData = NULL;
  192. DWORD i = 0;
  193. HANDLE hPolicyStore = NULL;
  194. DWORD dwNumPSObjects = 0;
  195. CComObject<CSecPolItem>* pResultItem = NULL;
  196. DWORD dwError = 0;
  197. SNP_PS_LIST::iterator theIterator;
  198. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  199. PSNP_PS_DATA pNfaData = NULL;
  200. // Unselect Everything First
  201. SELECT_NO_LISTITEM( m_lstActions );
  202. //empty the previous List
  203. if (!m_NfaList.empty()) {
  204. for(theIterator = m_NfaList.begin();theIterator != m_NfaList.end(); ++theIterator) {
  205. pNfaData = (PSNP_PS_DATA)(*theIterator);
  206. pWirelessPSData = pNfaData->pWirelessPSData;
  207. FreeWirelessPSData(pWirelessPSData);
  208. LocalFree(pNfaData);
  209. }
  210. }
  211. m_NfaList.clear();
  212. pWirelessPolicyData = m_currentWirelessPolicyData;
  213. ppWirelessPSData = pWirelessPolicyData->ppWirelessPSData;
  214. dwNumPSObjects = pWirelessPolicyData->dwNumPreferredSettings;
  215. for (i = 0; i < dwNumPSObjects; i++) {
  216. DWORD dwErrorTmp = ERROR_SUCCESS;
  217. pAWirelessPSData = *(ppWirelessPSData + i);
  218. PSNP_PS_DATA pNfaData = NULL;
  219. pNfaData = (PSNP_PS_DATA) LocalAlloc(LMEM_ZEROINIT, sizeof(SNP_PS_DATA));
  220. if(pNfaData == NULL) {
  221. goto error;
  222. }
  223. pNfaData->status = NOTMODIFIED; //taroonm
  224. dwError = CopyWirelessPSData(pAWirelessPSData,&pNfaData->pWirelessPSData);
  225. BAIL_ON_WIN32_ERROR(dwError);
  226. m_NfaList.push_back(pNfaData);
  227. }//for
  228. return;
  229. error:
  230. //
  231. // BugBug KrishnaG cleanup
  232. //
  233. // Taroon:: TODO Deallocate the m_nfa list here and report Error
  234. ReportError(IDS_DISPLAY_ERROR, HRESULT_FROM_WIN32(dwError));
  235. return;
  236. }
  237. void CSecPolRulesPage::UnPopulateListControl ()
  238. {
  239. int nIndex=0;
  240. // Make sure no items are selected so EnableDisableButtons doesn't do
  241. // so much work when its called by the LVN_ITEMCHANGED handler. (_DEBUG only)
  242. SELECT_NO_LISTITEM( m_lstActions );
  243. m_lstActions.DeleteAllItems();
  244. }
  245. CString CSecPolRulesPage::GetColumnStrBuffer (PWIRELESS_PS_DATA pWirelessPSData, int iColumn)
  246. {
  247. CString strBuffer;
  248. HANDLE hPolicyStore = NULL;
  249. GUID ZeroGuid;
  250. DWORD dwError = 0;
  251. BOOL bInitial = TRUE;
  252. CComObject<CSecPolItem>* pResultItem = NULL;
  253. pResultItem = GetResultObject();
  254. hPolicyStore = pResultItem->m_pComponentDataImpl->GetPolicyStoreHandle();
  255. switch (iColumn)
  256. {
  257. case 0:
  258. strBuffer = pWirelessPSData->pszWirelessSSID;
  259. break;
  260. case 1:
  261. if (pWirelessPSData->dwEnable8021x) {
  262. strBuffer.LoadString (IDS_8021X_ENABLED);
  263. } else {
  264. strBuffer.LoadString (IDS_8021X_DISABLED);
  265. }
  266. break;
  267. case 2:
  268. if (pWirelessPSData->dwWepEnabled) {
  269. strBuffer.LoadString (IDS_WEP_ENABLED);
  270. } else {
  271. strBuffer.LoadString (IDS_WEP_DISABLED);
  272. }
  273. break;
  274. default:
  275. ASSERT (0);
  276. strBuffer.LoadString (IDS_DATAERROR);
  277. break;
  278. }
  279. return strBuffer;
  280. }
  281. void CSecPolRulesPage::PopulateListControl()
  282. {
  283. HRESULT hr = S_OK;
  284. PSNP_PS_DATA pNfaData;
  285. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  286. LV_ITEM item;
  287. CString strBuffer;
  288. int nItem = 0;
  289. int nSubItem = 0;
  290. SNP_PS_LIST::reverse_iterator theIterator;
  291. // clear out the list control
  292. UnPopulateListControl();
  293. for (theIterator = m_NfaList.rbegin(); theIterator != m_NfaList.rend();
  294. theIterator++)
  295. {
  296. pNfaData = (PSNP_PS_DATA)(*theIterator);
  297. pWirelessPSData = pNfaData->pWirelessPSData;
  298. if( pNfaData->status == BEREMOVED || pNfaData->status == REMOVED || pNfaData->status == NEWREMOVED ) {
  299. continue;
  300. }
  301. item.mask = LVIF_TEXT | LVIF_IMAGE;
  302. // item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
  303. item.iItem = nItem;
  304. nSubItem = 0;
  305. // Set the Network type
  306. if (pWirelessPSData->dwNetworkType == WIRELESS_NETWORK_TYPE_ADHOC) {
  307. item.iImage = 5;
  308. }
  309. if (pWirelessPSData->dwNetworkType == WIRELESS_NETWORK_TYPE_AP) {
  310. item.iImage = 3;
  311. }
  312. // "Wireless SSID"
  313. item.iSubItem = nSubItem++;
  314. strBuffer = GetColumnStrBuffer (pWirelessPSData, 0);
  315. item.pszText = strBuffer.GetBuffer(32);
  316. item.iItem = m_lstActions.InsertItem (&item);
  317. // "Negotiation Policy
  318. item.iSubItem = nSubItem++;
  319. strBuffer = GetColumnStrBuffer (pWirelessPSData, 1);
  320. item.pszText = strBuffer.GetBuffer(20);
  321. m_lstActions.SetItem (&item);
  322. // "Authentication Method"
  323. item.iSubItem = nSubItem++;
  324. strBuffer = GetColumnStrBuffer (pWirelessPSData, 2);
  325. item.pszText = strBuffer.GetBuffer(20);
  326. m_lstActions.SetItem (&item);
  327. // store the pWirelessPSData
  328. ASSERT (pWirelessPSData);
  329. VERIFY( m_lstActions.SetItemData(item.iItem, (DWORD_PTR)pNfaData) );
  330. }
  331. EnableDisableButtons ();
  332. }
  333. void CSecPolRulesPage::HandleSideEffectApply()
  334. {
  335. // make sure we are marked as modified
  336. SetModified();
  337. // The Add has been committed, canceling it is no longer possible.
  338. // Disable the cancel button
  339. CancelToClose();
  340. }
  341. int CSecPolRulesPage::DisplayPSProperties (
  342. //PWIRELESS_PS_DATA pBWirelessPSData,
  343. PSNP_PS_DATA pNfaData,
  344. CString strTitle,
  345. BOOL bDoingAdd,
  346. BOOL* pbAfterWizardHook
  347. )
  348. {
  349. HANDLE hPolicyStore = NULL;
  350. DWORD dwError = 0;
  351. GUID PolicyIdentifier;
  352. PWIRELESS_PS_DATA pBWirelessPSData = pNfaData->pWirelessPSData;
  353. CComObject<CSecPolItem>* pResultItem = NULL;
  354. PWIRELESS_POLICY_DATA pWirelessPolicy = NULL;
  355. int nReturn = 0;
  356. pResultItem = GetResultObject();
  357. hPolicyStore = pResultItem->m_pComponentDataImpl->GetPolicyStoreHandle();
  358. pWirelessPolicy = m_currentWirelessPolicyData;
  359. PolicyIdentifier = pWirelessPolicy->PolicyIdentifier;
  360. CSingleLock cLock(&m_csDlg);
  361. CComPtr<CPSPropSheetManager> spPropshtManager =
  362. new CComObject<CPSPropSheetManager>;
  363. if (NULL == spPropshtManager.p) {
  364. ReportError(IDS_OPERATION_FAIL, E_OUTOFMEMORY);
  365. return nReturn;
  366. }
  367. // load in the property pages
  368. CPS8021XPropPage pageAdapter;
  369. CSSIDPage pageSSID;
  370. //
  371. spPropshtManager->SetData(
  372. GetResultObject(),
  373. pBWirelessPSData,
  374. bDoingAdd
  375. );
  376. // theory is that if one fails, they all fail
  377. pageAdapter.Initialize(pBWirelessPSData, GetResultObject()->m_pComponentDataImpl, pWirelessPolicy->dwFlags);
  378. pageSSID.Initialize(pBWirelessPSData, GetResultObject()->m_pComponentDataImpl, pWirelessPolicy);
  379. spPropshtManager->AddPage (&pageSSID);
  380. spPropshtManager->AddPage (&pageAdapter);
  381. spPropshtManager->GetSheet()->SetTitle (strTitle, PSH_PROPTITLE);
  382. m_pPrpSh = spPropshtManager->GetSheet();
  383. m_pPrpSh->m_psh.dwFlags |= PSH_NOAPPLYNOW;
  384. // display the dialog
  385. nReturn = spPropshtManager->GetSheet()->DoModal();
  386. //nReturn = spPropshtManager->GetSheet()->Create();
  387. cLock.Lock();
  388. m_pPrpSh = NULL;
  389. cLock.Unlock();
  390. if (m_bReadOnly) {
  391. return nReturn;
  392. }
  393. if (spPropshtManager->HasEverApplied())
  394. {
  395. nReturn = IDOK;
  396. }
  397. return nReturn;
  398. }
  399. void CSecPolRulesPage::OnActionAdd()
  400. {
  401. // handle the add on a different thread and then continue
  402. // this is to fix NT bug #203059 per MFC KB article ID Q177101
  403. GetParent()->EnableWindow (FALSE);
  404. AfxBeginThread((AFX_THREADPROC)DoThreadActionAdd, this);
  405. }
  406. void CSecPolRulesPage::OnActionUp()
  407. {
  408. //Taroon: Todo Check this is needed or not and then remvoe
  409. //GetParent()->EnableWindow (FALSE);
  410. CComObject<CSecPolItem>* pResultItem = NULL;
  411. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  412. //lower means lower indexed
  413. PWIRELESS_PS_DATA pLowerWirelessPSData = NULL;
  414. PWIRELESS_PS_DATA pUpperWirelessPSData = NULL;
  415. // Only 1 item can be selected for move to be enabled
  416. ASSERT( m_lstActions.GetSelectedCount() == 1 );
  417. // ok, one of the PSs must be selected
  418. int nIndex = m_lstActions.GetNextItem(-1,LVNI_SELECTED);
  419. if (-1 == nIndex)
  420. return;
  421. PSNP_PS_DATA pUpperNfaData;
  422. pUpperNfaData = (PSNP_PS_DATA) m_lstActions.GetItemData(nIndex);
  423. pUpperWirelessPSData = pUpperNfaData->pWirelessPSData;
  424. pWirelessPolicyData = m_currentWirelessPolicyData;
  425. if (pWirelessPolicyData && pUpperWirelessPSData)
  426. {
  427. DWORD dwCurrentId;
  428. dwCurrentId = pUpperWirelessPSData->dwId;
  429. if (dwCurrentId != 0) {
  430. WirelessPSMoveUp(pWirelessPolicyData,dwCurrentId);
  431. // update the m_nfaList as well.
  432. PSNP_PS_DATA pLowerNfaData = NULL;
  433. pLowerNfaData = m_NfaList[dwCurrentId-1];
  434. pLowerWirelessPSData = pLowerNfaData->pWirelessPSData;
  435. pLowerWirelessPSData->dwId = dwCurrentId;
  436. pUpperWirelessPSData->dwId = dwCurrentId-1;
  437. m_NfaList[dwCurrentId-1] = pUpperNfaData;
  438. m_NfaList[dwCurrentId] = pLowerNfaData;
  439. PopulateListControl ();
  440. SetModified();
  441. m_lstActions.SetItemState( dwCurrentId-1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  442. }
  443. }
  444. }
  445. void CSecPolRulesPage::OnActionDown()
  446. {
  447. //Taroon: Todo Check this is needed or not and then remvoe
  448. //GetParent()->EnableWindow (FALSE);
  449. CComObject<CSecPolItem>* pResultItem = NULL;
  450. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  451. //lower means lower indexed
  452. PWIRELESS_PS_DATA pLowerWirelessPSData = NULL;
  453. PWIRELESS_PS_DATA pUpperWirelessPSData = NULL;
  454. DWORD dwTotalItems = 0;
  455. // Only 1 item can be selected for move to be enabled
  456. ASSERT( m_lstActions.GetSelectedCount() == 1 );
  457. // ok, one of the PSs must be selected
  458. int nIndex = m_lstActions.GetNextItem(-1,LVNI_SELECTED);
  459. if (-1 == nIndex)
  460. return;
  461. PSNP_PS_DATA pLowerNfaData;
  462. pLowerNfaData = (PSNP_PS_DATA) m_lstActions.GetItemData(nIndex);
  463. pLowerWirelessPSData = pLowerNfaData->pWirelessPSData;
  464. pWirelessPolicyData = m_currentWirelessPolicyData;
  465. dwTotalItems = pWirelessPolicyData->dwNumPreferredSettings;
  466. if (pWirelessPolicyData && pLowerWirelessPSData)
  467. {
  468. DWORD dwCurrentId;
  469. dwCurrentId = pLowerWirelessPSData->dwId;
  470. if (dwCurrentId < dwTotalItems -1) {
  471. WirelessPSMoveDown(pWirelessPolicyData,dwCurrentId);
  472. // update the m_nfaList as well.
  473. PSNP_PS_DATA pUpperNfaData = NULL;
  474. pUpperNfaData = m_NfaList[dwCurrentId + 1];
  475. pUpperWirelessPSData = pUpperNfaData->pWirelessPSData;
  476. pLowerWirelessPSData->dwId = dwCurrentId +1;
  477. pUpperWirelessPSData->dwId = dwCurrentId;
  478. m_NfaList[dwCurrentId+1] = pLowerNfaData;
  479. m_NfaList[dwCurrentId] = pUpperNfaData;
  480. PopulateListControl ();
  481. SetModified();
  482. m_lstActions.SetItemState( dwCurrentId+1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  483. }
  484. }
  485. }
  486. UINT AFX_CDECL CSecPolRulesPage::DoThreadActionAdd(LPVOID pParam)
  487. {
  488. CSecPolRulesPage* pObject = (CSecPolRulesPage*)pParam;
  489. if (pObject == NULL ||
  490. !pObject->IsKindOf(RUNTIME_CLASS(CSecPolRulesPage)))
  491. return -1; // illegal parameter
  492. DWORD dwDlgRuleThreadId = GetCurrentThreadId();
  493. AttachThreadInput(dwDlgRuleThreadId, pObject->m_MMCthreadID, TRUE);
  494. HRESULT hr = CoInitialize(NULL);
  495. if (FAILED(hr))
  496. return hr;
  497. // call back to the objects ActionAdd handler
  498. pObject->OnThreadSafeActionAdd();
  499. pObject->GetParent()->EnableWindow (TRUE);
  500. pObject->GetParent()->SetFocus ();
  501. CoUninitialize();
  502. AttachThreadInput(dwDlgRuleThreadId, pObject->m_MMCthreadID, FALSE);
  503. return 0;
  504. }
  505. void CSecPolRulesPage::OnThreadSafeActionAdd()
  506. {
  507. DWORD dwError = 0;
  508. BOOL bDisplayProperties = FALSE;
  509. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  510. PSNP_PS_DATA pNfaData = NULL;
  511. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  512. PWIRELESS_PS_DATA pNewWirelessPSData = NULL;
  513. pNfaData = (PSNP_PS_DATA) LocalAlloc(LMEM_ZEROINIT, sizeof(SNP_PS_DATA));
  514. if(pNfaData == NULL) {
  515. ReportError(IDS_OPERATION_FAIL, E_OUTOFMEMORY);
  516. return;
  517. }
  518. //
  519. // Create the WIRELESS_PS Object
  520. //
  521. //
  522. //
  523. pWirelessPSData = (PWIRELESS_PS_DATA) AllocPolMem(sizeof(WIRELESS_PS_DATA));
  524. if(pWirelessPSData == NULL) {
  525. ReportError(IDS_OPERATION_FAIL, E_OUTOFMEMORY);
  526. return;
  527. }
  528. pNfaData->status = NEW;
  529. pNfaData->pWirelessPSData = pWirelessPSData;
  530. CString pszNewSSID;
  531. // Initialize the PWIRELESS_PS_DATA
  532. //
  533. //
  534. GenerateUniquePSName(IDS_NEW_PS_NAME,pszNewSSID);
  535. SSIDDupString(pWirelessPSData->pszWirelessSSID, pszNewSSID);
  536. pWirelessPSData->dwWirelessSSIDLen =
  537. lstrlenW(pWirelessPSData->pszWirelessSSID);
  538. pWirelessPSData->dwWepEnabled = 1;
  539. pWirelessPSData->dwNetworkAuthentication = 0;
  540. pWirelessPSData->dwAutomaticKeyProvision = 1;
  541. pWirelessPSData->dwNetworkType = WIRELESS_NETWORK_TYPE_AP;
  542. pWirelessPSData->dwEnable8021x = 1;
  543. pWirelessPSData->dw8021xMode =
  544. WIRELESS_8021X_MODE_NAS_TRANSMIT_EAPOLSTART_WIRED;
  545. pWirelessPSData->dwEapType = WIRELESS_EAP_TYPE_TLS;
  546. pWirelessPSData->dwEAPDataLen = 0;
  547. pWirelessPSData->pbEAPData = NULL;
  548. pWirelessPSData->dwMachineAuthentication = 1;
  549. pWirelessPSData->dwMachineAuthenticationType = WIRELESS_MC_AUTH_TYPE_MC_ONLY;
  550. pWirelessPSData->dwGuestAuthentication = 0;
  551. pWirelessPSData->dwIEEE8021xMaxStart = 3;
  552. pWirelessPSData->dwIEEE8021xStartPeriod = 60;
  553. pWirelessPSData->dwIEEE8021xAuthPeriod = 30;
  554. pWirelessPSData->dwIEEE8021xHeldPeriod = 60;
  555. pWirelessPSData->dwId = -1;
  556. pWirelessPSData->pszDescription = AllocPolStr(L"Sample Description");
  557. pWirelessPSData->dwDescriptionLen = 2*lstrlenW(pWirelessPSData->pszDescription);
  558. UpdateWirelessPSData(pWirelessPSData);
  559. // display the dialog
  560. int dlgRetVal = DisplayPSProperties (
  561. pNfaData,
  562. L"New Preferred Setting",
  563. TRUE,
  564. &bDisplayProperties
  565. );
  566. // IDOK in case we didn't use the wizard for some reason
  567. if ((dlgRetVal == ID_WIZFINISH) || (dlgRetVal == IDOK))
  568. {
  569. // turn on the wait cursor
  570. CWaitCursor waitCursor;
  571. //user added new nfa rule, update the m_NfaList
  572. UpdateWirelessPSData(pWirelessPSData);
  573. pWirelessPolicyData = m_currentWirelessPolicyData;
  574. dwError = CopyWirelessPSData(pWirelessPSData,&pNewWirelessPSData);
  575. BAIL_ON_WIN32_ERROR(dwError);
  576. dwError = WirelessAddPSToPolicy(pWirelessPolicyData, pNewWirelessPSData);
  577. BAIL_ON_WIN32_ERROR(dwError);
  578. pWirelessPSData->dwId = pNewWirelessPSData->dwId;
  579. m_NfaList.push_back(pNfaData);
  580. DWORD dwSelection = -1;
  581. dwSelection = pWirelessPSData->dwId;
  582. InitialzeNfaList();
  583. PopulateListControl ();
  584. // Select the new item only
  585. SELECT_NO_LISTITEM( m_lstActions );
  586. m_lstActions.SetItemState( dwSelection, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  587. //HandleSideEffectApply();
  588. SetModified();
  589. }
  590. else
  591. {
  592. if (pWirelessPSData) {
  593. FreeWirelessPSData(pWirelessPSData);
  594. }
  595. if (pNfaData) {
  596. LocalFree(pNfaData);
  597. }
  598. }
  599. return;
  600. error:
  601. ReportError(IDS_ADD_ERROR, HRESULT_FROM_WIN32(dwError));
  602. return;
  603. }
  604. void CSecPolRulesPage::OnActionEdit()
  605. {
  606. // handle the add on a different thread and then continue
  607. // this is to fix NT bug #203059 per MFC KB article ID Q177101
  608. GetParent()->EnableWindow (FALSE);
  609. AfxBeginThread((AFX_THREADPROC)DoThreadActionEdit, this);
  610. }
  611. UINT AFX_CDECL CSecPolRulesPage::DoThreadActionEdit(LPVOID pParam)
  612. {
  613. CSecPolRulesPage* pObject = (CSecPolRulesPage*)pParam;
  614. if (pObject == NULL ||
  615. !pObject->IsKindOf(RUNTIME_CLASS(CSecPolRulesPage)))
  616. return -1; // illegal parameter
  617. DWORD dwDlgRuleThreadId = GetCurrentThreadId();
  618. AttachThreadInput(dwDlgRuleThreadId, pObject->m_MMCthreadID, TRUE);
  619. HRESULT hr = CoInitialize(NULL);
  620. if (FAILED(hr))
  621. return hr;
  622. // call back to the objects ActionAdd handler
  623. pObject->OnThreadSafeActionEdit();
  624. pObject->GetParent()->EnableWindow (TRUE);
  625. pObject->GetParent()->SetFocus ();
  626. CoUninitialize();
  627. AttachThreadInput(dwDlgRuleThreadId, pObject->m_MMCthreadID, FALSE);
  628. return 0;
  629. }
  630. void CSecPolRulesPage::OnThreadSafeActionEdit()
  631. {
  632. // Only 1 item can be selected for Edit to be enabled
  633. ASSERT( m_lstActions.GetSelectedCount() == 1 );
  634. DWORD dwError = 0;
  635. // ok, one of the PSs must be selected
  636. int nIndex = m_lstActions.GetNextItem(-1,LVNI_SELECTED);
  637. if (-1 == nIndex)
  638. return;
  639. PSNP_PS_DATA pNfaData;
  640. PWIRELESS_PS_DATA pBWirelessPSData = NULL;
  641. pNfaData = (PSNP_PS_DATA) m_lstActions.GetItemData(nIndex);
  642. pBWirelessPSData = pNfaData->pWirelessPSData;
  643. // display the dialog
  644. if (pBWirelessPSData)
  645. {
  646. BOOL bHook = FALSE;
  647. DWORD dwError = 0;
  648. TCHAR pszTitle[60];
  649. wsprintf(pszTitle,L"Edit %ls",pBWirelessPSData->pszWirelessSSID);
  650. if (DisplayPSProperties (pNfaData,pszTitle, FALSE, &bHook) == IDOK)
  651. {
  652. if (!m_bReadOnly) {
  653. if( pNfaData->status != NEW )
  654. pNfaData->status = MODIFIED;
  655. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  656. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  657. DWORD dwCurrentId = 0;
  658. pWirelessPSData = pNfaData->pWirelessPSData;
  659. /* Taroon:RemoveRight
  660. pWirelessPolicyData = GetResultObject()->GetWirelessPolicy();
  661. */
  662. pWirelessPolicyData = m_currentWirelessPolicyData;
  663. UpdateWirelessPSData(pWirelessPSData);
  664. dwError = WirelessSetPSDataInPolicyId(pWirelessPolicyData, pWirelessPSData);
  665. BAIL_ON_WIN32_ERROR(dwError);
  666. nIndex = pWirelessPSData->dwId;
  667. SetModified();
  668. InitialzeNfaList();
  669. }
  670. }
  671. // PopulateListControl can disable the edit button, save its handle so we
  672. // can reset the focus if this happens.
  673. HWND hWndCtrl = ::GetFocus();
  674. // always redraw the listbox, they might have managed filters or negpols even in a
  675. // 'cancel' situation and thus we need to accurately reflect the current state
  676. PopulateListControl ();
  677. // Select the edited item
  678. m_lstActions.SetItemState( nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  679. if (::GetFocus() == NULL)
  680. ::SetFocus( hWndCtrl );
  681. }
  682. return;
  683. error:
  684. ReportError(IDS_SAVE_ERROR, HRESULT_FROM_WIN32(dwError));
  685. return;
  686. }
  687. void CSecPolRulesPage::OnActionRemove()
  688. {
  689. // Something must be selected to do a remove
  690. if (-1 == m_lstActions.GetNextItem(-1,LVNI_SELECTED))
  691. return;
  692. // verify that they really want to do this
  693. if (AfxMessageBox (IDS_SUREYESNO, MB_YESNO | MB_DEFBUTTON2) != IDYES)
  694. return;
  695. HANDLE hPolicyStore = NULL;
  696. DWORD dwError = 0;
  697. hPolicyStore = GetResultObject()->m_pComponentDataImpl->GetPolicyStoreHandle();
  698. ASSERT(hPolicyStore);
  699. // need to make sure that none of the selected items are the non-deleteable
  700. int nIndex = -1;
  701. DWORD nDeleteIndex = -1;
  702. DWORD dwNumRemoved = 0;
  703. while (-1 != (nIndex = m_lstActions.GetNextItem( nIndex, LVNI_SELECTED )))
  704. {
  705. PSNP_PS_DATA pNfaData;
  706. pNfaData = (PSNP_PS_DATA) m_lstActions.GetItemData(nIndex);
  707. PWIRELESS_PS_DATA pBWirelessPSData = pNfaData->pWirelessPSData;
  708. if (pBWirelessPSData)
  709. {
  710. if( pNfaData->status != NEW )
  711. pNfaData->status = BEREMOVED;
  712. else
  713. pNfaData->status = NEWREMOVED;
  714. nDeleteIndex = nIndex;
  715. }
  716. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  717. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  718. DWORD dwCurrentId = 0;
  719. //Remove the items right here from m_nfaList and Policy Object as well
  720. /* Taroon:RemoveRight
  721. pWirelessPolicyData = GetResultObject()->GetWirelessPolicy();
  722. */
  723. pWirelessPolicyData = m_currentWirelessPolicyData;
  724. pWirelessPSData = pNfaData->pWirelessPSData;
  725. dwCurrentId = pWirelessPSData->dwId - dwNumRemoved;
  726. dwError = WirelessRemovePSFromPolicyId(pWirelessPolicyData,dwCurrentId);
  727. BAIL_ON_WIN32_ERROR(dwError);
  728. dwNumRemoved++;
  729. }
  730. SELECT_NO_LISTITEM( m_lstActions );
  731. InitialzeNfaList();
  732. // Save the currently focused control, PopulateListControl disables some
  733. // controls so we may have to reset the focus if this happens.
  734. CWnd *pwndFocus = GetFocus();
  735. PopulateListControl ();
  736. // Select previous item in list only
  737. SELECT_NO_LISTITEM( m_lstActions );
  738. int nPrevSel = SELECT_PREV_LISTITEM( m_lstActions, nDeleteIndex );
  739. // Fix up button focus
  740. EnableDisableButtons();
  741. SetPostRemoveFocus( nPrevSel, IDC_ACTION_PS_ADD, IDC_ACTION_PS_REMOVE, pwndFocus );
  742. // If the currently selected item is non-deleteable, the Remove button is
  743. // now disabled. Move the focus to the Add button for this case.
  744. if (!GetDlgItem( IDC_ACTION_PS_REMOVE)->IsWindowEnabled())
  745. {
  746. GotoDlgCtrl( GetDlgItem( IDC_ACTION_PS_ADD) );
  747. }
  748. SetModified();
  749. return;
  750. error:
  751. ReportError(IDS_REMOVINGERROR, HRESULT_FROM_WIN32(dwError));
  752. return;
  753. }
  754. void CSecPolRulesPage::OnDblclkActionslist(NMHDR* pNMHDR, LRESULT* pResult)
  755. {
  756. // ok, sounds like maybe they have clicked something in which case
  757. // we want to do an add
  758. switch (pNMHDR->code)
  759. {
  760. case NM_DBLCLK:
  761. {
  762. // we only want to do the edit if ONE item is selected
  763. if (m_lstActions.GetSelectedCount() == 1 )
  764. {
  765. OnActionEdit();
  766. }
  767. break;
  768. }
  769. default:
  770. break;
  771. }
  772. *pResult = 0;
  773. }
  774. void CSecPolRulesPage::EnableDisableButtons ()
  775. {
  776. if (m_bReadOnly)
  777. {
  778. DisableControls();
  779. return;
  780. }
  781. // ok, one of the rules must be selected for the E/R buttons to be enabled
  782. if (-1 != m_lstActions.GetNextItem(-1,LVNI_SELECTED))
  783. {
  784. // Disable Edit button if multiple selection
  785. int nSelectionCount = m_lstActions.GetSelectedCount();
  786. // Edit is easy
  787. SAFE_ENABLEWINDOW (IDC_ACTION_PS_EDIT, (1 == nSelectionCount));
  788. // Enable Remove only if it all selected pols are removable type
  789. SAFE_ENABLEWINDOW (IDC_ACTION_PS_REMOVE, PSsRemovable());
  790. if(nSelectionCount == 1 ) {
  791. SAFE_ENABLEWINDOW(IDC_PS_UP, TRUE);
  792. SAFE_ENABLEWINDOW(IDC_PS_DOWN, TRUE);
  793. // ok, one of the PSs must be selected
  794. int nIndex = m_lstActions.GetNextItem(-1,LVNI_SELECTED);
  795. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  796. DWORD dwAdhocStart = 0;
  797. DWORD dwNumPreferredSettings = 0;
  798. /* Taroon:RemoveRight
  799. pWirelessPolicyData = GetResultObject()->GetWirelessPolicy();
  800. */
  801. pWirelessPolicyData = m_currentWirelessPolicyData;
  802. dwAdhocStart = pWirelessPolicyData->dwNumAPNetworks;
  803. dwNumPreferredSettings = pWirelessPolicyData->dwNumPreferredSettings;
  804. if ((dwAdhocStart == nIndex) || (nIndex == 0)) {
  805. SAFE_ENABLEWINDOW(IDC_PS_UP, FALSE);
  806. }
  807. if ((dwAdhocStart == (nIndex + 1))||
  808. (nIndex == (dwNumPreferredSettings - 1)))
  809. {
  810. SAFE_ENABLEWINDOW(IDC_PS_DOWN, FALSE);
  811. }
  812. } else {
  813. SAFE_ENABLEWINDOW(IDC_PS_UP, FALSE);
  814. SAFE_ENABLEWINDOW(IDC_PS_DOWN, FALSE);
  815. }
  816. }
  817. else
  818. {
  819. // if nothing was selected this takes care of it
  820. SAFE_ENABLEWINDOW (IDC_ACTION_PS_EDIT, FALSE);
  821. SAFE_ENABLEWINDOW (IDC_ACTION_PS_REMOVE, FALSE);
  822. SAFE_ENABLEWINDOW(IDC_PS_UP, FALSE);
  823. SAFE_ENABLEWINDOW(IDC_PS_DOWN, FALSE);
  824. }
  825. }
  826. void CSecPolRulesPage::DisableControls ()
  827. {
  828. SAFE_ENABLEWINDOW (IDC_ACTION_PS_EDIT, FALSE);
  829. SAFE_ENABLEWINDOW (IDC_ACTION_PS_ADD, FALSE);
  830. SAFE_ENABLEWINDOW (IDC_ACTION_PS_REMOVE, FALSE);
  831. SAFE_ENABLEWINDOW(IDC_PS_UP, FALSE);
  832. SAFE_ENABLEWINDOW(IDC_PS_DOWN, FALSE);
  833. return;
  834. }
  835. BOOL CSecPolRulesPage::OnHelpInfo(HELPINFO* pHelpInfo)
  836. {
  837. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  838. {
  839. DWORD* pdwHelp = (DWORD*) &g_aHelpIDs_IDD_PS_LIST[0];
  840. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  841. c_szWlsnpHelpFile,
  842. HELP_WM_HELP,
  843. (DWORD_PTR)(LPVOID)pdwHelp);
  844. }
  845. return CSnapinPropPage::OnHelpInfo(pHelpInfo);
  846. }
  847. void CSecPolRulesPage::OnItemchangedActionslist(NMHDR* pNMHDR, LRESULT* pResult)
  848. {
  849. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  850. EnableDisableButtons ();
  851. *pResult = 0;
  852. }
  853. void CSecPolRulesPage::OnKeydownActionslist(NMHDR* pNMHDR, LRESULT* pResult)
  854. {
  855. // Something must be selected to do process the key opration
  856. if (-1 == m_lstActions.GetNextItem(-1,LVNI_SELECTED))
  857. return;
  858. LV_KEYDOWN* pLVKeyDown = (LV_KEYDOWN*)pNMHDR;
  859. if (VK_SPACE == pLVKeyDown->wVKey)
  860. {
  861. if (m_lstActions.GetSelectedCount() == 1)
  862. {
  863. int nItem;
  864. if (-1 != (nItem = m_lstActions.GetNextItem(-1, LVNI_SELECTED)))
  865. {
  866. PWIRELESS_PS_DATA pBWirelessPSData = NULL;
  867. PSNP_PS_DATA pNfaData;
  868. pNfaData = (PSNP_PS_DATA) m_lstActions.GetItemData(nItem);
  869. pBWirelessPSData = pNfaData->pWirelessPSData;
  870. ASSERT(pBWirelessPSData);
  871. // Redraw the list
  872. PopulateListControl ();
  873. // Reselect the toggled item
  874. DWORD dwSelection = -1;
  875. dwSelection = pBWirelessPSData->dwId;
  876. m_lstActions.SetItemState( dwSelection, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED );
  877. }
  878. }
  879. }
  880. else if (VK_DELETE == pLVKeyDown->wVKey)
  881. {
  882. if (!PSsRemovable())
  883. return;
  884. OnActionRemove();
  885. }
  886. *pResult = 0;
  887. }
  888. // Function: ToggleRuleActivation
  889. // Desc: Toggle the activation of the Security Policy Rule in the dlg's
  890. // list control.
  891. // Args:
  892. // nItemIndex: the 0-based index of the list item to be toggled
  893. HRESULT CSecPolRulesPage::ToggleRuleActivation( int nItemIndex )
  894. {
  895. HRESULT hr = S_OK;
  896. PSNP_PS_DATA pNfaData;
  897. pNfaData = (PSNP_PS_DATA) m_lstActions.GetItemData(nItemIndex);
  898. PWIRELESS_PS_DATA pBWirelessPSData = pNfaData->pWirelessPSData;
  899. SetModified();
  900. return hr;
  901. }
  902. void CSecPolRulesPage::OnDestroy()
  903. {
  904. // Note: We never receive a WM_CLOSE, so clean up here.
  905. SNP_PS_LIST::iterator theIterator;
  906. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  907. PSNP_PS_DATA pNfaData = NULL;
  908. FreeWirelessPolicyData(m_currentWirelessPolicyData);
  909. // Free objects associated with list.
  910. UnPopulateListControl();
  911. /* Taroon * found this leak from dh.. clearing Nfa List */
  912. //empty the previous List
  913. if (!m_NfaList.empty()) {
  914. for(theIterator = m_NfaList.begin();theIterator != m_NfaList.end(); ++theIterator) {
  915. pNfaData = (PSNP_PS_DATA)(*theIterator);
  916. pWirelessPSData = pNfaData->pWirelessPSData;
  917. FreeWirelessPSData(pWirelessPSData);
  918. LocalFree(pNfaData);
  919. }
  920. }
  921. m_NfaList.clear();
  922. CSnapinPropPage::OnDestroy();
  923. }
  924. BOOL CSecPolRulesPage::PSsRemovable()
  925. {
  926. if (m_lstActions.GetSelectedCount() == 0)
  927. return FALSE;
  928. BOOL bRemoveable = TRUE;
  929. int nIndex = -1;
  930. while (-1 != (nIndex = m_lstActions.GetNextItem( nIndex, LVNI_SELECTED )))
  931. {
  932. PSNP_PS_DATA pNfaData;
  933. pNfaData = (PSNP_PS_DATA) m_lstActions.GetItemData(nIndex);
  934. PWIRELESS_PS_DATA pBWirelessPSData = pNfaData->pWirelessPSData;
  935. if (NULL == pBWirelessPSData)
  936. continue;
  937. }
  938. return bRemoveable;
  939. }
  940. void CSecPolRulesPage::GenerateUniquePSName (UINT nID, CString& strName)
  941. {
  942. BOOL bUnique = TRUE;
  943. int iUTag = 0;
  944. CString strUName;
  945. DWORD dwError = 0;
  946. DWORD i = 0;
  947. PWIRELESS_POLICY_DATA pWirelessPolicyData = NULL;
  948. PWIRELESS_PS_DATA *ppWirelessPSData = NULL;
  949. PWIRELESS_PS_DATA pWirelessPSData = NULL;
  950. DWORD dwNumPreferredSettings = 0;
  951. // if an nID was passed in then start with that
  952. if (nID != 0)
  953. {
  954. strName.LoadString (nID);
  955. }
  956. /* Taroon:RemoveRight
  957. pWirelessPolicyData = GetResultObject()->GetWirelessPolicy();
  958. */
  959. pWirelessPolicyData = m_currentWirelessPolicyData;
  960. // zip through the ps and verify name is unique
  961. do
  962. {
  963. // only start tacking numbers on after the first pass
  964. if (iUTag > 0)
  965. {
  966. TCHAR buff[32];
  967. wsprintf (buff, _T(" (%d)"), iUTag);
  968. strUName = strName + buff;
  969. bUnique = TRUE;
  970. } else
  971. {
  972. strUName = strName;
  973. bUnique = TRUE;
  974. }
  975. ppWirelessPSData = pWirelessPolicyData->ppWirelessPSData;
  976. dwNumPreferredSettings = pWirelessPolicyData->dwNumPreferredSettings;
  977. for (i = 0; i < dwNumPreferredSettings ; i++) {
  978. pWirelessPSData = *(ppWirelessPSData + i);
  979. if (0 == strUName.CompareNoCase(pWirelessPSData->pszWirelessSSID)) {
  980. // set bUnique to FALSE
  981. bUnique = FALSE;
  982. iUTag++;
  983. }
  984. }
  985. }
  986. while (bUnique == FALSE);
  987. // done
  988. strName = strUName;
  989. }
  990. ////////////////////////////////////////////////////////////////////////////////////
  991. // CSecPolPropSheetManager
  992. BOOL CSecPolPropSheetManager::OnApply()
  993. {
  994. BOOL bRet = TRUE;
  995. //Query each page to apply
  996. bRet = CMMCPropSheetManager::OnApply();
  997. //if some page refuse to apply, dont do anything
  998. if (!bRet)
  999. return bRet;
  1000. ASSERT(m_pSecPolItem);
  1001. if (NULL == m_pSecPolItem)
  1002. return bRet;
  1003. DWORD dwError = 0;
  1004. dwError = WirelessSetPolicyData(
  1005. m_pSecPolItem->m_pComponentDataImpl->GetPolicyStoreHandle(),
  1006. m_pSecPolItem->GetWirelessPolicy()
  1007. );
  1008. if (ERROR_SUCCESS != dwError)
  1009. {
  1010. ReportError(IDS_SAVE_ERROR, HRESULT_FROM_WIN32(dwError));
  1011. }
  1012. GUID guidClientExt = CLSID_WIRELESSClientEx;
  1013. GUID guidSnapin = CLSID_Snapin;
  1014. m_pSecPolItem->m_pComponentDataImpl->UseGPEInformationInterface()->PolicyChanged (
  1015. TRUE,
  1016. TRUE,
  1017. &guidClientExt,
  1018. &guidSnapin
  1019. );
  1020. NotifyManagerApplied();
  1021. NotifyConsole();
  1022. return bRet;
  1023. }