diff options
-rw-r--r-- | ROOM_CONF_TODO | 3 | ||||
-rw-r--r-- | src/command/command.c | 8 | ||||
-rw-r--r-- | src/command/commands.c | 7 | ||||
-rw-r--r-- | src/ui/core.c | 29 | ||||
-rw-r--r-- | src/ui/ui.h | 1 |
5 files changed, 32 insertions, 16 deletions
diff --git a/ROOM_CONF_TODO b/ROOM_CONF_TODO index f4126b73..82c9b6d3 100644 --- a/ROOM_CONF_TODO +++ b/ROOM_CONF_TODO @@ -1,5 +1,4 @@ +Show field after setting/adding/removing Help command for form fields -Command to show current form Handle error on form submit -Show field after setting/adding/removing Autocompelte values for set/add/remove diff --git a/src/command/command.c b/src/command/command.c index d0b38f55..0f820a33 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -317,12 +317,13 @@ static struct cmd_t command_defs[] = { "/form", cmd_form, parse_args, 1, 3, NULL, - { "/form submit|cancel|set|add|remove [tag value]", "Form manipulation.", - { "/form submit|cancel|set|add|remove [tag value]", - "----------------------------------------------", + { "/form show|submit|cancel|set|add|remove [tag value]", "Form manipulation.", + { "/form show|submit|cancel|set|add|remove [tag value]", + "---------------------------------------------------", "set tag value - Set tagged form field to value.", "add tag value - Add value to tagged form field.", "remove tag value - Remove value from tagged form field.", + "show - Show the current form.", "submit - Submit the current form.", "cancel - Cancel changes to the current form.", NULL } } }, @@ -1228,6 +1229,7 @@ cmd_init(void) form_ac = autocomplete_new(); autocomplete_add(form_ac, "submit"); autocomplete_add(form_ac, "cancel"); + autocomplete_add(form_ac, "show"); autocomplete_add(form_ac, "set"); autocomplete_add(form_ac, "add"); autocomplete_add(form_ac, "remove"); diff --git a/src/command/commands.c b/src/command/commands.c index c2a85b23..0f181f31 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1805,6 +1805,7 @@ cmd_form(gchar **args, struct cmd_help_t help) if ((g_strcmp0(args[0], "submit") != 0) && (g_strcmp0(args[0], "cancel") != 0) && + (g_strcmp0(args[0], "show") != 0) && (g_strcmp0(args[0], "set") != 0) && (g_strcmp0(args[0], "add") != 0) && (g_strcmp0(args[0], "remove") != 0)) { @@ -1817,6 +1818,12 @@ cmd_form(gchar **args, struct cmd_help_t help) gchar **split_recipient = g_strsplit(recipient, " ", 2); char *room = split_recipient[0]; + if (g_strcmp0(args[0], "show") == 0) { + ui_show_form(current, room, current->form); + g_strfreev(split_recipient); + return TRUE; + } + if (g_strcmp0(args[0], "submit") == 0) { iq_submit_room_config(room, current->form); diff --git a/src/ui/core.c b/src/ui/core.c index 5dd28e0c..051d8189 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2016,18 +2016,8 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field) } static void -_ui_handle_room_configuration(const char * const room, DataForm *form) +_ui_show_form(ProfWin *window, const char * const room, DataForm *form) { - GString *title = g_string_new(room); - g_string_append(title, " config"); - ProfWin *window = wins_new(title->str, WIN_MUC_CONFIG); - g_string_free(title, TRUE); - - window->form = form; - - int num = wins_get_num(window); - ui_switch_win(num); - if (form->title != NULL) { win_save_print(window, '-', NULL, 0, 0, "", form->title); } else { @@ -2065,6 +2055,22 @@ TODO add command to get help for a field } static void +_ui_handle_room_configuration(const char * const room, DataForm *form) +{ + GString *title = g_string_new(room); + g_string_append(title, " config"); + ProfWin *window = wins_new(title->str, WIN_MUC_CONFIG); + g_string_free(title, TRUE); + + window->form = form; + + int num = wins_get_num(window); + ui_switch_win(num); + + ui_show_form(window, room, form); +} + +static void _ui_handle_room_config_submit_result(void) { cons_show("GOT ROOM CONFIG SUBMIT RESULT!!!!"); @@ -2310,4 +2316,5 @@ ui_init_module(void) ui_handle_room_configuration = _ui_handle_room_configuration; ui_handle_room_config_submit_result = _ui_handle_room_config_submit_result; ui_win_has_unsaved_form = _ui_win_has_unsaved_form; + ui_show_form = _ui_show_form; } diff --git a/src/ui/ui.h b/src/ui/ui.h index 6e9cb9e7..51eed7b5 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -162,6 +162,7 @@ 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_config_submit_result)(void); +void (*ui_show_form)(ProfWin *window, const char * const room, DataForm *form); // contact status functions void (*ui_status_room)(const char * const contact); |