Commit 8c059ef7 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

flatpak: prefer starting applications using the desktop file

Some applications (see bug) may need some further arguments and in the end
we want to run the application like the user will from the menu or
krunner.

BUG: 401789
parent 9136b27a
add_definitions(-DTRANSLATION_DOMAIN=\"libdiscover\")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-paths.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-paths.h)
add_subdirectory(backends)
add_subdirectory(notifiers)
add_subdirectory(tests)
......
......@@ -892,14 +892,11 @@ void FlatpakBackend::updateAppInstalledMetadata(FlatpakInstalledRef *installedRe
bool FlatpakBackend::updateAppMetadata(FlatpakInstallation* flatpakInstallation, FlatpakResource *resource)
{
g_autoptr(GFile) installationPath = nullptr;
if (resource->resourceType() != FlatpakResource::DesktopApp) {
return true;
}
installationPath = flatpak_installation_get_path(flatpakInstallation);
const QString path = QString::fromUtf8(g_file_get_path(installationPath)) + QStringLiteral("/app/%1/%2/%3/active/metadata").arg(resource->flatpakName()).arg(resource->arch()).arg(resource->branch());
const QString path = resource->installPath() + QStringLiteral("/metadata");
if (QFile::exists(path)) {
return updateAppMetadata(resource, path);
......
......@@ -21,6 +21,7 @@
#include "FlatpakResource.h"
#include "FlatpakBackend.h"
#include "config-paths.h"
#include <Transaction/AddonList.h>
......@@ -31,6 +32,7 @@
#include <KFormat>
#include <KLocalizedString>
#include <QProcess>
#include <QDir>
#include <QDebug>
#include <QDesktopServices>
......@@ -407,6 +409,13 @@ FlatpakResource::Id FlatpakResource::uniqueId() const
void FlatpakResource::invokeApplication() const
{
const QString desktopFile = installPath() + QStringLiteral("/export/share/applications/") + appstreamId();
const QString runservice = QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/discover/runservice");
if (QFile::exists(desktopFile) && QFile::exists(runservice)) {
QProcess::startDetached(runservice, {desktopFile});
return;
}
g_autoptr(GCancellable) cancellable = g_cancellable_new();
g_autoptr(GError) localError = nullptr;
......@@ -538,6 +547,11 @@ QString FlatpakResource::installationPath(FlatpakInstallation* flatpakInstallati
return QString::fromUtf8(g_file_get_path(path));
}
QString FlatpakResource::installPath() const
{
return installationPath() + QStringLiteral("/app/%1/%2/%3/active").arg(flatpakName()).arg(arch()).arg(branch());
}
QUrl FlatpakResource::url() const
{
return m_resourceFile.isEmpty() ? QUrl(QStringLiteral("appstream://") + appstreamId()) : m_resourceFile;
......
......@@ -153,6 +153,7 @@ public:
void updateFromRef(FlatpakRef* ref);
QString ref() const;
QString sourceIcon() const override;
QString installPath() const;
Q_SIGNALS:
void propertyStateChanged(PropertyKind kind, PropertyState state);
......
......@@ -2,8 +2,6 @@ find_package(KF5 REQUIRED Notifications)
add_subdirectory(runservice)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-paths.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-paths.h)
add_library(packagekit-backend MODULE PackageKitBackend.cpp
PackageKitResource.cpp
AppPackageKitResource.cpp
......
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