1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Make all mucconfwin functions take ProfMucConfWin

This commit is contained in:
James Booth 2015-11-02 22:19:01 +00:00
parent 9106029261
commit 38255e9be4
5 changed files with 24 additions and 20 deletions

View File

@ -2485,11 +2485,11 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
if (g_strcmp0(value, "on") == 0) { if (g_strcmp0(value, "on") == 0) {
form_set_value(form, tag, "1"); form_set_value(form, tag, "1");
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} else if (g_strcmp0(value, "off") == 0) { } else if (g_strcmp0(value, "off") == 0) {
form_set_value(form, tag, "0"); form_set_value(form, tag, "0");
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} else { } else {
ui_current_print_line("Invalid command, usage:"); ui_current_print_line("Invalid command, usage:");
mucconfwin_field_help(confwin, tag); mucconfwin_field_help(confwin, tag);
@ -2508,7 +2508,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
} else { } else {
form_set_value(form, tag, value); form_set_value(form, tag, value);
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} }
break; break;
case FIELD_LIST_SINGLE: case FIELD_LIST_SINGLE:
@ -2520,7 +2520,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
} else { } else {
form_set_value(form, tag, value); form_set_value(form, tag, value);
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} }
break; break;
@ -2544,7 +2544,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
if (g_strcmp0(cmd, "add") == 0) { if (g_strcmp0(cmd, "add") == 0) {
form_add_value(form, tag, value); form_add_value(form, tag, value);
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
break; break;
} }
if (g_strcmp0(args[0], "remove") == 0) { if (g_strcmp0(args[0], "remove") == 0) {
@ -2572,7 +2572,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
removed = form_remove_text_multi_value(form, tag, index); removed = form_remove_text_multi_value(form, tag, index);
if (removed) { if (removed) {
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} else { } else {
ui_current_print_line("Could not remove %s from %s", value, tag); ui_current_print_line("Could not remove %s from %s", value, tag);
} }
@ -2601,7 +2601,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
added = form_add_unique_value(form, tag, value); added = form_add_unique_value(form, tag, value);
if (added) { if (added) {
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} else { } else {
ui_current_print_line("Value %s already selected for %s", value, tag); ui_current_print_line("Value %s already selected for %s", value, tag);
} }
@ -2618,7 +2618,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
removed = form_remove_value(form, tag, value); removed = form_remove_value(form, tag, value);
if (removed) { if (removed) {
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} else { } else {
ui_current_print_line("Value %s is not currently set for %s", value, tag); ui_current_print_line("Value %s is not currently set for %s", value, tag);
} }
@ -2650,7 +2650,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
added = form_add_unique_value(form, tag, value); added = form_add_unique_value(form, tag, value);
if (added) { if (added) {
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} else { } else {
ui_current_print_line("JID %s already exists in %s", value, tag); ui_current_print_line("JID %s already exists in %s", value, tag);
} }
@ -2660,7 +2660,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args)
removed = form_remove_value(form, tag, value); removed = form_remove_value(form, tag, value);
if (removed) { if (removed) {
ui_current_print_line("Field updated..."); ui_current_print_line("Field updated...");
mucconfwin_show_form_field(window, form, tag); mucconfwin_show_form_field(confwin, form, tag);
} else { } else {
ui_current_print_line("Field %s does not contain %s", tag, value); ui_current_print_line("Field %s does not contain %s", tag, value);
} }

View File

@ -75,21 +75,24 @@ mucconfwin_show_form(ProfMucConfWin *confwin)
} }
void void
mucconfwin_show_form_field(ProfWin *window, DataForm *form, char *tag) mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag)
{ {
assert(confwin != NULL);
FormField *field = form_get_field_by_tag(form, tag); FormField *field = form_get_field_by_tag(form, tag);
ProfWin *window = (ProfWin*)confwin;
_mucconfwin_form_field(window, tag, field); _mucconfwin_form_field(window, tag, field);
win_println(window, 0, ""); win_println(window, 0, "");
} }
void void
mucconfwin_handle_configuration(const char *const roomjid, DataForm *form) mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form)
{ {
ProfWin *window = wins_new_muc_config(roomjid, form); assert(confwin != NULL);
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
ProfWin *window = (ProfWin*)confwin;
ui_focus_win(window); ui_focus_win(window);
mucconfwin_show_form(confwin); mucconfwin_show_form(confwin);
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_print(window, '-', 0, NULL, 0, 0, "", "");

View File

@ -108,12 +108,12 @@ void ui_handle_recipient_error(const char *const recipient, const char *const er
void ui_handle_error(const char *const err_msg); void ui_handle_error(const char *const err_msg);
void ui_clear_win_title(void); void ui_clear_win_title(void);
void ui_goodbye_title(void); void ui_goodbye_title(void);
void mucconfwin_handle_configuration(const char *const roomjid, DataForm *form); void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
void ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message); void ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message);
void ui_handle_room_config_submit_result(const char *const roomjid); void ui_handle_room_config_submit_result(const char *const roomjid);
void ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message); void ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message);
void mucconfwin_show_form(ProfMucConfWin *confwin); void mucconfwin_show_form(ProfMucConfWin *confwin);
void mucconfwin_show_form_field(ProfWin *window, DataForm *form, char *tag); void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag);
void mucconfwin_form_help(ProfMucConfWin *confwin); void mucconfwin_form_help(ProfMucConfWin *confwin);
void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag); void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag);
void ui_show_lines(ProfWin *window, const gchar** lines); void ui_show_lines(ProfWin *window, const gchar** lines);

