feat(plugins): add a plugin shop fed by a JSON catalogue
Installing a plugin meant compiling a shared library and dropping it in a directory by hand. The shop reads a catalogue (plugins/catalog.json, one entry per plugin with its description and download URL), lists what can be installed next to what already is, and installs an entry into ~/.local/share/PacManager/plugins — the directory the registry already scans — so a plugin becomes usable without root rights and without a restart. Installing runs third-party code in this process, so the shop only fetches what the user picked, checks the announced sha256 before writing anything, and a removal deletes only the files the shop wrote itself. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
b26e907221
commit
5033c4e940
9 files changed
+872
-6
No files matched your search
@@ -20,6 +20,7 @@ class QThread;
|
||||
class SearchWorker;
|
||||
class ListWorker;
|
||||
class InstallWorker;
|
||||
class PluginShop;
|
||||
|
||||
// Logic layer: everything the application *does*. It owns the providers
|
||||
// (pacman, Flatpak, AUR, ...), the plugin registry, the history, the privileged
|
||||
@@ -62,6 +63,7 @@ public:
|
||||
PluginManager* plugins() const { return m_plugins; }
|
||||
HistoryManager* history() const { return m_history; }
|
||||
UpdateManager* updateManager() const { return m_update; }
|
||||
PluginShop* shop() const { return m_shop; }
|
||||
std::vector<IPackageManager*> availableProviders() const;
|
||||
QStringList availableProviderNames() const;
|
||||
bool hasAvailableProvider() const;
|
||||
@@ -127,6 +129,14 @@ public:
|
||||
void setPluginEnabled(const std::string& pluginId, bool enabled);
|
||||
void reloadPlugins();
|
||||
|
||||
// ---- Plugin shop ----
|
||||
// Fetches the catalogue the shop offers and installs/removes one of its
|
||||
// entries. Installing drops the shared library in the per-user plugin
|
||||
// directory and reloads the registry, so the plugin is usable right away.
|
||||
void loadPluginCatalog();
|
||||
void installShopPlugin(const QString& id);
|
||||
void removeShopPlugin(const QString& id);
|
||||
|
||||
// ---- Application self-update ----
|
||||
bool shouldCheckForAppUpdate() const;
|
||||
void checkForAppUpdate();
|
||||
@@ -162,6 +172,10 @@ signals:
|
||||
void statusMessage(const QString& message);
|
||||
void historyChanged();
|
||||
void pluginsChanged();
|
||||
// The shop's catalogue was fetched (or failed to be), and an install or a
|
||||
// removal from it finished.
|
||||
void pluginCatalogChanged();
|
||||
void shopInstallFinished(const QString& id, bool success, const QString& message);
|
||||
void updateCheckFinished(bool hasUpdate, const QString& latestVersion,
|
||||
const QString& errorMessage);
|
||||
void selfUpdateFinished(bool success, const QString& message);
|
||||
@@ -210,6 +224,7 @@ private:
|
||||
void clearCredentialsAfterUse();
|
||||
|
||||
PluginManager* m_plugins = nullptr;
|
||||
PluginShop* m_shop = nullptr;
|
||||
PacmanManager* m_pacman = nullptr; // non-owning, for sudo credentials and the lock
|
||||
HistoryManager* m_history = nullptr;
|
||||
UpdateManager* m_update = nullptr;
|
||||
|
||||
Reference in new issue
Block a user