Commit c169387b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

snap: support finding packages by appstream id

parent 4cdcd02e
......@@ -9,6 +9,9 @@ endif()
if ("${Snapd_VERSION}" VERSION_GREATER 1.42)
target_compile_definitions(snap-backend PRIVATE -DSNAP_PUBLISHER)
endif()
if ("${Snapd_VERSION}" VERSION_GREATER 1.46)
target_compile_definitions(snap-backend PRIVATE -DSNAP_FIND_COMMON_ID)
endif()
install(TARGETS snap-backend DESTINATION ${PLUGIN_INSTALL_DIR}/discover)
install(FILES snap-backend-categories.xml DESTINATION ${DATA_INSTALL_DIR}/libdiscover/categories)
......
......@@ -104,8 +104,11 @@ ResultsStream * SnapBackend::search(const AbstractResourcesBackend::Filters& fil
ResultsStream * SnapBackend::findResourceByPackageName(const QUrl& search)
{
return search.scheme() == QLatin1String("snap") ? populate(m_client.find(QSnapdClient::MatchName, search.host())) :
search.scheme() == QLatin1String("appstream") ? new ResultsStream(QLatin1String("snap-appstreamurl"), kFilter<QVector<AbstractResource*>>(m_resources, [search](SnapResource* res){ return res->appstreamId() == search.host(); } )) :
Q_ASSERT(!search.host().isEmpty());
return search.scheme() == QLatin1String("snap") ? populate(m_client.find(QSnapdClient::MatchName, search.host())) :
#ifdef SNAP_FIND_COMMON_ID
search.scheme() == QLatin1String("appstream") ? populate(m_client.find(QSnapdClient::MatchCommonId, search.host())) :
#endif
voidStream();
}
......
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