mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:33:07 +00:00
[SETUPLIB][USETUP] Don't store UI-related display strings in GENERIC_LIST_ENTRY-ies, + other code adaptations.
- Apart from allowing a UI cache variable that may be used when displaying GENERIC_LIST_ENTRY-ies, do not store any display strings associated to these list entries. They should be instead computed only when initializing a list UI (or a combo-box or list control if the code is used in Win32 environment). For this matter a callback is provided to InitGenericListUi() that does the job of computing the displayed string corresponding to a given GENERIC_LIST_ENTRY. - Simplify the calls to InitGenericListUi(), and refactor the RestoreGenericListUiState() function. - Use for-loops for iterating over GENERIC_LIST items. - Adapt the storage data format for lists of settings items. - The txtsetup.sif INF format specified in LoadSetupInf() should not be INF_STYLE_WIN4 (to be investigated...).
This commit is contained in:
parent
765994c9e3
commit
1f4cb0977a
10 changed files with 264 additions and 170 deletions
|
@ -321,10 +321,8 @@ GetComputerIdentifier(
|
|||
*/
|
||||
typedef UCHAR
|
||||
(NTAPI *PPROCESS_ENTRY_ROUTINE)(
|
||||
IN PWCHAR KeyName,
|
||||
IN PWCHAR KeyValue,
|
||||
OUT PWCHAR DisplayText,
|
||||
IN SIZE_T DisplayTextSize,
|
||||
IN PCWSTR KeyName,
|
||||
IN PCWSTR KeyValue,
|
||||
OUT PVOID* UserData,
|
||||
OUT PBOOLEAN Current,
|
||||
IN PVOID Parameter OPTIONAL);
|
||||
|
@ -344,7 +342,6 @@ AddEntriesFromInfSection(
|
|||
PVOID UserData;
|
||||
BOOLEAN Current;
|
||||
UCHAR RetVal;
|
||||
WCHAR DisplayText[128];
|
||||
|
||||
if (!SetupFindFirstLineW(InfFile, SectionName, NULL, pContext))
|
||||
return -1;
|
||||
|
@ -374,8 +371,6 @@ AddEntriesFromInfSection(
|
|||
Current = FALSE;
|
||||
RetVal = ProcessEntry(KeyName,
|
||||
KeyValue,
|
||||
DisplayText,
|
||||
sizeof(DisplayText),
|
||||
&UserData,
|
||||
&Current,
|
||||
Parameter);
|
||||
|
@ -389,7 +384,7 @@ AddEntriesFromInfSection(
|
|||
}
|
||||
else if (RetVal == 1)
|
||||
{
|
||||
AppendGenericListEntry(List, DisplayText, UserData, Current);
|
||||
AppendGenericListEntry(List, UserData, Current);
|
||||
++TotalCount;
|
||||
}
|
||||
// else if (RetVal == 2), skip the entry.
|
||||
|
@ -402,29 +397,36 @@ AddEntriesFromInfSection(
|
|||
static UCHAR
|
||||
NTAPI
|
||||
DefaultProcessEntry(
|
||||
IN PWCHAR KeyName,
|
||||
IN PWCHAR KeyValue,
|
||||
OUT PWCHAR DisplayText,
|
||||
IN SIZE_T DisplayTextSize,
|
||||
IN PCWSTR KeyName,
|
||||
IN PCWSTR KeyValue,
|
||||
OUT PVOID* UserData,
|
||||
OUT PBOOLEAN Current,
|
||||
IN PVOID Parameter OPTIONAL)
|
||||
{
|
||||
PWSTR CompareKey = (PWSTR)Parameter;
|
||||
|
||||
*UserData = RtlAllocateHeap(ProcessHeap, 0,
|
||||
(wcslen(KeyName) + 1) * sizeof(WCHAR));
|
||||
if (*UserData == NULL)
|
||||
PGENENTRY GenEntry;
|
||||
SIZE_T IdSize, ValueSize;
|
||||
|
||||
IdSize = (wcslen(KeyName) + 1) * sizeof(WCHAR);
|
||||
ValueSize = (wcslen(KeyValue) + 1) * sizeof(WCHAR);
|
||||
|
||||
GenEntry = RtlAllocateHeap(ProcessHeap, 0,
|
||||
sizeof(*GenEntry) + IdSize + ValueSize);
|
||||
if (GenEntry == NULL)
|
||||
{
|
||||
/* Failure, stop enumeration */
|
||||
DPRINT1("RtlAllocateHeap() failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
wcscpy((PWCHAR)*UserData, KeyName);
|
||||
RtlStringCbCopyW(DisplayText, DisplayTextSize, KeyValue);
|
||||
GenEntry->Id = (PCWSTR)((ULONG_PTR)GenEntry + sizeof(*GenEntry));
|
||||
GenEntry->Value = (PCWSTR)((ULONG_PTR)GenEntry + sizeof(*GenEntry) + IdSize);
|
||||
RtlStringCbCopyW((PWSTR)GenEntry->Id, IdSize, KeyName);
|
||||
RtlStringCbCopyW((PWSTR)GenEntry->Value, ValueSize, KeyValue);
|
||||
|
||||
*Current = (CompareKey ? !_wcsicmp(KeyName, CompareKey) : FALSE);
|
||||
*UserData = GenEntry;
|
||||
*Current = (CompareKey ? !_wcsicmp(KeyName, CompareKey) : FALSE);
|
||||
|
||||
/* Add the entry */
|
||||
return 1;
|
||||
|
@ -765,7 +767,7 @@ ProcessComputerFiles(
|
|||
}
|
||||
|
||||
RtlStringCchPrintfW(SectionName, ARRAYSIZE(SectionName),
|
||||
L"Files.%s", (PCWSTR)GetListEntryUserData(Entry));
|
||||
L"Files.%s", ((PGENENTRY)GetListEntryData(Entry))->Id);
|
||||
*AdditionalSectionName = SectionName;
|
||||
|
||||
return TRUE;
|
||||
|
@ -797,7 +799,9 @@ ProcessDisplayRegistry(
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!SetupFindFirstLineW(InfFile, L"Display", (WCHAR*)GetListEntryUserData(Entry), &Context))
|
||||
if (!SetupFindFirstLineW(InfFile, L"Display",
|
||||
((PGENENTRY)GetListEntryData(Entry))->Id,
|
||||
&Context))
|
||||
{
|
||||
DPRINT1("SetupFindFirstLineW() failed\n");
|
||||
return FALSE;
|
||||
|
@ -936,7 +940,7 @@ ProcessLocaleRegistry(
|
|||
IN PGENERIC_LIST List)
|
||||
{
|
||||
PGENERIC_LIST_ENTRY Entry;
|
||||
PWCHAR LanguageId;
|
||||
PCWSTR LanguageId;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName;
|
||||
UNICODE_STRING ValueName;
|
||||
|
@ -948,7 +952,7 @@ ProcessLocaleRegistry(
|
|||
if (Entry == NULL)
|
||||
return FALSE;
|
||||
|
||||
LanguageId = (PWCHAR)GetListEntryUserData(Entry);
|
||||
LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id;
|
||||
if (LanguageId == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -1086,35 +1090,42 @@ typedef struct _LANG_ENTRY_PARAM
|
|||
static UCHAR
|
||||
NTAPI
|
||||
ProcessLangEntry(
|
||||
IN PWCHAR KeyName,
|
||||
IN PWCHAR KeyValue,
|
||||
OUT PWCHAR DisplayText,
|
||||
IN SIZE_T DisplayTextSize,
|
||||
IN PCWSTR KeyName,
|
||||
IN PCWSTR KeyValue,
|
||||
OUT PVOID* UserData,
|
||||
OUT PBOOLEAN Current,
|
||||
IN PVOID Parameter OPTIONAL)
|
||||
{
|
||||
PLANG_ENTRY_PARAM LangEntryParam = (PLANG_ENTRY_PARAM)Parameter;
|
||||
|
||||
PGENENTRY GenEntry;
|
||||
SIZE_T IdSize, ValueSize;
|
||||
|
||||
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)
|
||||
IdSize = (wcslen(KeyName) + 1) * sizeof(WCHAR);
|
||||
ValueSize = (wcslen(KeyValue) + 1) * sizeof(WCHAR);
|
||||
|
||||
GenEntry = RtlAllocateHeap(ProcessHeap, 0,
|
||||
sizeof(*GenEntry) + IdSize + ValueSize);
|
||||
if (GenEntry == NULL)
|
||||
{
|
||||
/* Failure, stop enumeration */
|
||||
DPRINT1("RtlAllocateHeap() failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
wcscpy((PWCHAR)*UserData, KeyName);
|
||||
RtlStringCbCopyW(DisplayText, DisplayTextSize, KeyValue);
|
||||
GenEntry->Id = (PCWSTR)((ULONG_PTR)GenEntry + sizeof(*GenEntry));
|
||||
GenEntry->Value = (PCWSTR)((ULONG_PTR)GenEntry + sizeof(*GenEntry) + IdSize);
|
||||
RtlStringCbCopyW((PWSTR)GenEntry->Id, IdSize, KeyName);
|
||||
RtlStringCbCopyW((PWSTR)GenEntry->Value, ValueSize, KeyValue);
|
||||
|
||||
*Current = FALSE;
|
||||
*UserData = GenEntry;
|
||||
*Current = FALSE;
|
||||
|
||||
if (!_wcsicmp(KeyName, LangEntryParam->DefaultLanguage))
|
||||
DefaultLanguageIndex = LangEntryParam->uIndex;
|
||||
|
@ -1168,7 +1179,7 @@ CreateLanguageList(
|
|||
{
|
||||
DefaultLanguageIndex = 0;
|
||||
wcscpy(DefaultLanguage,
|
||||
(PWSTR)GetListEntryUserData(GetFirstListEntry(List)));
|
||||
((PGENENTRY)GetListEntryData(GetFirstListEntry(List)))->Id);
|
||||
}
|
||||
|
||||
return List;
|
||||
|
@ -1239,7 +1250,7 @@ ProcessKeyboardLayoutRegistry(
|
|||
IN PCWSTR LanguageId)
|
||||
{
|
||||
PGENERIC_LIST_ENTRY Entry;
|
||||
PWCHAR LayoutId;
|
||||
PCWSTR LayoutId;
|
||||
const MUI_LAYOUTS* LayoutsList;
|
||||
MUI_LAYOUTS NewLayoutsList[20];
|
||||
ULONG uIndex;
|
||||
|
@ -1249,7 +1260,7 @@ ProcessKeyboardLayoutRegistry(
|
|||
if (Entry == NULL)
|
||||
return FALSE;
|
||||
|
||||
LayoutId = (PWCHAR)GetListEntryUserData(Entry);
|
||||
LayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id;
|
||||
if (LayoutId == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue