[RAPPS] Improve LicenseType handling (#5809)

Tries now to map the "License" text set to "Freeware" to the
LICENSE_FREEWARE "LicenseType" so it is translated correctly (LoadString).

Fixes the following:

- If only the "License" field is set in the DB, nothing will change
  (this applies to 99% of the current entries in the DB).

- If both "LicenseType" and "License" are set, both will be used
  (no observable change in behavior): "Open Source (GPL v2)" etc.

- If only "LicenseType" is set, it will now display just the type
  "Freeware" instead of "Freeware ()".
  This is done only for "Freeware", because the others (the open source ones)
  have many variations. "OpenSource", "Open Source", "Open Source (GPL)" etc.
This commit is contained in:
Whindmar Saksit 2023-11-04 22:08:10 +01:00 committed by GitHub
parent b3c1f652ec
commit 4b03981846
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View file

@ -159,13 +159,18 @@ CAvailableApplicationInfo::LicenseString()
m_Parser->GetString(L"License", szLicenseString);
LicenseType licenseType;
if (IsLicenseType(IntBuffer))
if (IsKnownLicenseType(IntBuffer))
{
licenseType = static_cast<LicenseType>(IntBuffer);
}
else
{
licenseType = LICENSE_NONE;
if (szLicenseString.CompareNoCase(L"Freeware") == 0)
{
licenseType = LICENSE_FREEWARE;
szLicenseString = L"";
}
}
CStringW szLicense;
@ -184,7 +189,9 @@ CAvailableApplicationInfo::LicenseString()
return szLicenseString;
}
return szLicense + L" (" + szLicenseString + L")";
if (!szLicenseString.IsEmpty())
szLicense += L" (" + szLicenseString + L")";
return szLicense;
}
VOID

View file

@ -8,17 +8,17 @@
enum LicenseType
{
LICENSE_NONE,
LICENSE_OPENSOURCE,
LICENSE_FREEWARE,
LICENSE_TRIAL,
LICENSE_OPENSOURCE = 1,
LICENSE_FREEWARE = 2,
LICENSE_TRIAL = 3,
LICENSE_MIN = LICENSE_NONE,
LICENSE_MAX = LICENSE_TRIAL
};
inline BOOL
IsLicenseType(INT x)
IsKnownLicenseType(INT x)
{
return (x >= LICENSE_MIN && x <= LICENSE_MAX);
return (x > LICENSE_NONE && x <= LICENSE_MAX);
}
enum AppsCategories