[ros-diffs] [janderwald] 23517: * make 2nd stage setup semi-unattendable (locale page is missing) * to enable add the boot\bootdata\unattend.inf 6 optional to boot\bootdata\packages\reactos.dff

janderwald at svn.reactos.org janderwald at svn.reactos.org
Mon Aug 7 15:31:12 CEST 2006


Author: janderwald
Date: Mon Aug  7 17:31:11 2006
New Revision: 23517

URL: http://svn.reactos.org/svn/reactos?rev=23517&view=rev
Log:
* make 2nd stage setup semi-unattendable (locale page is missing)
* to enable add the boot\bootdata\unattend.inf                          6   optional
to boot\bootdata\packages\reactos.dff

Modified:
    trunk/reactos/dll/win32/syssetup/globals.h
    trunk/reactos/dll/win32/syssetup/wizard.c

Modified: trunk/reactos/dll/win32/syssetup/globals.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/globals.h?rev=23517&r1=23516&r2=23517&view=diff
==============================================================================
--- trunk/reactos/dll/win32/syssetup/globals.h (original)
+++ trunk/reactos/dll/win32/syssetup/globals.h Mon Aug  7 17:31:11 2006
@@ -37,8 +37,6 @@
   ULONG Index;
 } TIMEZONE_ENTRY, *PTIMEZONE_ENTRY;
 
-
-
 typedef struct _SETUPDATA
 {
   HFONT hTitleFont;
@@ -47,10 +45,14 @@
   TCHAR OwnerOrganization[51];
   TCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1];	/* max. 63 characters */
   TCHAR AdminPassword[15];				/* max. 14 characters */
+  BOOL  UnattendSetup;
 
   SYSTEMTIME SystemTime;
   PTIMEZONE_ENTRY TimeZoneListHead;
   PTIMEZONE_ENTRY TimeZoneListTail;
+  DWORD TimeZoneIndex;
+  DWORD DisableAutoDaylightTimeSet;
+  LCID LocaleID;
 } SETUPDATA, *PSETUPDATA;
 
 

Modified: trunk/reactos/dll/win32/syssetup/wizard.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/wizard.c?rev=23517&r1=23516&r2=23517&view=diff
==============================================================================
--- trunk/reactos/dll/win32/syssetup/wizard.c (original)
+++ trunk/reactos/dll/win32/syssetup/wizard.c Mon Aug  7 17:31:11 2006
@@ -268,6 +268,15 @@
               case PSN_SETACTIVE:
                 /* Enable the Next button */
                 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
+                if (SetupData.UnattendSetup)
+                  {
+                    SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_ACKPAGE);
+                    return TRUE;
+                  }
+                break;
+
+              case PSN_WIZBACK:
+                SetupData.UnattendSetup = FALSE;
                 break;
 
               default:
@@ -360,6 +369,15 @@
               case PSN_SETACTIVE:
                 /* Enable the Back and Next buttons */
                 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
+                if (SetupData.UnattendSetup)
+                  {
+                    SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_OWNERPAGE);
+                    return TRUE;
+                  }
+                break;
+
+              case PSN_WIZBACK:
+                SetupData.UnattendSetup = FALSE;
                 break;
 
               default:
@@ -375,6 +393,50 @@
   return FALSE;
 }
 
