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.

470 lines
6.6 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. w3accts.cpp
  5. Abstract:
  6. WWW Accounts Property Page
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "w3scfg.h"
  18. #include "w3accts.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24. IMPLEMENT_DYNCREATE(CW3AccountsPage, CInetPropertyPage)
  25. CW3AccountsPage::CW3AccountsPage(
  26. IN CInetPropertySheet * pSheet
  27. )
  28. /*++
  29. Routine Description:
  30. Accounts page constructor
  31. Arguments:
  32. CInetPropertySheet * pSheet : Sheet data
  33. Return Value:
  34. N/A
  35. --*/
  36. : CInetPropertyPage(CW3AccountsPage::IDD, pSheet),
  37. m_ListBoxRes(
  38. IDB_ACLUSERS,
  39. CAccessEntryListBox::nBitmaps
  40. ),
  41. m_oblSID()
  42. {
  43. #ifdef _DEBUG
  44. afxMemDF |= checkAlwaysMemDF;
  45. #endif // _DEBUG
  46. m_list_Administrators.AttachResources(&m_ListBoxRes);
  47. #if 0 // Keep class wizard happy
  48. //{{AFX_DATA_INIT(CW3AccountsPage)
  49. //}}AFX_DATA_INIT
  50. #endif // 0
  51. }
  52. CW3AccountsPage::~CW3AccountsPage()
  53. /*++
  54. Routine Description:
  55. Destructor
  56. Arguments:
  57. N/A
  58. Return Value:
  59. N/A
  60. --*/
  61. {
  62. }
  63. void
  64. CW3AccountsPage::DoDataExchange(
  65. IN CDataExchange * pDX
  66. )
  67. /*
  68. Routine Description:
  69. Initialise/Store control data
  70. Arguments:
  71. CDataExchange * pDX - DDX/DDV control structure
  72. Return Value:
  73. None
  74. --*/
  75. {
  76. CInetPropertyPage::DoDataExchange(pDX);
  77. //{{AFX_DATA_MAP(CW3AccountsPage)
  78. DDX_Control(pDX, IDC_BUTTON_DELETE, m_button_RemoveAdministrator);
  79. DDX_Control(pDX, IDC_BUTTON_ADD, m_button_Add);
  80. //}}AFX_DATA_MAP
  81. //
  82. // Private DDX/DDV Routines
  83. //
  84. DDX_Control(pDX, IDC_LIST_ADMINISTRATORS, m_list_Administrators);
  85. }
  86. //
  87. // Message Map
  88. //
  89. BEGIN_MESSAGE_MAP(CW3AccountsPage, CInetPropertyPage)
  90. //{{AFX_MSG_MAP(CW3AccountsPage)
  91. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  92. ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
  93. ON_CBN_SELCHANGE(IDC_LIST_ADMINISTRATORS, OnSelchangeListAdministrators)
  94. //}}AFX_MSG_MAP
  95. END_MESSAGE_MAP()
  96. BOOL
  97. CW3AccountsPage::SetAdminRemoveState()
  98. /*++
  99. Routine Description:
  100. Set the state of the remove button depending on the selection in the
  101. administrators listbox. Remove is only enabled if ALL selected
  102. items are removable.
  103. Arguments:
  104. None
  105. Return Value:
  106. TRUE if the remove button is enabled
  107. --*/
  108. {
  109. int nSel = 0;
  110. int cSelectedItems = 0;
  111. BOOL fAllDeletable = TRUE;
  112. CAccessEntry * pAccess;
  113. while ((pAccess = m_list_Administrators.GetNextSelectedItem(&nSel)) != NULL)
  114. {
  115. ++cSelectedItems;
  116. if (!pAccess->IsDeletable())
  117. {
  118. fAllDeletable = FALSE;
  119. break;
  120. }
  121. ++nSel;
  122. }
  123. fAllDeletable = fAllDeletable && (cSelectedItems > 0);
  124. m_button_RemoveAdministrator.EnableWindow(
  125. fAllDeletable
  126. && HasOperatorList()
  127. && HasAdminAccess()
  128. );
  129. return fAllDeletable;
  130. }
  131. //
  132. // Message Handlers
  133. //
  134. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  135. BOOL
  136. CW3AccountsPage::OnInitDialog()
  137. /*++
  138. Routine Description:
  139. WM_INITDIALOG handler. Initialize the dialog.
  140. Arguments:
  141. None.
  142. Return Value:
  143. TRUE if no focus is to be set automatically, FALSE if the focus
  144. is already set.
  145. --*/
  146. {
  147. CInetPropertyPage::OnInitDialog();
  148. m_list_Administrators.Initialize();
  149. CWaitCursor wait;
  150. //
  151. // Build the ACL list
  152. //
  153. CError err(BuildAclOblistFromBlob(
  154. ((CW3Sheet *)GetSheet())->GetInstanceProperties().m_acl,
  155. m_oblSID
  156. ));
  157. err.MessageBoxOnFailure();
  158. m_list_Administrators.FillAccessListBox(m_oblSID);
  159. //
  160. // check if the operators controls are accessible
  161. //
  162. m_button_Add.EnableWindow(HasOperatorList());
  163. SetAdminRemoveState();
  164. return TRUE;
  165. }
  166. /* virtual */
  167. HRESULT
  168. CW3AccountsPage::FetchLoadedValues()
  169. /*++
  170. Routine Description:
  171. Move configuration data from sheet to dialog controls
  172. Arguments:
  173. None
  174. Return Value:
  175. HRESULT
  176. --*/
  177. {
  178. //
  179. // Nothing to do..
  180. //
  181. return S_OK;
  182. }
  183. /* virtual */
  184. HRESULT
  185. CW3AccountsPage::SaveInfo()
  186. /*++
  187. Routine Description:
  188. Save the information on this property page
  189. Arguments:
  190. BOOL fUpdateData : If TRUE, control data has not yet been stored. This
  191. is the case when "apply" is pressed.
  192. Return Value:
  193. Error return code
  194. --*/
  195. {
  196. ASSERT(IsDirty());
  197. TRACEEOLID("Saving W3 accounts page now...");
  198. //
  199. // Message crackers require m_ notation
  200. //
  201. CBlob m_acl;
  202. BOOL fAclDirty = BuildAclBlob(m_oblSID, m_acl);
  203. CError err;
  204. BeginWaitCursor();
  205. BEGIN_META_INST_WRITE(CW3Sheet)
  206. if (fAclDirty)
  207. {
  208. STORE_INST_DATA_ON_SHEET(m_acl)
  209. }
  210. END_META_INST_WRITE(err)
  211. EndWaitCursor();
  212. return err;
  213. }
  214. void
  215. CW3AccountsPage::OnItemChanged()
  216. /*++
  217. Routine Description:
  218. All EN_CHANGE and BN_CLICKED messages map to this function
  219. Arguments:
  220. None
  221. Return Value:
  222. None
  223. --*/
  224. {
  225. SetModified(TRUE);
  226. }
  227. void
  228. CW3AccountsPage::OnButtonAdd()
  229. /*++
  230. Routine Description:
  231. 'Add' button has been pressed
  232. Arguments:
  233. None
  234. Return Value:
  235. None
  236. --*/
  237. {
  238. if (m_list_Administrators.AddToAccessList(
  239. this,
  240. QueryServerName(),
  241. m_oblSID
  242. ))
  243. {
  244. OnItemChanged();
  245. }
  246. SetAdminRemoveState();
  247. }
  248. void
  249. CW3AccountsPage::OnSelchangeListAdministrators()
  250. /*++
  251. Routine Description:
  252. Selection Change in admin list box handler
  253. Arguments:
  254. None.
  255. Return Value:
  256. None
  257. --*/
  258. {
  259. SetAdminRemoveState();
  260. }
  261. void
  262. CW3AccountsPage::OnButtonDelete()
  263. /*
  264. Routine Description:
  265. Delete all selected items in the list box
  266. Arguments:
  267. None.
  268. Return Value:
  269. None
  270. --*/
  271. {
  272. int nSel = 0;
  273. int cChanges = 0;
  274. CAccessEntry * pAccess;
  275. while ((pAccess = m_list_Administrators.GetNextSelectedItem(&nSel)) != NULL)
  276. {
  277. //
  278. // Remove button should be disabled unless all selected
  279. // items are deletable
  280. //
  281. ASSERT(pAccess->IsDeletable());
  282. if (pAccess->IsDeletable())
  283. {
  284. ++cChanges;
  285. pAccess->FlagForDeletion();
  286. m_list_Administrators.DeleteString(nSel);
  287. //
  288. // Don't advance counter to account for shift
  289. //
  290. continue;
  291. }
  292. ++nSel;
  293. }
  294. if (cChanges)
  295. {
  296. OnItemChanged();
  297. }
  298. if (!SetAdminRemoveState())
  299. {
  300. m_button_Add.SetFocus();
  301. }
  302. }