From 672fcfe0090976814c066f7d926f77f90b3a3fdc Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 17 Sep 2014 20:59:56 +0100 Subject: [PATCH] Show errors in room when can't retrieve room config --- src/server_events.c | 14 +------------- src/ui/core.c | 25 +++++++++++++++++++++++++ src/ui/ui.h | 1 + 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/server_events.c b/src/server_events.c index 4e48aecb..59c461d3 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -478,19 +478,7 @@ handle_room_config_submit_result(void) void handle_room_configuration_form_error(const char * const room, const char * const message) { - if (room != NULL) { - if (message != NULL) { - cons_show_error("Room config error for %s: %s.", room, message); - } else { - cons_show_error("Room config error for %s.", room); - } - } else { - if (message != NULL) { - cons_show_error("Room config error: %s.", message); - } else { - cons_show_error("Room config error."); - } - } + ui_handle_room_configuration_form_error(room, message); } void diff --git a/src/ui/core.c b/src/ui/core.c index 53d3a2ad..892dc52a 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2068,6 +2068,30 @@ _ui_handle_room_configuration(const char * const room, DataForm *form) ui_show_form(window, room, form); } +static void +_ui_handle_room_configuration_form_error(const char * const room, const char * const message) +{ + ProfWin *window = NULL; + GString *message_str = g_string_new(""); + + if (room) { + window = wins_get_by_recipient(room); + g_string_printf(message_str, "Could not get room configuration for %s", room); + } else { + window = wins_get_console(); + g_string_printf(message_str, "Could not get room configuration"); + } + + if (message) { + g_string_append(message_str, ": "); + g_string_append(message_str, message); + } + + win_save_print(window, '-', NULL, 0, COLOUR_ERROR, "", message_str->str); + + g_string_free(message_str, TRUE); +} + static void _ui_handle_room_config_submit_result(void) { @@ -2420,4 +2444,5 @@ ui_init_module(void) ui_show_form_help = _ui_show_form_help; ui_show_form_field_help = _ui_show_form_field_help; ui_show_lines = _ui_show_lines; + ui_handle_room_configuration_form_error = _ui_handle_room_configuration_form_error; } diff --git a/src/ui/ui.h b/src/ui/ui.h index 52a93521..33640637 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -161,6 +161,7 @@ void (*ui_handle_error)(const char * const err_msg); void (*ui_clear_win_title)(void); void (*ui_handle_room_join_error)(const char * const room, const char * const err); void (*ui_handle_room_configuration)(const char * const room, DataForm *form); +void (*ui_handle_room_configuration_form_error)(const char * const room, const char * const message); void (*ui_handle_room_config_submit_result)(void); void (*ui_show_form)(ProfWin *window, const char * const room, DataForm *form); void (*ui_show_form_field)(ProfWin *window, DataForm *form, char *tag);