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.

204 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: ClientRoleSelPage.cxx
  9. //
  10. // Contents: Client Server Role Configuration Page.
  11. //
  12. // History: 25-Oct-01 Yanggao created
  13. //
  14. //-----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #include "resource.h"
  17. #include "misc.h"
  18. #include "state.h"
  19. #include "ClientRoleSelPage.h"
  20. #include "chklist.h"
  21. #include "otherpages.h"
  22. ClientRoleSelPage::ClientRoleSelPage()
  23. :
  24. SecCfgWizardPage(
  25. IDD_CLIENT_ROLE_SEL,
  26. IDS_CLIENT_ROLE_SEL_PAGE_TITLE,
  27. IDS_CLIENT_ROLE_SEL_PAGE_SUBTITLE)
  28. {
  29. LOG_CTOR(ClientRoleSelPage);
  30. }
  31. ClientRoleSelPage::~ClientRoleSelPage()
  32. {
  33. LOG_DTOR(ClientRoleSelPage);
  34. }
  35. void
  36. ClientRoleSelPage::OnInit()
  37. {
  38. LOG_FUNCTION(ClientRoleSelPage::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. ClientRoleSelPage::OnCommand(
  57. HWND /*windowFrom*/,
  58. unsigned controlIDFrom,
  59. unsigned code)
  60. {
  61. LOG_FUNCTION(ClientRoleSelPage::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. ClientRoleSelPage::OnSetActive()
  83. {
  84. LOG_FUNCTION(ClientRoleSelPage::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 it is a client role
  100. if (FAILED(hr) || !pRole)
  101. {
  102. return true;
  103. }
  104. int nIndex = (int) Win::SendMessage(hWnd,
  105. CLM_ADDITEM,
  106. (WPARAM)pRole->getDisplayName(),
  107. (LPARAM)0);
  108. if (nIndex != -1)
  109. {
  110. BOOL bSet;
  111. //First column setting
  112. bSet = CLST_CHECKED;
  113. Win::SendMessage(hWnd,
  114. CLM_SETSTATE,
  115. MAKELONG(nIndex,1),
  116. bSet ? CLST_CHECKED : CLST_UNCHECKED);
  117. // Second column setting if there is
  118. //bSet = CLST_UNCHECKED;
  119. //Win::SendMessage(hWnd,
  120. // CLM_SETSTATE,
  121. // MAKELONG(nIndex,2),
  122. // CLST_DISABLED | (bSet ? CLST_CHECKED : CLST_UNCHECKED));
  123. }
  124. // role objects should be saved as item data rather than being deleted here:
  125. delete pRole;
  126. }
  127. return true;
  128. }
  129. int
  130. ClientRoleSelPage::Validate()
  131. {
  132. LOG_FUNCTION(ClientRoleSelPage::Validate);
  133. int nextPage = IDD_ADDITIONAL_FUNC_SEL;
  134. // State& state = State::GetInstance();
  135. // HRESULT hr = S_OK;
  136. DWORD dw = 0;
  137. HWND hWnd = Win::GetDlgItem(hwnd, IDC_CHECKBOX);
  138. if (!hWnd) {
  139. ;//error
  140. }
  141. else
  142. {
  143. int nItems = (int) Win::SendMessage(hWnd,CLM_GETITEMCOUNT,0,0);
  144. for (int i=0;i<nItems;i++)
  145. {
  146. dw = (DWORD)Win::SendMessage(hWnd,CLM_GETSTATE,MAKELONG(i,1),0);
  147. if (CLST_CHECKED == dw)
  148. {
  149. ;//selected
  150. }
  151. }
  152. }
  153. return nextPage;
  154. }