Commit 5673ade2 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

flatpak: allow listing extensions

BUG: 400795
parent acd304d9
...@@ -521,6 +521,10 @@ void FlatpakBackend::addResource(FlatpakResource *resource) ...@@ -521,6 +521,10 @@ void FlatpakBackend::addResource(FlatpakResource *resource)
updateAppSize(installation, resource); updateAppSize(installation, resource);
m_resources.insert(resource->uniqueId(), resource); m_resources.insert(resource->uniqueId(), resource);
if (!resource->extends().isEmpty()) {
m_extends.append(resource->extends());
m_extends.removeDuplicates();
}
} }
class FlatpakSource class FlatpakSource
...@@ -1101,13 +1105,13 @@ ResultsStream * FlatpakBackend::search(const AbstractResourcesBackend::Filters & ...@@ -1101,13 +1105,13 @@ ResultsStream * FlatpakBackend::search(const AbstractResourcesBackend::Filters &
return stream; return stream;
} else if(filter.resourceUrl.scheme() == QLatin1String("appstream")) { } else if(filter.resourceUrl.scheme() == QLatin1String("appstream")) {
return findResourceByPackageName(filter.resourceUrl); return findResourceByPackageName(filter.resourceUrl);
} else if (!filter.resourceUrl.isEmpty() || !filter.extends.isEmpty()) } else if (!filter.resourceUrl.isEmpty() || (!filter.extends.isEmpty() && !m_extends.contains(filter.extends)))
return new ResultsStream(QStringLiteral("FlatpakStream-void"), {}); return new ResultsStream(QStringLiteral("FlatpakStream-void"), {});
auto stream = new ResultsStream(QStringLiteral("FlatpakStream")); auto stream = new ResultsStream(QStringLiteral("FlatpakStream"));
auto f = [this, stream, filter] () { auto f = [this, stream, filter] () {
QVector<AbstractResource*> ret; QVector<AbstractResource*> ret;
foreach(AbstractResource* r, m_resources) { foreach(auto r, m_resources) {
if (r->type() == AbstractResource::Technical && filter.state != AbstractResource::Upgradeable) { if (r->type() == AbstractResource::Technical && filter.state != AbstractResource::Upgradeable) {
continue; continue;
} }
...@@ -1115,6 +1119,9 @@ ResultsStream * FlatpakBackend::search(const AbstractResourcesBackend::Filters & ...@@ -1115,6 +1119,9 @@ ResultsStream * FlatpakBackend::search(const AbstractResourcesBackend::Filters &
if (r->state() < filter.state) if (r->state() < filter.state)
continue; continue;
if (!filter.extends.isEmpty() && !r->extends().contains(filter.extends))
continue;
if (filter.search.isEmpty() || r->name().contains(filter.search, Qt::CaseInsensitive) || r->comment().contains(filter.search, Qt::CaseInsensitive)) { if (filter.search.isEmpty() || r->name().contains(filter.search, Qt::CaseInsensitive) || r->comment().contains(filter.search, Qt::CaseInsensitive)) {
ret += r; ret += r;
} }
......
...@@ -63,6 +63,7 @@ public: ...@@ -63,6 +63,7 @@ public:
QString displayName() const override; QString displayName() const override;
bool hasApplications() const override { return true; } bool hasApplications() const override { return true; }
FlatpakResource * addSourceFromFlatpakRepo(const QUrl &url); FlatpakResource * addSourceFromFlatpakRepo(const QUrl &url);
QStringList extends() const override { return m_extends; }
private Q_SLOTS: private Q_SLOTS:
void onFetchMetadataFinished(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource, const QByteArray &metadata); void onFetchMetadataFinished(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource, const QByteArray &metadata);
...@@ -111,6 +112,7 @@ private: ...@@ -111,6 +112,7 @@ private:
QSharedPointer<OdrsReviewsBackend> m_reviews; QSharedPointer<OdrsReviewsBackend> m_reviews;
uint m_isFetching = 0; uint m_isFetching = 0;
uint m_refreshAppstreamMetadataJobs; uint m_refreshAppstreamMetadataJobs;
QStringList m_extends;
GCancellable *m_cancellable; GCancellable *m_cancellable;
QVector<FlatpakInstallation *> m_installations; QVector<FlatpakInstallation *> m_installations;
......
...@@ -141,7 +141,9 @@ void FlatpakResource::updateFromRef(FlatpakRef* ref) ...@@ -141,7 +141,9 @@ void FlatpakResource::updateFromRef(FlatpakRef* ref)
setBranch(QString::fromUtf8(flatpak_ref_get_branch(ref))); setBranch(QString::fromUtf8(flatpak_ref_get_branch(ref)));
setCommit(QString::fromUtf8(flatpak_ref_get_commit(ref))); setCommit(QString::fromUtf8(flatpak_ref_get_commit(ref)));
setFlatpakName(QString::fromUtf8(flatpak_ref_get_name(ref))); setFlatpakName(QString::fromUtf8(flatpak_ref_get_name(ref)));
setType(flatpak_ref_get_kind(ref) == FLATPAK_REF_KIND_APP ? FlatpakResource::DesktopApp : FlatpakResource::Runtime); setType(flatpak_ref_get_kind(ref) == FLATPAK_REF_KIND_APP ? DesktopApp :
extends().isEmpty() ? Runtime
: Extension);
setObjectName(packageName()); setObjectName(packageName());
} }
...@@ -244,7 +246,14 @@ int FlatpakResource::installedSize() const ...@@ -244,7 +246,14 @@ int FlatpakResource::installedSize() const
AbstractResource::Type FlatpakResource::type() const AbstractResource::Type FlatpakResource::type() const
{ {
return m_id.type == FlatpakResource::Runtime ? Technical : Application; switch (m_id.type) {
case FlatpakResource::Runtime:
return Technical;
case FlatpakResource::Extension:
return Addon;
default:
return Application;
}
} }
QUrl FlatpakResource::homepage() QUrl FlatpakResource::homepage()
...@@ -381,11 +390,11 @@ FlatpakResource::ResourceType FlatpakResource::resourceType() const ...@@ -381,11 +390,11 @@ FlatpakResource::ResourceType FlatpakResource::resourceType() const
QString FlatpakResource::typeAsString() const QString FlatpakResource::typeAsString() const
{ {
switch (m_id.type) { switch (m_id.type) {
case FlatpakResource::DesktopApp:
case FlatpakResource::Source:
return QLatin1String("app");
case FlatpakResource::Runtime: case FlatpakResource::Runtime:
case FlatpakResource::Extension:
return QLatin1String("runtime"); return QLatin1String("runtime");
case FlatpakResource::DesktopApp:
case FlatpakResource::Source:
default: default:
return QLatin1String("app"); return QLatin1String("app");
} }
...@@ -549,7 +558,12 @@ QString FlatpakResource::sourceIcon() const ...@@ -549,7 +558,12 @@ QString FlatpakResource::sourceIcon() const
return QStringLiteral("flatpak-discover"); return QStringLiteral("flatpak-discover");
} }
QString FlatpakResource::author() const QString FlatpakResource::author() const
{ {
return m_appdata.developerName(); return m_appdata.developerName();
} }
QStringList FlatpakResource::extends() const
{
return m_appdata.extends();
}
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
enum ResourceType { enum ResourceType {
DesktopApp = 0, DesktopApp = 0,
Runtime, Runtime,
Extension,
Source Source
}; };
...@@ -125,6 +126,7 @@ public: ...@@ -125,6 +126,7 @@ public:
QUrl url() const override; QUrl url() const override;
QDate releaseDate() const override; QDate releaseDate() const override;
QString author() const override; QString author() const override;
QStringList extends() const override;
FlatpakInstallation* installation() const { return m_id.installation; } FlatpakInstallation* installation() const { return m_id.installation; }
......
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