2 * ReactOS Access Control List Editor
3 * Copyright (C) 2004 ReactOS Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * PROJECT: ReactOS Access Control List Editor
22 * FILE: lib/aclui/aclui.c
23 * PURPOSE: Access Control List Editor
24 * PROGRAMMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
34 #include <rosrtl/resstr.h>
38 HINSTANCE hDllInstance
;
41 SecurityPageCallback(HWND hwnd
, UINT uMsg
, LPPROPSHEETPAGE ppsp
)
49 sp
= LocalAlloc(LHND
, sizeof(SECURITY_PAGE
));
52 /* save the pointer to the ISecurityInformation interface */
53 sp
->psi
= (LPSECURITYINFO
)ppsp
->lParam
;
54 /* set the lParam to the allocated structure */
55 ppsp
->lParam
= (LPARAM
)sp
;
64 PSECURITY_PAGE sp
= (PSECURITY_PAGE
)ppsp
->lParam
;
65 if(sp
->hiUsrs
!= NULL
)
67 ImageList_Destroy(sp
->hiUsrs
);
69 LocalFree((HLOCAL
)sp
);
80 SecurityPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
88 sp
= (PSECURITY_PAGE
)lParam
;
95 sp
->hWndUsrList
= GetDlgItem(hwndDlg
, IDC_ACELIST
);
96 sp
->hiUsrs
= ImageList_LoadBitmap(hDllInstance
, MAKEINTRESOURCE(IDB_USRGRPIMAGES
), 16, 3, 0);
98 /* save the pointer to the structure */
99 SetWindowLongPtr(hwndDlg
, DWL_USER
, (DWORD_PTR
)sp
);
101 GetClientRect(sp
->hWndUsrList
, &rcLvClient
);
103 /* setup the listview control */
104 ListView_SetExtendedListViewStyleEx(sp
->hWndUsrList
, LVS_EX_FULLROWSELECT
, LVS_EX_FULLROWSELECT
);
105 ListView_SetImageList(sp
->hWndUsrList
, sp
->hiUsrs
, LVSIL_SMALL
);
107 /* add a column to the list view */
108 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
109 lvc
.fmt
= LVCFMT_LEFT
;
110 lvc
.cx
= rcLvClient
.right
;
111 ListView_InsertColumn(sp
->hWndUsrList
, 0, &lvc
);
113 /* FIXME - hide controls in case the flags aren't present */
123 * CreateSecurityPage EXPORTED
129 CreateSecurityPage(LPSECURITYINFO psi
)
132 SI_OBJECT_INFO ObjectInfo
;
137 SetLastError(ERROR_INVALID_PARAMETER
);
139 DPRINT("No ISecurityInformation class passed!\n");
143 /* get the object information from the server interface */
144 hRet
= psi
->lpVtbl
->GetObjectInformation(psi
, &ObjectInfo
);
150 DPRINT("CreateSecurityPage() failed!\n");
154 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
155 psp
.dwFlags
= PSP_DEFAULT
| PSP_USECALLBACK
;
156 psp
.hInstance
= hDllInstance
;
157 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SECPAGE
);
158 psp
.pfnDlgProc
= SecurityPageProc
;
159 psp
.lParam
= (LPARAM
)psi
;
160 psp
.pfnCallback
= SecurityPageCallback
;
162 if((ObjectInfo
.dwFlags
& SI_PAGE_TITLE
) != 0 &&
163 ObjectInfo
.pszPageTitle
!= NULL
&& ObjectInfo
.pszPageTitle
[0] != L
'\0')
165 /* Set the page title if the flag is present and the string isn't empty */
166 psp
.pszTitle
= ObjectInfo
.pszPageTitle
;
167 psp
.dwFlags
|= PSP_USETITLE
;
170 return CreatePropertySheetPage(&psp
);
175 * EditSecurity EXPORTED
181 EditSecurity(HWND hwndOwner
, LPSECURITYINFO psi
)
184 SI_OBJECT_INFO ObjectInfo
;
186 HPROPSHEETPAGE hPages
[1];
192 SetLastError(ERROR_INVALID_PARAMETER
);
194 DPRINT("No ISecurityInformation class passed!\n");
198 /* get the object information from the server interface */
199 hRet
= psi
->lpVtbl
->GetObjectInformation(psi
, &ObjectInfo
);
205 DPRINT("GetObjectInformation() failed!\n");
209 /* create the page */
210 hPages
[0] = CreateSecurityPage(psi
);
211 if(hPages
[0] == NULL
)
213 DPRINT("CreateSecurityPage(), couldn't create property sheet!\n");
217 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
218 psh
.dwFlags
= PSH_DEFAULT
;
219 psh
.hwndParent
= hwndOwner
;
220 psh
.hInstance
= hDllInstance
;
221 if((ObjectInfo
.dwFlags
& SI_PAGE_TITLE
) != 0 &&
222 ObjectInfo
.pszPageTitle
!= NULL
&& ObjectInfo
.pszPageTitle
[0] != L
'\0')
224 /* Set the page title if the flag is present and the string isn't empty */
225 psh
.pszCaption
= ObjectInfo
.pszPageTitle
;
230 /* Set the page title to the object name, make sure the format string
231 has "%1" NOT "%s" because it uses FormatMessage() to automatically
232 allocate the right amount of memory. */
233 RosLoadAndFormatStr(hDllInstance
, IDS_PSP_TITLE
, &lpCaption
, ObjectInfo
.pszObjectName
);
234 psh
.pszCaption
= lpCaption
;
236 psh
.nPages
= sizeof(hPages
) / sizeof(HPROPSHEETPAGE
);
240 Ret
= (PropertySheet(&psh
) != -1);
242 if(lpCaption
!= NULL
)
244 LocalFree((HLOCAL
)lpCaption
);
251 DllMain(HINSTANCE hinstDLL
,
257 case DLL_PROCESS_ATTACH
:
258 hDllInstance
= hinstDLL
;
260 case DLL_THREAD_ATTACH
:
262 case DLL_THREAD_DETACH
:
264 case DLL_PROCESS_DETACH
: