Author: hbelusca
Date: Wed Feb 1 03:12:56 2017
New Revision: 73656
URL:
http://svn.reactos.org/svn/reactos?rev=73656&view=rev
Log:
[WELCOME]: Follow-up to r73590: Load a "welcome.ini" configuration file inside
the path of the welcome.exe application, if present, that specifies few default values to
use for the interface, as well as the path (possibly relative) to a subdirectory
containing ini files specifying localized resources for the interface.
[BOOTDATA]: Add a default "welcome.ini" file to the build, only for hybrid-cds.
The ini files containing the localized resources are automatically converted to UTF-16
prior to inclusion in the hybridcd.
Added:
trunk/reactos/boot/bootdata/welcome_config/
trunk/reactos/boot/bootdata/welcome_config/welcome.ini (with props)
Modified:
trunk/reactos/base/setup/welcome/welcome.c
trunk/reactos/boot/bootdata/CMakeLists.txt
Modified: trunk/reactos/base/setup/welcome/welcome.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/welcome/welcome…
==============================================================================
--- trunk/reactos/base/setup/welcome/welcome.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/welcome/welcome.c [iso-8859-1] Wed Feb 1 03:12:56 2017
@@ -71,8 +71,7 @@
HWND hWndCloseButton = NULL;
HWND hWndCheckButton = NULL;
-/* TODO: Retrieve the preferences from a configuration file */
-BOOL bDisplayCheckBox = FALSE; // FIXME!
+BOOL bDisplayCheckBox = FALSE; // FIXME: We should also repaint the OS version
correctly!
BOOL bDisplayExitBtn = TRUE;
#define BUFFER_SIZE 1024
@@ -121,7 +120,7 @@
/* FUNCTIONS ****************************************************************/
-INT GetLocaleName(LCID Locale, LPTSTR lpLCData, SIZE_T cchData)
+INT GetLocaleName(IN LCID Locale, OUT LPTSTR lpLCData, IN SIZE_T cchData)
{
INT ret, ret2;
@@ -197,7 +196,8 @@
}
}
-BOOL LoadTopicsFromINI(LCID Locale)
+static BOOL
+LoadTopicsFromINI(LCID Locale, LPTSTR lpResPath)
{
DWORD dwRet;
DWORD dwSize;
@@ -215,7 +215,7 @@
}
/* Build the INI file name */
- GetCurrentDirectory(ARRAYSIZE(szIniPath), szIniPath);
+ StringCchCopy(szIniPath, ARRAYSIZE(szIniPath), lpResPath);
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT("\\"));
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), szBuffer);
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT(".ini"));
@@ -225,7 +225,7 @@
{
StringCchCopy(szBuffer, ARRAYSIZE(szBuffer), TEXT("en-US"));
- GetCurrentDirectory(ARRAYSIZE(szIniPath), szIniPath);
+ StringCchCopy(szIniPath, ARRAYSIZE(szIniPath), lpResPath);
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT("\\"));
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), szBuffer);
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT(".ini"));
@@ -324,7 +324,8 @@
return TRUE;
}
-BOOL LoadTopics(VOID)
+static BOOL
+LoadTopics(LPTSTR lpResPath)
{
#define MAX_NUMBER_INTERNAL_TOPICS 3
@@ -344,7 +345,7 @@
*szDefaultDesc = 0;
/* Try to load the topics from INI file */
- if (LoadTopicsFromINI(LOCALE_USER_DEFAULT))
+ if (*lpResPath && LoadTopicsFromINI(LOCALE_USER_DEFAULT, lpResPath))
return TRUE;
/* We failed, fall back to internal (localized) resource */
@@ -379,7 +380,8 @@
return TRUE;
}
-VOID FreeTopics(VOID)
+static VOID
+FreeTopics(VOID)
{
if (!pTopics)
return;
@@ -392,6 +394,50 @@
HeapFree(GetProcessHeap(), 0, pTopics);
pTopics = NULL;
dwNumberTopics = 0;
+}
+
+static BOOL
+LoadConfiguration(VOID)
+{
+ TCHAR szAppPath[MAX_PATH];
+ TCHAR szIniPath[MAX_PATH];
+ TCHAR szResPath[MAX_PATH];
+
+ /* Retrieve the full path to this application */
+ GetModuleFileName(NULL, szAppPath, ARRAYSIZE(szAppPath));
+ if (*szAppPath)
+ {
+ LPTSTR lpFileName = _tcsrchr(szAppPath, _T('\\'));
+ if (lpFileName)
+ *lpFileName = 0;
+ else
+ *szAppPath = 0;
+ }
+
+ /* Build the full INI file path name */
+ StringCchCopy(szIniPath, ARRAYSIZE(szIniPath), szAppPath);
+ StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT("\\welcome.ini"));
+
+ /* Verify that the file exists, otherwise use the default configuration */
+ if (GetFileAttributes(szIniPath) == INVALID_FILE_ATTRIBUTES)
+ {
+ /* Use the default configuration and retrieve the default topics */
+ return LoadTopics(TEXT(""));
+ }
+
+ /* Load the settings from the INI configuration file */
+ bDisplayCheckBox = !!GetPrivateProfileInt(TEXT("Welcome"),
TEXT("DisplayCheckBox"), FALSE /* default */, szIniPath);
+ bDisplayExitBtn = !!GetPrivateProfileInt(TEXT("Welcome"),
TEXT("DisplayExitButton"), TRUE /* default */, szIniPath);
+
+ if (!GetPrivateProfileString(TEXT("Welcome"),
TEXT("ResourceDir"), NULL /* default */,
+ szResPath, ARRAYSIZE(szResPath), szIniPath))
+ {
+ *szResPath = 0;
+ }
+
+ /* Set the current directory to the one of this application, and retrieve the topics
*/
+ SetCurrentDirectory(szAppPath);
+ return LoadTopics(szResPath);
}
#if 0
@@ -513,7 +559,8 @@
if (!LoadString(hInstance, IDS_APPTITLE, szAppTitle, ARRAYSIZE(szAppTitle)))
StringCchCopy(szAppTitle, ARRAYSIZE(szAppTitle), TEXT("ReactOS
Welcome"));
- LoadTopics();
+ /* Load the configuration and the topics */
+ LoadConfiguration();
/* Create main window */
hWndMain = CreateWindow(szFrameClass,
@@ -544,6 +591,7 @@
DispatchMessage(&msg);
}
+ /* Cleanup */
FreeTopics();
return msg.wParam;
Modified: trunk/reactos/boot/bootdata/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/CMakeLists.t…
==============================================================================
--- trunk/reactos/boot/bootdata/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/CMakeLists.txt [iso-8859-1] Wed Feb 1 03:12:56 2017
@@ -1,7 +1,7 @@
add_subdirectory(packages)
-#common hives
+# Common hives
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/txtsetup.sif DESTINATION reactos NO_CAB FOR
bootcd regtest)
@@ -14,31 +14,51 @@
hivebcd.inf)
-#regtest
+# Regtest
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcdregtest/regtest.cmd DESTINATION
reactos/bin FOR all)
-#autorun.inf
+# autorun.inf
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/autorun-bootcd.inf DESTINATION root NO_CAB
NOT_IN_HYBRIDCD NAME_ON_CD autorun.inf FOR bootcd)
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/autorun-livecd.inf DESTINATION root NO_CAB
NOT_IN_HYBRIDCD NAME_ON_CD autorun.inf FOR livecd)
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/autorun-hybridcd.inf DESTINATION root NO_CAB
NOT_IN_HYBRIDCD NAME_ON_CD autorun.inf FOR hybridcd)
-#icon.ico
+# icon.ico
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/icon.ico DESTINATION root NO_CAB
NOT_IN_HYBRIDCD FOR all hybridcd)
-#readme.txt
+# readme.txt
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/readme.txt DESTINATION root NO_CAB
NOT_IN_HYBRIDCD FOR all hybridcd)
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/readme.txt DESTINATION reactos FOR all)
-#freeldr.ini
+# Welcome.exe optional custom configuration (only for HybridCD)
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/welcome_config/)
+ # Copy the main configuration file
+ add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/welcome_config/welcome.ini DESTINATION
bootcd/reactos NO_CAB FOR hybridcd)
+
+ # Convert the translation files (name format: xx-YY.ini) into UTF-16
+ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/welcome_config)
+ file(GLOB I18N_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/welcome_config/
${CMAKE_CURRENT_SOURCE_DIR}/welcome_config/*-*.ini)
+ foreach(_file ${I18N_FILES})
+ set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/welcome_config/${_file})
+ set(_source_file ${CMAKE_CURRENT_SOURCE_DIR}/welcome_config/${_file})
+ add_custom_command(OUTPUT "${_converted_file}"
+ COMMAND native-utf16le "${_source_file}"
"${_converted_file}"
+ DEPENDS native-utf16le "${_source_file}")
+ add_cd_file(TARGET converted_welcome_i18n_files FILE ${_converted_file}
DESTINATION bootcd/reactos/welcome NO_CAB NAME_ON_CD ${_file} FOR hybridcd)
+ list(APPEND _converted_welcome_i18n_files ${_converted_file})
+ endforeach(_file)
+ add_custom_target(converted_welcome_i18n_files DEPENDS
${_converted_welcome_i18n_files})
+endif()
+
+# freeldr.ini
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcd.ini DESTINATION root NO_CAB
NOT_IN_HYBRIDCD NAME_ON_CD freeldr.ini FOR bootcd regtest)
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/livecd.ini DESTINATION root NOT_IN_HYBRIDCD
NAME_ON_CD freeldr.ini FOR livecd)
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/hybridcd.ini DESTINATION root NAME_ON_CD
freeldr.ini FOR hybridcd)
-#unattend
+# Unattend
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcdregtest/unattend.inf DESTINATION
reactos NO_CAB FOR regtest)
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcd/unattend.inf DESTINATION reactos
NO_CAB FOR bootcd)
-#LiveCD shortcuts
+# LiveCD shortcuts
macro(add_livecd_shortcut name app dest)
add_link(NAME ${name} CMD_LINE_ARGS ${app} ICON ${app} PATH livecd_start.cmd GUID
"{450D8FBA-AD25-11D0-98A8-0800361B1103}" MINIMIZE)
list(APPEND LIVECD_SHORTCUTS "${CMAKE_CURRENT_BINARY_DIR}/${name}.lnk")
Added: trunk/reactos/boot/bootdata/welcome_config/welcome.ini
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/welcome_conf…
==============================================================================
--- trunk/reactos/boot/bootdata/welcome_config/welcome.ini (added)
+++ trunk/reactos/boot/bootdata/welcome_config/welcome.ini [iso-8859-1] Wed Feb 1
03:12:56 2017
@@ -0,0 +1,5 @@
+
+[Welcome]
+DisplayCheckBox = 0
+DisplayExitButton = 1
+ResourceDir = welcome\
Propchange: trunk/reactos/boot/bootdata/welcome_config/welcome.ini
------------------------------------------------------------------------------
svn:eol-style = native