View File

@ -1260,7 +1260,8 @@ _room_config_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
} }
DataForm *form = form_create(x); DataForm *form = form_create(x);
mucconfwin_handle_configuration(from, form); ProfMucConfWin *confwin = (ProfMucConfWin*)wins_new_muc_config(from, form);
mucconfwin_handle_configuration(confwin, form);
return 0; return 0;
} }

View File

@ -244,7 +244,7 @@ void ui_handle_error(const char * const err_msg)
void ui_clear_win_title(void) {} void ui_clear_win_title(void) {}
void ui_goodbye_title(void) {} void ui_goodbye_title(void) {}
void mucconfwin_handle_configuration(const char * const roomjid, DataForm *form) {} void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form) {}
void ui_handle_room_configuration_form_error(const char * const roomjid, const char * const message) {} void ui_handle_room_configuration_form_error(const char * const roomjid, const char * const message) {}
void ui_handle_room_config_submit_result(const char * const roomjid) {} void ui_handle_room_config_submit_result(const char * const roomjid) {}
void ui_handle_room_config_submit_result_error(const char * const roomjid, const char * const message) {} void ui_handle_room_config_submit_result_error(const char * const roomjid, const char * const message) {}
@ -258,7 +258,7 @@ void mucwin_role_list_error(ProfMucWin *mucwin, const char * const role, const c
void mucwin_handle_role_list(ProfMucWin *mucwin, const char * const role, GSList *nicks) {} void mucwin_handle_role_list(ProfMucWin *mucwin, const char * const role, GSList *nicks) {}
void mucwin_kick_error(ProfMucWin *mucwin, const char * const nick, const char * const error) {} void mucwin_kick_error(ProfMucWin *mucwin, const char * const nick, const char * const error) {}
void mucconfwin_show_form(ProfMucConfWin *confwin) {} void mucconfwin_show_form(ProfMucConfWin *confwin) {}
void mucconfwin_show_form_field(ProfWin *window, DataForm *form, char *tag) {} void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag) {}
void mucconfwin_form_help(ProfMucConfWin *confwin) {} void mucconfwin_form_help(ProfMucConfWin *confwin) {}
void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) {} void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) {}
void ui_show_lines(ProfWin *window, const gchar** lines) {} void ui_show_lines(ProfWin *window, const gchar** lines) {}