Allow BA to update feed source
Fixes wixtoolset/issues#5568
Rob Mensching committed
Apr 13, 2021 at 18:16 UTC
d32f770ca05748df9e356444c7e617d5eeedb60c
6 files changed
+77
-2
src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h
+12
@@ -112,6 +112,7 @@ enum BOOTSTRAPPER_ENGINE_MESSAGE
112
BOOTSTRAPPER_ENGINE_MESSAGE_APPLY,
113
BOOTSTRAPPER_ENGINE_MESSAGE_QUIT,
114
BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE,
115
+ BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE,
116
BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS,
117
};
118
@@ -276,6 +277,17 @@ typedef struct _BAENGINE_LAUNCHAPPROVEDEXE_RESULTS
277
DWORD cbSize;
278
} BAENGINE_LAUNCHAPPROVEDEXE_RESULTS;
279
280
+typedef struct _BAENGINE_SETUPDATESOURCE_ARGS
281
+{
282
+ DWORD cbSize;
283
+ LPCWSTR wzUrl;
284
+} BAENGINE_SETUPDATESOURCE_ARGS;
285
+
286
+typedef struct _BAENGINE_SETUPDATESOURCE_RESULTS
287
+{
288
+ DWORD cbSize;
289
+} BAENGINE_SETUPDATESOURCE_RESULTS;
290
+
291
typedef struct _BAENGINE_LOG_ARGS
292
{
293
DWORD cbSize;
src/engine/EngineForApplication.cpp
+19
@@ -411,6 +411,22 @@ LExit:
411
return hr;
412
}
413
414
+static HRESULT BAEngineSetUpdateSource(
415
+ __in BOOTSTRAPPER_ENGINE_CONTEXT* pContext,
416
+ __in const LPVOID pvArgs,
417
+ __inout LPVOID pvResults
418
+ )
419
+{
420
+ HRESULT hr = S_OK;
421
+ ValidateMessageArgs(hr, pvArgs, BAENGINE_SETUPDATESOURCE_ARGS, pArgs);
422
+ ValidateMessageResults(hr, pvResults, BAENGINE_SETUPDATESOURCE_RESULTS, pResults);
423
+
424
+ hr = ExternalEngineSetUpdateSource(pContext->pEngineState, pArgs->wzUrl);
425
+
426
+LExit:
427
+ return hr;
428
+}
429
+
430
HRESULT WINAPI EngineForApplicationProc(
431
__in BOOTSTRAPPER_ENGINE_MESSAGE message,
432
__in const LPVOID pvArgs,
@@ -497,6 +513,9 @@ HRESULT WINAPI EngineForApplicationProc(
513
case BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE:
514
hr = BAEngineLaunchApprovedExe(pContext, pvArgs, pvResults);
515
break;
516
+ case BOOTSTRAPPER_ENGINE_MESSAGE_SETUPDATESOURCE:
517
+ hr = BAEngineSetUpdateSource(pContext, pvArgs, pvResults);
518
+ break;
519
case BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS:
520
hr = BAEngineCompareVersions(pContext, pvArgs, pvResults);
521
break;
src/engine/detect.cpp
+8
-1
@@ -258,6 +258,7 @@ extern "C" HRESULT DetectUpdate(
258
BOOL fBeginCalled = FALSE;
259
BOOL fSkip = TRUE;
260
BOOL fIgnoreError = FALSE;
261
+ LPWSTR sczOriginalSource = NULL;
262
263
// If no update source was specified, skip update detection.
264
if (!pUpdate->sczUpdateSource || !*pUpdate->sczUpdateSource)
@@ -266,7 +267,11 @@ extern "C" HRESULT DetectUpdate(
267
}
268
269
fBeginCalled = TRUE;
269
- hr = UserExperienceOnDetectUpdateBegin(pUX, pUpdate->sczUpdateSource, &fSkip);
270
+
271
+ hr = StrAllocString(&sczOriginalSource, pUpdate->sczUpdateSource, 0);
272
+ ExitOnFailure(hr, "Failed to duplicate update feed source.");
273
+
274
+ hr = UserExperienceOnDetectUpdateBegin(pUX, sczOriginalSource, &fSkip);
275
ExitOnRootFailure(hr, "BA aborted detect update begin.");
276
277
if (!fSkip)
@@ -276,6 +281,8 @@ extern "C" HRESULT DetectUpdate(
281
}
282
283
LExit:
284
+ ReleaseStr(sczOriginalSource);
285
+
286
if (fBeginCalled)
287
{
288
UserExperienceOnDetectUpdateComplete(pUX, hr, &fIgnoreError);
src/engine/externalengine.cpp
+32
@@ -733,6 +733,38 @@ LExit:
733
return hr;
734
}
735
736
+HRESULT ExternalEngineSetUpdateSource(
737
+ __in BURN_ENGINE_STATE* pEngineState,
738
+ __in_z LPCWSTR wzUrl
739
+ )
740
+{
741
+ HRESULT hr = S_OK;
742
+ BOOL fLeaveCriticalSection = FALSE;
743
+
744
+ ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive);
745
+ fLeaveCriticalSection = TRUE;
746
+ hr = UserExperienceEnsureEngineInactive(&pEngineState->userExperience);
747
+ ExitOnFailure(hr, "Engine is active, cannot change engine state.");
748
+
749
+ if (wzUrl && *wzUrl)
750
+ {
751
+ hr = StrAllocString(&pEngineState->update.sczUpdateSource, wzUrl, 0);
752
+ ExitOnFailure(hr, "Failed to set feed download URL.");
753
+ }
754
+ else // no URL provided means clear out the whole download source.
755
+ {
756
+ ReleaseNullStr(pEngineState->update.sczUpdateSource);
757
+ }
758
+
759
+LExit:
760
+ if (fLeaveCriticalSection)
761
+ {
762
+ ::LeaveCriticalSection(&pEngineState->userExperience.csEngineActive);
763
+ }
764
+
765
+ return hr;
766
+}
767
+
768
// TODO: callers need to provide the original size (at the time of first public release) of the struct instead of the current size.
769
HRESULT WINAPI ExternalEngineValidateMessageParameter(
770
__in_opt const LPVOID pv,
src/engine/externalengine.h
+5
@@ -165,6 +165,11 @@ HRESULT ExternalEngineLaunchApprovedExe(
165
__in const DWORD dwWaitForInputIdleTimeout
166
);
167
168
+HRESULT ExternalEngineSetUpdateSource(
169
+ __in BURN_ENGINE_STATE* pEngineState,
170
+ __in_z LPCWSTR wzUrl
171
+ );
172
+
173
HRESULT WINAPI ExternalEngineValidateMessageParameter(
174
__in_opt const LPVOID pv,
175
__in SIZE_T cbSizeOffset,
src/engine/userexperience.cpp
+1
-1
@@ -111,7 +111,7 @@ extern "C" HRESULT UserExperienceLoad(
111
args.pCommand = pCommand;
112
args.pfnBootstrapperEngineProc = EngineForApplicationProc;
113
args.pvBootstrapperEngineProcContext = pEngineContext;
114
- args.qwEngineAPIVersion = MAKEQWORDVERSION(2021, 3, 2, 0);
114
+ args.qwEngineAPIVersion = MAKEQWORDVERSION(2021, 4, 14, 0);
115
116
results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS);
117