#include "addon/manager.hpp"
#include "filesystem.hpp"
#include "log.hpp"
#include "serialization/parser.hpp"
#include "serialization/schema_validator.hpp"
#include "game_version.hpp"
#include "wml_exception.hpp"
#include <boost/algorithm/string.hpp>
Go to the source code of this file.
Macros | |
#define | ERR_CFG LOG_STREAM(err , log_config) |
#define | LOG_CFG LOG_STREAM(info, log_config) |
#define | WRN_CFG LOG_STREAM(warn, log_config) |
#define | ERR_FS LOG_STREAM(err , log_filesystem) |
#define | ERR_NET LOG_STREAM(err , log_network) |
#define | LOG_NET LOG_STREAM(info, log_network) |
Enumerations | |
enum | ADDON_ENUM_CRITERIA |
Functions | |
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... | |
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... | |
config | get_addon_pbl_info (const std::string &addon_name, bool do_validate) |
Gets the publish information for an add-on. More... | |
void | set_addon_pbl_info (const std::string &addon_name, const config &cfg) |
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, config &cfg) |
Gets the installation info (_info.cfg) for an add-on. More... | |
void | write_addon_install_info (const std::string &addon_name, const config &cfg) |
bool | remove_local_addon (const std::string &addon) |
Removes the specified add-on, deleting its full directory structure. 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... | |
static bool | IsCR (const char &c) |
static std::string | strip_cr (std::string str, bool strip) |
static filesystem::blacklist_pattern_list | read_ignore_patterns (const std::string &addon_name) |
static void | archive_file (const std::string &path, const std::string &fname, config &cfg) |
static void | archive_dir (const std::string &path, const std::string &dirname, config &cfg, const filesystem::blacklist_pattern_list &ignore_patterns) |
void | archive_addon (const std::string &addon_name, config &cfg) |
Archives an add-on into a config object for campaignd transactions. More... | |
static void | unarchive_file (const std::string &path, const config &cfg) |
static void | unarchive_dir (const std::string &path, const config &cfg, std::function< void()> file_callback={}) |
static unsigned | count_pack_files (const config &cfg) |
void | unarchive_addon (const config &cfg, std::function< void(unsigned)> progress_callback) |
static void | purge_dir (const std::string &path, const config &removelist) |
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... | |
Variables | |
static lg::log_domain | log_config ("config") |
static lg::log_domain | log_filesystem ("filesystem") |
static lg::log_domain | log_network ("network") |
#define ERR_CFG LOG_STREAM(err , log_config) |
Definition at line 29 of file manager.cpp.
Referenced by get_addon_install_info(), and remove_local_addon().
#define ERR_FS LOG_STREAM(err , log_filesystem) |
Definition at line 34 of file manager.cpp.
#define ERR_NET LOG_STREAM(err , log_network) |
Definition at line 37 of file manager.cpp.
#define LOG_CFG LOG_STREAM(info, log_config) |
Definition at line 30 of file manager.cpp.
Referenced by read_ignore_patterns(), refresh_addon_version_info_cache(), remove_local_addon(), and write_addon_install_info().
#define LOG_NET LOG_STREAM(info, log_network) |
Definition at line 38 of file manager.cpp.
#define WRN_CFG LOG_STREAM(warn, log_config) |
Definition at line 31 of file manager.cpp.
Referenced by refresh_addon_version_info_cache().
enum ADDON_ENUM_CRITERIA |
Definition at line 159 of file manager.cpp.
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 297 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().
|
static |
Definition at line 275 of file manager.cpp.
References config::add_child(), archive_file(), filesystem::get_files_in_dir(), filesystem::looks_like_pbl(), filesystem::blacklist_pattern_list::match_dir(), and filesystem::blacklist_pattern_list::match_file().
Referenced by archive_addon().
|
static |
Definition at line 268 of file manager.cpp.
References encode_binary(), filesystem::read_file(), and strip_cr().
Referenced by archive_dir().
std::vector<std::string> available_addons | ( | ) |
Returns a list of local add-ons that can be published.
Definition at line 186 of file manager.cpp.
Referenced by gui2::dialogs::addon_manager::load_addon_list(), and invalid_pbl_exception::what().
|
static |
Definition at line 332 of file manager.cpp.
References config::child_count(), config::child_range(), and d.
Referenced by unarchive_addon().
void get_addon_install_info | ( | const std::string & | addon_name, |
class config & | cfg | ||
) |
Gets the installation info (_info.cfg) for an add-on.
addon_name | The add-on's main directory/file name. |
cfg | A config object to store the add-on's properties. |
Definition at line 106 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().
config get_addon_pbl_info | ( | const std::string & | addon_name, |
bool | do_validate | ||
) |
Gets the publish information for an add-on.
addon_name | The add-on's main directory/file name. |
do_validate | Whether we want to run validation on the .pbl file. |
invalid_pbl_exception | If it is not possible to read the .pbl file (often due to invalid WML). |
Definition at line 70 of file manager.cpp.
References wml_exception::dev_message, e, filesystem::get_wml_location(), filesystem::istream_file(), game::error::message, wfl::msg(), read(), filesystem::sanitize_path(), schema_validation::schema_validator::set_create_exceptions(), wml_exception::show(), and wml_exception::user_message.
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().
version_info get_addon_version_info | ( | const std::string & | addon | ) |
Returns a particular installed add-on's version information.
Definition at line 429 of file manager.cpp.
Referenced by addons_client::download_addon(), get_addon_tracking_info(), and invalid_pbl_exception::what().
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 56 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().
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 101 of file manager.cpp.
References filesystem::file_exists().
Referenced by invalid_pbl_exception::what().
bool have_addon_pbl_info | ( | const std::string & | addon_name | ) |
Returns whether a .pbl file is present for the specified add-on or not.
Definition at line 65 of file manager.cpp.
References filesystem::file_exists().
Referenced by addons_client::do_check_before_overwriting_addon(), get_addon_tracking_info(), installed_addons_and_versions(), game_config_manager::load_addons_cfg(), refresh_addon_version_info_cache(), gui2::dialogs::addon_manager::uninstall_addon(), and invalid_pbl_exception::what().
std::vector<std::string> installed_addons | ( | ) |
Retrieves the names of all installed add-ons.
Definition at line 191 of file manager.cpp.
Referenced by installed_addons_and_versions(), manage_addons(), refresh_addon_version_info_cache(), mp::lobby_info::refresh_installed_addons_cache(), and invalid_pbl_exception::what().
std::map<std::string, std::string> installed_addons_and_versions | ( | ) |
Retrieves the ids and versions of all installed add-ons.
Definition at line 196 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().
bool is_addon_installed | ( | const std::string & | addon_name | ) |
Check whether the specified add-on is currently installed.
Definition at line 219 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().
|
inlinestatic |
Definition at line 225 of file manager.cpp.
Referenced by strip_cr().
void purge_addon | ( | const config & | removelist | ) |
Removes the listed files from the addon.
Definition at line 378 of file manager.cpp.
References filesystem::get_addons_dir(), and purge_dir().
Referenced by addons_client::install_addon(), and invalid_pbl_exception::what().
|
static |
Definition at line 353 of file manager.cpp.
References config::child_range(), d, filesystem::delete_directory(), filesystem::delete_file(), filesystem::dir_size(), f, filesystem::is_directory(), and game_config::path.
Referenced by purge_addon().
|
static |
Definition at line 239 of file manager.cpp.
References filesystem::blacklist_pattern_list::add_directory_pattern(), filesystem::blacklist_pattern_list::add_file_pattern(), filesystem::default_blacklist, filesystem::file_exists(), filesystem::get_addons_dir(), filesystem::istream_file(), draw::line(), LOG_CFG, and utils::trim().
Referenced by archive_addon().
void refresh_addon_version_info_cache | ( | ) |
Refreshes the per-session cache of add-on's version information structs.
Definition at line 388 of file manager.cpp.
References config::empty(), filesystem::file_exists(), get_addon_install_info(), have_addon_in_vcs_tree(), have_addon_pbl_info(), i, installed_addons(), LOG_CFG, and WRN_CFG.
Referenced by do_gameloop(), gui2::dialogs::addon_manager::load_addon_list(), game_config_manager::reload_changed_game_config(), gui2::dialogs::addon_manager::update_all_addons(), and invalid_pbl_exception::what().
bool remove_local_addon | ( | const std::string & | addon | ) |
Removes the specified add-on, deleting its full directory structure.
Definition at line 143 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().
void set_addon_pbl_info | ( | const std::string & | addon_name, |
const config & | cfg | ||
) |
Definition at line 95 of file manager.cpp.
References filesystem::ostream_file(), and write().
|
static |
void unarchive_addon | ( | const config & | cfg, |
std::function< void(unsigned)> | progress_callback | ||
) |
Definition at line 343 of file manager.cpp.
References count_pack_files(), filesystem::get_addons_dir(), and unarchive_dir().
Referenced by addons_client::install_addon().
|
static |
Definition at line 310 of file manager.cpp.
References config::child_range(), d, f, filesystem::make_directory(), game_config::path, and unarchive_file().
Referenced by unarchive_addon().
|
static |
Definition at line 305 of file manager.cpp.
References unencode_binary(), and filesystem::write_file().
Referenced by unarchive_dir().
void write_addon_install_info | ( | const std::string & | addon_name, |
const config & | cfg | ||
) |
Definition at line 126 of file manager.cpp.
References config::add_child(), LOG_CFG, filesystem::ostream_file(), and write().
Referenced by addons_client::install_addon().
|
static |
|
static |
|
static |