Author: hbelusca
Date: Thu May 18 01:24:41 2017
New Revision: 74576
URL:
http://svn.reactos.org/svn/reactos?rev=74576&view=rev
Log:
[USETUP]: Implement most of the "upgrade" page (where existing NTOS
installations are listed).
- Modify a bit the page flow so that the upgrade page is inserted before the
Device-settings page, and after the Install-Intro page.
- Insert some extra 'RepairUpdateFlag' checks in SelectPartitionPage() and
InstallDirectoryPage() to take specific actions in case the flag is TRUE.
- As overviewed in r74573, move 'TempPartition' and 'FormatState' back to
USETUP.
Added:
branches/setup_improvements/base/setup/usetup/osdetect.h (with props)
Modified:
branches/setup_improvements/base/setup/usetup/interface/usetup.c
branches/setup_improvements/base/setup/usetup/osdetect.c
branches/setup_improvements/base/setup/usetup/usetup.h
Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1]
(original)
+++ branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] Thu May
18 01:24:41 2017
@@ -58,7 +58,11 @@
WCHAR DefaultKBLayout[20];
BOOLEAN RepairUpdateFlag = FALSE;
HANDLE hPnpThread = INVALID_HANDLE_VALUE;
+
PPARTLIST PartitionList = NULL;
+PPARTENTRY TempPartition = NULL;
+FORMATMACHINESTATE FormatState = Start;
+
/* LOCALS *******************************************************************/
@@ -86,11 +90,14 @@
static UNICODE_STRING DestinationArcPath;
static UNICODE_STRING DestinationRootPath;
-static WCHAR DestinationDriveLetter;
+static WCHAR DestinationDriveLetter; // FIXME: Is it really useful??
static HINF SetupInf;
static HSPFILEQ SetupFileQueue = NULL;
+
+static PNTOS_INSTALLATION CurrentInstallation = NULL;
+static PGENERIC_LIST NtOsInstallsList = NULL;
static PGENERIC_LIST ComputerList = NULL;
static PGENERIC_LIST DisplayList = NULL;
@@ -936,7 +943,7 @@
*
* Next pages:
* InstallIntroPage (default)
- * RepairIntroPage
+ * RecoveryPage
* LicensePage
* QuitPage
*
@@ -966,7 +973,7 @@
}
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R') /* R */
{
- return REPAIR_INTRO_PAGE;
+ return RECOVERY_PAGE;
}
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'L') /* L */
{
@@ -1007,48 +1014,127 @@
/*
- * Displays the RepairIntroPage.
+ * Displays the UpgradeRepairPage.
*
* Next pages:
* RebootPage (default)
* InstallIntroPage
* RecoveryPage
- * IntroPage
+ * WelcomePage
*
* RETURNS
* Number of the next page.
*/
static PAGE_NUMBER
-RepairIntroPage(PINPUT_RECORD Ir)
+UpgradeRepairPage(PINPUT_RECORD Ir)
{
- MUIDisplayPage(REPAIR_INTRO_PAGE);
-
- while(TRUE)
+ GENERIC_LIST_UI ListUi;
+
+/*** HACK!! ***/
+ if (PartitionList == NULL)
+ {
+ PartitionList = CreatePartitionList();
+ if (PartitionList == NULL)
+ {
+ /* FIXME: show an error dialog */
+ MUIDisplayError(ERROR_DRIVE_INFORMATION, Ir, POPUP_WAIT_ENTER);
+ return QUIT_PAGE;
+ }
+ else if (IsListEmpty(&PartitionList->DiskListHead))
+ {
+ MUIDisplayError(ERROR_NO_HDD, Ir, POPUP_WAIT_ENTER);
+ return QUIT_PAGE;
+ }
+
+ TempPartition = NULL;
+ FormatState = Start;
+ }
+/**************/
+
+ NtOsInstallsList = CreateNTOSInstallationsList(PartitionList);
+ if (!NtOsInstallsList)
+ DPRINT1("Failed to get a list of NTOS installations; continue
installation...\n");
+ if (!NtOsInstallsList || GetNumberOfListEntries(NtOsInstallsList) == 0)
+ {
+ RepairUpdateFlag = FALSE;
+
+ // return INSTALL_INTRO_PAGE;
+ return DEVICE_SETTINGS_PAGE;
+ // return SCSI_CONTROLLER_PAGE;
+ }
+
+ MUIDisplayPage(UPGRADE_REPAIR_PAGE);
+
+ InitGenericListUi(&ListUi, NtOsInstallsList);
+ DrawGenericList(&ListUi,
+ 2, 23,
+ xScreen - 3,
+ yScreen - 3);
+
+ SaveGenericListState(NtOsInstallsList);
+
+ // return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
+ while (TRUE)
{
CONSOLE_ConInKey(Ir);
- if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
- {
- return REBOOT_PAGE;
- }
- else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'U') /* U */
- {
- RepairUpdateFlag = TRUE;
- return INSTALL_INTRO_PAGE;
- }
- else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R') /* R */
- {
- return RECOVERY_PAGE;
+ if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
+ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
+ {
+ ScrollDownGenericList(&ListUi);
+ }
+ else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
+ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
+ {
+ ScrollUpGenericList(&ListUi);
+ }
+ else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
+ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
+ {
+ ScrollPageDownGenericList(&ListUi);
+ }
+ else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
+ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
+ {
+ ScrollPageUpGenericList(&ListUi);
+ }
+ else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
+ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
+ {
+ if (ConfirmQuit(Ir) == TRUE)
+ return QUIT_PAGE;
+ else
+ RedrawGenericList(&ListUi);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
{
- return WELCOME_PAGE;
- }
- }
-
- return REPAIR_INTRO_PAGE;
+ RestoreGenericListState(NtOsInstallsList);
+ // return nextPage; // prevPage;
+ }
+ // else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
+ else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'U') /* U */
+ {
+ /* Retrieve the current installation */
+ CurrentInstallation =
(PNTOS_INSTALLATION)GetListEntryUserData(GetCurrentListEntry(NtOsInstallsList));
+ DPRINT1("Selected installation for repair: \"%S\" ; DiskNumber
= %d , PartitionNumber = %d\n",
+ CurrentInstallation->InstallationName,
CurrentInstallation->DiskNumber, CurrentInstallation->PartitionNumber);
+
+ RepairUpdateFlag = TRUE;
+
+ // return nextPage;
+ /***/return INSTALL_INTRO_PAGE;/***/
+ }
+ else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) &&
(Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
+ {
+ /* a-z */
+ GenericListKeyPress(&ListUi, Ir->Event.KeyEvent.uChar.AsciiChar);
+ }
+ }
+
+ return UPGRADE_REPAIR_PAGE;
}
+
/*
* Displays the InstallIntroPage.
@@ -1067,8 +1153,17 @@
{
if (RepairUpdateFlag)
{
- //return SELECT_PARTITION_PAGE;
+#if 1 /* Old code that looks good */
+
+ // return SELECT_PARTITION_PAGE;
return DEVICE_SETTINGS_PAGE;
+
+#else /* Possible new code? */
+
+ return DEVICE_SETTINGS_PAGE;
+ // return SCSI_CONTROLLER_PAGE;
+
+#endif
}
if (IsUnattendedSetup)
@@ -1090,8 +1185,7 @@
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
- return DEVICE_SETTINGS_PAGE;
- // return SCSI_CONTROLLER_PAGE;
+ return UPGRADE_REPAIR_PAGE;
}
}
@@ -1555,6 +1649,25 @@
MUIDisplayError(ERROR_NO_HDD, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
+
+ TempPartition = NULL;
+ FormatState = Start;
+ }
+
+ if (RepairUpdateFlag)
+ {
+ /* Determine the selected installation disk & partition */
+ if (!SelectPartition(PartitionList,
+ CurrentInstallation->DiskNumber,
+ CurrentInstallation->PartitionNumber))
+ {
+ DPRINT1("Whaaaaaat?!?! ASSERT!\n");
+ ASSERT(FALSE);
+ }
+
+ DestinationDriveLetter =
(WCHAR)PartitionList->CurrentPartition->DriveLetter;
+
+ return SELECT_FILE_SYSTEM_PAGE;
}
MUIDisplayPage(SELECT_PARTITION_PAGE);
@@ -2602,25 +2715,25 @@
return QUIT_PAGE;
}
- PreviousFormatState = PartitionList->FormatState;
- switch (PartitionList->FormatState)
+ PreviousFormatState = FormatState;
+ switch (FormatState)
{
case Start:
{
if (PartitionList->CurrentPartition != PartitionList->SystemPartition)
{
- PartitionList->TempPartition = PartitionList->SystemPartition;
- PartitionList->TempPartition->NeedsCheck = TRUE;
-
- PartitionList->FormatState = FormatSystemPartition;
+ TempPartition = PartitionList->SystemPartition;
+ TempPartition->NeedsCheck = TRUE;
+
+ FormatState = FormatSystemPartition;
DPRINT1("FormatState: Start --> FormatSystemPartition\n");
}
else
{
- PartitionList->TempPartition = PartitionList->CurrentPartition;
- PartitionList->TempPartition->NeedsCheck = TRUE;
-
- PartitionList->FormatState = FormatInstallPartition;
+ TempPartition = PartitionList->CurrentPartition;
+ TempPartition->NeedsCheck = TRUE;
+
+ FormatState = FormatInstallPartition;
DPRINT1("FormatState: Start --> FormatInstallPartition\n");
}
break;
@@ -2628,10 +2741,10 @@
case FormatSystemPartition:
{
- PartitionList->TempPartition = PartitionList->CurrentPartition;
- PartitionList->TempPartition->NeedsCheck = TRUE;
-
- PartitionList->FormatState = FormatInstallPartition;
+ TempPartition = PartitionList->CurrentPartition;
+ TempPartition->NeedsCheck = TRUE;
+
+ FormatState = FormatInstallPartition;
DPRINT1("FormatState: FormatSystemPartition -->
FormatInstallPartition\n");
break;
}
@@ -2640,15 +2753,15 @@
{
if (GetNextUnformattedPartition(PartitionList,
NULL,
- &PartitionList->TempPartition))
- {
- PartitionList->FormatState = FormatOtherPartition;
- PartitionList->TempPartition->NeedsCheck = TRUE;
+ &TempPartition))
+ {
+ FormatState = FormatOtherPartition;
+ TempPartition->NeedsCheck = TRUE;
DPRINT1("FormatState: FormatInstallPartition -->
FormatOtherPartition\n");
}
else
{
- PartitionList->FormatState = FormatDone;
+ FormatState = FormatDone;
DPRINT1("FormatState: FormatInstallPartition -->
FormatDone\n");
return CHECK_FILE_SYSTEM_PAGE;
}
@@ -2659,15 +2772,15 @@
{
if (GetNextUnformattedPartition(PartitionList,
NULL,
- &PartitionList->TempPartition))
- {
- PartitionList->FormatState = FormatOtherPartition;
- PartitionList->TempPartition->NeedsCheck = TRUE;
+ &TempPartition))
+ {
+ FormatState = FormatOtherPartition;
+ TempPartition->NeedsCheck = TRUE;
DPRINT1("FormatState: FormatOtherPartition -->
FormatOtherPartition\n");
}
else
{
- PartitionList->FormatState = FormatDone;
+ FormatState = FormatDone;
DPRINT1("FormatState: FormatOtherPartition -->
FormatDone\n");
return CHECK_FILE_SYSTEM_PAGE;
}
@@ -2682,7 +2795,7 @@
}
}
- PartEntry = PartitionList->TempPartition;
+ PartEntry = TempPartition;
DiskEntry = PartEntry->DiskEntry;
/* Adjust disk size */
@@ -2743,7 +2856,7 @@
}
else if (PartEntry->New == TRUE)
{
- switch (PartitionList->FormatState)
+ switch (FormatState)
{
case FormatSystemPartition:
CONSOLE_SetTextXY(6, 8, MUIGetString(STRING_NONFORMATTEDSYSTEMPART));
@@ -2851,7 +2964,7 @@
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
{
- PartitionList->FormatState = Start;
+ FormatState = Start;
return SELECT_PARTITION_PAGE;
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
@@ -2873,7 +2986,7 @@
}
}
- PartitionList->FormatState = PreviousFormatState;
+ FormatState = PreviousFormatState;
return SELECT_FILE_SYSTEM_PAGE;
}
@@ -2914,14 +3027,13 @@
MUIDisplayPage(FORMAT_PARTITION_PAGE);
- if (PartitionList == NULL ||
- PartitionList->TempPartition == NULL)
+ if (PartitionList == NULL || TempPartition == NULL)
{
/* FIXME: show an error dialog */
return QUIT_PAGE;
}
- PartEntry = PartitionList->TempPartition;
+ PartEntry = TempPartition;
DiskEntry = PartEntry->DiskEntry;
SelectedFileSystem = FileSystemList->Selected;
@@ -3238,6 +3350,8 @@
if (IsUnattendedSetup)
wcscpy(InstallDir, UnattendInstallationDirectory);
+ else if (RepairUpdateFlag)
+ wcscpy(InstallDir, CurrentInstallation->SystemRoot);
else
wcscpy(InstallDir, L"\\ReactOS");
@@ -3248,6 +3362,13 @@
// FIXME: Check the validity of the InstallDir; however what to do
// if it is invalid but we are in unattended setup? (case of somebody
// specified an invalid installation directory in the unattended file).
+
+ if (RepairUpdateFlag)
+ {
+ return InstallDirectoryPage1(InstallDir,
+ DiskEntry,
+ PartEntry);
+ }
if (IsUnattendedSetup)
{
@@ -4441,12 +4562,21 @@
{
MUIDisplayPage(QUIT_PAGE);
+ /* Destroy the NTOS installations list */
+ if (NtOsInstallsList != NULL)
+ {
+ DestroyGenericList(NtOsInstallsList, TRUE);
+ NtOsInstallsList = NULL;
+ }
+
/* Destroy the partition list */
if (PartitionList != NULL)
{
DestroyPartitionList(PartitionList);
PartitionList = NULL;
}
+ TempPartition = NULL;
+ FormatState = Start;
/* Destroy the filesystem list */
if (FileSystemList != NULL)
@@ -4745,8 +4875,8 @@
break;
/* Repair pages */
- case REPAIR_INTRO_PAGE:
- Page = RepairIntroPage(&Ir);
+ case UPGRADE_REPAIR_PAGE:
+ Page = UpgradeRepairPage(&Ir);
break;
case SUCCESS_PAGE:
Modified: branches/setup_improvements/base/setup/usetup/osdetect.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/osdetect.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/osdetect.c [iso-8859-1] Thu May 18
01:24:41 2017
@@ -563,16 +563,6 @@
return Success;
}
-typedef struct _NTOS_INSTALLATION
-{
- LIST_ENTRY ListEntry;
- ULONG DiskNumber;
- ULONG PartitionNumber;
-// Vendor????
- WCHAR SystemRoot[MAX_PATH];
-/**/WCHAR InstallationName[MAX_PATH];/**/
-} NTOS_INSTALLATION, *PNTOS_INSTALLATION;
-
static VOID
ListNTOSInstalls(
IN PGENERIC_LIST List)
@@ -682,6 +672,7 @@
PVOID ViewBase;
WCHAR PathBuffer[MAX_PATH];
WCHAR SystemRoot[MAX_PATH];
+ WCHAR InstallNameW[MAX_PATH];
/* Set PartitionRootPath */
swprintf(PathBuffer,
@@ -741,7 +732,9 @@
{
DPRINT1("Found a valid NTOS installation in disk #%d, partition #%d,
SystemRoot %S\n",
DiskNumber, PartitionNumber, SystemRoot);
- AddNTOSInstallation(List, DiskNumber, PartitionNumber, SystemRoot,
L"Install_Windows");
+ StringCchPrintfW(InstallNameW, ARRAYSIZE(InstallNameW), L"%C:
\\Device\\Harddisk%lu\\Partition%lu\\%s \"%s\"",
+ 'X' /* FIXME: Partition letter */, DiskNumber,
PartitionNumber, SystemRoot, L"Windows (placeholder)");
+ AddNTOSInstallation(List, DiskNumber, PartitionNumber, SystemRoot,
InstallNameW);
}
// Here we get a SystemRootPath for each installation // FIXME!
@@ -751,7 +744,9 @@
{
DPRINT1("Found a valid NTOS installation in disk #%d, partition #%d,
SystemRoot %S\n",
DiskNumber, PartitionNumber, SystemRoot);
- AddNTOSInstallation(List, DiskNumber, PartitionNumber, SystemRoot,
L"Install_ReactOS");
+ StringCchPrintfW(InstallNameW, ARRAYSIZE(InstallNameW), L"%C:
\\Device\\Harddisk%lu\\Partition%lu\\%s \"%s\"",
+ 'X' /* FIXME: Partition letter */, DiskNumber,
PartitionNumber, SystemRoot, L"ReactOS (placeholder)");
+ AddNTOSInstallation(List, DiskNumber, PartitionNumber, SystemRoot,
InstallNameW);
}
/* Finally, unmap and close the file */
Added: branches/setup_improvements/base/setup/usetup/osdetect.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/osdetect.h (added)
+++ branches/setup_improvements/base/setup/usetup/osdetect.h [iso-8859-1] Thu May 18
01:24:41 2017
@@ -0,0 +1,15 @@
+
+typedef struct _NTOS_INSTALLATION
+{
+ LIST_ENTRY ListEntry;
+ ULONG DiskNumber;
+ ULONG PartitionNumber;
+// Vendor????
+ WCHAR SystemRoot[MAX_PATH];
+/**/WCHAR InstallationName[MAX_PATH];/**/
+} NTOS_INSTALLATION, *PNTOS_INSTALLATION;
+
+// EnumerateNTOSInstallations
+PGENERIC_LIST
+CreateNTOSInstallationsList(
+ IN PPARTLIST List);
Propchange: branches/setup_improvements/base/setup/usetup/osdetect.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/setup_improvements/base/setup/usetup/usetup.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/usetup.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/usetup.h [iso-8859-1] Thu May 18
01:24:41 2017
@@ -72,6 +72,7 @@
#include "cabinet.h"
#include "filesup.h"
#include "genlist.h"
+#include "osdetect.h"
#include "host.h"
#include "mui.h"