refactor: replace plugin system with native pacman manager

Remove the dynamic plugin loader (pacman/apt/pkg/universal) and drive
the UI directly through PacmanManager. Rename sources and headers to
kebab-case to match the project's file naming convention.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
BlackAngelTV committed 2026-08-27 19:29:24 +02:00
1 parent 4a773c63ce
commit 5054f04c54
23 files changed
+276 -1735

No files matched your search

-45
View File
@@ -1,45 +0,0 @@
#pragma once
#include <string>
#include <vector>
#include "dynlib.h"
#include "IPackageManager.h"
struct PluginInfo {
std::string path;
std::string name;
IPackageManager* instance = nullptr;
dynlib_handle handle = nullptr;
bool loaded = false;
};
class PluginManager {
public:
PluginManager();
~PluginManager();
// Load plugins from a directory
void loadPluginsFromDirectory(const std::string& directory);
// Load a specific plugin
bool loadPlugin(const std::string& path);
// Unload all plugins
void unloadAll();
// Get loaded plugins
const std::vector<PluginInfo>& getPlugins() const;
// Get a plugin by index
IPackageManager* getPlugin(size_t index) const;
// Get plugin count
size_t getPluginCount() const;
// Find plugin by name
IPackageManager* findPlugin(const std::string& name) const;
private:
std::vector<PluginInfo> m_plugins;
std::vector<std::string> m_searchPaths;
};
-21
View File
@@ -1,21 +0,0 @@
#pragma once
#ifdef _WIN32
#include <windows.h>
typedef HMODULE dynlib_handle;
inline dynlib_handle dynlib_open(const char* path) { return LoadLibraryA(path); }
inline void* dynlib_sym(dynlib_handle h, const char* name) { return (void*)GetProcAddress(h, name); }
inline void dynlib_close(dynlib_handle h) { FreeLibrary(h); }
inline const char* dynlib_error() {
static char buf[256];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buf, sizeof(buf), NULL);
return buf;
}
#else
#include <dlfcn.h>
typedef void* dynlib_handle;
inline dynlib_handle dynlib_open(const char* path) { return dlopen(path, RTLD_NOW); }
inline void* dynlib_sym(dynlib_handle h, const char* name) { return dlsym(h, name); }
inline void dynlib_close(dynlib_handle h) { dlclose(h); }
inline const char* dynlib_error() { return dlerror(); }
#endif
File renamed without changes.
@@ -16,7 +16,7 @@ struct PackageInfo {
bool updateAvailable = false;
};
// Abstract interface for all package manager plugins
// Abstract interface for the package manager
class IPackageManager {
public:
virtual ~IPackageManager() = default;
@@ -42,13 +42,11 @@ public:
virtual bool update(const std::string& packageName = "",
std::function<void(const std::string&)> progressCallback = nullptr) = 0;
virtual std::vector<PackageInfo> listInstalled() = 0;
virtual std::vector<PackageInfo> listUpdates() = 0;
virtual bool refresh(std::function<void(const std::string&)> progressCallback = nullptr) = 0;
// Check if the package manager is available on the system
virtual bool isAvailable() const = 0;
};
// Plugin entry point types
extern "C" {
IPackageManager* createPlugin();
void destroyPlugin(IPackageManager* plugin);
}
@@ -4,7 +4,7 @@
#include <QAbstractListModel>
#include <QVariant>
#include <vector>
#include "IPackageManager.h"
#include "package-manager.h"
class PackageModel : public QAbstractListModel {
Q_OBJECT
+41
View File
@@ -0,0 +1,41 @@
#pragma once
#include "package-manager.h"
// Native Arch Linux package manager, integrated directly into the application
class PacmanManager : public IPackageManager {
public:
std::string getName() const override { return "pacman"; }
std::string getVersion() const override { return "1.0.0"; }
std::string getDescription() const override {
return "Gestionnaire de paquets natif d'Arch Linux";
}
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 pacman > /dev/null 2>&1") == 0;
}
// Parse `pacman -Q` output (one "name version" line per package).
// Exposed as static so the parsing can be unit-tested without invoking pacman.
static std::vector<PackageInfo> parseInstalledOutput(const std::string& output);
std::vector<PackageInfo> search(const std::string& query) override;
bool install(const std::string& packageName,
std::function<void(const std::string&)> progressCallback) override;
bool remove(const std::string& packageName,
std::function<void(const std::string&)> progressCallback) override;
bool update(const std::string& packageName = "",
std::function<void(const std::string&)> progressCallback = nullptr) override;
std::vector<PackageInfo> listInstalled() override;
std::vector<PackageInfo> listUpdates() override;
bool refresh(std::function<void(const std::string&)> progressCallback = nullptr) override;
private:
bool isPackageInstalled(const std::string& name);
};