30 #ifndef CATALOG_HANDLER_H__
31 #define CATALOG_HANDLER_H__
38 #include "model/catalog_parser.h"
52 enum class ServerStatus {
102 ServerStatus
ParseCatalog(
const std::string xml,
bool latest =
false);
128 ServerStatus DoParseCatalog(
const std::string xml,
CatalogCtx* ctx);
134 void LoadCatalogData(
const std::string& path,
CatalogData& data);
136 const char*
const GET_BRANCHES_PATH =
"/repos/OpenCPN/plugins/branches";
137 const char*
const GITHUB_API =
"https://api.github.com";
139 const char*
const REPO_URL =
"https://raw.githubusercontent.com";
140 const char*
const REPO_PATH =
"/OpenCPN/plugins/@branch@/ocpn-plugins.xml";
142 const char*
const DEFAULT_CHANNEL =
"master";
145 std::vector<std::string> channels;
147 std::ostream* stream;
148 std::string error_msg;
152 ServerStatus m_catalog_status;
156 typedef CatalogHandler::ServerStatus catalog_status;
Plugin catalog management: Check for available versions and branches, download as required.
std::vector< std::string > GetChannels()
Get the downloaded list of channels, empty on errors.
ServerStatus LoadChannels(std::ostream *json)
Download channel json data, possibly return error code.
CatalogHandler()
Initiate the handler.
CatalogData DefaultCatalogData()
Data for default version, installed with main opencpn.
std::string GetDefaultUrl()
Get the default URL, with actual channel included.
CatalogData LatestCatalogData()
Data for latest parsed data marked as latest.
CatalogCtx * GetActiveCatalogContext()
Return a pointer to the currently active plugin catalog context.
std::string LastErrorMsg()
Last error message, free format.
CatalogData UserCatalogData()
Data for user catalog which overrides the default one.
bool AddMetadataToActiveContext(PluginMetadata metadata)
Add an abritrary stub metadata netry to the active catalog context.
ServerStatus ParseCatalog(const std::string xml, bool latest=false)
Parse XML contents, save as latest data if latest is true.
std::string GetActiveChannel()
Get the branch (a.
void SetCustomUrl(const char *url)
Set a custom url, overrides also channel settings.
ServerStatus DownloadCatalog(std::ostream *stream)
Download the latest catalog to given stream.
void ClearCatalogData()
Invalidate *CatalogData caches.
std::string GetCustomUrl()
Set a custom url, overrides also channel settings.
ServerStatus GetCatalogStatus()
Retrieve status of currently active plugin catalog
bool SetActiveChannel(const char *channel)
Set the active channel used when downloading catalog.
The result from parsing the xml catalog i.
Datatypes and methods to parse ocpn-plugins.xml XML data, either complete catalog or a single plugin.