+static
+BOOL
+WriteOwnerSettings(TCHAR * OwnerName,
+                   TCHAR * OwnerOrganization)
+{
+  HKEY hKey;
+  LONG res;
+
+
+
+  res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                     _T("Software\\Microsoft\\Windows NT\\CurrentVersion"),
+                     0,
+                     KEY_ALL_ACCESS,
+                     &hKey);
+
+  if (res != ERROR_SUCCESS)
+    {
+      return FALSE;
+    }
+
+  res = RegSetValueEx(hKey,
+                      _T("RegisteredOwner"),
+                      0,
+                      REG_SZ,
+                      (LPBYTE)OwnerName,
+                      (_tcslen(OwnerName) + 1) * sizeof(TCHAR));
+
+  if (res != ERROR_SUCCESS)
+    {
+      RegCloseKey(hKey);
+      return FALSE;
+    }
+ 
+  res = RegSetValueEx(hKey,
+                      _T("RegisteredOrganization"),
+                      0,
+                      REG_SZ,
+                      (LPBYTE)OwnerOrganization,
+                      (_tcslen(OwnerOrganization) + 1) * sizeof(TCHAR));
+
+  RegCloseKey(hKey);
+  return (res == ERROR_SUCCESS);
+}
 
 static INT_PTR CALLBACK
 OwnerPageDlgProc(HWND hwndDlg,
@@ -384,7 +446,6 @@
 {
   TCHAR OwnerName[51];
   TCHAR OwnerOrganization[51];
-  HKEY hKey;
   LPNMHDR lpnm;
 
   switch (uMsg)
@@ -409,6 +470,16 @@
               case PSN_SETACTIVE:
                 /* Enable the Back and Next buttons */
                 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
+                if (SetupData.UnattendSetup)
+                  {
+                    SendMessage(GetDlgItem(hwndDlg, IDC_OWNERNAME), WM_SETTEXT, 0, (LPARAM)SetupData.OwnerName);
+                    SendMessage(GetDlgItem(hwndDlg, IDC_OWNERORGANIZATION), WM_SETTEXT, 0, (LPARAM)SetupData.OwnerOrganization);
+                    if (WriteOwnerSettings(SetupData.OwnerName, SetupData.OwnerOrganization))
+                      {
+                        SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_COMPUTERPAGE);
+                        return TRUE;
+                      }
+                  }
                 break;
 
               case PSN_WIZNEXT:
@@ -429,30 +500,15 @@
                 OwnerOrganization[0] = 0;
                 GetDlgItemTextW(hwndDlg, IDC_OWNERORGANIZATION, OwnerOrganization, 50);
 
-                RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-                             _T("Software\\Microsoft\\Windows NT\\CurrentVersion"),
-                             0,
-                             KEY_ALL_ACCESS,
-                             &hKey);
-                /* FIXME: check error code */
-
-                RegSetValueEx(hKey,
-                              _T("RegisteredOwner"),
-                              0,
-                              REG_SZ,
-                              (LPBYTE)OwnerName,
-                              (_tcslen(OwnerName) + 1) * sizeof(TCHAR));
-                /* FIXME: check error code */
-
-                RegSetValueEx(hKey,
-                              _T("RegisteredOrganization"),
-                              0,
-                              REG_SZ,
-                              (LPBYTE)OwnerOrganization,
-                              (_tcslen(OwnerOrganization) + 1) * sizeof(TCHAR));
-                /* FIXME: check error code */
-
-                RegCloseKey(hKey);
+                if (!WriteOwnerSettings(OwnerName, OwnerOrganization))
+                  {
+                    SetFocus(GetDlgItem(hwndDlg, IDC_OWNERNAME));
+                    SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+                    return TRUE;
+                  }
+
+              case PSN_WIZBACK:
+                SetupData.UnattendSetup = FALSE;
                 break;
 
               default:
@@ -467,7 +523,25 @@
 
   return FALSE;
 }
-
+static
+BOOL
+WriteComputerSettings(TCHAR * ComputerName, HWND hwndDlg)
+{
+  if (!SetComputerName(ComputerName))
+    {
+      MessageBox(hwndDlg,
+                 _T("Setup failed to set the computer name."),
+                 _T("ReactOS Setup"),
+                 MB_ICONERROR | MB_OK);
+
+      return FALSE;
+    }
+
+   /* Try to also set DNS hostname */
+  SetComputerNameEx(ComputerNamePhysicalDnsHostname, ComputerName);
+
+  return TRUE;
+}
 
 static INT_PTR CALLBACK
 ComputerPageDlgProc(HWND hwndDlg,
@@ -499,6 +573,13 @@
 
           /* Set focus to computer name */
           SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
+          if (SetupData.UnattendSetup)
+            {
+              SendMessage(GetDlgItem(hwndDlg, IDC_COMPUTERNAME), WM_SETTEXT, 0, (LPARAM)SetupData.ComputerName);
+              SendMessage(GetDlgItem(hwndDlg, IDC_ADMINPASSWORD1), WM_SETTEXT, 0, (LPARAM)SetupData.AdminPassword);
+              SendMessage(GetDlgItem(hwndDlg, IDC_ADMINPASSWORD2), WM_SETTEXT, 0, (LPARAM)SetupData.AdminPassword);
+            }
+
         }
         break;
 
@@ -512,6 +593,11 @@
               case PSN_SETACTIVE:
                 /* Enable the Back and Next buttons */
                 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
+                if (SetupData.UnattendSetup && WriteComputerSettings(SetupData.ComputerName, hwndDlg))
+                  {
+                    SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_LOCALEPAGE);
+                    return TRUE;
+                  }
                 break;
 
               case PSN_WIZNEXT:
@@ -528,18 +614,12 @@
 
                 /* FIXME: check computer name for invalid characters */
 
