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

Handle result of room configuration submit

This commit is contained in:
James Booth 2014-09-17 21:48:55 +01:00
parent 672fcfe009
commit d2a06ab18e
5 changed files with 98 additions and 13 deletions

View File

@ -469,18 +469,24 @@ handle_room_configure(const char * const room, DataForm *form)
ui_handle_room_configuration(room, form); ui_handle_room_configuration(room, form);
} }
void
handle_room_config_submit_result(void)
{
ui_handle_room_config_submit_result();
}
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)
{ {
ui_handle_room_configuration_form_error(room, message); ui_handle_room_configuration_form_error(room, message);
} }
void
handle_room_config_submit_result(const char * const room)
{
ui_handle_room_config_submit_result(room);
}
void
handle_room_config_submit_result_error(const char * const room, const char * const message)
{
ui_handle_room_config_submit_result_error(room, message);
}
void void
handle_room_roster_complete(const char * const room) handle_room_roster_complete(const char * const room)
{ {

View File

@ -98,6 +98,7 @@ void handle_ping_result(const char * const from, int millis);
void handle_ping_error_result(const char * const from, const char * const error); void handle_ping_error_result(const char * const from, const char * const error);
void handle_room_configure(const char * const room, DataForm *form); void handle_room_configure(const char * const room, DataForm *form);
void handle_room_configuration_form_error(const char * const from, const char * const message); void handle_room_configuration_form_error(const char * const from, const char * const message);
void handle_room_config_submit_result(void); void handle_room_config_submit_result(const char * const room);
void handle_room_config_submit_result_error(const char * const room, const char * const message);
#endif #endif

View File

@ -2093,9 +2093,75 @@ _ui_handle_room_configuration_form_error(const char * const room, const char * c
} }
static void static void
_ui_handle_room_config_submit_result(void) _ui_handle_room_config_submit_result(const char * const room)
{ {
cons_show("GOT ROOM CONFIG SUBMIT RESULT!!!!"); ProfWin *muc_window = NULL;
ProfWin *form_window = NULL;
int num;
if (room) {
GString *form_recipient = g_string_new(room);
g_string_append(form_recipient, " config");
muc_window = wins_get_by_recipient(room);
form_window = wins_get_by_recipient(form_recipient->str);
g_string_free(form_recipient, TRUE);
if (form_window) {
num = wins_get_num(form_window);
wins_close_by_num(num);
}
if (muc_window) {
int num = wins_get_num(muc_window);
ui_switch_win(num);
win_save_print(muc_window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room configuration successfull");
} else {
ui_switch_win(1);
cons_show("Room configuration successfull: %s", room);
}
} else {
cons_show("Room configuration successful");
}
}
static void
_ui_handle_room_config_submit_result_error(const char * const room, const char * const message)
{
ProfWin *console = wins_get_console();
ProfWin *muc_window = NULL;
ProfWin *form_window = NULL;
if (room) {
GString *form_recipient = g_string_new(room);
g_string_append(form_recipient, " config");
muc_window = wins_get_by_recipient(room);
form_window = wins_get_by_recipient(form_recipient->str);
g_string_free(form_recipient, TRUE);
if (form_window) {
if (message) {
win_save_vprint(form_window, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error: %s", message);
} else {
win_save_print(form_window, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error");
}
} else if (muc_window) {
if (message) {
win_save_vprint(muc_window, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error: %s", message);
} else {
win_save_print(muc_window, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error");
}
} else {
if (message) {
win_save_vprint(console, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error for %s: %s", room, message);
} else {
win_save_vprint(console, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error for %s", room);
}
}
} else {
win_save_print(console, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error");
}
} }
static void static void
@ -2438,6 +2504,7 @@ ui_init_module(void)
ui_room_destroyed = _ui_room_destroyed; ui_room_destroyed = _ui_room_destroyed;
ui_handle_room_configuration = _ui_handle_room_configuration; ui_handle_room_configuration = _ui_handle_room_configuration;
ui_handle_room_config_submit_result = _ui_handle_room_config_submit_result; ui_handle_room_config_submit_result = _ui_handle_room_config_submit_result;
ui_handle_room_config_submit_result_error = _ui_handle_room_config_submit_result_error;
ui_win_has_unsaved_form = _ui_win_has_unsaved_form; ui_win_has_unsaved_form = _ui_win_has_unsaved_form;
ui_show_form = _ui_show_form; ui_show_form = _ui_show_form;
ui_show_form_field = _ui_show_form_field; ui_show_form_field = _ui_show_form_field;

View File

@ -162,7 +162,8 @@ 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_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)(const char * const room);
void (*ui_handle_room_config_submit_result_error)(const char * const room, const char * const message);
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);
void (*ui_show_form_help)(ProfWin *window, DataForm *form); void (*ui_show_form_help)(ProfWin *window, DataForm *form);

View File

@ -666,14 +666,24 @@ _room_config_submit_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan
void * const userdata) void * const userdata)
{ {
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
const char *type = xmpp_stanza_get_type(stanza);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
if (id != NULL) { if (id != NULL) {
log_debug("IQ room config handler fired, id: %s.", id); log_debug("IQ room config submit handler fired, id: %s.", id);
} else { } else {
log_debug("IQ room config handler fired."); log_debug("IQ room config submit handler fired.");
} }
handle_room_config_submit_result(); // handle error responses
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
char *error_message = stanza_get_error_message(stanza);
handle_room_config_submit_result_error(from, error_message);
free(error_message);
return 0;
}
handle_room_config_submit_result(from);
return 0; return 0;
} }