Search now publishes provider results in small batches as they arrive, so the first matches appear in the table while slower providers keep running. The bottom status-bar bar is now a determinate indicator: pacman output is streamed live and its (n/Total) package counter is parsed into a percentage that fills the bar during install/update, instead of an indeterminate spinner. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
69 lines
3.1 KiB
C++
69 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include "package-manager.h"
|
|
|
|
// Flatpak provider: manages flatpak applications through the `flatpak` CLI.
|
|
// Unlike pacman it runs per-user (no sudo), so requiresPassword() is false.
|
|
class FlatpakManager : public IPackageManager {
|
|
public:
|
|
std::string getName() const override { return "flatpak"; }
|
|
std::string getVersion() const override { return "1.0.0"; }
|
|
std::string getDescription() const override {
|
|
return "Gestionnaire d'applications Flatpak";
|
|
}
|
|
|
|
bool canSearch() const override { return true; }
|
|
bool canInstall() const override { return true; }
|
|
bool canRemove() const override { return true; }
|
|
bool canUpdate() const override { return true; }
|
|
bool canListInstalled() const override { return true; }
|
|
|
|
bool isAvailable() const override {
|
|
return system("which flatpak > /dev/null 2>&1") == 0;
|
|
}
|
|
|
|
// Last lines of the failed command output, shown to the user on failure.
|
|
std::string lastError() const override { return m_lastError; }
|
|
|
|
// Parse `flatpak search` output (one whitespace-aligned row per app:
|
|
// "Name Description Application ID Version Branch Remotes").
|
|
// Exposed as static so the parsing can be unit-tested without flatpak.
|
|
static std::vector<PackageInfo> parseSearchOutput(const std::string& output);
|
|
|
|
// Parse `flatpak list --columns=application,version,origin` output
|
|
// (tab-separated fields per installed application).
|
|
static std::vector<PackageInfo> parseInstalledOutput(const std::string& output);
|
|
|
|
// Parse `flatpak remote-ls --updates --columns=application,version` output
|
|
// (tab-separated fields per application with a pending update).
|
|
static std::vector<PackageInfo> parseUpdatesOutput(const std::string& output);
|
|
|
|
std::vector<PackageInfo> search(const std::string& query) override;
|
|
bool install(const std::string& packageName,
|
|
ProgressCallback progressCallback) override;
|
|
bool remove(const std::string& packageName,
|
|
ProgressCallback progressCallback) override;
|
|
bool update(const std::string& packageName = "",
|
|
ProgressCallback progressCallback = nullptr) override;
|
|
std::vector<PackageInfo> listInstalled() override;
|
|
std::vector<PackageInfo> listUpdates() override;
|
|
bool refresh(ProgressCallback progressCallback = nullptr) override;
|
|
|
|
// Make an app appear in the desktop's application launcher (wofi, GNOME,
|
|
// KDE, ...) regardless of XDG_DATA_DIRS, like a pacman install would: link
|
|
// its .desktop entries and icons from flatpak's exports into the user's
|
|
// standard XDG directories (~/.local/share/{applications,icons}). Exposed
|
|
// as static so the linking can be unit/integration tested without flatpak.
|
|
static void integrateDesktopEntries(const std::string& appId);
|
|
static void uninstallDesktopEntries(const std::string& appId);
|
|
|
|
// Re-link every installed app so launchers pick up apps whose integration
|
|
// is missing (e.g. installed before this feature existed).
|
|
void integrateAllInstalled();
|
|
|
|
private:
|
|
bool isInstalled(const std::string& appId);
|
|
|
|
std::string m_lastError;
|
|
};
|