OpenCPN Partial API docs
CatalogHandler Class Reference

Plugin catalog management: Check for available versions and branches, download as required. More...

#include <catalog_handler.h>

Public Types

enum class  ServerStatus {
  UNKNOWN , OK , OK_MSG , CURL_ERROR ,
  JSON_ERROR , XML_ERROR , OS_ERROR , FILE_ERROR
}
 

Public Member Functions

ServerStatus LoadChannels (std::ostream *json)
 Download channel json data, possibly return error code.
 
ServerStatus LoadChannels (const std::string &json)
 Parse and store json channel data, possibly return error code.
 
std::vector< std::string > GetChannels ()
 Get the downloaded list of channels, empty on errors.
 
bool SetActiveChannel (const char *channel)
 Set the active channel used when downloading catalog.
 
std::string GetActiveChannel ()
 Get the branch (a. More...
 
void SetCustomUrl (const char *url)
 Set a custom url, overrides also channel settings.
 
std::string GetCustomUrl ()
 Set a custom url, overrides also channel settings.
 
std::string GetDefaultUrl ()
 Get the default URL, with actual channel included.
 
ServerStatus DownloadCatalog (std::ostream *stream)
 Download the latest catalog to given stream.
 
ServerStatus DownloadCatalog (std::string &path)
 Download the latest catalog to local path.
 
ServerStatus DownloadCatalog (std::ostream *stream, std::string url)
 Download the specified catalog to given stream.
 
ServerStatus DownloadCatalog (std::string &filePath, std::string url)
 Download the specified catalog to local path.
 
ServerStatus ParseCatalog (const std::string xml, bool latest=false)
 Parse XML contents, save as latest data if latest is true.
 
CatalogData DefaultCatalogData ()
 Data for default version, installed with main opencpn.
 
CatalogData UserCatalogData ()
 Data for user catalog which overrides the default one.
 
CatalogData LatestCatalogData ()
 Data for latest parsed data marked as latest.
 
void ClearCatalogData ()
 Invalidate *CatalogData caches.
 
CatalogCtxGetActiveCatalogContext ()
 Return a pointer to the currently active plugin catalog context.
 
ServerStatus GetCatalogStatus ()
 Retrieve status of currently active plugin catalog

 
bool AddMetadataToActiveContext (PluginMetadata metadata)
 Add an abritrary stub metadata netry to the active catalog context.
 
std::string LastErrorMsg ()
 Last error message, free format.
 
ServerStatus DoParseCatalog (const std::string xml, CatalogCtx *ctx)
 

Static Public Member Functions

static CatalogHandlergetInstance ()
 

Protected Member Functions

 CatalogHandler ()
 Initiate the handler.
 
void LoadCatalogData (const std::string &path, CatalogData &data)
 

Protected Attributes

const char *const GET_BRANCHES_PATH = "/repos/OpenCPN/plugins/branches"
 
const char *const GITHUB_API = "https://api.github.com"
 
const char *const REPO_URL = "https://raw.githubusercontent.com"
 
const char *const REPO_PATH = "/OpenCPN/plugins/@branch@/ocpn-plugins.xml"
 
const char *const DEFAULT_CHANNEL = "master"
 

Detailed Description

Plugin catalog management: Check for available versions and branches, download as required.

A local proxy for the catalog server. The server has a number of branches, some of which containing a plugin catalog.

Backend code for channel management (which catalog to get) and the important download function.

Also: CatalogData handling, basically version and date for various ocpn-plugins.xml.

Definition at line 50 of file catalog_handler.h.

Member Function Documentation

◆ GetActiveChannel()

std::string CatalogHandler::GetActiveChannel ( )

Get the branch (a.

k. a. channel) used to download.

Definition at line 251 of file catalog_handler.cpp.


The documentation for this class was generated from the following files: