Add the Membership and Profile pages to the users property sheet. Changing the settin...
authorEric Kohl <eric.kohl@reactos.org>
Sun, 1 Jun 2008 15:05:22 +0000 (15:05 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 1 Jun 2008 15:05:22 +0000 (15:05 +0000)
svn path=/trunk/; revision=33808

reactos/dll/cpl/usrmgr/lang/en-US.rc
reactos/dll/cpl/usrmgr/resource.h
reactos/dll/cpl/usrmgr/userprops.c

index 576cb98..869536e 100644 (file)
@@ -54,6 +54,38 @@ BEGIN
 END
 
 
 END
 
 
+IDD_USER_MEMBERSHIP DIALOGEX DISCARDABLE  0, 0, 252, 223
+STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Membership"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    LTEXT "Member of:", -1, 7, 7, 56, 8
+    CONTROL "", IDC_USER_MEMBERSHIP_LIST, "SysListView32", LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
+            7, 18, 238, 173, WS_EX_CLIENTEDGE
+END
+
+
+IDD_USER_PROFILE DIALOGEX DISCARDABLE  0, 0, 252, 223
+STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Profile"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "User profile", -1, 7, 7, 238, 54
+    LTEXT "Profile path:", -1, 16, 22, 55, 8
+    EDITTEXT IDC_USER_PROFILE_PATH, 78, 19, 160, 13, ES_AUTOHSCROLL
+    LTEXT "Logon script:", -1, 16, 40, 55, 8
+    EDITTEXT IDC_USER_PROFILE_SCRIPT, 78, 37, 160, 13, ES_AUTOHSCROLL
+
+    GROUPBOX "Home directory", -1, 7, 68, 238, 54
+    AUTORADIOBUTTON "Local path:", IDC_USER_PROFILE_LOCAL, 16, 83, 60, 10
+    AUTORADIOBUTTON "Connect:", IDC_USER_PROFILE_REMOTE, 16, 100, 60, 10
+    EDITTEXT IDC_USER_PROFILE_LOCAL_PATH, 78, 81, 160, 13, ES_AUTOHSCROLL
+    COMBOBOX IDC_USER_PROFILE_DRIVE, 78, 99, 26, 160, CBS_DROPDOWNLIST | CBS_SORT | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL
+    LTEXT "to:", -1, 112, 101, 12, 8
+    EDITTEXT IDC_USER_PROFILE_REMOTE_PATH, 130, 99, 108, 13, ES_AUTOHSCROLL
+END
+
+
 IDD_GROUP_GENERAL DIALOGEX DISCARDABLE  0, 0, 252, 223
 STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
 CAPTION "General"
 IDD_GROUP_GENERAL DIALOGEX DISCARDABLE  0, 0, 252, 223
 STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
 CAPTION "General"
index 5c6ccc1..8539aca 100644 (file)
 #define IDC_USER_NEW_NEVER_EXPIRES  368
 #define IDC_USER_NEW_DISABLED       369
 
 #define IDC_USER_NEW_NEVER_EXPIRES  368
 #define IDC_USER_NEW_DISABLED       369
 
-
-#define IDD_GROUP_NEW               370
-#define IDC_GROUP_NEW_NAME          371
-#define IDC_GROUP_NEW_DESCRIPTION   372
+#define IDD_USER_MEMBERSHIP         370
+#define IDC_USER_MEMBERSHIP_LIST    371
+
+#define IDD_USER_PROFILE             380
+#define IDC_USER_PROFILE_PATH        381
+#define IDC_USER_PROFILE_SCRIPT      382
+#define IDC_USER_PROFILE_LOCAL       383
+#define IDC_USER_PROFILE_REMOTE      384
+#define IDC_USER_PROFILE_LOCAL_PATH  385
+#define IDC_USER_PROFILE_DRIVE       386
+#define IDC_USER_PROFILE_REMOTE_PATH 387
+
+#define IDD_GROUP_NEW                390
+#define IDC_GROUP_NEW_NAME           391
+#define IDC_GROUP_NEW_DESCRIPTION    392
 
 
 /* Strings */
 
 
 /* Strings */
index c535186..80f0497 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS User Manager Control Panel
 /*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS User Manager Control Panel
- * FILE:            dll/cpl/usrmgr/users.c
+ * FILE:            dll/cpl/usrmgr/userprops.c
  * PURPOSE:         User property sheet
  *
  * PROGRAMMERS:     Eric Kohl
  * PURPOSE:         User property sheet
  *
  * PROGRAMMERS:     Eric Kohl
@@ -9,6 +9,182 @@
 
 #include "usrmgr.h"
 
 
 #include "usrmgr.h"
 
+
+static VOID
+GetProfileData(HWND hwndDlg, LPTSTR lpUserName)
+{
+    PUSER_INFO_3 userInfo = NULL;
+    NET_API_STATUS status;
+    BOOL bLocal;
+    TCHAR szDrive[8];
+    INT i;
+    INT nSel;
+
+    status = NetUserGetInfo(NULL, lpUserName, 3, (LPBYTE*)&userInfo);
+    if (status != NERR_Success)
+        return;
+
+    SetDlgItemText(hwndDlg, IDC_USER_PROFILE_PATH, userInfo->usri3_profile);
+    SetDlgItemText(hwndDlg, IDC_USER_PROFILE_SCRIPT, userInfo->usri3_script_path);
+
+
+    bLocal = (userInfo->usri3_home_dir_drive == NULL) ||
+              (_tcslen(userInfo->usri3_home_dir_drive) == 0);
+    CheckRadioButton(hwndDlg, IDC_USER_PROFILE_LOCAL, IDC_USER_PROFILE_REMOTE,
+                     bLocal ? IDC_USER_PROFILE_LOCAL : IDC_USER_PROFILE_REMOTE);
+
+    for (i = 0; i < 26; i++)
+    {
+        wsprintf(szDrive, _T("%c:"), (TCHAR)('A' + i));
+        nSel = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
+                           CB_INSERTSTRING, -1, (LPARAM)szDrive);
+    }
+
+    if (bLocal)
+    {
+        SetDlgItemText(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH, userInfo->usri3_home_dir);
+        EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), FALSE);
+        EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), FALSE);
+    }
+    else
+    {
+        SetDlgItemText(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH, userInfo->usri3_home_dir);
+        nSel = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
+                           CB_FINDSTRINGEXACT, -1, (LPARAM)userInfo->usri3_home_dir_drive);
+    }
+
+    SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
+                CB_SETCURSEL, nSel, 0);
+
+    NetApiBufferFree(userInfo);
+}
+
+
+INT_PTR CALLBACK
+UserProfilePageProc(HWND hwndDlg,
+                    UINT uMsg,
+                    WPARAM wParam,
+                    LPARAM lParam)
+{
+
+    UNREFERENCED_PARAMETER(lParam);
+    UNREFERENCED_PARAMETER(wParam);
+    UNREFERENCED_PARAMETER(hwndDlg);
+
+    switch (uMsg)
+    {
+        case WM_INITDIALOG:
+            GetProfileData(hwndDlg,
+                           (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
+            break;
+
+        case WM_COMMAND:
+            switch (LOWORD(wParam))
+            {
+                case IDC_USER_PROFILE_LOCAL:
+                    EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH), TRUE);
+                    EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), FALSE);
+                    EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), FALSE);
+                    break;
+
+                case IDC_USER_PROFILE_REMOTE:
+                    EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH), FALSE);
+                    EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), TRUE);
+                    EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), TRUE);
+                    break;
+            }
+            break;
+    }
+
+    return FALSE;
+}
+
+
+static VOID
+GetMembershipData(HWND hwndDlg, LPTSTR lpUserName)
+{
+    PLOCALGROUP_USERS_INFO_0 usersInfo = NULL;
+    NET_API_STATUS status;
+    DWORD dwRead;
+    DWORD dwTotal;
+    DWORD i;
+    HIMAGELIST hImgList;
+    HICON hIcon;
+    LV_ITEM lvi;
+    HWND hwndLV;
+    LV_COLUMN column;
+    RECT rect;
+
+
+    hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST);
+
+    /* Create the image list */
+    hImgList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 5, 5);
+    hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_GROUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+    ImageList_AddIcon(hImgList, hIcon);
+    DestroyIcon(hIcon);
+    (void)ListView_SetImageList(hwndLV, hImgList, LVSIL_SMALL);
+
+    /* Set the list column */
+    GetClientRect(hwndLV, &rect);
+
+    memset(&column, 0x00, sizeof(column));
+    column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
+    column.fmt = LVCFMT_LEFT;
+    column.cx = (INT)(rect.right - rect.left);
+    column.iSubItem = 0;
+    (void)ListView_InsertColumn(hwndLV, 0, &column);
+
+
+    status = NetUserGetLocalGroups(NULL, lpUserName, 0, 0,
+                                   (LPBYTE*)&usersInfo,
+                                   MAX_PREFERRED_LENGTH,
+                                   &dwRead,
+                                   &dwTotal);
+    if (status != NERR_Success)
+        return;
+
+    for (i = 0; i < dwRead; i++)
+    {
+        ZeroMemory(&lvi, sizeof(lvi));
+        lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
+        lvi.pszText = usersInfo[i].lgrui0_name;
+        lvi.state = 0;
+        lvi.iImage = 0; 
+
+        (void)ListView_InsertItem(hwndLV, &lvi);
+    }
+
+
+    NetApiBufferFree(usersInfo);
+
+}
+
+
+INT_PTR CALLBACK
+UserMembershipPageProc(HWND hwndDlg,
+                       UINT uMsg,
+                       WPARAM wParam,
+                       LPARAM lParam)
+{
+
+    UNREFERENCED_PARAMETER(lParam);
+    UNREFERENCED_PARAMETER(wParam);
+    UNREFERENCED_PARAMETER(hwndDlg);
+
+    switch (uMsg)
+    {
+        case WM_INITDIALOG:
+            GetMembershipData(hwndDlg,
+                              (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
+            break;
+
+    }
+
+    return FALSE;
+}
+
+
 static VOID
 UpdateUserOptions(HWND hwndDlg,
                   PUSER_INFO_3 userInfo,
 static VOID
 UpdateUserOptions(HWND hwndDlg,
                   PUSER_INFO_3 userInfo,
@@ -131,7 +307,7 @@ InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszUse
 VOID
 UserProperties(HWND hwndDlg)
 {
 VOID
 UserProperties(HWND hwndDlg)
 {
-    PROPSHEETPAGE psp[1];
+    PROPSHEETPAGE psp[3];
     PROPSHEETHEADER psh;
     TCHAR szUserName[UNLEN];
     INT nItem;
     PROPSHEETHEADER psh;
     TCHAR szUserName[UNLEN];
     INT nItem;
@@ -160,8 +336,8 @@ UserProperties(HWND hwndDlg)
     psh.ppsp = psp;
 
     InitPropSheetPage(&psp[0], IDD_USER_GENERAL, (DLGPROC)UserGeneralPageProc, szUserName);
     psh.ppsp = psp;
 
     InitPropSheetPage(&psp[0], IDD_USER_GENERAL, (DLGPROC)UserGeneralPageProc, szUserName);
-//    InitPropSheetPage(&psp[1], IDD_USER_MEMBERSHIP, (DLGPROC)UserMembershipPageProc);
-//    InitPropSheetPage(&psp[2], IDD_USER_PROFILE, (DLGPROC)UserProfilePageProc);
+    InitPropSheetPage(&psp[1], IDD_USER_MEMBERSHIP, (DLGPROC)UserMembershipPageProc, szUserName);
+    InitPropSheetPage(&psp[2], IDD_USER_PROFILE, (DLGPROC)UserProfilePageProc, szUserName);
 
     PropertySheet(&psh);
 }
 
     PropertySheet(&psh);
 }