bool addons_client::delete_remote_addon(const std::string& id, std::string& response_message) { response_message.clear(); config cfg; get_addon_pbl_info(id, cfg); utils::string_map i18n_symbols; i18n_symbols["addon_title"] = cfg["title"]; if(i18n_symbols["addon_title"].empty()) { i18n_symbols["addon_title"] = make_addon_title(id); } config request_buf, response_buf; config& request_body = request_buf.add_child("delete"); request_body["name"] = id; request_body["passphrase"] = cfg["passphrase"]; 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 )); if(const config& message_cfg = response_buf.child("message")) { response_message = message_cfg["message"].str(); LOG_ADDONS << "server response: " << response_message << '\n'; } return !this->update_last_error(response_buf); }
std::string addon_info::display_title() const { if(this->title.empty()) { return make_addon_title(this->id); } else { return this->title; } }
std::string addon_info::display_title() const { if(this->title.empty()) { return font::escape_text(make_addon_title(this->id)); } else { return font::escape_text(this->title); } }
bool addons_client::upload_addon(const std::string& id, std::string& response_message) { LOG_ADDONS << "preparing to upload " << id << '\n'; response_message.clear(); config cfg; get_addon_pbl_info(id, cfg); utils::string_map i18n_symbols; i18n_symbols["addon_title"] = cfg["title"]; if(i18n_symbols["addon_title"].empty()) { i18n_symbols["addon_title"] = make_addon_title(id); } std::string passphrase = cfg["passphrase"]; // generate a random passphrase and write it to disk // if the .pbl file doesn't provide one already if(passphrase.empty()) { passphrase.resize(8); for(size_t n = 0; n != 8; ++n) { passphrase[n] = 'a' + (rand()%26); } cfg["passphrase"] = passphrase; set_addon_pbl_info(id, cfg); LOG_ADDONS << "automatically generated an initial passphrase for " << id << '\n'; } cfg["name"] = id; config addon_data; archive_addon(id, addon_data); config request_buf, response_buf; request_buf.add_child("upload", cfg).add_child("data", addon_data); 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 )); if(const config& message_cfg = response_buf.child("message")) { response_message = message_cfg["message"].str(); LOG_ADDONS << "server response: " << response_message << '\n'; } return !this->update_last_error(response_buf); }
void taddon_uninstall_list::pre_show(CVideo& /*video*/, twindow& window) { tlistbox& list = find_widget<tlistbox>(&window, "addons_list", false); window.keyboard_capture(&list); this->names_.clear(); this->selections_.clear(); foreach(const std::string& id, this->ids_) { this->names_.push_back(make_addon_title(id)); this->selections_[id] = false; std::map<std::string, string_map> data; string_map column; column["label"] = this->names_.back(); data.insert(std::make_pair("name", column)); list.add_row(data); } }
/** Warns the user about unresolved dependencies and installs them if they choose to do so. * Returns: outcome: ABORT in case the user chose to abort because of an issue * SUCCESS otherwise * wml_change: indicates if new wml content was installed */ addon_op_result do_resolve_addon_dependencies(display& disp, addons_client& client, const addons_list& addons, const addon_info& addon) { addon_op_result result; result.outcome = SUCCESS; result.wml_changed = false; boost::scoped_ptr<cursor::setter> cursor_setter(new cursor::setter(cursor::WAIT)); // TODO: We don't currently check for the need to upgrade. I'll probably // work on that when implementing dependency tiers later. const std::set<std::string>& deps = addon.resolve_dependencies(addons); std::vector<std::string> missing_deps; std::vector<std::string> broken_deps; BOOST_FOREACH(const std::string& dep, deps) { if(!is_addon_installed(dep)) { if(addons.find(dep) != addons.end()) { missing_deps.push_back(dep); } else { broken_deps.push_back(dep); } } } cursor_setter.reset(); if(!broken_deps.empty()) { std::string broken_deps_report; broken_deps_report = _n( "The selected add-on has the following dependency, which is not currently installed or available from the server. Do you wish to continue?", "The selected add-on has the following dependencies, which are not currently installed or available from the server. Do you wish to continue?", broken_deps.size()); broken_deps_report += "\n"; BOOST_FOREACH(const std::string& broken_dep_id, broken_deps) { broken_deps_report += "\n " + utils::unicode_bullet + " " + make_addon_title(broken_dep_id); }