Files
FWS-PacManage/include/provider-plugin.h
T
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

64 lines
2.9 KiB
C

#pragma once
#include "plugin.h"
#include "package-manager.h"
// ---- External plugin contract (C ABI) ----
//
// A plugin is a shared library (lib*.so / *.dll) dropped in a plugin directory
// (see PluginManager). It must export the metadata symbols below plus one
// create function, depending on its kind:
// - provider plugins (kind "provider") export fws_create_provider() returning
// an IPackageManager* (use FWS_PROVIDER_PLUGIN);
// - addon plugins (kind "addon") export fws_create_plugin() returning an
// IPlugin* (use FWS_ADDON_PLUGIN).
// A plugin that does not export fws_plugin_kind() is treated as a provider
// (legacy plugins keep working).
//
// #include "provider-plugin.h"
// #include "my-manager.h"
// FWS_PROVIDER_PLUGIN(MyManager, "myprov", "My Provider", "1.0.0",
// "Manages my stuff", "Jane Doe");
//
// #include "provider-plugin.h"
// #include "my-addon.h"
// FWS_ADDON_PLUGIN(MyAddon, "myaddon", "My Addon", "1.0.0",
// "Tweaks the UI", "Jane Doe");
//
// Plugins are compiled with the same toolchain/headers as the host, exactly
// like Qt plugins, so the IPackageManager/IPlugin vtables and struct layouts
// match.
extern "C" {
const char* fws_plugin_id();
const char* fws_plugin_name();
const char* fws_plugin_version();
const char* fws_plugin_description();
const char* fws_plugin_author();
// "provider" (default when missing) or "addon": picks which create
// function the host resolves.
const char* fws_plugin_kind();
IPackageManager* fws_create_provider();
IPlugin* fws_create_plugin();
// Optional: OS package name that provides the backing tool, so the app can
// offer to install it when unavailable. May be omitted by a plugin.
const char* fws_plugin_install_hint();
}
#define FWS_PROVIDER_PLUGIN(PluginClass, id_, name_, version_, desc_, author_) \
extern "C" const char* fws_plugin_kind() { return "provider"; } \
extern "C" const char* fws_plugin_id() { return id_; } \
extern "C" const char* fws_plugin_name() { return name_; } \
extern "C" const char* fws_plugin_version() { return version_; } \
extern "C" const char* fws_plugin_description() { return desc_; } \
extern "C" const char* fws_plugin_author() { return author_; } \
extern "C" IPackageManager* fws_create_provider() { return new PluginClass(); }
#define FWS_ADDON_PLUGIN(AddonClass, id_, name_, version_, desc_, author_) \
extern "C" const char* fws_plugin_kind() { return "addon"; } \
extern "C" const char* fws_plugin_id() { return id_; } \
extern "C" const char* fws_plugin_name() { return name_; } \
extern "C" const char* fws_plugin_version() { return version_; } \
extern "C" const char* fws_plugin_description() { return desc_; } \
extern "C" const char* fws_plugin_author() { return author_; } \
extern "C" IPlugin* fws_create_plugin() { return new AddonClass(); }