Commit 997762e3 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Use the right API for retrieving SPDX licences

BUG: 408112
parent c550098a
......@@ -55,6 +55,11 @@ if(AppStreamQt_FOUND)
else()
target_compile_definitions(DiscoverCommon PRIVATE -DAPPSTREAM_HAS_SPDX=0)
endif()
if(AppStreamQt_VERSION VERSION_GREATER 0.12.7)
target_compile_definitions(DiscoverCommon PRIVATE -DAPPSTREAM_HAS_SPDX_LICENSEURL=1)
else()
target_compile_definitions(DiscoverCommon PRIVATE -DAPPSTREAM_HAS_SPDX_LICENSEURL=0)
endif()
endif()
target_link_libraries(DiscoverCommon
......
......@@ -87,11 +87,14 @@ QJsonArray AppStreamUtils::licenses(const AppStream::Component& appdata)
license.remove(0, 1); //tokenize prefixes with an @ for some reason
if (!AppStream::SPDX::isLicenseId(license))
continue;
#if APPSTREAM_HAS_SPDX_LICENSEURL
ret.append(QJsonObject{ {QStringLiteral("name"), license}, {QStringLiteral("url"), { AppStream::SPDX::licenseUrl(license) } }});
#else
if (license.startsWith(prop))
ret.append(QJsonObject{ {QStringLiteral("name"), i18n("Proprietary")}, {QStringLiteral("url"), license.mid(prop.size())} });
else
ret.append(QJsonObject{ {QStringLiteral("name"), license}, {QStringLiteral("url"), { QLatin1String("https://spdx.org/licenses/") + AppStream::SPDX::asSpdxId(license) + QLatin1String(".html#licenseText") } }});
#endif
}
return ret;
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment