56 #ifndef PLUGIN_HANDLER_H__
57 #define PLUGIN_HANDLER_H__
64 #include <unordered_map>
67 #include <wx/cmdline.h>
71 #include "model/catalog_parser.h"
72 #include "observable_evtvar.h"
74 bool isRegularFile(
const char* path);
79 std::string name()
const {
return _name; }
80 std::string version()
const {
return _version; }
97 static void cleanup(
const std::string& filelist,
const std::string& plugname);
98 static void cleanupFiles(
const std::string& manifestFile,
99 const std::string& plugname);
118 const char* os = PKG_TARGET,
119 const char* os_version = PKG_TARGET_VERSION);
170 bool uninstall(
const std::string plugin);
178 std::string getLastErrorMsg() {
return last_error_msg; }
180 CatalogData* GetCatalogData() {
return &catalogData; }
186 std::string metadataPath;
187 std::vector<PluginMetadata> installed;
189 std::string last_error_msg;
190 bool InstallPlugin(
const std::string& path,std::string& filelist,
191 const std::string metadata_path,
194 bool explodeTarball(
struct archive* src,
struct archive* dest,
195 std::string& filelist,
196 const std::string& metadata_path,
198 bool extractTarball(
const std::string path, std::string& filelist,
199 const std::string metadata_path =
"",
200 bool only_metadata =
false);
201 bool archive_check(
int r,
const char* msg,
struct archive* a);
202 std::unordered_map<std::string, std::vector<std::string>> files_by_plugin;
203 bool DoClearInstallData(
const std::string plugin_name);
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
const std::vector< PluginMetadata > getInstalled()
Return list of all installed and loaded plugins.
void setMetadata(std::string path)
Set path to metadata XML file.
static void cleanup(const std::string &filelist, const std::string &plugname)
Cleanup failed installation attempt using filelist for plugin.
static std::vector< std::string > GetImportPaths()
List of paths for imported plugins metadata.
bool installPluginFromCache(PluginMetadata plugin)
Install plugin tarball from local cache.
const std::map< std::string, int > getCountByTarget()
Map of available plugin targets -> number of occurences.
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.
std::string getPluginByLibrary(const std::string &filename)
Return plugin containing given filename or "" if not found.
bool isPluginWritable(std::string name)
Check if given plugin can be installed/updated.
static std::string pluginsInstallDataPath()
Return base directory for installation data.
std::vector< std::string > GetInstalldataPlugins()
Return list of installed plugins lower case names, not necessarily loaded.
static std::string fileListPath(std::string name)
Return path to installation manifest for given plugin.
static std::string versionPath(std::string name)
Return path to file containing version for given plugin.
bool uninstall(const std::string plugin)
Uninstall an installed and loaded plugin.
bool installPlugin(PluginMetadata plugin)
Download and install a new, not installed plugin.
bool ClearInstallData(const std::string plugin_name)
Remove installation data for not loaded plugin.
std::string getMetadataPath()
Return path to metadata XML file.
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.
const std::vector< PluginMetadata > getAvailable()
Update catalog and return list of available, not installed plugins.
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.
Datatypes and methods to parse ocpn-plugins.xml XML data, either complete catalog or a single plugin.