The Battle for Wesnoth  1.17.0-dev
Classes | Functions
manager.hpp File Reference

Local add-on content management interface. More...

#include "addon/validation.hpp"
#include <string>
#include <vector>
#include <utility>
#include <map>
Include dependency graph for manager.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  invalid_pbl_exception
 Exception thrown when the WML parser fails to read a .pbl file. More...
 

Functions

bool remove_local_addon (const std::string &addon)
 Removes the specified add-on, deleting its full directory structure. More...
 
bool have_addon_pbl_info (const std::string &addon_name)
 Returns whether a .pbl file is present for the specified add-on or not. More...
 
bool have_addon_in_vcs_tree (const std::string &addon_name)
 Returns whether the specified add-on appears to be managed by a VCS or not. More...
 
config get_addon_pbl_info (const std::string &addon_name)
 Gets the publish information for an add-on. More...
 
void set_addon_pbl_info (const std::string &addon_name, const class config &cfg)
 Sets the publish information for an add-on. More...
 
bool have_addon_install_info (const std::string &addon_name)
 Returns true if there is a local installation info (_info.cfg) file for the add-on. More...
 
void get_addon_install_info (const std::string &addon_name, class config &cfg)
 Gets the installation info (_info.cfg) for an add-on. More...
 
void write_addon_install_info (const std::string &addon_name, const class config &cfg)
 Writes the installation info (_info.cfg) for an add-on to disk. More...
 
std::vector< std::string > available_addons ()
 Returns a list of local add-ons that can be published. More...
 
std::vector< std::string > installed_addons ()
 Retrieves the names of all installed add-ons. More...
 
std::map< std::string, std::string > installed_addons_and_versions ()
 Retrieves the ids and versions of all installed add-ons. More...
 
bool is_addon_installed (const std::string &addon_name)
 Check whether the specified add-on is currently installed. More...
 
void archive_addon (const std::string &addon_name, class config &cfg)
 Archives an add-on into a config object for campaignd transactions. More...
 
void unarchive_addon (const class config &cfg)
 Unarchives an add-on from campaignd's retrieved config object. More...
 
void purge_addon (const config &removelist)
 Removes the listed files from the addon. More...
 
void refresh_addon_version_info_cache ()
 Refreshes the per-session cache of add-on's version information structs. More...
 
version_info get_addon_version_info (const std::string &addon)
 Returns a particular installed add-on's version information. More...
 

Detailed Description

Local add-on content management interface.

This API only concerns local functionality dealing with enumerating and manipulating installed add-ons, as well as extracting add-ons in WML pack form, usually but not necessarily obtained through the networked client.

It also includes functions for the handling of add-on versioning information (_info.cfg) and publishing information (_server.pbl).

Definition in file manager.hpp.

Function Documentation

◆ archive_addon()

void archive_addon ( const std::string &  addon_name,
class config cfg 
)

Archives an add-on into a config object for campaignd transactions.

Definition at line 283 of file manager.cpp.

References config::add_child(), archive_dir(), filesystem::get_addons_dir(), and read_ignore_patterns().

Referenced by addons_client::upload_addon(), and invalid_pbl_exception::what().

◆ available_addons()

std::vector<std::string> available_addons ( )

Returns a list of local add-ons that can be published.

Definition at line 173 of file manager.cpp.

Referenced by gui2::dialogs::addon_manager::load_addon_list(), and invalid_pbl_exception::what().

◆ get_addon_install_info()

void get_addon_install_info ( const std::string &  addon_name,
class config cfg 
)

Gets the installation info (_info.cfg) for an add-on.

Parameters
addon_nameThe add-on's main directory/file name.
cfgA config object to store the add-on's properties.

Definition at line 93 of file manager.cpp.

References config::child(), config::clear(), e, ERR_CFG, lg::info(), filesystem::istream_file(), game::error::message, and read().

Referenced by installed_addons_and_versions(), refresh_addon_version_info_cache(), and invalid_pbl_exception::what().

◆ get_addon_pbl_info()

config get_addon_pbl_info ( const std::string &  addon_name)

Gets the publish information for an add-on.

Parameters
addon_nameThe add-on's main directory/file name.
Exceptions
invalid_pbl_exceptionIf it is not possible to read the .pbl file (often due to invalid WML).

Definition at line 68 of file manager.cpp.

