From 4cd1c4e06145434ca940ac828772dc47b9d9738e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 13 Mar 2022 23:45:32 -0500 Subject: Allow the BA to override the bundle relation type during plan. --- .../inc/BootstrapperApplication.h | 29 ++++++++++- .../WixToolset.Mba.Core/BootstrapperApplication.cs | 26 ++++++++++ src/api/burn/WixToolset.Mba.Core/EventArgs.cs | 31 +++++++++++ .../IBootstrapperApplication.cs | 60 +++++++++++++++++++++- .../IDefaultBootstrapperApplication.cs | 5 ++ src/api/burn/balutil/inc/BAFunctions.h | 1 + src/api/burn/balutil/inc/BalBaseBAFunctions.h | 10 ++++ src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h | 1 + .../balutil/inc/BalBaseBootstrapperApplication.h | 11 ++++ .../inc/BalBaseBootstrapperApplicationProc.h | 12 +++++ .../burn/balutil/inc/IBootstrapperApplication.h | 8 +++ 11 files changed, 192 insertions(+), 2 deletions(-) (limited to 'src/api') diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h index 9a5fb8f8..b507b167 100644 --- a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h @@ -103,10 +103,22 @@ enum BOOTSTRAPPER_RELATION_TYPE BOOTSTRAPPER_RELATION_UPGRADE, BOOTSTRAPPER_RELATION_ADDON, BOOTSTRAPPER_RELATION_PATCH, - BOOTSTRAPPER_RELATION_DEPENDENT, + BOOTSTRAPPER_RELATION_DEPENDENT_ADDON, + BOOTSTRAPPER_RELATION_DEPENDENT_PATCH, BOOTSTRAPPER_RELATION_UPDATE, }; +enum BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE +{ + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_NONE, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DOWNGRADE, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_UPGRADE, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_ADDON, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_PATCH, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DEPENDENT_ADDON, + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_DEPENDENT_PATCH, +}; + enum BOOTSTRAPPER_CACHE_TYPE { BOOTSTRAPPER_CACHE_TYPE_REMOVE, @@ -210,6 +222,7 @@ enum BOOTSTRAPPER_APPLICATION_MESSAGE BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, + BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, }; enum BOOTSTRAPPER_APPLYCOMPLETE_ACTION @@ -1209,6 +1222,20 @@ struct BA_ONPLANRELATEDBUNDLE_RESULTS BOOTSTRAPPER_REQUEST_STATE requestedState; }; +struct BA_ONPLANRELATEDBUNDLETYPE_ARGS +{ + DWORD cbSize; + LPCWSTR wzBundleId; + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE recommendedType; +}; + +struct BA_ONPLANRELATEDBUNDLETYPE_RESULTS +{ + DWORD cbSize; + BOOL fCancel; + BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE requestedType; +}; + struct BA_ONPLANRESTORERELATEDBUNDLE_ARGS { DWORD cbSize; diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs index 1df992be..fd36cf26 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -88,6 +88,9 @@ namespace WixToolset.Mba.Core /// public event EventHandler PlanRelatedBundle; + /// + public event EventHandler PlanRelatedBundleType; + /// public event EventHandler PlanRollbackBoundary; @@ -533,6 +536,19 @@ namespace WixToolset.Mba.Core } } + /// + /// Called by the engine, raises the event. + /// + /// Additional arguments for this event. + protected virtual void OnPlanRelatedBundleType(PlanRelatedBundleTypeEventArgs args) + { + EventHandler handler = this.PlanRelatedBundleType; + if (null != handler) + { + handler(this, args); + } + } + /// /// Called by the engine, raises the event. /// @@ -1514,6 +1530,16 @@ namespace WixToolset.Mba.Core return args.HResult; } + int IBootstrapperApplication.OnPlanRelatedBundleType(string wzBundleId, RelatedBundlePlanType recommendedType, ref RelatedBundlePlanType pRequestedType, ref bool fCancel) + { + PlanRelatedBundleTypeEventArgs args = new PlanRelatedBundleTypeEventArgs(wzBundleId, recommendedType, pRequestedType, fCancel); + this.OnPlanRelatedBundleType(args); + + pRequestedType = args.Type; + fCancel = args.Cancel; + return args.HResult; + } + int IBootstrapperApplication.OnPlanRollbackBoundary(string wzRollbackBoundaryId, bool fRecommendedTransaction, ref bool fTransaction, ref bool fCancel) { PlanRollbackBoundaryEventArgs args = new PlanRollbackBoundaryEventArgs(wzRollbackBoundaryId, fRecommendedTransaction, fTransaction, fCancel); diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs index 816757cc..d8ec7998 100644 --- a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs +++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs @@ -745,6 +745,37 @@ namespace WixToolset.Mba.Core public RequestState State { get; set; } } + /// + /// Event arguments for + /// + [Serializable] + public class PlanRelatedBundleTypeEventArgs : CancellableHResultEventArgs + { + /// + public PlanRelatedBundleTypeEventArgs(string bundleId, RelatedBundlePlanType recommendedType, RelatedBundlePlanType type, bool cancelRecommendation) + : base(cancelRecommendation) + { + this.BundleId = bundleId; + this.RecommendedType = recommendedType; + this.Type = type; + } + + /// + /// Gets the identity of the bundle to plan for. + /// + public string BundleId { get; private set; } + + /// + /// Gets the recommended plan type for the bundle. + /// + public RelatedBundlePlanType RecommendedType { get; private set; } + + /// + /// Gets or sets the plan type for the bundle. + /// + public RelatedBundlePlanType Type { get; set; } + } + /// /// Event arguments for /// diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs index 489e3b6d..4ab0f8d9 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -1148,6 +1148,18 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); + + /// + /// See . + /// + [PreserveSig] + [return: MarshalAs(UnmanagedType.I4)] + int OnPlanRelatedBundleType( + [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, + [MarshalAs(UnmanagedType.U4)] RelatedBundlePlanType recommendedType, + [MarshalAs(UnmanagedType.U4)] ref RelatedBundlePlanType pRequestedType, + [MarshalAs(UnmanagedType.Bool)] ref bool fCancel + ); } /// @@ -1669,7 +1681,12 @@ namespace WixToolset.Mba.Core /// /// /// - Dependent, + DependentAddon, + + /// + /// + /// + DependentPatch, /// /// @@ -1677,6 +1694,47 @@ namespace WixToolset.Mba.Core Update, } + /// + /// The planned relation type for related bundles. + /// + public enum RelatedBundlePlanType + { + /// + /// + /// + None, + + /// + /// + /// + Downgrade, + + /// + /// + /// + Upgrade, + + /// + /// + /// + Addon, + + /// + /// + /// + Patch, + + /// + /// + /// + DependentAddon, + + /// + /// + /// + DependentPatch, + } + /// /// One or more reasons why the application is requested to be closed or is being closed. /// diff --git a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index c237cb9d..ebd1580b 100644 --- a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs @@ -333,6 +333,11 @@ namespace WixToolset.Mba.Core /// event EventHandler PlanRelatedBundle; + /// + /// Fired when the engine has begun planning the related bundle relation type. + /// + event EventHandler PlanRelatedBundleType; + /// /// Fired when the engine has begun planning an upgrade related bundle for restoring in case of failure. /// diff --git a/src/api/burn/balutil/inc/BAFunctions.h b/src/api/burn/balutil/inc/BAFunctions.h index cbef88df..f772eb3f 100644 --- a/src/api/burn/balutil/inc/BAFunctions.h +++ b/src/api/burn/balutil/inc/BAFunctions.h @@ -89,6 +89,7 @@ enum BA_FUNCTIONS_MESSAGE BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE, BA_FUNCTIONS_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE, BA_FUNCTIONS_MESSAGE_ONPLANRESTORERELATEDBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE, + BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLETYPE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE, BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024, BA_FUNCTIONS_MESSAGE_WNDPROC, diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctions.h b/src/api/burn/balutil/inc/BalBaseBAFunctions.h index 60a70e3e..f558828f 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctions.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctions.h @@ -859,6 +859,16 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnPlanRelatedBundleType( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE /*recommendedType*/, + __inout BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE* /*pRequestedType*/, + __inout BOOL* /*pfCancel*/ + ) + { + return S_OK; + } + public: // IBAFunctions virtual STDMETHODIMP OnPlan( ) diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h index 09cc189e..ede00f28 100644 --- a/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h +++ b/src/api/burn/balutil/inc/BalBaseBAFunctionsProc.h @@ -160,6 +160,7 @@ static HRESULT WINAPI BalBaseBAFunctionsProc( case BA_FUNCTIONS_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE: case BA_FUNCTIONS_MESSAGE_ONPLANNEDCOMPATIBLEPACKAGE: case BA_FUNCTIONS_MESSAGE_ONPLANRESTORERELATEDBUNDLE: + case BA_FUNCTIONS_MESSAGE_ONPLANRELATEDBUNDLETYPE: hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext); break; case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED: diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h index 7b3cf827..49f4b7ca 100644 --- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h @@ -1058,6 +1058,17 @@ public: // IBootstrapperApplication return S_OK; } + virtual STDMETHODIMP OnPlanRelatedBundleType( + __in_z LPCWSTR /*wzBundleId*/, + __in BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE /*recommendedType*/, + __inout BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE* /*pRequestedType*/, + __inout BOOL* pfCancel + ) + { + *pfCancel |= CheckCanceled(); + return S_OK; + } + public: //CBalBaseBootstrapperApplication virtual STDMETHODIMP Initialize( __in const BOOTSTRAPPER_CREATE_ARGS* pCreateArgs diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h index 8c3b8b72..698349f7 100644 --- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -729,6 +729,15 @@ static HRESULT BalBaseBAProcOnPlanRestoreRelatedBundle( return pBA->OnPlanRestoreRelatedBundle(pArgs->wzBundleId, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); } +static HRESULT BalBaseBAProcOnPlanRelatedBundleType( + __in IBootstrapperApplication* pBA, + __in BA_ONPLANRELATEDBUNDLETYPE_ARGS* pArgs, + __inout BA_ONPLANRELATEDBUNDLETYPE_RESULTS* pResults + ) +{ + return pBA->OnPlanRelatedBundleType(pArgs->wzBundleId, pArgs->recommendedType, &pResults->requestedType, &pResults->fCancel); +} + /******************************************************************* BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication. Provides a default mapping between the new message based BA interface and @@ -988,6 +997,9 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc( case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRESTORERELATEDBUNDLE: hr = BalBaseBAProcOnPlanRestoreRelatedBundle(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; + case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANRELATEDBUNDLETYPE: + hr = BalBaseBAProcOnPlanRelatedBundleType(pBA, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; } } diff --git a/src/api/burn/balutil/inc/IBootstrapperApplication.h b/src/api/burn/balutil/inc/IBootstrapperApplication.h index e916d41e..462df0cc 100644 --- a/src/api/burn/balutil/inc/IBootstrapperApplication.h +++ b/src/api/burn/balutil/inc/IBootstrapperApplication.h @@ -699,4 +699,12 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, __inout BOOL* pfCancel ) = 0; + + // OnPlanRelatedBundleType - called when the engine begins planning the related bundle relation type. + STDMETHOD(OnPlanRelatedBundleType)( + __in_z LPCWSTR wzBundleId, + __in BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE recommendedType, + __inout BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE* pRequestedType, + __inout BOOL* pfCancel + ) = 0; }; -- cgit v1.2.3-55-g6feb