OpenCPN Partial API docs
Loading...
Searching...
No Matches
CatalogHandler Class Reference

Local proxy for the catalog server and other catalog sources. 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.
 
void SetCustomUrl (const char *url)
 Set a custom url, overrides also channel settings.
 
std::string GetCustomUrl ()
 Get the custom url set by SetCustomUrl.
 
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)
 Parse the catalog by merging data from imported metadata, meta-urls and the standard url.
 

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

Local proxy for the catalog server and other catalog sources.

The active catalog is exported by GetActiveCatalogContext(). This catalog is the merged results of

  • The active downloaded catalog,
  • Possible meta-urls reflecting developers' personal catalogs.
  • Imported metadata living in the data directory, created at import.

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 52 of file catalog_handler.h.

Member Enumeration Documentation

◆ ServerStatus

enum class CatalogHandler::ServerStatus
strong

Definition at line 54 of file catalog_handler.h.

Constructor & Destructor Documentation

◆ CatalogHandler()

CatalogHandler::CatalogHandler ( )
protected

Initiate the handler.

Definition at line 60 of file catalog_handler.cpp.

Member Function Documentation

◆ AddMetadataToActiveContext()

bool CatalogHandler::AddMetadataToActiveContext ( PluginMetadata  metadata)

Add an abritrary stub metadata netry to the active catalog context.

Definition at line 107 of file catalog_handler.cpp.

◆ ClearCatalogData()

void CatalogHandler::ClearCatalogData ( )

Invalidate *CatalogData caches.

Definition at line 309 of file catalog_handler.cpp.

◆ DefaultCatalogData()

CatalogData CatalogHandler::DefaultCatalogData ( )

Data for default version, installed with main opencpn.

Definition at line 298 of file catalog_handler.cpp.

◆ DoParseCatalog()

catalog_status CatalogHandler::DoParseCatalog ( const std::string  xml,
CatalogCtx ctx 
)

Parse the catalog by merging data from imported metadata, meta-urls and the standard url.

Definition at line 175 of file catalog_handler.cpp.

◆ DownloadCatalog() [1/4]

catalog_status CatalogHandler::DownloadCatalog ( std::ostream *  stream)

Download the latest catalog to given stream.

Definition at line 115 of file catalog_handler.cpp.

◆ DownloadCatalog() [2/4]

catalog_status CatalogHandler::DownloadCatalog ( std::ostream *  stream,
std::string  url 
)

Download the specified catalog to given stream.

Definition at line 131 of file catalog_handler.cpp.

◆ DownloadCatalog() [3/4]

catalog_status CatalogHandler::DownloadCatalog ( std::string &  filePath,
std::string  url 
)

Download the specified catalog to local path.

Definition at line 158 of file catalog_handler.cpp.

◆ DownloadCatalog() [4/4]

catalog_status CatalogHandler::DownloadCatalog ( std::string &  path)

Download the latest catalog to local path.

Definition at line 142 of file catalog_handler.cpp.

◆ GetActiveCatalogContext()

CatalogCtx * CatalogHandler::GetActiveCatalogContext ( )

Return a pointer to the currently active plugin catalog context.

Definition at line 83 of file catalog_handler.cpp.

◆ GetActiveChannel()

std::string CatalogHandler::GetActiveChannel ( )

Get the branch (a.

k. a. channel) used to download.

Definition at line 245 of file catalog_handler.cpp.

◆ GetCatalogStatus()

catalog_status CatalogHandler::GetCatalogStatus ( )

Retrieve status of currently active plugin catalog

Definition at line 81 of file catalog_handler.cpp.

◆ GetChannels()

std::vector< std::string > CatalogHandler::GetChannels ( )

Get the downloaded list of channels, empty on errors.

Definition at line 231 of file catalog_handler.cpp.

◆ GetCustomUrl()

std::string CatalogHandler::GetCustomUrl ( )

Get the custom url set by SetCustomUrl.

Definition at line 322 of file catalog_handler.cpp.

◆ GetDefaultUrl()

std::string CatalogHandler::GetDefaultUrl ( )

Get the default URL, with actual channel included.

Definition at line 75 of file catalog_handler.cpp.

◆ getInstance()

CatalogHandler * CatalogHandler::getInstance ( )
static

Definition at line 67 of file catalog_handler.cpp.

◆ LastErrorMsg()

std::string CatalogHandler::LastErrorMsg ( )

Last error message, free format.

Definition at line 326 of file catalog_handler.cpp.

◆ LatestCatalogData()

CatalogData CatalogHandler::LatestCatalogData ( )

Data for latest parsed data marked as latest.

Definition at line 253 of file catalog_handler.cpp.

◆ LoadCatalogData()

void CatalogHandler::LoadCatalogData ( const std::string &  path,
CatalogData data 
)
protected

Definition at line 263 of file catalog_handler.cpp.

◆ LoadChannels() [1/2]

catalog_status CatalogHandler::LoadChannels ( const std::string &  json)

Parse and store json channel data, possibly return error code.

Definition at line 338 of file catalog_handler.cpp.

◆ LoadChannels() [2/2]

catalog_status CatalogHandler::LoadChannels ( std::ostream *  json)

Download channel json data, possibly return error code.

Definition at line 328 of file catalog_handler.cpp.

◆ ParseCatalog()

catalog_status CatalogHandler::ParseCatalog ( const std::string  xml,
bool  latest = false 
)

Parse XML contents, save as latest data if latest is true.

Definition at line 219 of file catalog_handler.cpp.

◆ SetActiveChannel()

bool CatalogHandler::SetActiveChannel ( const char *  channel)

Set the active channel used when downloading catalog.

Definition at line 233 of file catalog_handler.cpp.

◆ SetCustomUrl()

void CatalogHandler::SetCustomUrl ( const char *  url)

Set a custom url, overrides also channel settings.

Definition at line 249 of file catalog_handler.cpp.

◆ UserCatalogData()

CatalogData CatalogHandler::UserCatalogData ( )

Data for user catalog which overrides the default one.

Definition at line 287 of file catalog_handler.cpp.

Member Data Documentation

◆ DEFAULT_CHANNEL

const char* const CatalogHandler::DEFAULT_CHANNEL = "master"
protected

Definition at line 148 of file catalog_handler.h.

◆ GET_BRANCHES_PATH

const char* const CatalogHandler::GET_BRANCHES_PATH = "/repos/OpenCPN/plugins/branches"
protected

Definition at line 142 of file catalog_handler.h.

◆ GITHUB_API

const char* const CatalogHandler::GITHUB_API = "https://api.github.com"
protected

Definition at line 143 of file catalog_handler.h.

◆ REPO_PATH

const char* const CatalogHandler::REPO_PATH = "/OpenCPN/plugins/@branch@/ocpn-plugins.xml"
protected

Definition at line 146 of file catalog_handler.h.

◆ REPO_URL

const char* const CatalogHandler::REPO_URL = "https://raw.githubusercontent.com"
protected

Definition at line 145 of file catalog_handler.h.


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