Skip to content

Commit

Permalink
Merge pull request #426 from Vultraz/master
Browse files Browse the repository at this point in the history
Display an error if trying to upload an addon with an invalid icon
  • Loading branch information
Vultraz committed Jul 30, 2015
2 parents fcaa2ab + c0e6a4d commit 60400f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/addon/client.cpp
Expand Up @@ -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()) {
Expand Down
3 changes: 2 additions & 1 deletion src/addon/client.hpp
Expand Up @@ -116,8 +116,9 @@ class addons_client : private boost::noncopyable
*
* @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.
Expand Down
9 changes: 7 additions & 2 deletions src/addon/manager_ui.cpp
Expand Up @@ -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());
Expand Down

0 comments on commit 60400f2

Please sign in to comment.