Clean up excessive use of this pointers in add-ons client
I have no idea what code style statement past me was trying to make here anymore.
This commit is contained in:
parent
d4ca82bbbb
commit
f1d4f352a4
2 changed files with 91 additions and 91 deletions
|
@ -67,7 +67,7 @@ void addons_client::connect()
|
|||
|
||||
conn_.reset(new network_asio::connection(host_, port_));
|
||||
|
||||
this->wait_for_transfer_done(
|
||||
wait_for_transfer_done(
|
||||
VGETTEXT("Connecting to $server_address|...", i18n_symbols),
|
||||
transfer_mode::connect);
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ bool addons_client::request_addons_list(config& cfg)
|
|||
/** @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..."));
|
||||
send_simple_request("request_campaign_list", response_buf);
|
||||
wait_for_transfer_done(_("Downloading list of add-ons..."));
|
||||
|
||||
std::swap(cfg, response_buf.child("campaigns"));
|
||||
|
||||
return !this->update_last_error(response_buf);
|
||||
return !update_last_error(response_buf);
|
||||
}
|
||||
|
||||
bool addons_client::request_distribution_terms(std::string& terms)
|
||||
|
@ -95,14 +95,14 @@ bool addons_client::request_distribution_terms(std::string& terms)
|
|||
|
||||
config response_buf;
|
||||
|
||||
this->send_simple_request("request_terms", response_buf);
|
||||
this->wait_for_transfer_done(_("Requesting distribution terms..."));
|
||||
send_simple_request("request_terms", response_buf);
|
||||
wait_for_transfer_done(_("Requesting distribution terms..."));
|
||||
|
||||
if(const config& msg_cfg = response_buf.child("message")) {
|
||||
terms = msg_cfg["message"].str();
|
||||
}
|
||||
|
||||
return !this->update_last_error(response_buf);
|
||||
return !update_last_error(response_buf);
|
||||
}
|
||||
|
||||
bool addons_client::upload_addon(const std::string& id, std::string& response_message, config& cfg, bool local_only)
|
||||
|
@ -119,7 +119,7 @@ bool addons_client::upload_addon(const std::string& id, std::string& response_me
|
|||
|
||||
if(!addon_name_legal(id)){
|
||||
i18n_symbols["addon_id"] = font::escape_text(id);
|
||||
this->last_error_ =
|
||||
last_error_ =
|
||||
VGETTEXT("The add-on <i>$addon_title</i> has an invalid id '$addon_id' "
|
||||
"and cannot be published.", i18n_symbols);
|
||||
return false;
|
||||
|
@ -145,7 +145,7 @@ bool addons_client::upload_addon(const std::string& id, std::string& response_me
|
|||
try {
|
||||
archive_addon(id, addon_data);
|
||||
} catch(const utf8::invalid_utf8_exception&){
|
||||
this->last_error_ =
|
||||
last_error_ =
|
||||
VGETTEXT("The add-on <i>$addon_title</i> has a file or directory "
|
||||
"containing invalid characters and cannot be published.", i18n_symbols);
|
||||
return false;
|
||||
|
@ -153,21 +153,21 @@ bool addons_client::upload_addon(const std::string& id, std::string& response_me
|
|||
|
||||
std::vector<std::string> badnames;
|
||||
if(!check_names_legal(addon_data, &badnames)){
|
||||
this->last_error_ =
|
||||
last_error_ =
|
||||
VGETTEXT("The add-on <i>$addon_title</i> has an invalid file or directory "
|
||||
"name and cannot be published. "
|
||||
|
||||
"File or directory names may not contain '..' or end with '.' or be longer than 255 characters. "
|
||||
"It also may not contain whitespace, control characters, or any of the following characters:\n\n" * / : < > ? \\ | ~"
|
||||
, i18n_symbols);
|
||||
this->last_error_data_ = font::escape_text(utils::join(badnames, "\n"));
|
||||
last_error_data_ = font::escape_text(utils::join(badnames, "\n"));
|
||||
return false;
|
||||
}
|
||||
if(!check_case_insensitive_duplicates(addon_data, &badnames)){
|
||||
this->last_error_ =
|
||||
last_error_ =
|
||||
VGETTEXT("The add-on <i>$addon_title</i> contains files or directories with case conflicts. "
|
||||
"File or directory names may not be differently-cased versions of the same string.", i18n_symbols);
|
||||
this->last_error_data_ = font::escape_text(utils::join(badnames, "\n"));
|
||||
last_error_data_ = font::escape_text(utils::join(badnames, "\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,8 @@ bool addons_client::upload_addon(const std::string& id, std::string& response_me
|
|||
// #TODO: Make a selection of the base version for the update ?
|
||||
request_body["name"] = cfg["name"];
|
||||
// request_body["from"] = ???
|
||||
this->send_request(hash_request, hashlist);
|
||||
this->wait_for_transfer_done(VGETTEXT("Requesting the older version composition for the add-on <i>$addon_title</i>...", i18n_symbols));
|
||||
send_request(hash_request, hashlist);
|
||||
wait_for_transfer_done(VGETTEXT("Requesting the older version composition for the add-on <i>$addon_title</i>...", i18n_symbols));
|
||||
|
||||
// A silent error check
|
||||
if(!hashlist.child("error")) {
|
||||
|
@ -195,8 +195,8 @@ bool addons_client::upload_addon(const std::string& id, std::string& response_me
|
|||
request_buf.add_child("upload", cfg).append(std::move(updatepack));
|
||||
// #TODO: Make a selection of the base version for the update ? ,
|
||||
// For now, if it's unspecified we'll use the latest avaible before the upload version
|
||||
this->send_request(request_buf, response_buf);
|
||||
this->wait_for_transfer_done(VGETTEXT("Sending an update pack for the add-on <i>$addon_title</i>...", i18n_symbols
|
||||
send_request(request_buf, response_buf);
|
||||
wait_for_transfer_done(VGETTEXT("Sending an update pack for the add-on <i>$addon_title</i>...", i18n_symbols
|
||||
), transfer_mode::upload);
|
||||
|
||||
if(const config& message_cfg = response_buf.child("message")) {
|
||||
|
@ -204,7 +204,7 @@ bool addons_client::upload_addon(const std::string& id, std::string& response_me
|
|||
LOG_ADDONS << "server response: " << response_message << '\n';
|
||||
}
|
||||
|
||||
if(!this->update_last_error(response_buf))
|
||||
if(!update_last_error(response_buf))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -216,8 +216,8 @@ bool addons_client::upload_addon(const std::string& id, std::string& response_me
|
|||
|
||||
LOG_ADDONS << "sending " << id << '\n';
|
||||
|
||||
this->send_request(request_buf, response_buf);
|
||||
this->wait_for_transfer_done(VGETTEXT("Sending add-on <i>$addon_title</i>...", i18n_symbols
|
||||
send_request(request_buf, response_buf);
|
||||
wait_for_transfer_done(VGETTEXT("Sending add-on <i>$addon_title</i>...", i18n_symbols
|
||||
), transfer_mode::upload);
|
||||
|
||||
if(const config& message_cfg = response_buf.child("message")) {
|
||||
|
@ -225,7 +225,7 @@ bool addons_client::upload_addon(const std::string& id, std::string& response_me
|
|||
LOG_ADDONS << "server response: " << response_message << '\n';
|
||||
}
|
||||
|
||||
return !this->update_last_error(response_buf);
|
||||
return !update_last_error(response_buf);
|
||||
|
||||
}
|
||||
|
||||
|
@ -249,8 +249,8 @@ bool addons_client::delete_remote_addon(const std::string& id, std::string& resp
|
|||
|
||||
LOG_ADDONS << "requesting server to delete " << id << '\n';
|
||||
|
||||
this->send_request(request_buf, response_buf);
|
||||
this->wait_for_transfer_done(VGETTEXT("Removing add-on <i>$addon_title</i> from the server...", i18n_symbols
|
||||
send_request(request_buf, response_buf);
|
||||
wait_for_transfer_done(VGETTEXT("Removing add-on <i>$addon_title</i> from the server...", i18n_symbols
|
||||
));
|
||||
|
||||
if(const config& message_cfg = response_buf.child("message")) {
|
||||
|
@ -258,7 +258,7 @@ bool addons_client::delete_remote_addon(const std::string& id, std::string& resp
|
|||
LOG_ADDONS << "server response: " << response_message << '\n';
|
||||
}
|
||||
|
||||
return !this->update_last_error(response_buf);
|
||||
return !update_last_error(response_buf);
|
||||
}
|
||||
|
||||
bool addons_client::download_addon(config& archive_cfg, const std::string& id, const std::string& title, bool increase_downloads)
|
||||
|
@ -277,10 +277,10 @@ bool addons_client::download_addon(config& archive_cfg, const std::string& id, c
|
|||
|
||||
LOG_ADDONS << "downloading " << id << '\n';
|
||||
|
||||
this->send_request(request_buf, archive_cfg);
|
||||
this->wait_for_transfer_done(VGETTEXT("Downloading add-on <i>$addon_title</i>...", i18n_symbols));
|
||||
send_request(request_buf, archive_cfg);
|
||||
wait_for_transfer_done(VGETTEXT("Downloading add-on <i>$addon_title</i>...", i18n_symbols));
|
||||
|
||||
return !this->update_last_error(archive_cfg);
|
||||
return !update_last_error(archive_cfg);
|
||||
}
|
||||
|
||||
static std::string write_info_contents(const addon_info& info)
|
||||
|
@ -577,13 +577,13 @@ addons_client::install_result addons_client::install_addon_with_checks(const add
|
|||
bool addons_client::update_last_error(config& response_cfg)
|
||||
{
|
||||
if(const config& error = response_cfg.child("error")) {
|
||||
this->last_error_ = font::escape_text(error["message"].str());
|
||||
this->last_error_data_ = font::escape_text(error["extra_data"].str());
|
||||
last_error_ = font::escape_text(error["message"].str());
|
||||
last_error_data_ = font::escape_text(error["extra_data"].str());
|
||||
ERR_ADDONS << "server error: " << error << '\n';
|
||||
return true;
|
||||
} else {
|
||||
this->last_error_.clear();
|
||||
this->last_error_data_.clear();
|
||||
last_error_.clear();
|
||||
last_error_data_.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -602,14 +602,14 @@ void addons_client::send_request(const config& request, config& response)
|
|||
check_connected();
|
||||
|
||||
response.clear();
|
||||
this->conn_->transfer(request, response);
|
||||
conn_->transfer(request, response);
|
||||
}
|
||||
|
||||
void addons_client::send_simple_request(const std::string& request_string, config& response)
|
||||
{
|
||||
config request;
|
||||
request.add_child(request_string);
|
||||
this->send_request(request, response);
|
||||
send_request(request, response);
|
||||
}
|
||||
struct read_addon_connection_data : public network_transmission::connection_data
|
||||
{
|
||||
|
|
|
@ -61,94 +61,94 @@ namespace {
|
|||
|
||||
void addon_info_translation::read(const config& cfg)
|
||||
{
|
||||
this->supported = cfg["supported"].to_bool(true);
|
||||
this->title = cfg["title"].str();
|
||||
this->description = cfg["description"].str();
|
||||
supported = cfg["supported"].to_bool(true);
|
||||
title = cfg["title"].str();
|
||||
description = cfg["description"].str();
|
||||
}
|
||||
|
||||
void addon_info_translation::write(config& cfg) const
|
||||
{
|
||||
cfg["supported"] = this->supported;
|
||||
cfg["title"] = this->title;
|
||||
cfg["description"] = this->description;
|
||||
cfg["supported"] = supported;
|
||||
cfg["title"] = title;
|
||||
cfg["description"] = description;
|
||||
}
|
||||
|
||||
void addon_info::read(const config& cfg)
|
||||
{
|
||||
this->id = cfg["name"].str();
|
||||
this->title = cfg["title"].str();
|
||||
this->description = cfg["description"].str();
|
||||
this->icon = cfg["icon"].str();
|
||||
this->version = cfg["version"].str();
|
||||
this->author = cfg["author"].str();
|
||||
this->size = cfg["size"];
|
||||
this->downloads = cfg["downloads"];
|
||||
this->uploads = cfg["uploads"];
|
||||
this->type = get_addon_type(cfg["type"].str());
|
||||
id = cfg["name"].str();
|
||||
title = cfg["title"].str();
|
||||
description = cfg["description"].str();
|
||||
icon = cfg["icon"].str();
|
||||
version = cfg["version"].str();
|
||||
author = cfg["author"].str();
|
||||
size = cfg["size"];
|
||||
downloads = cfg["downloads"];
|
||||
uploads = cfg["uploads"];
|
||||
type = get_addon_type(cfg["type"].str());
|
||||
|
||||
const config::const_child_itors& locales_as_configs = cfg.child_range("translation");
|
||||
|
||||
for(const config& locale : locales_as_configs) {
|
||||
if(locale["supported"].to_bool(true))
|
||||
this->locales.emplace_back(locale["language"].str());
|
||||
this->info_translations.emplace(locale["language"].str(), addon_info_translation(locale));
|
||||
locales.emplace_back(locale["language"].str());
|
||||
info_translations.emplace(locale["language"].str(), addon_info_translation(locale));
|
||||
}
|
||||
|
||||
this->core = cfg["core"].str();
|
||||
this->depends = utils::split(cfg["dependencies"].str());
|
||||
this->tags = utils::split(cfg["tags"].str());
|
||||
this->feedback_url = cfg["feedback_url"].str();
|
||||
core = cfg["core"].str();
|
||||
depends = utils::split(cfg["dependencies"].str());
|
||||
tags = utils::split(cfg["tags"].str());
|
||||
feedback_url = cfg["feedback_url"].str();
|
||||
|
||||
this->updated = cfg["timestamp"].to_time_t();
|
||||
this->created = cfg["original_timestamp"].to_time_t();
|
||||
updated = cfg["timestamp"].to_time_t();
|
||||
created = cfg["original_timestamp"].to_time_t();
|
||||
|
||||
this->local_only = cfg["local_only"].to_bool();
|
||||
local_only = cfg["local_only"].to_bool();
|
||||
}
|
||||
|
||||
void addon_info::write(config& cfg) const
|
||||
{
|
||||
cfg["id"] = this->id;
|
||||
cfg["title"] = this->title;
|
||||
cfg["description"] = this->description;
|
||||
cfg["icon"] = this->icon;
|
||||
cfg["version"] = this->version.str();
|
||||
cfg["author"] = this->author;
|
||||
cfg["size"] = this->size;
|
||||
cfg["downloads"] = this->downloads;
|
||||
cfg["uploads"] = this->uploads;
|
||||
cfg["type"] = get_addon_type_string(this->type);
|
||||
cfg["id"] = id;
|
||||
cfg["title"] = title;
|
||||
cfg["description"] = description;
|
||||
cfg["icon"] = icon;
|
||||
cfg["version"] = version.str();
|
||||
cfg["author"] = author;
|
||||
cfg["size"] = size;
|
||||
cfg["downloads"] = downloads;
|
||||
cfg["uploads"] = uploads;
|
||||
cfg["type"] = get_addon_type_string(type);
|
||||
|
||||
for(const auto& element : this->info_translations) {
|
||||
for(const auto& element : info_translations) {
|
||||
config& locale = cfg.add_child("translation");
|
||||
locale["language"] = element.first;
|
||||
element.second.write(locale);
|
||||
}
|
||||
|
||||
cfg["core"] = this->core;
|
||||
cfg["dependencies"] = utils::join(this->depends);
|
||||
cfg["tags"] = utils::join(this->tags);
|
||||
cfg["feedback_url"] = this->feedback_url;
|
||||
cfg["core"] = core;
|
||||
cfg["dependencies"] = utils::join(depends);
|
||||
cfg["tags"] = utils::join(tags);
|
||||
cfg["feedback_url"] = feedback_url;
|
||||
|
||||
cfg["timestamp"] = this->updated;
|
||||
cfg["original_timestamp"] = this->created;
|
||||
cfg["timestamp"] = updated;
|
||||
cfg["original_timestamp"] = created;
|
||||
}
|
||||
|
||||
void addon_info::write_minimal(config& cfg) const
|
||||
{
|
||||
cfg["version"] = this->version.str();
|
||||
cfg["uploads"] = this->uploads;
|
||||
cfg["type"] = get_addon_type_string(this->type);
|
||||
cfg["title"] = this->title;
|
||||
cfg["dependencies"] = utils::join(this->depends);
|
||||
cfg["core"] = this->core;
|
||||
cfg["version"] = version.str();
|
||||
cfg["uploads"] = uploads;
|
||||
cfg["type"] = get_addon_type_string(type);
|
||||
cfg["title"] = title;
|
||||
cfg["dependencies"] = utils::join(depends);
|
||||
cfg["core"] = core;
|
||||
}
|
||||
|
||||
std::string addon_info::display_title() const
|
||||
{
|
||||
if(this->title.empty()) {
|
||||
return font::escape_text(make_addon_title(this->id));
|
||||
if(title.empty()) {
|
||||
return font::escape_text(make_addon_title(id));
|
||||
} else {
|
||||
return font::escape_text(this->title);
|
||||
return font::escape_text(title);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ addon_info_translation addon_info::translated_info() const
|
|||
|
||||
std::string addon_info::display_title_translated() const
|
||||
{
|
||||
addon_info_translation info = this->translated_info();
|
||||
addon_info_translation info = translated_info();
|
||||
|
||||
if(info.valid()) {
|
||||
return info.title;
|
||||
|
@ -203,13 +203,13 @@ std::string addon_info::display_title_translated_or_original() const
|
|||
|
||||
std::string addon_info::description_translated() const
|
||||
{
|
||||
addon_info_translation info = this->translated_info();
|
||||
addon_info_translation info = translated_info();
|
||||
|
||||
if(info.valid() && !info.description.empty()) {
|
||||
return info.description;
|
||||
}
|
||||
|
||||
return this->description;
|
||||
return description;
|
||||
}
|
||||
|
||||
std::string addon_info::display_title_full() const
|
||||
|
@ -272,11 +272,11 @@ std::string addon_info::display_type() const
|
|||
std::set<std::string> addon_info::resolve_dependencies(const addons_list& addons) const
|
||||
{
|
||||
std::set<std::string> deps;
|
||||
resolve_deps_recursive(addons, this->id, deps);
|
||||
resolve_deps_recursive(addons, id, deps);
|
||||
|
||||
if(deps.find(this->id) != deps.end()) {
|
||||
LOG_AC << this->id << " depends upon itself; breaking circular dependency\n";
|
||||
deps.erase(this->id);
|
||||
if(deps.find(id) != deps.end()) {
|
||||
LOG_AC << id << " depends upon itself; breaking circular dependency\n";
|
||||
deps.erase(id);
|
||||
}
|
||||
|
||||
return deps;
|
||||
|
|
Loading…
Add table
Reference in a new issue