The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions | Variables
manager.cpp File Reference
#include "global.hpp"
#include "addon/manager.hpp"
#include "addon/manager_ui.hpp"
#include "dialogs.hpp"
#include "filesystem.hpp"
#include "formatter.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "gui/dialogs/addon/connect.hpp"
#include "gui/dialogs/addon/list.hpp"
#include "gui/dialogs/addon/description.hpp"
#include "gui/dialogs/addon/uninstall_list.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/dialogs/network_transmission.hpp"
#include "gui/dialogs/simple_item_selector.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "log.hpp"
#include "marked-up_text.hpp"
#include "serialization/parser.hpp"
#include "version.hpp"
#include "wml_separators.hpp"
#include "formula/string_utils.hpp"
#include "addon/client.hpp"
Include dependency graph for manager.cpp:

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)
 

Functions

bool have_addon_in_vcs_tree (const std::string &addon_name)
 Returns true if the specified add-ons appear to be managed by a 'supported' VCS. More...
 
bool have_addon_pbl_info (const std::string &addon_name)
 Returns true if there's a local .pbl file stored for the specified add-on. More...
 
void get_addon_pbl_info (const std::string &addon_name, config &cfg)
 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...
 
bool remove_local_addon (const std::string &addon)
 
std::vector< std::stringavailable_addons ()
 Returns a list of local add-ons that can be published. More...
 
std::vector< std::stringinstalled_addons ()
 Retrieves the names 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 std::pair< std::vector
< std::string >, std::vector
< std::string > > 
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, std::pair< std::vector< std::string >, std::vector< std::string > > &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)
 
void unarchive_addon (const config &cfg)
 
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")
 

Macro Definition Documentation

#define ERR_CFG   LOG_STREAM(err , log_config)

Definition at line 44 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 49 of file manager.cpp.

#define ERR_NET   LOG_STREAM(err , log_network)

Definition at line 52 of file manager.cpp.

#define LOG_CFG   LOG_STREAM(info, log_config)
#define LOG_NET   LOG_STREAM(info, log_network)

Definition at line 53 of file manager.cpp.

#define WRN_CFG   LOG_STREAM(warn, log_config)

Definition at line 46 of file manager.cpp.

Referenced by refresh_addon_version_info_cache().

Function Documentation

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 294 of file manager.cpp.

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

Referenced by addons_client::upload_addon().

static void archive_dir ( const std::string path,
const std::string dirname,
config cfg,
std::pair< std::vector< std::string >, std::vector< std::string > > &  ignore_patterns 
)
static
static void archive_file ( const std::string path,
const std::string fname,
config cfg 
)
static

Definition at line 253 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 134 of file manager.cpp.

References filesystem::file_exists(), filesystem::get_addons_dir(), filesystem::get_files_in_dir(), have_addon_pbl_info(), and i.

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 107 of file manager.cpp.

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

Referenced by refresh_addon_version_info_cache().

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

Gets the publish information for an add-on.

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

Definition at line 85 of file manager.cpp.

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

Referenced by addons_client::delete_remote_addon(), and get_addon_tracking_info().

version_info get_addon_version_info ( const std::string addon)

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

Definition at line 379 of file manager.cpp.

Referenced by get_addon_tracking_info(), and game_config_manager::load_addons_cfg().

bool have_addon_in_vcs_tree ( const std::string addon_name)

Returns true if the specified add-ons appear to be managed by a 'supported' VCS.

Currently supported VCSes are: Subversion, Git, Mercurial.

Definition at line 71 of file manager.cpp.

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

Referenced by get_addon_tracking_info(), and refresh_addon_version_info_cache().

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 102 of file manager.cpp.

References filesystem::file_exists().

bool have_addon_pbl_info ( const std::string addon_name)

Returns true if there's a local .pbl file stored for the specified add-on.

Definition at line 80 of file manager.cpp.

References filesystem::file_exists().

Referenced by available_addons(), get_addon_tracking_info(), and refresh_addon_version_info_cache().

std::vector<std::string> installed_addons ( )
bool is_addon_installed ( const std::string addon_name)

Check whether the specified add-on is currently installed.

Definition at line 166 of file manager.cpp.

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

Referenced by get_addon_tracking_info().

static bool IsCR ( const char &  c)
inlinestatic

Definition at line 172 of file manager.cpp.

Referenced by strip_cr().

static std::pair<std::vector<std::string>, std::vector<std::string> > read_ignore_patterns ( const std::string addon_name)
static
void refresh_addon_version_info_cache ( )

Refreshes the per-session cache of add-on's version information structs.

Definition at line 337 of file manager.cpp.

References config::child(), filesystem::file_exists(), get_addon_install_info(), have_addon_in_vcs_tree(), have_addon_pbl_info(), i, installed_addons(), LOG_CFG, game_config::version, and WRN_CFG.

Referenced by do_gameloop(), and game_config_manager::reload_changed_game_config().

bool remove_local_addon ( const std::string addon)
void set_addon_pbl_info ( const std::string addon_name,
const config cfg 
)

Definition at line 96 of file manager.cpp.

References filesystem::ostream_file(), and write().

Referenced by addons_client::upload_addon().

static std::string strip_cr ( std::string  str,
bool  strip 
)
static

Definition at line 177 of file manager.cpp.

References IsCR().

Referenced by archive_file().

void unarchive_addon ( const config cfg)

Definition at line 327 of file manager.cpp.

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

Referenced by addons_client::install_addon().

static void unarchive_dir ( const std::string path,
const config cfg 
)
static

Definition at line 308 of file manager.cpp.

References config::child_range(), d, filesystem::make_directory(), and unarchive_file().

Referenced by unarchive_addon().

static void unarchive_file ( const std::string path,
const config cfg 
)
static

Definition at line 303 of file manager.cpp.

References unencode_binary(), and filesystem::write_file().

Referenced by unarchive_dir().

Variable Documentation

lg::log_domain log_config("config")
static
lg::log_domain log_filesystem("filesystem")
static
lg::log_domain log_network("network")
static