implemented EditSecurity()
[reactos.git] / reactos / lib / aclui / aclui.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: aclui.c,v 1.3 2004/08/10 15:47:54 weiden Exp $
20 *
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)
25 *
26 * UPDATE HISTORY:
27 * 08/10/2004 Created
28 */
29 #define INITGUID
30 #include <windows.h>
31 #include <prsht.h>
32 #include <aclui.h>
33 #include <rosrtl/resstr.h>
34 #include "internal.h"
35 #include "resource.h"
36
37 HINSTANCE hDllInstance;
38
39
40
41 BOOL STDCALL
42 DllMain(HINSTANCE hinstDLL,
43 DWORD dwReason,
44 LPVOID lpvReserved)
45 {
46 switch (dwReason)
47 {
48 case DLL_PROCESS_ATTACH:
49 hDllInstance = hinstDLL;
50 break;
51 case DLL_THREAD_ATTACH:
52 break;
53 case DLL_THREAD_DETACH:
54 break;
55 case DLL_PROCESS_DETACH:
56 break;
57 }
58 return TRUE;
59 }
60
61 /*
62 * EditSecurity EXPORTED
63 *
64 * @implemented
65 */
66 BOOL
67 WINAPI
68 EditSecurity(HWND hwndOwner, LPSECURITYINFO psi)
69 {
70 HRESULT hRet;
71 SI_OBJECT_INFO ObjectInfo;
72 PROPSHEETHEADER psh;
73 HPROPSHEETPAGE hPages[1];
74 LPWSTR lpCaption;
75 BOOL Ret;
76
77 if(psi == NULL)
78 {
79 SetLastError(ERROR_INVALID_PARAMETER);
80
81 DPRINT("No ISecurityInformation class passed!\n");
82 return FALSE;
83 }
84
85 /* get the object information from the client interface */
86 hRet = psi->lpVtbl->GetObjectInformation(psi, &ObjectInfo);
87
88 if(FAILED(hRet))
89 {
90 SetLastError(hRet);
91
92 DPRINT("GetObjectInformation() failed!\n");
93 return FALSE;
94 }
95
96 /* create the page */
97 hPages[0] = CreateSecurityPage(psi);
98 if(hPages[0] == NULL)
99 {
100 DPRINT("CreateSecurityPage(), couldn't create property sheet!\n");
101 return FALSE;
102 }
103
104 psh.dwSize = sizeof(PROPSHEETHEADER);
105 psh.dwFlags = PSH_DEFAULT;
106 psh.hwndParent = hwndOwner;
107 psh.hInstance = hDllInstance;
108 if((ObjectInfo.dwFlags & SI_PAGE_TITLE) != 0 &&
109 ObjectInfo.pszPageTitle != NULL && ObjectInfo.pszPageTitle[0] != L'\0')
110 {
111 /* Set the page title if the flag is present and the string isn't empty */
112 psh.pszCaption = ObjectInfo.pszPageTitle;
113 lpCaption = NULL;
114 }
115 else
116 {
117 /* Set the page title to the object name, make sure the format string
118 has "%1" NOT "%s" because it uses FormatMessage() to automatically
119 allocate the right amount of memory. */
120 RosLoadAndFormatStr(hDllInstance, IDS_PSP_TITLE, &lpCaption, ObjectInfo.pszObjectName);
121 psh.pszCaption = lpCaption;
122 }
123 psh.nPages = sizeof(hPages) / sizeof(HPROPSHEETPAGE);
124 psh.nStartPage = 0;
125 psh.phpage = hPages;
126
127 Ret = (PropertySheet(&psh) != -1);
128
129 if(lpCaption != NULL)
130 {
131 LocalFree((HLOCAL)lpCaption);
132 }
133
134 return Ret;
135 }
136