OpenCPN Partial API docs
Loading...
Searching...
No Matches
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
}
 

Public Member Functions

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

Static Public Member Functions

static CatalogHandlergetInstance ()
 

Protected Member Functions

 CatalogHandler ()
 Initiate the handler. More...
 
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 Enumeration Documentation

◆ ServerStatus

enum class CatalogHandler::ServerStatus
strong

Definition at line 52 of file catalog_handler.h.

Constructor & Destructor Documentation

◆ CatalogHandler()

CatalogHandler::CatalogHandler ( )
protected

Initiate the handler.

Definition at line 62 of file catalog_handler.cpp.

Member Function Documentation

◆ ClearCatalogData()

void CatalogHandler::ClearCatalogData ( )

Invalidate *CatalogData caches.

Definition at line 270 of file catalog_handler.cpp.

◆ DefaultCatalogData()

CatalogData CatalogHandler::DefaultCatalogData ( )

Data for default version, installed with main opencpn.

Definition at line 259 of file catalog_handler.cpp.

◆ DoParseCatalog()

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

Definition at line 142 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 82 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 98 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 125 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 109 of file catalog_handler.cpp.

◆ GetActiveChannel()

std::string CatalogHandler::GetActiveChannel ( )

Get the branch (a.

k. a. channel) used to download.

Definition at line 206 of file catalog_handler.cpp.

◆ GetChannels()

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

Get the downloaded list of channels, empty on errors.

Definition at line 192 of file catalog_handler.cpp.

◆ GetCustomUrl()

std::string CatalogHandler::GetCustomUrl ( )

Set a custom url, overrides also channel settings.

Definition at line 276 of file catalog_handler.cpp.

◆ GetDefaultUrl()

std::string CatalogHandler::GetDefaultUrl ( )

Get the default URL, with actual channel included.

Definition at line 76 of file catalog_handler.cpp.

◆ getInstance()

CatalogHandler * CatalogHandler::getInstance ( )
static

Definition at line 68 of file catalog_handler.cpp.

◆ LastErrorMsg()

std::string CatalogHandler::LastErrorMsg ( )

Last error message, free format.

Definition at line 280 of file catalog_handler.cpp.

◆ LatestCatalogData()

CatalogData CatalogHandler::LatestCatalogData ( )

Data for latest parsed data marked as latest.

Definition at line 214 of file catalog_handler.cpp.

◆ LoadCatalogData()

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

Definition at line 224 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 292 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 282 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 180 of file catalog_handler.cpp.

◆ SetActiveChannel()

bool CatalogHandler::SetActiveChannel ( const char *  channel)

Set the active channel used when downloading catalog.

Definition at line 194 of file catalog_handler.cpp.

◆ SetCustomUrl()

void CatalogHandler::SetCustomUrl ( const char *  url)

Set a custom url, overrides also channel settings.

Definition at line 210 of file catalog_handler.cpp.

◆ UserCatalogData()

CatalogData CatalogHandler::UserCatalogData ( )

Data for user catalog which overrides the default one.

Definition at line 248 of file catalog_handler.cpp.

Member Data Documentation

◆ DEFAULT_CHANNEL

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

Definition at line 132 of file catalog_handler.h.

◆ GET_BRANCHES_PATH

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

Definition at line 126 of file catalog_handler.h.

◆ GITHUB_API

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

Definition at line 127 of file catalog_handler.h.

◆ REPO_PATH

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

Definition at line 130 of file catalog_handler.h.

◆ REPO_URL

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

Definition at line 129 of file catalog_handler.h.


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