Skip to content

Commit

Permalink
Made get_addon_pbl_info return its own config object
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Feb 15, 2017
1 parent 3e68d47 commit 3a1b6ee
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/addon/client.cpp
Expand Up @@ -157,8 +157,7 @@ bool addons_client::delete_remote_addon(const std::string& id, std::string& resp
{
response_message.clear();

config cfg;
get_addon_pbl_info(id, cfg);
config cfg = get_addon_pbl_info(id);

utils::string_map i18n_symbols;
i18n_symbols["addon_title"] = cfg["title"];
Expand Down
5 changes: 4 additions & 1 deletion src/addon/manager.cpp
Expand Up @@ -79,15 +79,18 @@ bool have_addon_pbl_info(const std::string& addon_name)
return filesystem::file_exists(get_pbl_file_path(addon_name));
}

void get_addon_pbl_info(const std::string& addon_name, config& cfg)
config get_addon_pbl_info(const std::string& addon_name)
{
config cfg;
const std::string& pbl_path = get_pbl_file_path(addon_name);
try {
filesystem::scoped_istream stream = filesystem::istream_file(pbl_path);
read(cfg, *stream);
} catch(const config::error& e) {
throw invalid_pbl_exception(pbl_path, e.message);
}

return cfg;
}

void set_addon_pbl_info(const std::string& addon_name, const config& cfg)
Expand Down
4 changes: 1 addition & 3 deletions src/addon/manager.hpp
Expand Up @@ -65,13 +65,11 @@ bool have_addon_in_vcs_tree(const std::string& addon_name);
* Gets the publish information for an add-on.
*
* @param addon_name The add-on's main directory/file name.
* @param cfg A config object to store the add-on's
* properties.
*
* @exception invalid_pbl_exception If it is not possible to read the .pbl file
* (often due to invalid WML).
*/
void get_addon_pbl_info(const std::string& addon_name, class config& cfg);
config get_addon_pbl_info(const std::string& addon_name);

/**
* Sets the publish information for an add-on
Expand Down
3 changes: 1 addition & 2 deletions src/addon/manager_ui.cpp
Expand Up @@ -143,8 +143,7 @@ void do_remote_addon_publish(CVideo& video, addons_client& client, const std::st
{
std::string server_msg;

config cfg;
get_addon_pbl_info(addon_id, cfg);
config cfg = get_addon_pbl_info(addon_id);

const version_info& version_to_publish = cfg["version"].str();

Expand Down
3 changes: 1 addition & 2 deletions src/addon/state.cpp
Expand Up @@ -33,8 +33,7 @@ addon_tracking_info get_addon_tracking_info(const addon_info& addon)
if(is_addon_installed(id)) {
if(t.can_publish) {
// Try to obtain the version number from the .pbl first.
config pbl;
get_addon_pbl_info(id, pbl);
config pbl = get_addon_pbl_info(id);

if(pbl.has_attribute("version")) {
t.installed_version = pbl["version"].str();
Expand Down
3 changes: 1 addition & 2 deletions src/gui/dialogs/addon/manager.cpp
Expand Up @@ -566,8 +566,7 @@ void addon_manager::do_remote_addon_publish(const std::string& addon_id, window&
{
std::string server_msg;

config cfg;
get_addon_pbl_info(addon_id, cfg);
config cfg = get_addon_pbl_info(addon_id);

const version_info& version_to_publish = cfg["version"].str();

Expand Down

0 comments on commit 3a1b6ee

Please sign in to comment.