Move OnDetectUpdate from IBootstrapperApplication to BAProc.

This commit is contained in:
Sean Hall 2016-08-28 18:04:38 -05:00 коммит произвёл Rob Mensching
Родитель 66a0bd99f6
Коммит f2c59257f7
17 изменённых файлов: 153 добавлений и 89 удалений

Просмотреть файл

@ -45,7 +45,7 @@
<Properties>VisualStudioTargetVersion=2015</Properties>
</ProjectReference>
<ProjectReference Include="..\VotiveMsi\VotiveMsi.wixproj" />
<ProjectReference Include="..\WixBA\WixBA.csproj" Condition="'$(WixStdBundle)' != 'true'" />
<ProjectReference Include="..\WixBA\WixBA.csproj" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -160,7 +160,7 @@ namespace WixToolset.UX
if ((UpdateState.Failed != this.State) && (LaunchAction.Uninstall != WixBA.Model.Command.Action) && (Display.Full == WixBA.Model.Command.Display))
{
this.State = UpdateState.Checking;
e.Result = Result.Ok;
e.Skip = false;
}
}
@ -168,7 +168,7 @@ namespace WixToolset.UX
{
// The list of updates is sorted in descending version, so the first callback should be the largest update available.
// This update should be either larger than ours (so we are out of date), the same as ours (so we are current)
// or smaller than ours (we have a private build). If we really wanted to, we could leave the e.Result alone and
// or smaller than ours (we have a private build). If we really wanted to, we could leave the e.StopProcessingUpdates alone and
// enumerate all of the updates.
WixBA.Model.Engine.Log(LogLevel.Verbose, String.Format("Potential update v{0} from '{1}'; current version: v{2}", e.Version, e.UpdateLocation, WixBA.Model.Version));
if (e.Version > WixBA.Model.Version)
@ -178,13 +178,12 @@ namespace WixToolset.UX
string changesFormat = @"<body style='overflow: auto;'>{0}</body>";
this.UpdateChanges = String.Format(changesFormat, e.Content);
this.State = UpdateState.Available;
e.Result = Result.Ok;
}
else if (e.Version <= WixBA.Model.Version)
else
{
this.State = UpdateState.Current;
e.Result = Result.Cancel;
}
e.StopProcessingUpdates = true;
}
private void DetectUpdateComplete(object sender, Bootstrapper.DetectUpdateCompleteEventArgs e)

Просмотреть файл

