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

Snap: support looking up by appstream id

parent 2b79366e
......@@ -80,7 +80,9 @@ 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())) : voidStream();
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(); } )) :
voidStream();
}
template <class T>
......
......@@ -216,12 +216,6 @@ bool SnapResource::isTechnical() const
return m_snap->snapType() != QLatin1String("app");
}
QUrl SnapResource::url() const
{
//FIXME interim, until it has an appstreamId
return QUrl(QStringLiteral("snap://") + packageName());
}
void SnapResource::setSnap(const QSharedPointer<QSnapdSnap>& snap)
{
Q_ASSERT(snap->name() == m_snap->name());
......@@ -326,3 +320,9 @@ QAbstractItemModel* SnapResource::plugs(QObject* p)
return new PlugsModel(m_snap.data(), qobject_cast<SnapBackend*>(parent()), p);
}
QString SnapResource::appstreamId() const
{
const auto ids = m_snap->commonIds();
return ids.isEmpty() ? QLatin1String("com.snap.") + m_snap->name() : ids.first();
}
......@@ -56,7 +56,6 @@ public:
void fetchChangelog() override;
void fetchScreenshots() override;
QList<PackageState> addonsInformation() override { return {}; }
QUrl url() const override;
void setSnap(const QSharedPointer<QSnapdSnap> &snap);
void setState(AbstractResource::State state);
......@@ -65,6 +64,7 @@ public:
QDate releaseDate() const override;
Q_SCRIPTABLE QAbstractItemModel* plugs(QObject* parents);
QString appstreamId() const override;
public:
void gotIcon();
......
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