-                if (!SetComputerName(ComputerName))
-                {
-                  MessageBox(hwndDlg,
-                             _T("Setup failed to set the computer name."),
-                             _T("ReactOS Setup"),
-                             MB_ICONERROR | MB_OK);
-                  SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
-                  SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
-                  return TRUE;
-                }
-                /* Try to also set DNS hostname */
-                SetComputerNameEx(ComputerNamePhysicalDnsHostname, ComputerName);
+                if (!WriteComputerSettings(ComputerName, hwndDlg))
+                  {
+                    SetFocus(GetDlgItem(hwndDlg, IDC_COMPUTERNAME));
+                    SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+                    return TRUE;
+                  }
 
                 /* Check admin passwords */
                 GetDlgItemText(hwndDlg, IDC_ADMINPASSWORD1, Password1, 15);
@@ -560,6 +640,10 @@
                 /* FIXME: Set admin password */
                 break;
 
+              case PSN_WIZBACK:
+                SetupData.UnattendSetup = FALSE;
+                break;
+
               default:
                 break;
             }
@@ -666,6 +750,14 @@
   FreeLibrary(hDll);
 }
 
+static BOOL
+SetInputLocale()
+{
+  //TODO
+  //store the default locale
+
+  return FALSE;
+}
 
 static INT_PTR CALLBACK
 LocalePageDlgProc(HWND hwndDlg,
@@ -722,9 +814,18 @@
               case PSN_SETACTIVE:
                 /* Enable the Back and Next buttons */
                 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
+                if (SetupData->UnattendSetup && SetInputLocale())
+                  {
+                    SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE);
+                    return TRUE;
+                  }
                 break;
 
               case PSN_WIZNEXT:
+                break;
+
+              case PSN_WIZBACK:
+                SetupData->UnattendSetup = FALSE;
                 break;
 
               default:
@@ -1044,17 +1145,15 @@
 
 
 static VOID
-ShowTimeZoneList(HWND hwnd, PSETUPDATA SetupData)
+ShowTimeZoneList(HWND hwnd, PSETUPDATA SetupData, DWORD dwEntryIndex)
 {
   PTIMEZONE_ENTRY Entry;
   DWORD dwIndex = 0;
-  DWORD dwEntryIndex = 0;
   DWORD dwCount;
 
 #if 0
   GetTimeZoneListIndex(&dwEntryIndex);
 #endif
-  dwEntryIndex = 85; /* GMT time zone */
 
   Entry = SetupData->TimeZoneListHead;
   while (Entry != NULL)
@@ -1235,6 +1334,25 @@
   return Ret;
 }
 
+static BOOL
+WriteDateTimeSettings(HWND hwndDlg, PSETUPDATA SetupData)
+{
+  GetLocalSystemTime(hwndDlg, SetupData);
+  SetLocalTimeZone(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
+                   SetupData);
+
+  SetAutoDaylightInfo(GetDlgItem(hwndDlg, IDC_AUTODAYLIGHT));
+  if(!SetSystemLocalTime(hwndDlg, SetupData))
+    {
+      MessageBox(hwndDlg,
+                 _T("Setup was unable to set the local time."),
+                 _T("ReactOS Setup"),
+                 MB_ICONWARNING | MB_OK);
+      return FALSE;
+    }
+
+  return TRUE;
+}
 
 static INT_PTR CALLBACK
 DateTimePageDlgProc(HWND hwndDlg,
@@ -1256,11 +1374,25 @@
           SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)SetupData);
 
           CreateTimeZoneList(SetupData);
-
-          ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
-                           SetupData);
-
-          SendDlgItemMessage(hwndDlg, IDC_AUTODAYLIGHT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
+          
+          if (SetupData->UnattendSetup)
+            {
+              ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
+                               SetupData, SetupData->TimeZoneIndex);
+
+              if (!SetupData->DisableAutoDaylightTimeSet)
+                {
+                  SendDlgItemMessage(hwndDlg, IDC_AUTODAYLIGHT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
+                }
+            }
+          else
+            {
+              ShowTimeZoneList(GetDlgItem(hwndDlg, IDC_TIMEZONELIST),
+                               SetupData, 85 /* GMT time zone */);
+
+              SendDlgItemMessage(hwndDlg, IDC_AUTODAYLIGHT, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
+            }
+
         }
         break;
 
@@ -1274,6 +1406,11 @@
               case PSN_SETACTIVE:
                 /* Enable the Back and Next buttons */
                 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
+                if (SetupData->UnattendSetup && WriteDateTimeSettings(hwndDlg, SetupData))
+                  {
+                    SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_PROCESSPAGE);
+                    return TRUE;
+                  }
                 break;
 
               case PSN_WIZNEXT:
