Skip to content
30 changes: 15 additions & 15 deletions src/AppInstallerCLICore/Workflows/MSStoreInstallerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,37 +70,37 @@ namespace AppInstaller::CLI::Workflow
return errorCode;
}

bool GetFreeUserEntitlement(Execution::Context& context, const std::wstring& productId)
bool GetFreeEntitlement(Execution::Context& context, const std::wstring& productId)
{
AppInstallManager installManager;

// Verifying/Acquiring product ownership
context.Reporter.Info() << Resource::String::MSStoreInstallTryGetEntitlement << std::endl;
GetEntitlementResult enr = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get();

if (enr.Status() == GetEntitlementStatus::Succeeded)
AICLI_LOG(CLI, Info, << "Get user entitlement.");
GetEntitlementResult result = installManager.GetFreeUserEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get();
if (result.Status() == GetEntitlementStatus::NoStoreAccount)
{
context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl;
AICLI_LOG(CLI, Error, << "Get entitlement succeeded.");

AICLI_LOG(CLI, Info, << "Get device entitlement.");
result = installManager.GetFreeDeviceEntitlementAsync(productId, winrt::hstring(), winrt::hstring()).get();
}
else if (enr.Status() == GetEntitlementStatus::NoStoreAccount)

if (result.Status() == GetEntitlementStatus::Succeeded)
{
context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNoStoreAccount << std::endl;
AICLI_LOG(CLI, Error, << "Get entitlement failed. No Store account.");
context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementSuccess << std::endl;
}
else if (enr.Status() == GetEntitlementStatus::NetworkError)
else if (result.Status() == GetEntitlementStatus::NetworkError)
{
context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementNetworkError << std::endl;
AICLI_LOG(CLI, Error, << "Get entitlement failed. Network error.");
}
else if (enr.Status() == GetEntitlementStatus::ServerError)
else if (result.Status() == GetEntitlementStatus::ServerError)
{
context.Reporter.Info() << Resource::String::MSStoreInstallGetEntitlementServerError << std::endl;
AICLI_LOG(CLI, Error, << "Get entitlement succeeded. Server error. ProductId: " << Utility::ConvertToUTF8(productId));
}

return enr.Status() == GetEntitlementStatus::Succeeded;
return result.Status() == GetEntitlementStatus::Succeeded;
}
}

Expand All @@ -111,7 +111,7 @@ namespace AppInstaller::CLI::Workflow
AppInstallManager installManager;

// Verifying/Acquiring product ownership
if (!GetFreeUserEntitlement(context, productId))
if (!GetFreeEntitlement(context, productId))
{
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_MSSTORE_INSTALL_FAILED);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ namespace AppInstaller::CLI::Workflow
AppInstallManager installManager;

// Verifying/Acquiring product ownership
if (!GetFreeUserEntitlement(context, productId))
if (!GetFreeEntitlement(context, productId))
{
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_MSSTORE_INSTALL_FAILED);
}
Expand All @@ -160,7 +160,7 @@ namespace AppInstaller::CLI::Workflow
AppInstallItem installItem = installManager.SearchForUpdatesAsync(
productId, // ProductId
winrt::hstring() // SkuId
).get();
).get();

if (!installItem)
{
Expand Down