25#ifndef PLUGIN_HANDLER_H__
26#define PLUGIN_HANDLER_H__
33#include <unordered_map>
36#include <wx/cmdline.h>
41#include "observable_evtvar.h"
43bool isRegularFile(
const char* path);
49 std::string name()
const {
return _name; }
50 std::string version()
const {
return _version; }
105 static void Cleanup(
const std::string& filelist,
const std::string& plugname);
107 static void CleanupFiles(
const std::string& manifestFile,
108 const std::string& plugname);
127 const char* os = PKG_TARGET,
128 const char* os_version = PKG_TARGET_VERSION);
179 bool Uninstall(
const std::string plugin);
187 CatalogData* GetCatalogData() {
return &catalogData; }
193 std::string metadataPath;
194 std::vector<PluginMetadata> installed;
196 std::string last_error_msg;
197 bool InstallPlugin(
const std::string& path, std::string& filelist,
198 const std::string metadata_path,
bool only_metadata);
213 bool ExplodeTarball(
struct archive* src,
struct archive* dest,
214 std::string& filelist,
const std::string& metadata_path,
228 bool ExtractTarball(
const std::string path, std::string& filelist,
229 const std::string metadata_path =
"",
230 bool only_metadata =
false);
231 bool ArchiveCheck(
int r,
const char* msg,
struct archive* a);
233 std::unordered_map<std::string, std::vector<std::string>> FilesByPlugin;
235 bool DoClearInstallData(
const std::string plugin_name);
Datatypes and methods to parse ocpn-plugins.xml XML data, either complete catalog or a single plugin.
Internal helper wrapping host OS and version.
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Handle plugin install from remote repositories and local operations to Uninstall and list plugins.
void setMetadata(std::string path)
Set path to metadata XML file.
static std::vector< std::string > GetImportPaths()
List of paths for imported plugins metadata.
bool Uninstall(const std::string plugin)
Uninstall an installed and loaded plugin.
const std::vector< PluginMetadata > GetInstalled()
Return list of all installed and loaded plugins.
const std::map< std::string, int > GetCountByTarget()
Map of available plugin targets -> number of occurences.
static void Cleanup(const std::string &filelist, const std::string &plugname)
Cleanup failed installation attempt using filelist for plugin.
bool IsPluginWritable(std::string name)
Check if given plugin can be installed/updated.
std::vector< PluginMetadata > getCompatiblePlugins()
Return list of available, unique and compatible plugins from configured XML catalog.
static std::string ImportedMetadataPath(std::string name)
Return path to imported metadata for given plugin.
static std::string VersionPath(std::string name)
Return path to file containing version for given plugin.
std::string GetMetadataPath()
Return path to metadata XML file.
std::vector< std::string > GetInstalldataPlugins()
Return list of installed plugins lower case names, not necessarily loaded.
bool InstallPlugin(PluginMetadata plugin)
Download and install a new, not installed plugin.
const std::vector< PluginMetadata > GetAvailable()
Update catalog and return list of available, not installed plugins.
bool ClearInstallData(const std::string plugin_name)
Remove installation data for not loaded plugin.
static bool IsCompatible(const PluginMetadata &metadata, const char *os=PKG_TARGET, const char *os_version=PKG_TARGET_VERSION)
Return true if given plugin is loadable on given os/version.
static std::string FileListPath(std::string name)
Return path to installation manifest for given plugin.
EventVar evt_download_failed
Notified with plugin name after failed download attempt.
void SetInstalledMetadata(const PluginMetadata &pm)
Set metadata for an installed plugin.
bool ExtractMetadata(const std::string &path, PluginMetadata &metadata)
Extract metadata in given tarball path.
bool InstallPluginFromCache(PluginMetadata plugin)
Install plugin tarball from local cache.
std::string GetPluginByLibrary(const std::string &filename)
Return plugin containing given filename or "" if not found.
static PluginHandler * GetInstance()
Singleton factory.
static std::string PluginsInstallDataPath()
Return base directory for installation data.
EventVar evt_download_ok
Notified with plugin name + version string after successful download from repository.
Overall metadata for the set of plugins used.