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.

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