diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-12-10 11:42:44 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-12-11 20:03:13 -0600 |
commit | fc30db9fa3aa1d25a6ef078452864673caa67ec5 (patch) | |
tree | e3415a5a1329a867b2934a038243e95098214ec3 /src/burn/engine/externalengine.cpp | |
parent | 1d58b3333d1d694d08b68f6c87223aa504bfe773 (diff) | |
download | wix-fc30db9fa3aa1d25a6ef078452864673caa67ec5.tar.gz wix-fc30db9fa3aa1d25a6ef078452864673caa67ec5.tar.bz2 wix-fc30db9fa3aa1d25a6ef078452864673caa67ec5.zip |
Add BA events for setting the update bundle.
Fixes #6410
Diffstat (limited to 'src/burn/engine/externalengine.cpp')
-rw-r--r-- | src/burn/engine/externalengine.cpp | 86 |
1 files changed, 52 insertions, 34 deletions
diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp index da84c83d..abe9b8bc 100644 --- a/src/burn/engine/externalengine.cpp +++ b/src/burn/engine/externalengine.cpp | |||
@@ -269,64 +269,82 @@ HRESULT ExternalEngineSetUpdate( | |||
269 | ) | 269 | ) |
270 | { | 270 | { |
271 | HRESULT hr = S_OK; | 271 | HRESULT hr = S_OK; |
272 | BOOL fLeaveCriticalSection = FALSE; | ||
272 | LPWSTR sczFilePath = NULL; | 273 | LPWSTR sczFilePath = NULL; |
273 | LPWSTR sczCommandline = NULL; | 274 | LPWSTR sczCommandline = NULL; |
275 | LPWSTR sczPreviousId = NULL; | ||
276 | LPCWSTR wzNewId = NULL; | ||
274 | UUID guid = { }; | 277 | UUID guid = { }; |
275 | WCHAR wzGuid[39]; | 278 | WCHAR wzGuid[39]; |
276 | RPC_STATUS rs = RPC_S_OK; | 279 | RPC_STATUS rs = RPC_S_OK; |
280 | BOOL fRemove = (!wzLocalSource || !*wzLocalSource) && (!wzDownloadSource || !*wzDownloadSource); | ||
281 | |||
282 | UserExperienceOnSetUpdateBegin(&pEngineState->userExperience); | ||
277 | 283 | ||
278 | ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive); | 284 | ::EnterCriticalSection(&pEngineState->userExperience.csEngineActive); |
285 | fLeaveCriticalSection = TRUE; | ||
279 | hr = UserExperienceEnsureEngineInactive(&pEngineState->userExperience); | 286 | hr = UserExperienceEnsureEngineInactive(&pEngineState->userExperience); |
280 | ExitOnFailure(hr, "Engine is active, cannot change engine state."); | 287 | ExitOnFailure(hr, "Engine is active, cannot change engine state."); |
281 | 288 | ||
282 | if ((!wzLocalSource || !*wzLocalSource) && (!wzDownloadSource || !*wzDownloadSource)) | 289 | if (!fRemove) |
283 | { | ||
284 | UpdateUninitialize(&pEngineState->update); | ||
285 | } | ||
286 | else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && (0 != cbHash || rgbHash)) | ||
287 | { | 290 | { |
288 | hr = E_INVALIDARG; | 291 | if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && (0 != cbHash || rgbHash)) |
292 | { | ||
293 | ExitFunction1(hr = E_INVALIDARG); | ||
294 | } | ||
295 | else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (SHA512_HASH_LEN != cbHash || !rgbHash)) | ||
296 | { | ||
297 | ExitFunction1(hr = E_INVALIDARG); | ||
298 | } | ||
289 | } | 299 | } |
290 | else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (SHA512_HASH_LEN != cbHash || !rgbHash)) | 300 | |
301 | sczPreviousId = pEngineState->update.package.sczId; | ||
302 | pEngineState->update.package.sczId = NULL; | ||
303 | UpdateUninitialize(&pEngineState->update); | ||
304 | |||
305 | if (fRemove) | ||
291 | { | 306 | { |
292 | hr = E_INVALIDARG; | 307 | ExitFunction(); |
293 | } | 308 | } |
294 | else | ||
295 | { | ||
296 | UpdateUninitialize(&pEngineState->update); | ||
297 | 309 | ||
298 | hr = CoreCreateUpdateBundleCommandLine(&sczCommandline, &pEngineState->internalCommand, &pEngineState->command); | 310 | hr = CoreCreateUpdateBundleCommandLine(&sczCommandline, &pEngineState->internalCommand, &pEngineState->command); |
299 | ExitOnFailure(hr, "Failed to create command-line for update bundle."); | 311 | ExitOnFailure(hr, "Failed to create command-line for update bundle."); |
300 | 312 | ||
301 | // Bundles would fail to use the downloaded update bundle, as the running bundle would be one of the search paths. | 313 | // Bundles would fail to use the downloaded update bundle, as the running bundle would be one of the search paths. |
302 | // Here I am generating a random guid, but in the future it would be nice if the feed would provide the ID of the update. | 314 | // Here I am generating a random guid, but in the future it would be nice if the feed would provide the ID of the update. |
303 | rs = ::UuidCreate(&guid); | 315 | rs = ::UuidCreate(&guid); |
304 | hr = HRESULT_FROM_RPC(rs); | 316 | hr = HRESULT_FROM_RPC(rs); |
305 | ExitOnFailure(hr, "Failed to create bundle update guid."); | 317 | ExitOnFailure(hr, "Failed to create bundle update guid."); |
306 | 318 | ||
307 | if (!::StringFromGUID2(guid, wzGuid, countof(wzGuid))) | 319 | if (!::StringFromGUID2(guid, wzGuid, countof(wzGuid))) |
308 | { | 320 | { |
309 | hr = E_OUTOFMEMORY; | 321 | hr = E_OUTOFMEMORY; |
310 | ExitOnRootFailure(hr, "Failed to convert bundle update guid into string."); | 322 | ExitOnRootFailure(hr, "Failed to convert bundle update guid into string."); |
311 | } | 323 | } |
312 | 324 | ||
313 | hr = StrAllocFormatted(&sczFilePath, L"%ls\\%ls", wzGuid, pEngineState->registration.sczExecutableName); | 325 | hr = StrAllocFormatted(&sczFilePath, L"%ls\\%ls", wzGuid, pEngineState->registration.sczExecutableName); |
314 | ExitOnFailure(hr, "Failed to build bundle update file path."); | 326 | ExitOnFailure(hr, "Failed to build bundle update file path."); |
315 | 327 | ||
316 | if (!wzLocalSource || !*wzLocalSource) | 328 | if (!wzLocalSource || !*wzLocalSource) |
317 | { | 329 | { |
318 | wzLocalSource = sczFilePath; | 330 | wzLocalSource = sczFilePath; |
319 | } | 331 | } |
320 | 332 | ||
321 | hr = PseudoBundleInitialize(FILEMAKEVERSION(rmj, rmm, rup, rpr), &pEngineState->update.package, FALSE, pEngineState->registration.sczId, BOOTSTRAPPER_RELATION_UPDATE, BOOTSTRAPPER_PACKAGE_STATE_ABSENT, FALSE, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, TRUE, sczCommandline, NULL, NULL, NULL, rgbHash, cbHash); | 333 | hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzGuid, pEngineState->registration.sczId, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, rgbHash, cbHash); |
322 | ExitOnFailure(hr, "Failed to set update bundle."); | 334 | ExitOnFailure(hr, "Failed to set update bundle."); |
323 | 335 | ||
324 | pEngineState->update.fUpdateAvailable = TRUE; | 336 | pEngineState->update.fUpdateAvailable = TRUE; |
325 | } | 337 | wzNewId = wzGuid; |
326 | 338 | ||
327 | LExit: | 339 | LExit: |
328 | ::LeaveCriticalSection(&pEngineState->userExperience.csEngineActive); | 340 | if (fLeaveCriticalSection) |
341 | { | ||
342 | ::LeaveCriticalSection(&pEngineState->userExperience.csEngineActive); | ||
343 | } | ||
344 | |||
345 | UserExperienceOnSetUpdateComplete(&pEngineState->userExperience, hr, sczPreviousId, wzNewId); | ||
329 | 346 | ||
347 | ReleaseStr(sczPreviousId); | ||
330 | ReleaseStr(sczCommandline); | 348 | ReleaseStr(sczCommandline); |
331 | ReleaseStr(sczFilePath); | 349 | ReleaseStr(sczFilePath); |
332 | 350 | ||