The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions | Variables
manager.cpp File Reference
#include "addon/manager.hpp"
#include "addon/manager_ui.hpp"
#include "filesystem.hpp"
#include "formatter.hpp"
#include "preferences/game.hpp"
#include "gettext.hpp"
#include "gui/dialogs/addon/connect.hpp"
#include "gui/dialogs/addon/manager.hpp"
#include "gui/dialogs/addon/uninstall_list.hpp"
#include "gui/dialogs/message.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 "serialization/parser.hpp"
#include "version.hpp"
#include "formula/string_utils.hpp"
#include "addon/client.hpp"
#include <boost/algorithm/string.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...
 
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 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::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...
 
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 39 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 44 of file manager.cpp.

#define ERR_NET   LOG_STREAM(err , log_network)

Definition at line 47 of file manager.cpp.

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

Definition at line 48 of file manager.cpp.

#define WRN_CFG   LOG_STREAM(warn, log_config)

Definition at line 41 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 298 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 257 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 132 of file manager.cpp.

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

Referenced by gui2::dialogs::addon_manager::load_addon_list().

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

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

Referenced by refresh_addon_version_info_cache().

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 80 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(), gui2::dialogs::addon_manager::load_addon_list(), and gui2::dialogs::addon_manager::publish_addon().

version_info get_addon_version_info ( const std::string &  addon)

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

Definition at line 383 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 66 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(), and gui2::dialogs::addon_manager::uninstall_addon().

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

References filesystem::file_exists().

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

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

Retrieves the names of all installed add-ons.

Definition at line 148 of file manager.cpp.

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

Referenced by manage_addons(), refresh_addon_version_info_cache(), and mp::start_client().

bool is_addon_installed ( const std::string &  addon_name)

Check whether the specified add-on is currently installed.

Definition at line 164 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(), and addons_client::try_fetch_addon().

static bool IsCR ( const char &  c)
inlinestatic

Definition at line 170 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 ( )
bool remove_local_addon ( const std::string &  addon)
void set_addon_pbl_info ( const std::string &  addon_name,
const config cfg 
)

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

References IsCR().

Referenced by archive_file().

void unarchive_addon ( const config cfg)

Definition at line 331 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
static void unarchive_file ( const std::string &  path,
const config cfg 
)
static

Definition at line 307 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