diff options
author | James Booth <boothj5@gmail.com> | 2014-09-14 00:18:06 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-14 00:18:06 +0100 |
commit | 68b839a50870184d13970401035b462b6fb7087f (patch) | |
tree | baeabfb0f9847d376dabe724f6a789e4b9592751 /src/command/commands.c | |
parent | b52911f7b4de2212dd699eb0419ae4e442497a03 (diff) | |
download | profani-tty-68b839a50870184d13970401035b462b6fb7087f.tar.gz |
Added /room add for *-multi
Diffstat (limited to 'src/command/commands.c')
-rw-r--r-- | src/command/commands.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index 81e8660b..57687ea9 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1921,37 +1921,37 @@ cmd_room(gchar **args, struct cmd_help_t help) if (!form_tag_exists(current->form, tag)) { ui_current_print_line("Form does not contain a field with tag %s", tag); } else { - form_field_type_t field_type = form_get_field_type_by_tag(current->form, tag); + form_field_type_t field_type = form_get_field_type(current->form, tag); gboolean valid = FALSE; switch (field_type) { case FIELD_TEXT_SINGLE: case FIELD_TEXT_PRIVATE: case FIELD_JID_SINGLE: - form_set_value_by_tag(current->form, tag, value); + form_set_value(current->form, tag, value); ui_current_print_line("%s set to %s", tag, value); break; case FIELD_BOOLEAN: if (g_strcmp0(value, "on") == 0) { - form_set_value_by_tag(current->form, tag, "1"); + form_set_value(current->form, tag, "1"); ui_current_print_line("%s set to %s", tag, value); } else if (g_strcmp0(value, "off") == 0) { - form_set_value_by_tag(current->form, tag, "0"); + form_set_value(current->form, tag, "0"); ui_current_print_line("%s set to %s", tag, value); } else { ui_current_print_line("Value %s not valid for boolean field: %s", value, tag); } break; case FIELD_LIST_SINGLE: - valid = form_field_contains_option_by_tag(current->form, tag, value); + valid = form_field_contains_option(current->form, tag, value); if (valid == TRUE) { - form_set_value_by_tag(current->form, tag, value); + form_set_value(current->form, tag, value); ui_current_print_line("%s set to %s", tag, value); } else { ui_current_print_line("Value %s not a valid option for field: %s", value, tag); } break; default: - ui_current_print_line("Set command not valid for field: %s", value, tag); + ui_current_print_line("Set command not valid for field: %s", tag); break; } } @@ -1977,7 +1977,27 @@ cmd_room(gchar **args, struct cmd_help_t help) if (!form_tag_exists(current->form, tag)) { ui_current_print_line("Form does not contain a field with tag %s", tag); } else { - ui_current_print_line("Add Tag: %s, Value: %s", tag, value); + form_field_type_t field_type = form_get_field_type(current->form, tag); + gboolean valid = FALSE; + switch (field_type) { + case FIELD_LIST_MULTI: + valid = form_field_contains_option(current->form, tag, value); + if (valid == TRUE) { + form_add_value(current->form, tag, value); + ui_current_print_line("Added %s to %s", value, tag); + } else { + ui_current_print_line("Value %s not a valid option for field: %s", value, tag); + } + break; + case FIELD_TEXT_MULTI: + case FIELD_JID_MULTI: + form_add_value(current->form, tag, value); + ui_current_print_line("Added %s to %s", value, tag); + break; + default: + ui_current_print_line("Add command not valid for field: %s", tag); + break; + } } } |