summaryrefslogtreecommitdiff
path: root/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-06-16 12:05:47 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-06-17 12:01:02 -0600
commit43cc8d743cbae0c21c694621069c916109bdfbc7 (patch)
tree18fb5f9d28eec8698fa58b02bfd25d4d550dfad3 /src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
parent6895a3e9625afe647a94f970103bdbb4f58fb0f8 (diff)
downloadwix-43cc8d743cbae0c21c694621069c916109bdfbc7.tar.gz
wix-43cc8d743cbae0c21c694621069c916109bdfbc7.tar.bz2
wix-43cc8d743cbae0c21c694621069c916109bdfbc7.zip
Add Success page to prereq BA.
This was needed to explain to the user that a restart is required but not allowed. It also allows localizing the reboot prompt. Fixes #3957, #5395
Diffstat (limited to 'src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp')
-rw-r--r--src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
index a266fa1d..62cdc70a 100644
--- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
+++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp
@@ -228,9 +228,9 @@ public: // IBootstrapperApplication
228 } 228 }
229 229
230 // If a restart was required. 230 // If a restart was required.
231 if (BOOTSTRAPPER_APPLY_RESTART_NONE != m_restartResult) 231 if (m_fRestartRequired)
232 { 232 {
233 if (m_fRestartRequired && m_fAllowRestart) 233 if (m_fShouldRestart && m_fAllowRestart)
234 { 234 {
235 *pAction = BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART; 235 *pAction = BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART;
236 } 236 }
@@ -1097,13 +1097,13 @@ public: // IBootstrapperApplication
1097 __super::OnApplyComplete(hrStatus, restart, recommendation, pAction); 1097 __super::OnApplyComplete(hrStatus, restart, recommendation, pAction);
1098 1098
1099 m_restartResult = restart; // remember the restart result so we return the correct error code no matter what the user chooses to do in the UI. 1099 m_restartResult = restart; // remember the restart result so we return the correct error code no matter what the user chooses to do in the UI.
1100 1100 m_fRestartRequired = BOOTSTRAPPER_APPLY_RESTART_NONE != restart;
1101 // If a restart was encountered and we are not suppressing restarts, then restart is required.
1102 m_fRestartRequired = (BOOTSTRAPPER_APPLY_RESTART_NONE != restart && BOOTSTRAPPER_RESTART_NEVER < m_command.restart);
1103 BalSetStringVariable(WIXSTDBA_VARIABLE_RESTART_REQUIRED, m_fRestartRequired ? L"1" : NULL, FALSE); 1101 BalSetStringVariable(WIXSTDBA_VARIABLE_RESTART_REQUIRED, m_fRestartRequired ? L"1" : NULL, FALSE);
1104 1102
1105 // If a restart is required and we're not displaying a UI or we are not supposed to prompt for restart then allow the restart. 1103 m_fShouldRestart = m_fRestartRequired && BOOTSTRAPPER_RESTART_NEVER < m_command.restart;
1106 m_fAllowRestart = m_fRestartRequired && (BOOTSTRAPPER_DISPLAY_FULL > m_command.display || BOOTSTRAPPER_RESTART_PROMPT < m_command.restart); 1104
1105 // Automatically restart if we're not displaying a UI or the command line said to always allow restarts.
1106 m_fAllowRestart = m_fShouldRestart && (BOOTSTRAPPER_DISPLAY_FULL > m_command.display || BOOTSTRAPPER_RESTART_PROMPT < m_command.restart);
1107 1107
1108 if (m_fPrereq) 1108 if (m_fPrereq)
1109 { 1109 {
@@ -3163,20 +3163,11 @@ private: // privates
3163 m_state = state; 3163 m_state = state;
3164 3164
3165 // If our install is at the end (success or failure) and we're not showing full UI or 3165 // If our install is at the end (success or failure) and we're not showing full UI or
3166 // we successfully installed the prerequisite then exit (prompt for restart if required). 3166 // we successfully installed the prerequisite(s) and either no restart is required or can automatically restart
3167 // then exit.
3167 if ((WIXSTDBA_STATE_APPLIED <= m_state && BOOTSTRAPPER_DISPLAY_FULL > m_command.display) || 3168 if ((WIXSTDBA_STATE_APPLIED <= m_state && BOOTSTRAPPER_DISPLAY_FULL > m_command.display) ||
3168 (WIXSTDBA_STATE_APPLIED == m_state && m_fPrereq)) 3169 (WIXSTDBA_STATE_APPLIED == m_state && m_fPrereq && (!m_fRestartRequired || m_fShouldRestart && m_fAllowRestart)))
3169 { 3170 {
3170 // If a restart was required but we were not automatically allowed to
3171 // accept the reboot then do the prompt.
3172 if (m_fRestartRequired && !m_fAllowRestart)
3173 {
3174 StrAllocFromError(&sczUnformattedText, HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED), NULL);
3175
3176 int nResult = ::MessageBoxW(m_hWnd, sczUnformattedText ? sczUnformattedText : L"The requested operation is successful. Changes will not be effective until the system is rebooted.", m_pTheme->sczCaption, MB_ICONEXCLAMATION | MB_OKCANCEL);
3177 m_fAllowRestart = (IDOK == nResult);
3178 }
3179
3180 // Quietly exit. 3171 // Quietly exit.
3181 ::PostMessageW(m_hWnd, WM_CLOSE, 0, 0); 3172 ::PostMessageW(m_hWnd, WM_CLOSE, 0, 0);
3182 } 3173 }
@@ -3214,13 +3205,13 @@ private: // privates
3214 } 3205 }
3215 else if (m_rgdwPageIds[WIXSTDBA_PAGE_SUCCESS] == dwNewPageId) // on the "Success" page, check if the restart or launch button should be enabled. 3206 else if (m_rgdwPageIds[WIXSTDBA_PAGE_SUCCESS] == dwNewPageId) // on the "Success" page, check if the restart or launch button should be enabled.
3216 { 3207 {
3217 BOOL fShowRestartButton = FALSE; 3208 BOOL fEnableRestartButton = FALSE;
3218 BOOL fLaunchTargetExists = FALSE; 3209 BOOL fLaunchTargetExists = FALSE;
3219 if (m_fRestartRequired) 3210 if (m_fShouldRestart)
3220 { 3211 {
3221 if (BOOTSTRAPPER_RESTART_PROMPT == m_command.restart) 3212 if (BOOTSTRAPPER_RESTART_PROMPT == m_command.restart)
3222 { 3213 {
3223 fShowRestartButton = TRUE; 3214 fEnableRestartButton = TRUE;
3224 } 3215 }
3225 } 3216 }
3226 else if (ThemeControlExists(m_pTheme, WIXSTDBA_CONTROL_LAUNCH_BUTTON)) 3217 else if (ThemeControlExists(m_pTheme, WIXSTDBA_CONTROL_LAUNCH_BUTTON))
@@ -3229,13 +3220,13 @@ private: // privates
3229 } 3220 }
3230 3221
3231 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_LAUNCH_BUTTON, fLaunchTargetExists && BOOTSTRAPPER_ACTION_UNINSTALL < m_plannedAction); 3222 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_LAUNCH_BUTTON, fLaunchTargetExists && BOOTSTRAPPER_ACTION_UNINSTALL < m_plannedAction);
3232 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_SUCCESS_RESTART_BUTTON, fShowRestartButton); 3223 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_SUCCESS_RESTART_BUTTON, fEnableRestartButton);
3233 } 3224 }
3234 else if (m_rgdwPageIds[WIXSTDBA_PAGE_FAILURE] == dwNewPageId) // on the "Failure" page, show error message and check if the restart button should be enabled. 3225 else if (m_rgdwPageIds[WIXSTDBA_PAGE_FAILURE] == dwNewPageId) // on the "Failure" page, show error message and check if the restart button should be enabled.
3235 { 3226 {
3236 BOOL fShowLogLink = (m_Bundle.sczLogVariable && *m_Bundle.sczLogVariable); // if there is a log file variable then we'll assume the log file exists. 3227 BOOL fShowLogLink = (m_Bundle.sczLogVariable && *m_Bundle.sczLogVariable); // if there is a log file variable then we'll assume the log file exists.
3237 BOOL fShowErrorMessage = FALSE; 3228 BOOL fShowErrorMessage = FALSE;
3238 BOOL fShowRestartButton = FALSE; 3229 BOOL fEnableRestartButton = FALSE;
3239 3230
3240 if (FAILED(m_hrFinal)) 3231 if (FAILED(m_hrFinal))
3241 { 3232 {
@@ -3317,17 +3308,17 @@ private: // privates
3317 fShowErrorMessage = TRUE; 3308 fShowErrorMessage = TRUE;
3318 } 3309 }
3319 3310
3320 if (m_fRestartRequired) 3311 if (m_fShouldRestart)
3321 { 3312 {
3322 if (BOOTSTRAPPER_RESTART_PROMPT == m_command.restart) 3313 if (BOOTSTRAPPER_RESTART_PROMPT == m_command.restart)
3323 { 3314 {
3324 fShowRestartButton = TRUE; 3315 fEnableRestartButton = TRUE;
3325 } 3316 }
3326 } 3317 }
3327 3318
3328 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_LOGFILE_LINK, fShowLogLink); 3319 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_LOGFILE_LINK, fShowLogLink);
3329 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_MESSAGE_TEXT, fShowErrorMessage); 3320 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_MESSAGE_TEXT, fShowErrorMessage);
3330 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_RESTART_BUTTON, fShowRestartButton); 3321 ThemeControlEnable(m_pTheme, WIXSTDBA_CONTROL_FAILURE_RESTART_BUTTON, fEnableRestartButton);
3331 } 3322 }
3332 3323
3333 HRESULT hr = ThemeShowPage(m_pTheme, dwOldPageId, SW_HIDE); 3324 HRESULT hr = ThemeShowPage(m_pTheme, dwOldPageId, SW_HIDE);
@@ -3977,6 +3968,7 @@ public:
3977 m_fDowngrading = FALSE; 3968 m_fDowngrading = FALSE;
3978 m_restartResult = BOOTSTRAPPER_APPLY_RESTART_NONE; 3969 m_restartResult = BOOTSTRAPPER_APPLY_RESTART_NONE;
3979 m_fRestartRequired = FALSE; 3970 m_fRestartRequired = FALSE;
3971 m_fShouldRestart = FALSE;
3980 m_fAllowRestart = FALSE; 3972 m_fAllowRestart = FALSE;
3981 3973
3982 m_sczLicenseFile = NULL; 3974 m_sczLicenseFile = NULL;
@@ -4079,6 +4071,7 @@ private:
4079 BOOL m_fDowngrading; 4071 BOOL m_fDowngrading;
4080 BOOTSTRAPPER_APPLY_RESTART m_restartResult; 4072 BOOTSTRAPPER_APPLY_RESTART m_restartResult;
4081 BOOL m_fRestartRequired; 4073 BOOL m_fRestartRequired;
4074 BOOL m_fShouldRestart;
4082 BOOL m_fAllowRestart; 4075 BOOL m_fAllowRestart;
4083 4076
4084 LPWSTR m_sczLicenseFile; 4077 LPWSTR m_sczLicenseFile;