@@ -1290,6 +1427,10 @@
                                MB_ICONWARNING | MB_OK);
                   }
                 }
+                break;
+
+              case PSN_WIZBACK:
+                SetupData->UnattendSetup = FALSE;
                 break;
 
               default:
@@ -1610,6 +1751,10 @@
               case PSN_WIZNEXT:
                 break;
 
+              case PSN_WIZBACK:
+                SetupData->UnattendSetup = FALSE;
+                break;
+
               default:
                 break;
             }
@@ -1745,8 +1890,8 @@
                 KillTimer(hwndDlg, 1);
 
                 /* Skip the progress page */
-                PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_DATETIMEPAGE);
-                SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+                SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_DATETIMEPAGE);
+                SetupData.UnattendSetup = FALSE;
                 return TRUE;
 
               case PSN_WIZFINISH:
@@ -1764,6 +1909,86 @@
     }
 
   return FALSE;
+}
+BOOL
+ProcessUnattendInf(HINF hUnattendedInf)
+{
+  INFCONTEXT InfContext;
+  TCHAR szName[256];
+  TCHAR szValue[256];
+  DWORD LineLength;
+
+  if (!SetupFindFirstLine(hUnattendedInf,
+              _T("Unattend"),
+              NULL,
+              &InfContext))
+    {
+      DPRINT1("Error: SetupFindFirstLine failed %d\n", GetLastError());
+      return FALSE;
+    }
+
+  do
+  {	
+    if (!SetupGetStringField(&InfContext,
+                 0,
+                 szName,
+                 sizeof(szName) / sizeof(TCHAR),
+                 &LineLength))
+      {
+        DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
+        return FALSE;
+      }
+
+    if (!SetupGetStringField(&InfContext,
+                 1,
+                 szValue,
+                 sizeof(szValue) / sizeof(TCHAR),
+                 &LineLength))
+      {
+        DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
+        return FALSE;
+      }
+    DPRINT1("Name %S Value %S\n",szName, szValue);
+    if (!_tcscmp(szName, _T("FullName")))
+      {
+        if ((sizeof(SetupData.OwnerName) / sizeof(TCHAR)) > LineLength)
+          {
+            _tcscpy(SetupData.OwnerName, szValue);
+          }
+      }
+    else if (!_tcscmp(szName, _T("OrgName")))
+      {
+        if ((sizeof(SetupData.OwnerOrganization) / sizeof(TCHAR)) > LineLength)
+          {
+            _tcscpy(SetupData.OwnerOrganization, szValue);
+          }
+      }
+    else if (!_tcscmp(szName, _T("ComputerName")))
+      {
+        if ((sizeof(SetupData.ComputerName) / sizeof(TCHAR)) > LineLength)
+        {
+          _tcscpy(SetupData.ComputerName, szValue);
+        }
+    }
+    else if (!_tcscmp(szName, _T("AdminPassword")))
+      {
+        if ((sizeof(SetupData.AdminPassword) / sizeof(TCHAR)) > LineLength)
+          {
+            _tcscpy(SetupData.AdminPassword, szValue);
+          }
+      }
+    else if (!_tcscmp(szName, _T("TimeZoneIndex")))
+      {
+        SetupData.TimeZoneIndex = _ttoi(szValue);
+      }
+    else if (_tcscmp(szName, _T("DisableAutoDaylightTimeSet")))
+      {
+        SetupData.DisableAutoDaylightTimeSet = _ttoi(szValue);
+      }
+  }
+  while (SetupFindNextLine(&InfContext, &InfContext));
+
+  return TRUE;
 }
 
 
@@ -1774,9 +1999,21 @@
   HPROPSHEETPAGE ahpsp[8];
   PROPSHEETPAGE psp = {0};
   UINT nPages = 0;
+  HINF hUnattendedInf;
 
   /* Clear setup data */
   ZeroMemory(&SetupData, sizeof(SETUPDATA));
+
+  hUnattendedInf = SetupOpenInfFileW(L"unattend.inf",
+                           NULL,
+                           INF_STYLE_OLDNT,
+                           NULL);
+  
+  if (hUnattendedInf != INVALID_HANDLE_VALUE)
+  {
+    SetupData.UnattendSetup = ProcessUnattendInf(hUnattendedInf);
+    SetupCloseInfFile(hUnattendedInf);
+  }
 
   /* Create the Welcome page */
   psp.dwSize = sizeof(PROPSHEETPAGE);




More information about the Ros-diffs mailing list