enumerate the permission names and display them

svn path=/trunk/; revision=16375
This commit is contained in:
Thomas Bluemel
2005-07-02 01:34:18 +00:00
parent 15436e184a
commit 16c7672bfd
7 changed files with 113 additions and 29 deletions
+80
View File
@@ -460,6 +460,77 @@ SetAceCheckListColumns(IN HWND hAceCheckList,
pt.x);
}
static VOID
LoadPermissionsList(IN PSECURITY_PAGE sp,
IN GUID *GuidObjectType,
IN DWORD dwFlags,
OUT SI_ACCESS *DefaultAccess)
{
HRESULT hRet;
PSI_ACCESS AccessList;
ULONG nAccessList, DefaultAccessIndex;
/* clear the permissions list */
SendMessage(sp->hAceCheckList,
CLM_CLEAR,
0,
0);
/* query the access rights from the server */
hRet = sp->psi->lpVtbl->GetAccessRights(sp->psi,
GuidObjectType,
dwFlags,
&AccessList,
&nAccessList,
&DefaultAccessIndex);
if (SUCCEEDED(hRet) && nAccessList != 0)
{
LPCWSTR NameStr;
PSI_ACCESS CurAccess, LastAccess;
WCHAR NameBuffer[MAX_PATH];
/* save the default access rights to be used when adding ACEs later */
if (DefaultAccess != NULL)
{
*DefaultAccess = AccessList[DefaultAccessIndex];
}
LastAccess = AccessList + nAccessList;
for (CurAccess = &AccessList[0];
CurAccess != LastAccess;
CurAccess++)
{
if (CurAccess->dwFlags & dwFlags)
{
/* get the permission name, load it from a string table if necessary */
if (IS_INTRESOURCE(CurAccess->pszName))
{
if (!LoadString(sp->ObjectInfo.hInstance,
(UINT)((ULONG_PTR)CurAccess->pszName),
NameBuffer,
sizeof(NameBuffer) / sizeof(NameBuffer[0])))
{
LoadString(hDllInstance,
IDS_UNKNOWN,
NameBuffer,
sizeof(NameBuffer) / sizeof(NameBuffer[0]));
}
NameStr = NameBuffer;
}
else
{
NameStr = CurAccess->pszName;
}
SendMessage(sp->hAceCheckList,
CLM_ADDITEM,
CIS_DISABLED | CIS_NONE,
(LPARAM)NameStr);
}
}
}
}
static INT_PTR CALLBACK
SecurityPageProc(IN HWND hwndDlg,
@@ -547,6 +618,12 @@ SecurityPageProc(IN HWND hwndDlg,
GetDlgItem(hwndDlg, IDC_LABEL_DENY));
/* FIXME - hide controls in case the flags aren't present */
LoadPermissionsList(sp,
NULL,
SI_ACCESS_GENERAL |
((sp->ObjectInfo.dwFlags & SI_CONTAINER) ? SI_ACCESS_CONTAINER : 0),
&sp->DefaultAccess);
}
break;
}
@@ -607,6 +684,8 @@ CreateSecurityPage(IN LPSECURITYINFO psi)
sPage->psi = psi;
sPage->ObjectInfo = ObjectInfo;
ZeroMemory(&psp, sizeof(psp));
psp.dwSize = sizeof(PROPSHEETPAGE);
psp.dwFlags = PSP_USECALLBACK;
psp.hInstance = hDllInstance;
@@ -683,6 +762,7 @@ EditSecurity(IN HWND hwndOwner,
{
/* Set the page title if the flag is present and the string isn't empty */
psh.pszCaption = ObjectInfo.pszPageTitle;
psh.dwFlags |= PSH_PROPTITLE;
lpCaption = NULL;
}
else
+1
View File
@@ -17,4 +17,5 @@ END
STRINGTABLE DISCARDABLE
{
IDS_PSP_TITLE "Berechtigungen für %1"
IDS_UNKNOWN "Unbekannt"
}
+1
View File
@@ -17,5 +17,6 @@ END
STRINGTABLE DISCARDABLE
{
IDS_PSP_TITLE "Permissions for %1"
IDS_UNKNOWN "Unknown"
}
+1
View File
@@ -35,5 +35,6 @@ END
STRINGTABLE DISCARDABLE
{
IDS_PSP_TITLE "Behörigheter för %1"
IDS_UNKNOWN "Unknown"
}
+6 -3
View File
@@ -44,6 +44,8 @@ typedef struct _SECURITY_PAGE
LPSECURITYINFO psi;
SI_OBJECT_INFO ObjectInfo;
SI_ACCESS DefaultAccess;
} SECURITY_PAGE, *PSECURITY_PAGE;
/* MISC ***********************************************************************/
@@ -68,10 +70,11 @@ ListViewSelectItem(IN HWND hwnd,
/* CHECKLIST CONTROL **********************************************************/
#define CIS_DISABLED (0x2)
#define CIS_DISABLED (0x4)
#define CIS_ENABLED (0x0)
#define CIS_ALLOW (0x1)
#define CIS_DENY (0x0)
#define CIS_ALLOW (0x2)
#define CIS_DENY (0x1)
#define CIS_NONE (0x0)
#define CLB_ALLOW (0x1)
#define CLB_DENY (0x0)
+23 -26
View File
@@ -281,12 +281,11 @@ PaintControl(IN PCHECKLISTWND infoPtr,
ScrollPos + VisibleFirstIndex);
if (FirstItem != NULL)
{
RECT TextRect, ItemRect;
RECT TextRect, ItemRect, CheckBox;
HFONT hOldFont;
DWORD CurrentIndex;
COLORREF OldTextColor;
BOOL Enabled, PrevEnabled;
POINT ptOld;
Enabled = IsWindowEnabled(infoPtr->hSelf);
PrevEnabled = Enabled;
@@ -299,11 +298,6 @@ PaintControl(IN PCHECKLISTWND infoPtr,
TextRect.right = ItemRect.right - 6;
TextRect.top = ItemRect.top + 2;
MoveToEx(hDC,
infoPtr->CheckBoxLeft[CLB_ALLOW],
ItemRect.top,
&ptOld);
OldTextColor = SetTextColor(hDC,
infoPtr->TextColor[Enabled]);
@@ -324,26 +318,34 @@ PaintControl(IN PCHECKLISTWND infoPtr,
infoPtr->TextColor[PrevEnabled]);
}
/* draw the text */
DrawText(hDC,
Item->Name,
-1,
&TextRect,
DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
MoveToEx(hDC,
infoPtr->CheckBoxLeft[CLB_ALLOW],
TextRect.top - 6,
NULL);
LineTo(hDC,
infoPtr->CheckBoxLeft[CLB_ALLOW],
TextRect.bottom - 6);
MoveToEx(hDC,
infoPtr->CheckBoxLeft[CLB_DENY],
TextRect.top - 6,
NULL);
LineTo(hDC,
infoPtr->CheckBoxLeft[CLB_DENY],
TextRect.bottom - 6);
/* draw the Allow checkbox */
CheckBox.left = infoPtr->CheckBoxLeft[CLB_ALLOW] - ((TextRect.bottom - TextRect.top) / 2);
CheckBox.right = CheckBox.left + (TextRect.bottom - TextRect.top) - 4;
CheckBox.top = TextRect.top;
CheckBox.bottom = CheckBox.top + (TextRect.bottom - TextRect.top) - 4;
DrawFrameControl(hDC,
&CheckBox,
DFC_BUTTON,
DFCS_BUTTONCHECK | DFCS_FLAT |
((Item->State & CIS_DISABLED) && Enabled ? DFCS_INACTIVE : 0) |
((Item->State & CIS_ALLOW) ? DFCS_CHECKED : 0));
/* draw the Deny checkbox */
CheckBox.left = infoPtr->CheckBoxLeft[CLB_DENY] - ((TextRect.bottom - TextRect.top) / 2);
CheckBox.right = CheckBox.left + (TextRect.bottom - TextRect.top) - 4;
DrawFrameControl(hDC,
&CheckBox,
DFC_BUTTON,
DFCS_BUTTONCHECK | DFCS_FLAT |
((Item->State & CIS_DISABLED) && Enabled ? DFCS_INACTIVE : 0) |
((Item->State & CIS_DENY) ? DFCS_CHECKED : 0));
TextRect.top += infoPtr->ItemHeight;
}
@@ -353,11 +355,6 @@ PaintControl(IN PCHECKLISTWND infoPtr,
SetTextColor(hDC,
OldTextColor);
MoveToEx(hDC,
ptOld.x,
ptOld.y,
NULL);
}
}
+1
View File
@@ -13,6 +13,7 @@
#define IDI_DEVMGR 100
#define IDS_PSP_TITLE 1001
#define IDS_UNKNOWN 1002
#define IDB_USRGRPIMAGES 1001