https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba783adf1e2456745e6e48...
commit ba783adf1e2456745e6e483ac3ae04cd0e3f0c0b Author: Eric Kohl eric.kohl@reactos.org AuthorDate: Sat Jan 4 14:54:30 2020 +0100 Commit: Eric Kohl eric.kohl@reactos.org CommitDate: Sat Jan 4 14:54:30 2020 +0100
[SYSDM] Improve the user profile dialog
- Currently used profiles cannot be copied or deleted. - Unknown profiles cannot be copied. - A double click on a profile opens the change profile type dialog. --- dll/cpl/sysdm/userprofile.c | 62 ++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 21 deletions(-)
diff --git a/dll/cpl/sysdm/userprofile.c b/dll/cpl/sysdm/userprofile.c index bd2ac0fe80d..faef5431970 100644 --- a/dll/cpl/sysdm/userprofile.c +++ b/dll/cpl/sysdm/userprofile.c @@ -18,6 +18,7 @@ typedef struct _PROFILEDATA { DWORD dwRefCount; DWORD dwState; + BOOL bUnknownProfile; PWSTR pszFullName; PWSTR pszProfilePath; } PROFILEDATA, *PPROFILEDATA; @@ -391,7 +392,8 @@ BOOL GetProfileName( _In_ PSID pProfileSid, _In_ DWORD dwNameBufferSize, - _Out_ PWSTR pszNameBuffer) + _Out_ PWSTR pszNameBuffer, + _Out_ PBOOL pbUnknownProfile) { WCHAR szAccountName[128], szDomainName[128]; DWORD dwAccountNameSize, dwDomainNameSize; @@ -409,6 +411,7 @@ GetProfileName( { /* Unknown account */ LoadStringW(hApplet, IDS_USERPROFILE_ACCOUNT_UNKNOWN, pszNameBuffer, dwNameBufferSize); + *pbUnknownProfile = TRUE; } else { @@ -426,6 +429,7 @@ GetProfileName( /* Normal account */ wsprintf(pszNameBuffer, L"%s\%s", szDomainName, szAccountName); } + *pbUnknownProfile = FALSE; }
return TRUE; @@ -479,6 +483,7 @@ AddUserProfile( HANDLE hFile; SYSTEMTIME SystemTime; ULONGLONG ullProfileSize; + BOOL bUnknownProfile; DWORD dwError;
/* Get the profile path */ @@ -521,7 +526,10 @@ AddUserProfile( GetProfileSize(szProfilePath, &ullProfileSize);
/* Get the profile name */ - if (!GetProfileName(pProfileSid, ARRAYSIZE(szNameBuffer), szNameBuffer)) + if (!GetProfileName(pProfileSid, + ARRAYSIZE(szNameBuffer), + szNameBuffer, + &bUnknownProfile)) return;
/* Get the profile state value */ @@ -560,6 +568,7 @@ AddUserProfile(
pProfileData->dwRefCount = dwRefCount; pProfileData->dwState = dwState; + pProfileData->bUnknownProfile = bUnknownProfile;
ptr = (PWSTR)((ULONG_PTR)pProfileData + sizeof(PROFILEDATA)); pProfileData->pszFullName = ptr; @@ -629,29 +638,37 @@ UpdateButtonState( BOOL bChange = FALSE; BOOL bCopy = FALSE; BOOL bDelete = FALSE; + PPROFILEDATA pProfileData;
- iSelected = ListView_GetNextItem(hwndListView, -1, LVNI_SELECTED); - if (iSelected != -1) + if (ListView_GetSelectedCount(hwndListView) != 0) { - Item.mask = LVIF_PARAM; - Item.iItem = iSelected; - Item.iSubItem = 0; - if (ListView_GetItem(hwndListView, &Item)) + iSelected = ListView_GetNextItem(hwndListView, -1, LVNI_SELECTED); + if (iSelected != -1) { - if (Item.lParam != 0) + Item.mask = LVIF_PARAM; + Item.iItem = iSelected; + Item.iSubItem = 0; + if (ListView_GetItem(hwndListView, &Item)) { - bCopy = (((PPROFILEDATA)Item.lParam)->dwRefCount == 0); - bDelete = (((PPROFILEDATA)Item.lParam)->dwRefCount == 0); + if (Item.lParam != 0) + { + pProfileData = (PPROFILEDATA)Item.lParam; + + if (pProfileData->bUnknownProfile) + { + bDelete = TRUE; + bCopy = FALSE; + } + else + { + bDelete = (pProfileData->dwRefCount == 0); + bCopy = (pProfileData->dwRefCount == 0); + } + } } - }
- bChange = TRUE; - } - else - { - bChange = FALSE; - bCopy = FALSE; - bDelete = FALSE; + bChange = TRUE; + } }
EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_CHANGE), bChange); @@ -823,9 +840,12 @@ OnNotify( { ShellExecuteW(hwndDlg, NULL, L"usrmgr.cpl", NULL, NULL, 0); } - else if (nmhdr->idFrom == IDC_USERPROFILE_LIST && nmhdr->code == LVN_ITEMCHANGED) + else if (nmhdr->idFrom == IDC_USERPROFILE_LIST) { - UpdateButtonState(hwndDlg, nmhdr->hwndFrom); + if (nmhdr->code == LVN_ITEMCHANGED) + UpdateButtonState(hwndDlg, nmhdr->hwndFrom); + else if (nmhdr->code == NM_DBLCLK) + ChangeUserProfileType(hwndDlg); } }