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.

202 lines
4.2 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Windows NT Secure Server Roles Security Configuration Wizard
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 2002
  7. //
  8. // File: ServerRoleSelPage.cxx
  9. //
  10. // Contents: Select Server Role Configuration Page.
  11. //
  12. // History: 04-Oct-01 Yanggao created
  13. //
  14. //-----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #include "resource.h"
  17. #include "misc.h"
  18. #include "state.h"
  19. #include "ServerRoleSelPage.h"
  20. #include "chklist.h"
  21. #include "otherpages.h"
  22. ServerRoleSelPage::ServerRoleSelPage()
  23. :
  24. SecCfgWizardPage(
  25. IDD_SERVER_ROLE_SEL,
  26. IDS_SERVER_ROLE_SEL_PAGE_TITLE,
  27. IDS_SERVER_ROLE_SEL_PAGE_SUBTITLE)
  28. {
  29. LOG_CTOR(ServerRoleSelPage);
  30. }
  31. ServerRoleSelPage::~ServerRoleSelPage()
  32. {
  33. LOG_DTOR(ServerRoleSelPage);
  34. }
  35. void
  36. ServerRoleSelPage::OnInit()
  37. {
  38. LOG_FUNCTION(ServerRoleSelPage::OnInit);
  39. }
  40. static
  41. void
  42. enable(HWND dialog)
  43. {
  44. ASSERT(Win::IsWindow(dialog));
  45. /*int next = PSWIZB_NEXT;
  46. if (Win::IsDlgButtonChecked(dialog, IDC_EDIT_CFG_RADIO))
  47. {
  48. next = !Win::GetTrimmedDlgItemText(dialog, IDC_EXISTING_CFG_EDIT).empty()
  49. ? PSWIZB_NEXT : 0;
  50. }
  51. Win::PropSheet_SetWizButtons(
  52. Win::GetParent(dialog),
  53. PSWIZB_BACK | next);*/
  54. }
  55. bool
  56. ServerRoleSelPage::OnCommand(
  57. HWND /*windowFrom*/,
  58. unsigned controlIDFrom,
  59. unsigned code)
  60. {
  61. LOG_FUNCTION(ServerRoleSelPage::OnCommand);
  62. // State& state = State::GetInstance();
  63. switch (controlIDFrom)
  64. {
  65. case IDC_ADDITIONALE_ROLE:
  66. {
  67. if (code == BN_CLICKED)
  68. {
  69. AdditionalRolesPage* pDlg = new AdditionalRolesPage();
  70. if( IDOK == pDlg->ModalExecute(hwnd) )
  71. {
  72. ;
  73. }
  74. return true;
  75. }
  76. break;
  77. }
  78. }
  79. return false;
  80. }
  81. bool
  82. ServerRoleSelPage::OnSetActive()
  83. {
  84. LOG_FUNCTION(ServerRoleSelPage::OnSetActive);
  85. enable(hwnd);
  86. HWND hWnd = Win::GetDlgItem(hwnd, IDC_CHECKBOX);
  87. if (!hWnd) {
  88. return FALSE;
  89. }
  90. Win::SendMessage(hWnd, CLM_RESETCONTENT,0,0);
  91. State& state = State::GetInstance();
  92. //Add Roles
  93. HRESULT hr = S_OK;
  94. RoleObject * pRole;
  95. for (long i = 0; i < state.GetNumRoles(); i++)
  96. {
  97. pRole = NULL;
  98. hr = state.GetRole(i, &pRole);
  99. if (FAILED(hr) || !pRole)
  100. {
  101. return true;
  102. }
  103. int nIndex = (int) Win::SendMessage(hWnd,
  104. CLM_ADDITEM,
  105. (WPARAM)pRole->getDisplayName(),
  106. (LPARAM)0);
  107. if (nIndex != -1)
  108. {
  109. BOOL bSet;
  110. //First column setting
  111. bSet = CLST_CHECKED;
  112. Win::SendMessage(hWnd,
  113. CLM_SETSTATE,
  114. MAKELONG(nIndex,1),
  115. bSet ? CLST_CHECKED : CLST_UNCHECKED);
  116. // Second column setting if there is
  117. //bSet = CLST_UNCHECKED;
  118. //Win::SendMessage(hWnd,
  119. // CLM_SETSTATE,
  120. // MAKELONG(nIndex,2),
  121. // CLST_DISABLED | (bSet ? CLST_CHECKED : CLST_UNCHECKED));
  122. }
  123. // role objects should be saved as item data rather than being deleted here:
  124. delete pRole;
  125. }
  126. return true;
  127. }
  128. int
  129. ServerRoleSelPage::Validate()
  130. {
  131. LOG_FUNCTION(ServerRoleSelPage::Validate);
  132. int nextPage = IDD_CLIENT_ROLE_SEL; //IDD_FINISH;
  133. // State& state = State::GetInstance();
  134. // HRESULT hr = S_OK;
  135. DWORD dw = 0;
  136. HWND hWnd = Win::GetDlgItem(hwnd, IDC_CHECKBOX);
  137. if (!hWnd) {
  138. ;//error
  139. }
  140. else
  141. {
  142. int nItems = (int) Win::SendMessage(hWnd,CLM_GETITEMCOUNT,0,0);
  143. for (int i=0;i<nItems;i++)
  144. {
  145. dw = (DWORD)Win::SendMessage(hWnd,CLM_GETSTATE,MAKELONG(i,1),0);
  146. if (CLST_CHECKED == dw)
  147. {
  148. ;//selected
  149. }
  150. }
  151. }
  152. return nextPage;
  153. }