@ -390,11 +390,10 @@ static HRESULT DetectAtomFeedUpdate(
HRESULT hr = S_OK;
int nResult = IDNOACTION;
LPWSTR sczUpdateFeedTempFile = NULL;
ATOM_FEED* pAtomFeed = NULL;
APPLICATION_UPDATE_CHAIN* pApupChain = NULL;
BOOL fStopProcessingUpdates = FALSE;
hr = AtomInitialize();
ExitOnFailure(hr, "Failed to initialize Atom.");
@ -414,27 +413,16 @@ static HRESULT DetectAtomFeedUpdate(
{
APPLICATION_UPDATE_ENTRY* pAppUpdateEntry = &pApupChain->rgEntries[i];
nResult = pUX->pUserExperience->OnDetectUpdate(pAppUpdateEntry->rgEnclosures ? pAppUpdateEntry->rgEnclosures->wzUrl : NULL,
hr = UserExperienceOnDetectUpdate(pUX, pAppUpdateEntry->rgEnclosures ? pAppUpdateEntry->rgEnclosures->wzUrl : NULL,
pAppUpdateEntry->rgEnclosures ? pAppUpdateEntry->rgEnclosures->dw64Size : 0,
pAppUpdateEntry->dw64Version, pAppUpdateEntry->wzTitle,
pAppUpdateEntry->wzSummary, pAppUpdateEntry->wzContentType, pAppUpdateEntry->wzContent, IDNOACTION);
pAppUpdateEntry->wzSummary, pAppUpdateEntry->wzContentType, pAppUpdateEntry->wzContent, &fStopProcessingUpdates);
ExitOnRootFailure(hr, "BA aborted detect update.");
switch (nResult)
if (fStopProcessingUpdates)
{
case IDNOACTION:
hr = S_OK;
continue;
case IDOK:
pUpdate->fUpdateAvailable = TRUE;
hr = S_OK;
break;
case IDCANCEL:
hr = S_FALSE;
break;
default:
ExitOnRootFailure(hr = E_INVALIDDATA, "UX aborted detect update begin.");
break;
}
break;
}
}

Просмотреть файл

@ -374,6 +374,47 @@ LExit:
return hr;
}
BAAPI UserExperienceOnDetectUpdate(
__in BURN_USER_EXPERIENCE* pUserExperience,
__in_z LPCWSTR wzUpdateLocation,
__in DWORD64 dw64Size,
__in DWORD64 dw64Version,
__in_z_opt LPCWSTR wzTitle,
__in_z_opt LPCWSTR wzSummary,
__in_z_opt LPCWSTR wzContentType,
__in_z_opt LPCWSTR wzContent,
__inout BOOL* pfStopProcessingUpdates
)
{
HRESULT hr = S_OK;
BA_ONDETECTUPDATE_ARGS args = { };
BA_ONDETECTUPDATE_RESULTS results = { };
args.cbSize = sizeof(args);
args.wzUpdateLocation = wzUpdateLocation;
args.dw64Size = dw64Size;
args.dw64Version = dw64Version;
args.wzTitle = wzTitle;
args.wzSummary = wzSummary;
args.wzContentType = wzContentType;
args.wzContent = wzContent;
results.cbSize = sizeof(results);
results.fStopProcessingUpdates = *pfStopProcessingUpdates;
hr = pUserExperience->pfnBAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE, &args, &results, pUserExperience->pvBAProcContext);
ExitOnFailure(hr, "BA OnDetectUpdate failed.");
if (results.fCancel)
{
hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT);
}
*pfStopProcessingUpdates = results.fStopProcessingUpdates;
LExit:
return hr;
}
BAAPI UserExperienceOnDetectUpdateBegin(
__in BURN_USER_EXPERIENCE* pUserExperience,
__in_z LPCWSTR wzUpdateLocation,

Просмотреть файл

@ -116,6 +116,17 @@ HRESULT UserExperienceOnDetectForwardCompatibleBundle(
__in DWORD64 dw64Version,
__inout BOOL* pfIgnoreBundle
);
HRESULT UserExperienceOnDetectUpdate(
__in BURN_USER_EXPERIENCE* pUserExperience,
__in_z LPCWSTR wzUpdateLocation,
__in DWORD64 dw64Size,
__in DWORD64 dw64Version,
__in_z_opt LPCWSTR wzTitle,
__in_z_opt LPCWSTR wzSummary,
__in_z_opt LPCWSTR wzContentType,
__in_z_opt LPCWSTR wzContent,
__inout BOOL* pfStopProcessingUpdates
);
HRESULT UserExperienceOnDetectUpdateBegin(
__in BURN_USER_EXPERIENCE* pUserExperience,
__in_z LPCWSTR wzUpdateLocation,

Просмотреть файл

@ -88,6 +88,7 @@ enum BOOTSTRAPPER_APPLICATION_MESSAGE
BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE,
};
enum BOOTSTRAPPER_SHUTDOWN_ACTION
@ -163,6 +164,25 @@ struct BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS
BOOL fIgnoreBundle;
};
struct BA_ONDETECTUPDATE_ARGS
{
DWORD cbSize;
LPCWSTR wzUpdateLocation;
DWORD64 dw64Size;
DWORD64 dw64Version;
LPCWSTR wzTitle;
LPCWSTR wzSummary;
LPCWSTR wzContentType;
LPCWSTR wzContent;
};
struct BA_ONDETECTUPDATE_RESULTS
{
DWORD cbSize;
BOOL fCancel;
BOOL fStopProcessingUpdates;
};
struct BA_ONDETECTUPDATEBEGIN_ARGS
{
DWORD cbSize;

Просмотреть файл

@ -45,14 +45,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A
) = 0;
// OnDetectUpdate - called when the engine has an update candidate for bundle update.
//
// Return:
// IDOK instructs the engine to stop further update detection.
//
// IDCANCEL instructs the engine to stop detection.
//
// IDNOACTION instructs the engine to process further update candidates.
STDMETHOD_(int, OnDetectUpdate)(
STDMETHOD(OnDetectUpdate)(
__in_z_opt LPCWSTR wzUpdateLocation,
__in DWORD64 dw64Size,
__in DWORD64 dw64Version,
@ -60,7 +53,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A
__in_z_opt LPCWSTR wzSummary,
__in_z_opt LPCWSTR wzContentType,
__in_z_opt LPCWSTR wzContent,
__in int nRecommendation
__inout BOOL* pfCancel,
__inout BOOL* pfStopProcessingUpdates
) = 0;
// OnDetectUpdateComplete - called when the engine completes detection for bundle update.

Просмотреть файл

@ -1141,12 +1141,14 @@ namespace WixToolset.Bootstrapper
return args.HResult;
}
Result IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, long dw64Version, string wzTitle, string wzSummary, string wzContentType, string wzContent, int nRecommendation)
int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, long dw64Version, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates)
{
DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, dw64Version, wzTitle, wzSummary, wzContentType, wzContent, nRecommendation);
DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, dw64Version, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates);
this.OnDetectUpdate(args);
return args.Result;
fCancel = args.Cancel;
fStopProcessingUpdates = args.StopProcessingUpdates;
return args.HResult;
}
Result IBootstrapperApplication.OnDetectUpdateComplete(int hrStatus, string wzUpdateLocation, int nRecommendation)

