| OpenCPN Partial API docs
    | 
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. | |
| CatalogCtx * | GetActiveCatalogContext () | 
| 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 CatalogHandler * | GetInstance () | 
| 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" | 
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 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 51 of file catalog_handler.h.
| 
 | strong | 
Definition at line 53 of file catalog_handler.h.
| 
 | protected | 
Initiate the handler.
Definition at line 60 of file catalog_handler.cpp.
| 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.
| void CatalogHandler::ClearCatalogData | ( | ) | 
Invalidate *CatalogData caches.
Definition at line 309 of file catalog_handler.cpp.
| CatalogData CatalogHandler::DefaultCatalogData | ( | ) | 
Data for default version, installed with main opencpn.
Definition at line 298 of file catalog_handler.cpp.
| 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.
| catalog_status CatalogHandler::DownloadCatalog | ( | std::ostream * | stream | ) | 
Download the latest catalog to given stream.
Definition at line 115 of file catalog_handler.cpp.
| 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.
| 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.
| catalog_status CatalogHandler::DownloadCatalog | ( | std::string & | path | ) | 
Download the latest catalog to local path.
Definition at line 142 of file catalog_handler.cpp.
| CatalogCtx * CatalogHandler::GetActiveCatalogContext | ( | ) | 
Return a pointer to the currently active plugin catalog context.
Definition at line 83 of file catalog_handler.cpp.
| std::string CatalogHandler::GetActiveChannel | ( | ) | 
Get the branch (a.
k. a. channel) used to download.
Definition at line 245 of file catalog_handler.cpp.
| catalog_status CatalogHandler::GetCatalogStatus | ( | ) | 
Retrieve status of currently active plugin catalog 
 
Definition at line 81 of file catalog_handler.cpp.
| std::vector< std::string > CatalogHandler::GetChannels | ( | ) | 
Get the downloaded list of channels, empty on errors.
Definition at line 231 of file catalog_handler.cpp.
| std::string CatalogHandler::GetCustomUrl | ( | ) | 
Get the custom url set by SetCustomUrl.
Definition at line 322 of file catalog_handler.cpp.
| std::string CatalogHandler::GetDefaultUrl | ( | ) | 
Get the default URL, with actual channel included.
Definition at line 75 of file catalog_handler.cpp.
| 
 | static | 
Definition at line 67 of file catalog_handler.cpp.
| std::string CatalogHandler::LastErrorMsg | ( | ) | 
Last error message, free format.
Definition at line 326 of file catalog_handler.cpp.
| CatalogData CatalogHandler::LatestCatalogData | ( | ) | 
Data for latest parsed data marked as latest.
Definition at line 253 of file catalog_handler.cpp.
| 
 | protected | 
Definition at line 263 of file catalog_handler.cpp.
| 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.
| catalog_status CatalogHandler::LoadChannels | ( | std::ostream * | json | ) | 
Download channel json data, possibly return error code.
Definition at line 328 of file catalog_handler.cpp.
| 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.
| bool CatalogHandler::SetActiveChannel | ( | const char * | channel | ) | 
Set the active channel used when downloading catalog.
Definition at line 233 of file catalog_handler.cpp.
| void CatalogHandler::SetCustomUrl | ( | const char * | url | ) | 
Set a custom url, overrides also channel settings.
Definition at line 249 of file catalog_handler.cpp.
| CatalogData CatalogHandler::UserCatalogData | ( | ) | 
Data for user catalog which overrides the default one.
Definition at line 287 of file catalog_handler.cpp.
| 
 | protected | 
Definition at line 147 of file catalog_handler.h.
| 
 | protected | 
Definition at line 141 of file catalog_handler.h.
| 
 | protected | 
Definition at line 142 of file catalog_handler.h.
| 
 | protected | 
Definition at line 145 of file catalog_handler.h.
| 
 | protected | 
Definition at line 144 of file catalog_handler.h.