Author: hbelusca
Date: Wed Aug 30 19:00:17 2017
New Revision: 75717
URL:
http://svn.reactos.org/svn/reactos?rev=75717&view=rev
Log:
[SETUPLIB][USETUP]: Adjust MUI and settings code.
- Re-enable settings code concerning language, keyboards & layout in the setuplib, and
remove the old code in usetup.
- Remove useless code in setuplib's mui.c
- Rename usetup's MUI "LanguageList" into "ResourceList" so as to
avoid colliding with the "LanguageList" of setuplib.
- Add the magic CMakeLists line "add_definitions(${I18N_DEFS})" that I forgot
previously, that caused the "LanguageList" of setuplib to be empty!
The code compiles and works during my tests.
Removed:
branches/setup_improvements/base/setup/usetup/settings.c
branches/setup_improvements/base/setup/usetup/settings.h
Modified:
branches/setup_improvements/base/setup/lib/CMakeLists.txt
branches/setup_improvements/base/setup/lib/mui.c
branches/setup_improvements/base/setup/lib/mui.h
branches/setup_improvements/base/setup/lib/muilanguages.h
branches/setup_improvements/base/setup/lib/settings.c
branches/setup_improvements/base/setup/lib/settings.h
branches/setup_improvements/base/setup/lib/setuplib.h
branches/setup_improvements/base/setup/usetup/CMakeLists.txt
branches/setup_improvements/base/setup/usetup/mui.c
branches/setup_improvements/base/setup/usetup/muilanguages.h
branches/setup_improvements/base/setup/usetup/usetup.c
Modified: branches/setup_improvements/base/setup/lib/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/CMakeLists.txt [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/CMakeLists.txt [iso-8859-1] Wed Aug 30
19:00:17 2017
@@ -1,3 +1,5 @@
+
+add_definitions(${I18N_DEFS})
include_directories(utils)
Modified: branches/setup_improvements/base/setup/lib/mui.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/mui.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/mui.c [iso-8859-1] Wed Aug 30 19:00:17
2017
@@ -38,13 +38,6 @@
/* FUNCTIONS ****************************************************************/
-extern
-VOID
-PopupError(IN PCCH Text,
- IN PCCH Status,
- IN PINPUT_RECORD Ir,
- IN ULONG WaitEvent);
-
static
ULONG
FindLanguageIndex(VOID)
@@ -59,17 +52,16 @@
do
{
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
+ if (_wcsicmp(LanguageList[lngIndex].LanguageID, SelectedLanguageId) == 0)
{
return lngIndex;
}
lngIndex++;
- } while (LanguageList[lngIndex].MuiPages != NULL);
+ } while (LanguageList[lngIndex].LanguageID != NULL);
return 0;
}
-
BOOLEAN
IsLanguageAvailable(
@@ -79,65 +71,29 @@
do
{
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , LanguageId) == 0)
+ if (_wcsicmp(LanguageList[lngIndex].LanguageID, LanguageId) == 0)
return TRUE;
lngIndex++;
- } while (LanguageList[lngIndex].MuiPages != NULL);
+ } while (LanguageList[lngIndex].LanguageID != NULL);
return FALSE;
}
-static
-const MUI_ENTRY *
-FindMUIEntriesOfPage(
- IN ULONG PageNumber)
-{
- ULONG muiIndex = 0;
- ULONG lngIndex;
- const MUI_PAGE * Pages = NULL;
-
- lngIndex = max(FindLanguageIndex(), 0);
- Pages = LanguageList[lngIndex].MuiPages;
-
- do
- {
- if (Pages[muiIndex].Number == PageNumber)
- return Pages[muiIndex].MuiEntry;
-
- muiIndex++;
- } while (Pages[muiIndex].MuiEntry != NULL);
-
- return NULL;
-}
-
-
-static
-const MUI_ERROR *
-FindMUIErrorEntries(VOID)
-{
- ULONG lngIndex = max(FindLanguageIndex(), 0);
- return LanguageList[lngIndex].MuiErrors;
-}
-
-
-static
-const MUI_STRING *
-FindMUIStringEntries(VOID)
-{
- ULONG lngIndex = max(FindLanguageIndex(), 0);
- return LanguageList[lngIndex].MuiStrings;
-}
-
-
-LPCWSTR
+PCWSTR
MUIDefaultKeyboardLayout(VOID)
{
ULONG lngIndex = max(FindLanguageIndex(), 0);
return LanguageList[lngIndex].MuiLayouts[0].LayoutID;
}
+PWCHAR
+MUIGetOEMCodePage(VOID)
+{
+ ULONG lngIndex = max(FindLanguageIndex(), 0);
+ return LanguageList[lngIndex].OEMCPage;
+}
PWCHAR
MUIGetGeoID(VOID)
@@ -146,7 +102,6 @@
return LanguageList[lngIndex].GeoID;
}
-
const MUI_LAYOUTS *
MUIGetLayoutsList(VOID)
{
@@ -155,146 +110,12 @@
}
-VOID
-MUIClearPage(
- IN ULONG page)
-{
- const MUI_ENTRY * entry;
- int index;
-
- entry = FindMUIEntriesOfPage(page);
- if (!entry)
- {
- PopupError("Error: Failed to find translated page",
- NULL,
- NULL,
- POPUP_WAIT_NONE);
- return;
- }
-
- index = 0;
- do
- {
- CONSOLE_ClearStyledText(entry[index].X,
- entry[index].Y,
- entry[index].Flags,
- strlen(entry[index].Buffer));
- index++;
- }
- while (entry[index].Buffer != NULL);
-}
-
-
-VOID
-MUIDisplayPage(
- IN ULONG page)
-{
- const MUI_ENTRY * entry;
- int index;
-
- entry = FindMUIEntriesOfPage(page);
- if (!entry)
- {
- PopupError("Error: Failed to find translated page",
- NULL,
- NULL,
- POPUP_WAIT_NONE);
- return;
- }
-
- index = 0;
- do
- {
- CONSOLE_SetStyledText(entry[index].X,
- entry[index].Y,
- entry[index].Flags,
- entry[index].Buffer);
-
- index++;
- }
- while (entry[index].Buffer != NULL);
-}
-
-
-VOID
-MUIDisplayError(
- IN ULONG ErrorNum,
- OUT PINPUT_RECORD Ir,
- IN ULONG WaitEvent,
- ...)
-{
- const MUI_ERROR * entry;
- CHAR Buffer[2048];
- va_list ap;
-
- if (ErrorNum >= ERROR_LAST_ERROR_CODE)
- {
- PopupError("Invalid error number provided",
- "Press ENTER to continue",
- Ir,
- POPUP_WAIT_ENTER);
-
- return;
- }
-
- entry = FindMUIErrorEntries();
- if (!entry)
- {
- PopupError("Error: Failed to find translated error message",
- NULL,
- NULL,
- POPUP_WAIT_NONE);
- return;
- }
-
- va_start(ap, WaitEvent);
- vsprintf(Buffer, entry[ErrorNum].ErrorText, ap);
- va_end(ap);
-
- PopupError(Buffer,
- entry[ErrorNum].ErrorStatus,
- Ir,
- WaitEvent);
-}
-
-
-LPSTR
-MUIGetString(
- ULONG Number)
-{
- ULONG i;
- const MUI_STRING * entry;
- CHAR szErr[128];
-
- entry = FindMUIStringEntries();
- if (entry)
- {
- for (i = 0; entry[i].Number != 0; i++)
- {
- if (entry[i].Number == Number)
- {
- return entry[i].String;
- }
- }
- }
-
- sprintf(szErr, "Error: failed find string id %lu for language index %lu\n",
Number, FindLanguageIndex());
-
- PopupError(szErr,
- NULL,
- NULL,
- POPUP_WAIT_NONE);
-
- return "<nostring>";
-}
-
-
static
BOOLEAN
AddHotkeySettings(
- IN LPCWSTR Hotkey,
- IN LPCWSTR LangHotkey,
- IN LPCWSTR LayoutHotkey)
+ IN PCWSTR Hotkey,
+ IN PCWSTR LangHotkey,
+ IN PCWSTR LayoutHotkey)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
@@ -376,7 +197,6 @@
NtClose(KeyHandle);
return TRUE;
}
-
BOOLEAN
AddKbLayoutsToRegistry(
@@ -547,7 +367,6 @@
return TRUE;
}
-
BOOLEAN
AddKeyboardLayouts(VOID)
{
@@ -555,25 +374,24 @@
do
{
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
+ if (_wcsicmp(LanguageList[lngIndex].LanguageID, SelectedLanguageId) == 0)
{
return AddKbLayoutsToRegistry(LanguageList[lngIndex].MuiLayouts);
}
lngIndex++;
}
- while (LanguageList[lngIndex].MuiPages != NULL);
+ while (LanguageList[lngIndex].LanguageID != NULL);
return FALSE;
}
-
static
BOOLEAN
AddCodepageToRegistry(
- IN LPCWSTR ACPage,
- IN LPCWSTR OEMCPage,
- IN LPCWSTR MACCPage)
+ IN PCWSTR ACPage,
+ IN PCWSTR OEMCPage,
+ IN PCWSTR MACCPage)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
@@ -647,7 +465,6 @@
return TRUE;
}
-
static
BOOLEAN
@@ -702,14 +519,13 @@
return TRUE;
}
-
BOOLEAN
AddCodePage(VOID)
{
ULONG lngIndex = 0;
do
{
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
+ if (_wcsicmp(LanguageList[lngIndex].LanguageID, SelectedLanguageId) == 0)
{
if (AddCodepageToRegistry(LanguageList[lngIndex].ACPage,
LanguageList[lngIndex].OEMCPage,
@@ -726,30 +542,9 @@
lngIndex++;
}
- while (LanguageList[lngIndex].MuiPages != NULL);
+ while (LanguageList[lngIndex].LanguageID != NULL);
return FALSE;
}
-
-VOID
-SetConsoleCodePage(VOID)
-{
- ULONG lngIndex = 0;
- UINT wCodePage;
-
- do
- {
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
- {
- wCodePage = (UINT) wcstoul(LanguageList[lngIndex].OEMCPage, NULL, 10);
- SetConsoleOutputCP(wCodePage);
- return;
- }
-
- lngIndex++;
- }
- while (LanguageList[lngIndex].MuiPages != NULL);
-}
-
/* EOF */
Modified: branches/setup_improvements/base/setup/lib/mui.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/mui.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/mui.h [iso-8859-1] Wed Aug 30 19:00:17
2017
@@ -24,12 +24,20 @@
const MUI_LAYOUTS * MuiLayouts;
} MUI_LANGUAGE;
+
+// HACK HACK HACK!!
+extern PWCHAR SelectedLanguageId;
+
+
BOOLEAN
IsLanguageAvailable(
PWCHAR LanguageId);
PCWSTR
MUIDefaultKeyboardLayout(VOID);
+
+PWCHAR
+MUIGetOEMCodePage(VOID);
PWCHAR
MUIGetGeoID(VOID);
Modified: branches/setup_improvements/base/setup/lib/muilanguages.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/muilanguages.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/muilanguages.h [iso-8859-1] Wed Aug 30
19:00:17 2017
@@ -838,5 +838,5 @@
#ifdef LANGUAGE_ZU_ZU
{L"00000435", L"1252", L"850", L"10000",
L"Zulu", L"1", LatinFonts, zuZULayouts},
#endif
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
};
Modified: branches/setup_improvements/base/setup/lib/settings.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/settings.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/settings.c [iso-8859-1] Wed Aug 30 19:00:17
2017
@@ -29,6 +29,7 @@
#include "precomp.h"
#include "genlist.h"
#include "infsupp.h"
+#include "mui.h"
#include "registry.h"
#include "settings.h"
@@ -38,9 +39,7 @@
/* GLOBALS ******************************************************************/
-#if 0 // FIXME: Disabled for now because it uses MUI* functions from usetup
-ULONG DefaultLanguageIndex = 0;
-#endif
+static ULONG DefaultLanguageIndex = 0;
/* FUNCTIONS ****************************************************************/
@@ -1055,8 +1054,6 @@
}
-#if 0 // FIXME: Disabled for now because it uses MUI* functions from usetup
-
ULONG
GetDefaultLanguageIndex(VOID)
{
@@ -1267,8 +1264,6 @@
return TRUE;
}
-#endif
-
#if 0
BOOLEAN
ProcessKeyboardLayoutFiles(
Modified: branches/setup_improvements/base/setup/lib/settings.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/settings.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/settings.h [iso-8859-1] Wed Aug 30 19:00:17
2017
@@ -87,8 +87,6 @@
CreateKeyboardDriverList(
HINF InfFile);
-#if 0 // FIXME: Disabled for now because it uses MUI* functions from usetup
-
PGENERIC_LIST
CreateKeyboardLayoutList(
HINF InfFile,
@@ -110,8 +108,6 @@
ProcessKeyboardLayoutFiles(
PGENERIC_LIST List);
-#endif
-
BOOLEAN
ProcessLocaleRegistry(
PGENERIC_LIST List);
Modified: branches/setup_improvements/base/setup/lib/setuplib.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/setuplib.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/setuplib.h [iso-8859-1] Wed Aug 30 19:00:17
2017
@@ -41,6 +41,7 @@
#include "utils/osdetect.h"
#include "utils/regutil.h"
#include "registry.h"
+#include "mui.h"
#include "settings.h"
Modified: branches/setup_improvements/base/setup/usetup/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/CMakeLists.txt [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/CMakeLists.txt [iso-8859-1] Wed Aug 30
19:00:17 2017
@@ -27,7 +27,6 @@
mui.c
partlist.c
progress.c
- settings.c
usetup.c
usetup.h)
Modified: branches/setup_improvements/base/setup/usetup/mui.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/mui.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/mui.c [iso-8859-1] Wed Aug 30 19:00:17
2017
@@ -51,18 +51,19 @@
do
{
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
+ if (_wcsicmp(ResourceList[lngIndex].LanguageID, SelectedLanguageId) == 0)
{
return lngIndex;
}
lngIndex++;
- } while (LanguageList[lngIndex].MuiPages != NULL);
+ } while (ResourceList[lngIndex].MuiPages != NULL);
return 0;
}
+#if 0
BOOLEAN
IsLanguageAvailable(
PWCHAR LanguageId)
@@ -71,14 +72,15 @@
do
{
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , LanguageId) == 0)
+ if (_wcsicmp(ResourceList[lngIndex].LanguageID, LanguageId) == 0)
return TRUE;
lngIndex++;
- } while (LanguageList[lngIndex].MuiPages != NULL);
+ } while (ResourceList[lngIndex].MuiPages != NULL);
return FALSE;
}
+#endif
static
@@ -91,59 +93,33 @@
const MUI_PAGE * Pages = NULL;
lngIndex = max(FindLanguageIndex(), 0);
- Pages = LanguageList[lngIndex].MuiPages;
-
- do
- {
- if (Pages[muiIndex].Number == PageNumber)
- return Pages[muiIndex].MuiEntry;
-
- muiIndex++;
+ Pages = ResourceList[lngIndex].MuiPages;
+
+ do
+ {
+ if (Pages[muiIndex].Number == PageNumber)
+ return Pages[muiIndex].MuiEntry;
+
+ muiIndex++;
} while (Pages[muiIndex].MuiEntry != NULL);
return NULL;
}
-
static
const MUI_ERROR *
FindMUIErrorEntries(VOID)
{
ULONG lngIndex = max(FindLanguageIndex(), 0);
- return LanguageList[lngIndex].MuiErrors;
-}
-
+ return ResourceList[lngIndex].MuiErrors;
+}
static
const MUI_STRING *
FindMUIStringEntries(VOID)
{
ULONG lngIndex = max(FindLanguageIndex(), 0);
- return LanguageList[lngIndex].MuiStrings;
-}
-
-
-LPCWSTR
-MUIDefaultKeyboardLayout(VOID)
-{
- ULONG lngIndex = max(FindLanguageIndex(), 0);
- return LanguageList[lngIndex].MuiLayouts[0].LayoutID;
-}
-
-
-PWCHAR
-MUIGetGeoID(VOID)
-{
- ULONG lngIndex = max(FindLanguageIndex(), 0);
- return LanguageList[lngIndex].GeoID;
-}
-
-
-const MUI_LAYOUTS *
-MUIGetLayoutsList(VOID)
-{
- ULONG lngIndex = max(FindLanguageIndex(), 0);
- return LanguageList[lngIndex].MuiLayouts;
+ return ResourceList[lngIndex].MuiStrings;
}
@@ -176,7 +152,6 @@
while (entry[index].Buffer != NULL);
}
-
VOID
MUIDisplayPage(
IN ULONG page)
@@ -206,7 +181,6 @@
}
while (entry[index].Buffer != NULL);
}
-
VOID
MUIDisplayError(
@@ -248,7 +222,6 @@
Ir,
WaitEvent);
}
-
LPSTR
MUIGetString(
@@ -280,468 +253,30 @@
return "<nostring>";
}
-
-static
-BOOLEAN
-AddHotkeySettings(
- IN LPCWSTR Hotkey,
- IN LPCWSTR LangHotkey,
- IN LPCWSTR LayoutHotkey)
-{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING KeyName;
- UNICODE_STRING ValueName;
- HANDLE KeyHandle;
- ULONG Disposition;
- NTSTATUS Status;
-
- RtlInitUnicodeString(&KeyName,
- L".DEFAULT\\Keyboard Layout\\Toggle");
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- GetRootKeyByPredefKey(HKEY_USERS, NULL),
- NULL);
-
- Status = NtCreateKey(&KeyHandle,
- KEY_SET_VALUE,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- &Disposition);
-
- if(!NT_SUCCESS(Status))
- {
- DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
- return FALSE;
- }
-
- RtlInitUnicodeString(&ValueName,
- L"Hotkey");
-
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)Hotkey,
- (1 + 1) * sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- RtlInitUnicodeString(&ValueName,
- L"Language Hotkey");
-
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)LangHotkey,
- (1 + 1) * sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- RtlInitUnicodeString(&ValueName,
- L"Layout Hotkey");
-
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)LayoutHotkey,
- (1 + 1) * sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- NtClose(KeyHandle);
- return TRUE;
-}
-
-
-BOOLEAN
-AddKbLayoutsToRegistry(
- IN const MUI_LAYOUTS *MuiLayouts)
-{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING KeyName;
- UNICODE_STRING ValueName;
- HANDLE KeyHandle;
- HANDLE SubKeyHandle;
- NTSTATUS Status;
- ULONG Disposition;
- ULONG uIndex = 0;
- ULONG uCount = 0;
- WCHAR szKeyName[48] = L".DEFAULT\\Keyboard Layout";
- WCHAR szValueName[3 + 1];
- WCHAR szLangID[8 + 1];
-
- // Open the keyboard layout key
- RtlInitUnicodeString(&KeyName, szKeyName);
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- GetRootKeyByPredefKey(HKEY_USERS, NULL),
- NULL);
-
- Status = NtCreateKey(&KeyHandle,
- KEY_CREATE_SUB_KEY,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- &Disposition);
-
- if(NT_SUCCESS(Status))
- NtClose(KeyHandle);
- else
- {
- DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
- return FALSE;
- }
-
- KeyName.MaximumLength = sizeof(szKeyName);
- Status = RtlAppendUnicodeToString(&KeyName, L"\\Preload");
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("RtlAppend failed! (%lx)\n", Status);
- DPRINT1("String is %wZ\n", &KeyName);
- return FALSE;
- }
-
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- GetRootKeyByPredefKey(HKEY_USERS, NULL),
- NULL);
-
- Status = NtCreateKey(&KeyHandle,
- KEY_SET_VALUE,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- &Disposition);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
- return FALSE;
- }
-
- RtlInitUnicodeString(&KeyName, L".DEFAULT\\Keyboard
Layout\\Substitutes");
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- GetRootKeyByPredefKey(HKEY_USERS, NULL),
- NULL);
-
- Status = NtCreateKey(&SubKeyHandle,
- KEY_SET_VALUE,
- &ObjectAttributes,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- &Disposition);
-
- if(!NT_SUCCESS(Status))
- {
- DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
- NtClose(SubKeyHandle);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- do
- {
- if (uIndex > 19) break;
-
- swprintf(szValueName, L"%u", uIndex + 1);
- RtlInitUnicodeString(&ValueName, szValueName);
-
- swprintf(szLangID, L"0000%s", MuiLayouts[uIndex].LangID);
-
- if (_wcsicmp(szLangID, MuiLayouts[uIndex].LayoutID) == 0)
+VOID
+SetConsoleCodePage(VOID)
+{
+ UINT wCodePage;
+
+#if 0
+ ULONG lngIndex = 0;
+
+ do
+ {
+ if (_wcsicmp(ResourceList[lngIndex].LanguageID, SelectedLanguageId) == 0)
{
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)MuiLayouts[uIndex].LayoutID,
- (wcslen(MuiLayouts[uIndex].LayoutID)+1) *
sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %d)\n",
Status, uIndex);
- NtClose(SubKeyHandle);
- NtClose(KeyHandle);
- return FALSE;
- }
- }
- else
- {
- swprintf(szLangID, L"d%03lu%s", uCount,
MuiLayouts[uIndex].LangID);
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)szLangID,
- (wcslen(szLangID)+1) * sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %d)\n",
Status, uIndex);
- NtClose(SubKeyHandle);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- RtlInitUnicodeString(&ValueName, szLangID);
-
- Status = NtSetValueKey(SubKeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)MuiLayouts[uIndex].LayoutID,
- (wcslen(MuiLayouts[uIndex].LayoutID)+1) *
sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %u)\n",
Status, uIndex);
- NtClose(SubKeyHandle);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- uCount++;
- }
-
- uIndex++;
- }
- while (MuiLayouts[uIndex].LangID != NULL);
-
- if (uIndex > 1)
- AddHotkeySettings(L"2", L"2", L"1");
- else
- AddHotkeySettings(L"3", L"3", L"3");
-
- NtClose(SubKeyHandle);
- NtClose(KeyHandle);
- return TRUE;
-}
-
-
-BOOLEAN
-AddKeyboardLayouts(VOID)
-{
- ULONG lngIndex = 0;
-
- do
- {
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
- {
- return AddKbLayoutsToRegistry(LanguageList[lngIndex].MuiLayouts);
- }
-
- lngIndex++;
- }
- while (LanguageList[lngIndex].MuiPages != NULL);
-
- return FALSE;
-}
-
-
-static
-BOOLEAN
-AddCodepageToRegistry(
- IN LPCWSTR ACPage,
- IN LPCWSTR OEMCPage,
- IN LPCWSTR MACCPage)
-{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING KeyName;
- UNICODE_STRING ValueName;
- HANDLE KeyHandle;
- NTSTATUS Status;
-
- // Open the nls codepage key
- RtlInitUnicodeString(&KeyName,
-
L"SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage");
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- GetRootKeyByPredefKey(HKEY_LOCAL_MACHINE, NULL),
- NULL);
- Status = NtOpenKey(&KeyHandle,
- KEY_WRITE,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
- return FALSE;
- }
-
- // Set ANSI codepage
- RtlInitUnicodeString(&ValueName, L"ACP");
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)ACPage,
- (wcslen(ACPage)+1) * sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- // Set OEM codepage
- RtlInitUnicodeString(&ValueName, L"OEMCP");
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)OEMCPage,
- (wcslen(OEMCPage)+1) * sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- // Set MAC codepage
- RtlInitUnicodeString(&ValueName, L"MACCP");
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)MACCPage,
- (wcslen(MACCPage)+1) * sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- NtClose(KeyHandle);
-
- return TRUE;
-}
-
-
-static
-BOOLEAN
-AddFontsSettingsToRegistry(
- IN const MUI_SUBFONT * MuiSubFonts)
-{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING KeyName;
- UNICODE_STRING ValueName;
- HANDLE KeyHandle;
- NTSTATUS Status;
- ULONG uIndex = 0;
-
- RtlInitUnicodeString(&KeyName,
- L"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\FontSubstitutes");
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- GetRootKeyByPredefKey(HKEY_LOCAL_MACHINE, NULL),
- NULL);
- Status = NtOpenKey(&KeyHandle,
- KEY_WRITE,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
- return FALSE;
- }
-
- do
- {
- RtlInitUnicodeString(&ValueName, MuiSubFonts[uIndex].FontName);
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)MuiSubFonts[uIndex].SubFontName,
- (wcslen(MuiSubFonts[uIndex].SubFontName)+1) *
sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %d)\n",
Status, uIndex);
- NtClose(KeyHandle);
- return FALSE;
- }
-
- uIndex++;
- }
- while (MuiSubFonts[uIndex].FontName != NULL);
-
- NtClose(KeyHandle);
-
- return TRUE;
-}
-
-
-BOOLEAN
-AddCodePage(VOID)
-{
- ULONG lngIndex = 0;
- do
- {
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
- {
- if (AddCodepageToRegistry(LanguageList[lngIndex].ACPage,
- LanguageList[lngIndex].OEMCPage,
- LanguageList[lngIndex].MACCPage)&&
- AddFontsSettingsToRegistry(LanguageList[lngIndex].MuiSubFonts))
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
-
- lngIndex++;
- }
- while (LanguageList[lngIndex].MuiPages != NULL);
-
- return FALSE;
-}
-
-
-VOID
-SetConsoleCodePage(VOID)
-{
- ULONG lngIndex = 0;
- UINT wCodePage;
-
- do
- {
- if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
- {
- wCodePage = (UINT) wcstoul(LanguageList[lngIndex].OEMCPage, NULL, 10);
+ wCodePage = (UINT) wcstoul(ResourceList[lngIndex].OEMCPage, NULL, 10);
SetConsoleOutputCP(wCodePage);
return;
}
lngIndex++;
}
- while (LanguageList[lngIndex].MuiPages != NULL);
+ while (ResourceList[lngIndex].MuiPages != NULL);
+#else
+ wCodePage = (UINT)wcstoul(MUIGetOEMCodePage(), NULL, 10);
+ SetConsoleOutputCP(wCodePage);
+#endif
}
/* EOF */
Modified: branches/setup_improvements/base/setup/usetup/muilanguages.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/muilanguages.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/muilanguages.h [iso-8859-1] Wed Aug 30
19:00:17 2017
@@ -411,7 +411,7 @@
// #include "lang/zh-TW.h"
// #endif
-const MUI_LANGUAGE_RESOURCE LanguageList[] =
+const MUI_LANGUAGE_RESOURCE ResourceList[] =
{
/* Lang ID, Language Name, Page strings, Error strings, Other strings */
#ifdef LANGUAGE_AF_ZA
@@ -840,5 +840,5 @@
#ifdef LANGUAGE_ZU_ZU
{L"00000435", L"Zulu", enUSPages, enUSErrorEntries,
enUSStrings},
#endif
- {NULL, NULL, NULL, NULL, NULL},
+ {NULL, NULL, NULL, NULL, NULL}
};
Removed: branches/setup_improvements/base/setup/usetup/settings.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/settings.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/settings.c (removed)
@@ -1,259 +0,0 @@
-/*
- * ReactOS kernel
- * Copyright (C) 2004 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-/* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS text-mode setup
- * FILE: base/setup/usetup/settings.c
- * PURPOSE: Device settings support functions
- * PROGRAMMERS: Eric Kohl
- * Colin Finck
- */
-
-/* INCLUDES *****************************************************************/
-
-#include "usetup.h"
-
-#define NDEBUG
-#include <debug.h>
-
-/* GLOBALS ******************************************************************/
-
-ULONG DefaultLanguageIndex = 0;
-
-/* FUNCTIONS ****************************************************************/
-
-ULONG
-GetDefaultLanguageIndex(VOID)
-{
- return DefaultLanguageIndex;
-}
-
-typedef struct _LANG_ENTRY_PARAM
-{
- ULONG uIndex;
- PWCHAR DefaultLanguage;
-} LANG_ENTRY_PARAM, *PLANG_ENTRY_PARAM;
-
-static UCHAR
-NTAPI
-ProcessLangEntry(
- IN PWCHAR KeyName,
- IN PWCHAR KeyValue,
- IN PCHAR DisplayText,
- IN SIZE_T DisplayTextSize,
- OUT PVOID* UserData,
- OUT PBOOLEAN Current,
- IN PVOID Parameter OPTIONAL)
-{
- PLANG_ENTRY_PARAM LangEntryParam = (PLANG_ENTRY_PARAM)Parameter;
-
- if (!IsLanguageAvailable(KeyName))
- {
- /* The specified language is unavailable, skip the entry */
- return 2;
- }
-
- *UserData = RtlAllocateHeap(ProcessHeap, 0,
- (wcslen(KeyName) + 1) * sizeof(WCHAR));
- if (*UserData == NULL)
- {
- /* Failure, stop enumeration */
- DPRINT1("RtlAllocateHeap() failed\n");
- return 0;
- }
-
- wcscpy((PWCHAR)*UserData, KeyName);
- sprintf(DisplayText, "%S", KeyValue);
-
- *Current = FALSE;
-
- if (!_wcsicmp(KeyName, LangEntryParam->DefaultLanguage))
- DefaultLanguageIndex = LangEntryParam->uIndex;
-
- LangEntryParam->uIndex++;
-
- /* Add the entry */
- return 1;
-}
-
-PGENERIC_LIST
-CreateLanguageList(
- HINF InfFile,
- WCHAR *DefaultLanguage)
-{
- PGENERIC_LIST List;
- INFCONTEXT Context;
- PWCHAR KeyValue;
-
- LANG_ENTRY_PARAM LangEntryParam;
-
- LangEntryParam.uIndex = 0;
- LangEntryParam.DefaultLanguage = DefaultLanguage;
-
- /* Get default language id */
- if (!SetupFindFirstLineW(InfFile, L"NLS", L"DefaultLanguage",
&Context))
- return NULL;
-
- if (!INF_GetData(&Context, NULL, &KeyValue))
- return NULL;
-
- wcscpy(DefaultLanguage, KeyValue);
- SelectedLanguageId = KeyValue;
-
- List = CreateGenericList();
- if (List == NULL)
- return NULL;
-
- if (AddEntriesFromInfSection(List,
- InfFile,
- L"Language",
- &Context,
- ProcessLangEntry,
- &LangEntryParam) == -1)
- {
- DestroyGenericList(List, TRUE);
- return NULL;
- }
-
- /* Only one language available, make it the default one */
- if (LangEntryParam.uIndex == 1)
- {
- DefaultLanguageIndex = 0;
- wcscpy(DefaultLanguage,
- (PWSTR)GetListEntryUserData(GetFirstListEntry(List)));
- }
-
- return List;
-}
-
-
-PGENERIC_LIST
-CreateKeyboardLayoutList(
- HINF InfFile,
- WCHAR *DefaultKBLayout)
-{
- PGENERIC_LIST List;
- INFCONTEXT Context;
- PWCHAR KeyValue;
- const MUI_LAYOUTS * LayoutsList;
- ULONG uIndex = 0;
-
- /* Get default layout id */
- if (!SetupFindFirstLineW(InfFile, L"NLS", L"DefaultLayout",
&Context))
- return NULL;
-
- if (!INF_GetData(&Context, NULL, &KeyValue))
- return NULL;
-
- wcscpy(DefaultKBLayout, KeyValue);
-
- List = CreateGenericList();
- if (List == NULL)
- return NULL;
-
- LayoutsList = MUIGetLayoutsList();
-
- do
- {
- // NOTE: See
https://svn.reactos.org/svn/reactos?view=revision&revision=68354
- if (AddEntriesFromInfSection(List,
- InfFile,
- L"KeyboardLayout",
- &Context,
- DefaultProcessEntry,
- DefaultKBLayout) == -1)
- {
- DestroyGenericList(List, TRUE);
- return NULL;
- }
-
- uIndex++;
-
- } while (LayoutsList[uIndex].LangID != NULL);
-
- /* Check whether some keyboard layouts have been found */
- /* FIXME: Handle this case */
- if (GetNumberOfListEntries(List) == 0)
- {
- DPRINT1("No keyboard layouts have been found\n");
- DestroyGenericList(List, TRUE);
- return NULL;
- }
-
- return List;
-}
-
-
-BOOLEAN
-ProcessKeyboardLayoutRegistry(
- PGENERIC_LIST List)
-{
- PGENERIC_LIST_ENTRY Entry;
- PWCHAR LayoutId;
- const MUI_LAYOUTS * LayoutsList;
- MUI_LAYOUTS NewLayoutsList[20];
- ULONG uIndex;
- ULONG uOldPos = 0;
-
- Entry = GetCurrentListEntry(List);
- if (Entry == NULL)
- return FALSE;
-
- LayoutId = (PWCHAR)GetListEntryUserData(Entry);
- if (LayoutId == NULL)
- return FALSE;
-
- LayoutsList = MUIGetLayoutsList();
-
- if (_wcsicmp(LayoutsList[0].LayoutID, LayoutId) != 0)
- {
- for (uIndex = 1; LayoutsList[uIndex].LangID != NULL; uIndex++)
- {
- if (_wcsicmp(LayoutsList[uIndex].LayoutID, LayoutId) == 0)
- {
- uOldPos = uIndex;
- continue;
- }
-
- NewLayoutsList[uIndex].LangID = LayoutsList[uIndex].LangID;
- NewLayoutsList[uIndex].LayoutID = LayoutsList[uIndex].LayoutID;
- }
-
- NewLayoutsList[uIndex].LangID = NULL;
- NewLayoutsList[uIndex].LayoutID = NULL;
- NewLayoutsList[uOldPos].LangID = LayoutsList[0].LangID;
- NewLayoutsList[uOldPos].LayoutID = LayoutsList[0].LayoutID;
- NewLayoutsList[0].LangID = LayoutsList[uOldPos].LangID;
- NewLayoutsList[0].LayoutID = LayoutsList[uOldPos].LayoutID;
-
- return AddKbLayoutsToRegistry(NewLayoutsList);
- }
-
- return TRUE;
-}
-
-#if 0
-BOOLEAN
-ProcessKeyboardLayoutFiles(
- PGENERIC_LIST List)
-{
- return TRUE;
-}
-#endif
-
-/* EOF */
Removed: branches/setup_improvements/base/setup/usetup/settings.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/settings.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/settings.h (removed)
@@ -1,51 +0,0 @@
-/*
- * ReactOS kernel
- * Copyright (C) 2004 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS text-mode setup
- * FILE: base/setup/usetup/settings.h
- * PURPOSE: Device settings support functions
- * PROGRAMMERS: Eric Kohl
- * Colin Finck
- */
-
-#pragma once
-
-PGENERIC_LIST
-CreateKeyboardLayoutList(
- HINF InfFile,
- WCHAR *DefaultKBLayout);
-
-PGENERIC_LIST
-CreateLanguageList(
- HINF InfFile,
- WCHAR *DefaultLanguage);
-
-ULONG
-GetDefaultLanguageIndex(VOID);
-
-BOOLEAN
-ProcessKeyboardLayoutRegistry(
- PGENERIC_LIST List);
-
-BOOLEAN
-ProcessKeyboardLayoutFiles(
- PGENERIC_LIST List);
-
-/* EOF */
Modified: branches/setup_improvements/base/setup/usetup/usetup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/usetup.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/usetup.c [iso-8859-1] Wed Aug 30
19:00:17 2017
@@ -32,7 +32,6 @@
#include "chkdsk.h"
#include "cmdcons.h"
#include "format.h"
-#include "settings.h"
#define NDEBUG
#include <debug.h>