diff --git a/src/addon/client.cpp b/src/addon/client.cpp index 68a662cac61d..667ab450c45c 100644 --- a/src/addon/client.cpp +++ b/src/addon/client.cpp @@ -82,15 +82,13 @@ bool addons_client::request_addons_list(config& cfg) config response_buf; + /** @todo FIXME: get rid of this legacy "campaign"/"campaigns" silliness + */ + this->send_simple_request("request_campaign_list", response_buf); this->wait_for_transfer_done(_("Downloading list of add-ons...")); - // Legacy support. The response key used to be "campaigns". - if(response_buf.has_child("campaigns")) { - cfg = std::move(response_buf.child("campaigns")); - } else { - cfg = std::move(response_buf.child("addons")); - } + cfg = std::move(response_buf.child("campaigns")); return !this->update_last_error(response_buf); } diff --git a/src/addon/info.cpp b/src/addon/info.cpp index 4eba4c5924d6..3e8bd46c90c1 100644 --- a/src/addon/info.cpp +++ b/src/addon/info.cpp @@ -199,14 +199,10 @@ void read_addons_list(const config& cfg, addons_list& dest) unsigned order = 0; - std::string key = "addon"; - - // Legacy support. The entry key used to be "campaign". - if(!cfg.has_child(key)) { - key = "campaign"; - } - - for(const config& addon_cfg : cfg.child_range(key)) { + /** @todo FIXME: get rid of this legacy "campaign"/"campaigns" silliness + */ + const config::const_child_itors &addon_cfgs = cfg.child_range("campaign"); + for(const config& addon_cfg : addon_cfgs) { const std::string& id = addon_cfg["name"].str(); if(dest.find(id) != dest.end()) { ERR_AC << "add-ons list has multiple entries for '" << id << "', not good; ignoring them" << std::endl; diff --git a/src/campaign_server/campaign_server.cpp b/src/campaign_server/campaign_server.cpp index 9e8dd8d9dcae..e7bac51e3d21 100644 --- a/src/campaign_server/campaign_server.cpp +++ b/src/campaign_server/campaign_server.cpp @@ -130,7 +130,7 @@ server::server(const std::string& cfg_file) // Ensure all campaigns to use secure hash passphrase storage if(!read_only_) { - for(config& campaign : addons().child_range("addon")) { + for(config& campaign : campaigns().child_range("campaign")) { // Campaign already has a hashed password if(campaign["passphrase"].empty()) { continue; @@ -207,7 +207,7 @@ void server::load_config() // Ensure the campaigns list WML exists even if empty, other functions // depend on its existence. - cfg_.child_or_add("addons"); + cfg_.child_or_add("campaigns"); // Certain config values are saved to WML again so that a given server // instance's parameters remain constant even if the code defaults change @@ -303,7 +303,7 @@ void server::handle_read_from_fifo(const boost::system::error_code& error, std:: } else { const std::string& addon_id = ctl[1]; const std::string& newpass = ctl[2]; - config& campaign = get_addon(addon_id); + config& campaign = get_campaign(addon_id); if(!campaign) { ERR_CS << "Add-on '" << addon_id << "' not found, cannot set passphrase\n"; @@ -505,7 +505,7 @@ void server::handle_request_campaign_list(const server::request& req) const std::string& name = req.cfg["name"]; const std::string& lang = req.cfg["language"]; - for(const config& i : addons().child_range("addon")) + for(const config& i : campaigns().child_range("campaign")) { if(!name.empty() && name != i["name"]) { continue; @@ -536,10 +536,10 @@ void server::handle_request_campaign_list(const server::request& req) } } - campaign_list.add_child("addon", i); + campaign_list.add_child("campaign", i); } - for(config& j : campaign_list.child_range("addon")) + for(config& j : campaign_list.child_range("campaign")) { j["passphrase"] = ""; j["passhash"] = ""; @@ -560,7 +560,7 @@ void server::handle_request_campaign_list(const server::request& req) } config response; - response.add_child("addons", std::move(campaign_list)); + response.add_child("campaigns", std::move(campaign_list)); std::ostringstream ostr; write(ostr, response); @@ -575,7 +575,7 @@ void server::handle_request_campaign(const server::request& req) { LOG_CS << "sending campaign '" << req.cfg["name"] << "' to " << req.addr << " using gzip\n"; - config& campaign = get_addon(req.cfg["name"]); + config& campaign = get_campaign(req.cfg["name"]); if(!campaign) { send_error("Add-on '" + req.cfg["name"].str() + "' not found.", req.sock); @@ -644,7 +644,7 @@ void server::handle_upload(const server::request& req) const std::string& lc_name = utf8::lowercase(name); passed_name_utf8_check = true; - for(config& c : addons().child_range("addon")) + for(config& c : campaigns().child_range("campaign")) { if(utf8::lowercase(c["name"]) == lc_name) { campaign = &c; @@ -747,7 +747,7 @@ void server::handle_upload(const server::request& req) std::string message = "Add-on accepted."; if(campaign == nullptr) { - campaign = &addons().add_child("addon"); + campaign = &campaigns().add_child("campaign"); (*campaign)["original_timestamp"] = upload_ts; } @@ -826,7 +826,7 @@ void server::handle_delete(const server::request& req) LOG_CS << "deleting campaign '" << erase["name"] << "' requested from " << req.addr << "\n"; - config& campaign = get_addon(erase["name"]); + config& campaign = get_campaign(erase["name"]); if(!campaign) { send_error("The add-on does not exist.", req.sock); @@ -834,8 +834,8 @@ void server::handle_delete(const server::request& req) } if(!authenticate(campaign, erase["passphrase"]) - && (addons()["master_password"].empty() - || addons()["master_password"] != erase["passphrase"])) + && (campaigns()["master_password"].empty() + || campaigns()["master_password"] != erase["passphrase"])) { send_error("The passphrase is incorrect.", req.sock); return; @@ -849,11 +849,11 @@ void server::handle_delete(const server::request& req) << '\n'; } - config::child_itors itors = addons().child_range("addon"); + config::child_itors itors = campaigns().child_range("campaign"); for(size_t index = 0; !itors.empty(); ++index, itors.pop_front()) { if(&campaign == &itors.front()) { - addons().remove_child("addon", index); + campaigns().remove_child("campaign", index); break; } } @@ -876,7 +876,7 @@ void server::handle_change_passphrase(const server::request& req) return; } - config& campaign = get_addon(cpass["name"]); + config& campaign = get_campaign(cpass["name"]); if(!campaign) { send_error("No add-on with that name exists.", req.sock); diff --git a/src/campaign_server/campaign_server.hpp b/src/campaign_server/campaign_server.hpp index aa86961fceb5..bc1983a38eae 100644 --- a/src/campaign_server/campaign_server.hpp +++ b/src/campaign_server/campaign_server.hpp @@ -135,13 +135,13 @@ class server : public server_base void fire(const std::string& hook, const std::string& addon); /** Retrieves the contents of the [campaigns] WML node. */ - const config& addons() const { return cfg_.child("addons"); } + const config& campaigns() const { return cfg_.child("campaigns"); } /** Retrieves the contents of the [campaigns] WML node. */ - config& addons() { return cfg_.child("addons"); } + config& campaigns() { return cfg_.child("campaigns"); } /** Retrieves a campaign by id if found, or a null config otherwise. */ - config& get_addon(const std::string& id) { return addons().find_child("addon", "name", id); } + config& get_campaign(const std::string& id) { return campaigns().find_child("campaign", "name", id); } /** Retrieves the contents of the [server_info] WML node. */ const config& server_info() const { return cfg_.child("server_info"); }