Просмотреть файл

@ -334,15 +334,8 @@ namespace WixToolset.Bootstrapper
/// Additional arguments used when the detection for an update has begun.
/// </summary>
[Serializable]
public class DetectUpdateEventArgs : ResultEventArgs
public class DetectUpdateEventArgs : CancellableHResultEventArgs
{
private long size;
private Version version;
private string title;
private string summary;
private string contentType;
private string content;
/// <summary>
/// Creates a new instance of the <see cref="DetectUpdateBeginEventArgs"/> class.
/// </summary>
@ -353,17 +346,19 @@ namespace WixToolset.Bootstrapper
/// <param name="summary">The summary of the updated bundle.</param>
/// <param name="contentType">The content type of the content of the updated bundle.</param>
/// <param name="content">The content of the updated bundle.</param>
/// <param name="recommendation">The recommendation from the engine.</param>
public DetectUpdateEventArgs(string updateLocation, long size, long version, string title, string summary, string contentType, string content, int recommendation)
: base(recommendation)
/// <param name="cancelRecommendation">The recommendation from the engine.</param>
/// <param name="stopRecommendation">The recommendation from the engine.</param>
public DetectUpdateEventArgs(string updateLocation, long size, long version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation)
: base(cancelRecommendation)
{
this.UpdateLocation = updateLocation;
this.size = size;
this.version = new Version((int)(version >> 48 & 0xFFFF), (int)(version >> 32 & 0xFFFF), (int)(version >> 16 & 0xFFFF), (int)(version & 0xFFFF));
this.title = title;
this.summary = summary;
this.contentType = contentType;
this.content = content;
this.Size = size;
this.Version = Engine.LongToVersion(version);
this.Title = title;
this.Summary = summary;
this.ContentType = contentType;
this.Content = content;
this.StopProcessingUpdates = stopRecommendation;
}
/// <summary>
@ -374,50 +369,37 @@ namespace WixToolset.Bootstrapper
/// <summary>
/// Gets the size of the updated bundle.
/// </summary>
public long Size
{
get { return this.size; }
}
public long Size { get; private set; }
/// <summary>
/// Gets the version of the updated bundle.
/// </summary>
public Version Version
{
get { return this.version; }
}
public Version Version { get; private set; }
/// <summary>
/// Gets the title of the the updated bundle.
/// </summary>
public string Title
{
get { return this.title; }
}
public string Title { get; private set; }
/// <summary>
/// Gets the summary of the updated bundle.
/// </summary>
public string Summary
{
get { return this.summary; }
}
public string Summary { get; private set; }
/// <summary>
/// Gets the content type of the content of the updated bundle.
/// </summary>
public string ContentType
{
get { return this.contentType; }
}
public string ContentType { get; private set; }
/// <summary>
/// Gets the content of the updated bundle.
/// </summary>
public string Content
{
get { return this.content; }
}
public string Content { get; private set; }
/// <summary>
/// Tells the engine to stop giving the rest of the updates found in the feed.
/// </summary>
public bool StopProcessingUpdates { get; set; }
}
/// <summary>

