Files
FWS-PacManage/plugins/example-provider/example-provider.cpp
BlackAngelTV 8658855cca feat(plugin): support generic addon plugins and build Flatpak by default
The Plugins page replaces the Providers tab and lists every plugin alike:
package-manager providers and generic C++ addons, which can be any extension
(UI tweak, helper, ...) via IPlugin (onLoad/onUnload/onUiReady) exported with
the new FWS_ADDON_PLUGIN macro. Flatpak now ships as a plugin built by
default (FWS_BUILD_FLATPAK_PLUGIN=ON), so a plain build is Flatpak-enabled.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-09-10 18:49:46 +02:00

50 lines
2.3 KiB
C++

// Example external provider plugin — a template for adding new package
// providers without touching the application code.
//
// Build it as a shared library and drop it in a plugin directory
// (next to the PacManager binary in ./plugins/ or in
// ~/.local/share/PacManager/plugins/); the app discovers it at launch and on
// the Plugins page via "Recharger".
//
// This is a *provider* plugin: it adds a package manager. For non-provider
// extensions (UI tweaks, helpers, ...), see plugins/example-addon instead.
//
// A plugin only needs to:
// 1. implement IPackageManager (see include/package-manager.h)
// 2. export the C ABI symbols via the FWS_PROVIDER_PLUGIN macro
//
// To build with CMake from the project root:
// cmake -B build -DFWS_BUILD_EXAMPLE_PLUGIN=ON && cmake --build build
#include "provider-plugin.h"
// A trivial provider that reports itself as always available but manages
// nothing — replace the stubs with real commands (apt, dnf, zypper, ...).
class SampleProvider : public IPackageManager {
public:
std::string getName() const override { return "sample"; }
std::string getVersion() const override { return "0.1.0"; }
std::string getDescription() const override {
return "Exemple de plugin fournisseur (modèle à copier)";
}
bool canSearch() const override { return false; }
bool canInstall() const override { return false; }
bool canRemove() const override { return false; }
bool canUpdate() const override { return false; }
bool canListInstalled() const override { return false; }
bool isAvailable() const override { return true; }
std::vector<PackageInfo> search(const std::string&) override { return {}; }
bool install(const std::string&, ProgressCallback) override { return false; }
bool remove(const std::string&, ProgressCallback) override { return false; }
bool update(const std::string&, ProgressCallback) override { return false; }
std::vector<PackageInfo> listInstalled() override { return {}; }
std::vector<PackageInfo> listUpdates() override { return {}; }
bool refresh(ProgressCallback) override { return false; }
};
FWS_PROVIDER_PLUGIN(SampleProvider, "sample", "Sample Provider", "0.1.0",
"Exemple de plugin fournisseur (modèle à copier)", "FWS");