References e, filesystem::istream_file(), game::error::message, and read().

Referenced by addons_client::delete_remote_addon(), get_addon_tracking_info(), installed_addons_and_versions(), gui2::dialogs::addon_manager::load_addon_list(), game_config_manager::load_addons_cfg(), gui2::dialogs::addon_manager::publish_addon(), and invalid_pbl_exception::what().

◆ get_addon_version_info()

version_info get_addon_version_info ( const std::string &  addon)

Returns a particular installed add-on's version information.

Definition at line 397 of file manager.cpp.

Referenced by addons_client::download_addon(), get_addon_tracking_info(), and invalid_pbl_exception::what().

◆ have_addon_in_vcs_tree()

bool have_addon_in_vcs_tree ( const std::string &  addon_name)

Returns whether the specified add-on appears to be managed by a VCS or not.

This is used by the add-ons client to prompt the user before overwriting add-ons that may currently be managed externally instead of through the built-in campaignd client.

Currently supported VCSes are: Subversion, Git, Mercurial.

Definition at line 54 of file manager.cpp.

References filesystem::file_exists(), and filesystem::get_addons_dir().

Referenced by addons_client::do_check_before_overwriting_addon(), get_addon_tracking_info(), refresh_addon_version_info_cache(), gui2::dialogs::addon_manager::uninstall_addon(), and invalid_pbl_exception::what().

◆ have_addon_install_info()

bool have_addon_install_info ( const std::string &  addon_name)

Returns true if there is a local installation info (_info.cfg) file for the add-on.

Definition at line 88 of file manager.cpp.

References filesystem::file_exists().

Referenced by invalid_pbl_exception::what().

◆ have_addon_pbl_info()

bool have_addon_pbl_info ( const std::string &  addon_name)

◆ installed_addons()

std::vector<std::string> installed_addons ( )

◆ installed_addons_and_versions()

std::map<std::string, std::string> installed_addons_and_versions ( )

Retrieves the ids and versions of all installed add-ons.

Definition at line 183 of file manager.cpp.

References config::empty(), filesystem::file_exists(), get_addon_install_info(), get_addon_pbl_info(), have_addon_pbl_info(), and installed_addons().

Referenced by game_config::full_build_report(), and invalid_pbl_exception::what().

◆ is_addon_installed()

bool is_addon_installed ( const std::string &  addon_name)

Check whether the specified add-on is currently installed.

Definition at line 205 of file manager.cpp.

References filesystem::file_exists(), and filesystem::get_addons_dir().

Referenced by addons_client::do_resolve_addon_dependencies(), get_addon_tracking_info(), addons_client::try_fetch_addon(), and invalid_pbl_exception::what().

◆ purge_addon()

void purge_addon ( const config removelist)

Removes the listed files from the addon.

Definition at line 346 of file manager.cpp.

References filesystem::get_addons_dir(), and purge_dir().

Referenced by addons_client::install_addon(), and invalid_pbl_exception::what().

◆ refresh_addon_version_info_cache()

void refresh_addon_version_info_cache ( )

◆ remove_local_addon()

bool remove_local_addon ( const std::string &  addon)

Removes the specified add-on, deleting its full directory structure.

Definition at line 130 of file manager.cpp.

References filesystem::delete_directory(), ERR_CFG, filesystem::file_exists(), filesystem::get_addons_dir(), and LOG_CFG.

Referenced by addons_client::install_addon(), gui2::dialogs::addon_manager::uninstall_addon(), and invalid_pbl_exception::what().

◆ set_addon_pbl_info()

void set_addon_pbl_info ( const std::string &  addon_name,
const class config cfg 
)

Sets the publish information for an add-on.

Parameters
addon_nameThe add-on's main directory/file name.
cfgA config object from which the add-on's properties are copied.

Referenced by invalid_pbl_exception::what().

◆ unarchive_addon()

void unarchive_addon ( const class config cfg)

Unarchives an add-on from campaignd's retrieved config object.

Referenced by invalid_pbl_exception::what().

◆ write_addon_install_info()

void write_addon_install_info ( const std::string &  addon_name,
const class config cfg 
)

Writes the installation info (_info.cfg) for an add-on to disk.

Parameters
addon_nameThe add-on's main directory/file name.
cfgA config object containing the add-on's properties.

Referenced by invalid_pbl_exception::what().