Просмотреть файл

@ -60,7 +60,7 @@ namespace WixToolset.Bootstrapper
[PreserveSig]
[return: MarshalAs(UnmanagedType.I4)]
Result OnDetectUpdate(
int OnDetectUpdate(
[MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation,
[MarshalAs(UnmanagedType.U8)] long dw64Size,
[MarshalAs(UnmanagedType.U8)] long dw64Version,
@ -68,7 +68,8 @@ namespace WixToolset.Bootstrapper
[MarshalAs(UnmanagedType.LPWStr)] string wzSummary,
[MarshalAs(UnmanagedType.LPWStr)] string wzContentType,
[MarshalAs(UnmanagedType.LPWStr)] string wzContent,
[MarshalAs(UnmanagedType.I4)] int nRecommendation
[MarshalAs(UnmanagedType.Bool)] ref bool fCancel,
[MarshalAs(UnmanagedType.Bool)] ref bool fStopProcessingUpdates
);
[PreserveSig]

Просмотреть файл

@ -945,6 +945,9 @@ public: // IBootstrapperApplication
case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN:
OnDetectUpdateBeginFallback(reinterpret_cast<BA_ONDETECTUPDATEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTUPDATEBEGIN_RESULTS*>(pvResults));
break;
case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE:
OnDetectUpdateFallback(reinterpret_cast<BA_ONDETECTUPDATE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTUPDATE_RESULTS*>(pvResults));
break;
default:
BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Forwarding unknown BA message: %d", message);
m_pfnBAFunctionsProc((BA_FUNCTIONS_MESSAGE)message, pvArgs, pvResults, m_pvBAFunctionsProcContext);
@ -1012,6 +1015,13 @@ private: // privates
m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN, pArgs, pResults, m_pvBAFunctionsProcContext);
}
void OnDetectUpdateFallback(
__in BA_ONDETECTUPDATE_ARGS* pArgs,
__inout BA_ONDETECTUPDATE_RESULTS* pResults)
{
m_pfnBAFunctionsProc(BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE, pArgs, pResults, m_pvBAFunctionsProcContext);
}
//
// UiThreadProc - entrypoint for UI thread.
//

Просмотреть файл

@ -18,6 +18,7 @@ enum BA_FUNCTIONS_MESSAGE
BA_FUNCTIONS_MESSAGE_ONSYSTEMSHUTDOWN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONSYSTEMSHUTDOWN,
BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE,
BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN,
BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE = BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE,
BA_FUNCTIONS_MESSAGE_ONTHEMELOADED = 1024,
};

Просмотреть файл

