1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Show errors in room when can't retrieve room config

This commit is contained in:
James Booth 2014-09-17 20:59:56 +01:00
parent 2a555157c3
commit 672fcfe009
3 changed files with 27 additions and 13 deletions

View File

@ -478,19 +478,7 @@ handle_room_config_submit_result(void)
void void
handle_room_configuration_form_error(const char * const room, const char * const message) handle_room_configuration_form_error(const char * const room, const char * const message)
{ {
if (room != NULL) { ui_handle_room_configuration_form_error(room, message);
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.");
}
}
} }
void void

View File

@ -2068,6 +2068,30 @@ _ui_handle_room_configuration(const char * const room, DataForm *form)
ui_show_form(window, room, 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 static void
_ui_handle_room_config_submit_result(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_help = _ui_show_form_help;
ui_show_form_field_help = _ui_show_form_field_help; ui_show_form_field_help = _ui_show_form_field_help;
ui_show_lines = _ui_show_lines; ui_show_lines = _ui_show_lines;
ui_handle_room_configuration_form_error = _ui_handle_room_configuration_form_error;
} }

View File

@ -161,6 +161,7 @@ void (*ui_handle_error)(const char * const err_msg);
void (*ui_clear_win_title)(void); void (*ui_clear_win_title)(void);
void (*ui_handle_room_join_error)(const char * const room, const char * const err); 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)(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_handle_room_config_submit_result)(void);
void (*ui_show_form)(ProfWin *window, const char * const room, DataForm *form); void (*ui_show_form)(ProfWin *window, const char * const room, DataForm *form);
void (*ui_show_form_field)(ProfWin *window, DataForm *form, char *tag); void (*ui_show_form_field)(ProfWin *window, DataForm *form, char *tag);