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. --- .../WixToolset.Mba.Core/BootstrapperApplication.cs | 26 ++++++++++ src/api/burn/WixToolset.Mba.Core/EventArgs.cs | 31 +++++++++++ .../IBootstrapperApplication.cs | 60 +++++++++++++++++++++- .../IDefaultBootstrapperApplication.cs | 5 ++ 4 files changed, 121 insertions(+), 1 deletion(-) (limited to 'src/api/burn/WixToolset.Mba.Core') 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. /// -- cgit v1.2.3-55-g6feb