@ -120,7 +120,7 @@ public: // IBootstrapperApplication
return S_OK;
}
virtual STDMETHODIMP_(int) OnDetectUpdate(
virtual STDMETHODIMP OnDetectUpdate(
__in_z LPCWSTR /*wzUpdateLocation*/,
__in DWORD64 /*dw64Size*/,
__in DWORD64 /*dw64Version*/,
@ -128,10 +128,11 @@ public: // IBootstrapperApplication
__in_z LPCWSTR /*wzSummary*/,
__in_z LPCWSTR /*wzContentType*/,
__in_z LPCWSTR /*wzContent*/,
__in int nRecommendation
__inout BOOL* /*pfCancel*/,
__inout BOOL* /*pfStopProcessingUpdates*/
)
{
return nRecommendation;
return S_OK;
}
virtual STDMETHODIMP_(int) OnDetectUpdateComplete(

Просмотреть файл

@ -44,6 +44,7 @@ static HRESULT WINAPI BalBaseBAFunctionsProc(
case BA_FUNCTIONS_MESSAGE_ONSYSTEMSHUTDOWN:
case BA_FUNCTIONS_MESSAGE_ONDETECTFORWARDCOMPATIBLEBUNDLE:
case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATEBEGIN:
case BA_FUNCTIONS_MESSAGE_ONDETECTUPDATE:
hr = BalBaseBootstrapperApplicationProc((BOOTSTRAPPER_APPLICATION_MESSAGE)message, pvArgs, pvResults, pvContext);
break;
case BA_FUNCTIONS_MESSAGE_ONTHEMELOADED:

Просмотреть файл

@ -120,7 +120,7 @@ public: // IBootstrapperApplication
return S_OK;
}
virtual STDMETHODIMP_(int) OnDetectUpdate(
virtual STDMETHODIMP OnDetectUpdate(
__in_z LPCWSTR /*wzUpdateLocation*/,
__in DWORD64 /*dw64Size*/,
__in DWORD64 /*dw64Version*/,
@ -128,10 +128,12 @@ public: // IBootstrapperApplication
__in_z LPCWSTR /*wzSummary*/,
__in_z LPCWSTR /*wzContentType*/,
__in_z LPCWSTR /*wzContent*/,
__in int nRecommendation
__inout BOOL* pfCancel,
__inout BOOL* /*pfStopProcessingUpdates*/
)
{
return CheckCanceled() ? IDCANCEL : nRecommendation;
*pfCancel |= CheckCanceled();
return S_OK;
}
virtual STDMETHODIMP_(int) OnDetectUpdateComplete(

Просмотреть файл

@ -90,6 +90,15 @@ static HRESULT BalBaseBAProcOnDetectUpdateBegin(
return pBA->OnDetectUpdateBegin(pArgs->wzUpdateLocation, &pResults->fCancel, &pResults->fSkip);
}
static HRESULT BalBaseBAProcOnDetectUpdate(
__in IBootstrapperApplication* pBA,
__in BA_ONDETECTUPDATE_ARGS* pArgs,
__inout BA_ONDETECTUPDATE_RESULTS* pResults
)
{
return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->dw64Version, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates);
}
/*******************************************************************
BalBaseBootstrapperApplicationProc - requires pvContext to be of type IBootstrapperApplication.
Provides a default mapping between the new message based BA interface and
@ -137,6 +146,9 @@ static HRESULT WINAPI BalBaseBootstrapperApplicationProc(
case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATEBEGIN:
hr = BalBaseBAProcOnDetectUpdateBegin(pBA, reinterpret_cast<BA_ONDETECTUPDATEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTUPDATEBEGIN_RESULTS*>(pvResults));
break;
case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTUPDATE:
hr = BalBaseBAProcOnDetectUpdate(pBA, reinterpret_cast<BA_ONDETECTUPDATE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTUPDATE_RESULTS*>(pvResults));
break;
}
}

Просмотреть файл

@ -123,7 +123,7 @@ namespace WixTest.BA
{
// The list of updates is sorted in descending version, so the first callback should be the largest update available.
// This update should be either larger than ours (so we are out of date), the same as ours (so we are current)
// or smaller than ours (we have a private build). If we really wanted to, we could leave the e.Result alone and
// or smaller than ours (we have a private build). If we really wanted to, we could leave the e.StopProcessingUpdates alone and
// enumerate all of the updates.
this.Log(String.Format("Potential update v{0} from '{1}'; current version: v{2}", e.Version, e.UpdateLocation, this.Version));
if (e.Version > this.Version)
@ -131,13 +131,12 @@ namespace WixTest.BA
this.Log(String.Format("Selected update v{0}", e.Version));
this.Engine.SetUpdate(null, e.UpdateLocation, e.Size, UpdateHashType.None, null);
this.UpdateAvailable = true;
e.Result = Result.Ok;
}
else if (e.Version <= this.Version)
else
{
e.Result = Result.Cancel;
this.UpdateAvailable = false;
}
e.StopProcessingUpdates = true;
}
protected override void OnDetectUpdateComplete(DetectUpdateCompleteEventArgs e)