Merge pull request #426 from Vultraz/master
Display an error if trying to upload an addon with an invalid icon
This commit is contained in:
commit
60400f29a2
3 changed files with 10 additions and 7 deletions
|
@ -100,15 +100,12 @@ bool addons_client::request_distribution_terms(std::string& terms)
|
|||
return !this->update_last_error(response_buf);
|
||||
}
|
||||
|
||||
bool addons_client::upload_addon(const std::string& id, std::string& response_message)
|
||||
bool addons_client::upload_addon(const std::string& id, std::string& response_message, config& cfg)
|
||||
{
|
||||
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()) {
|
||||
|
|
|
@ -116,8 +116,9 @@ public:
|
|||
*
|
||||
* @param id Id. of the add-on to upload.
|
||||
* @param response_message The server response message on success, such as "add-on accepted".
|
||||
* @param cfg The pbl config of the add-on with the specified id.
|
||||
*/
|
||||
bool upload_addon(const std::string& id, std::string& response_message);
|
||||
bool upload_addon(const std::string& id, std::string& response_message, config& cfg);
|
||||
|
||||
/**
|
||||
* Requests the specified add-on to be removed from the server.
|
||||
|
|
|
@ -383,12 +383,17 @@ void do_remote_addon_publish(CVideo& video, addons_client& client, const std::st
|
|||
{
|
||||
std::string server_msg;
|
||||
|
||||
if(!client.request_distribution_terms(server_msg)) {
|
||||
config cfg;
|
||||
get_addon_pbl_info(addon_id, cfg);
|
||||
|
||||
if(!image::exists(cfg["icon"].str())) {
|
||||
gui2::show_error_message(video, _("Invalid icon path. Please make sure the path points to a valid image."));
|
||||
} else if(!client.request_distribution_terms(server_msg)) {
|
||||
gui2::show_error_message(video,
|
||||
std::string(_("The server responded with an error:")) + "\n" +
|
||||
client.get_last_server_error());
|
||||
} else if(gui2::show_message(video, _("Terms"), server_msg, gui2::tmessage::ok_cancel_buttons) == gui2::twindow::OK) {
|
||||
if(!client.upload_addon(addon_id, server_msg)) {
|
||||
if(!client.upload_addon(addon_id, server_msg, cfg)) {
|
||||
gui2::show_error_message(video,
|
||||
std::string(_("The server responded with an error:")) + "\n" +
|
||||
client.get_last_server_error());
|
||||
|
|
Loading…
Add table
Reference in a new issue