about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-09-14 16:23:25 +0100
committerJames Booth <boothj5@gmail.com>2014-09-14 16:23:25 +0100
commit8cfe80e979ddbc3ada0794020f313d59e23320aa (patch)
tree4b9c308f82d828fd429e422047aafb4199014120 /src/command
parentb6242fbd3d8749e3b68de7ca83d9252f0c192f83 (diff)
downloadprofani-tty-8cfe80e979ddbc3ada0794020f313d59e23320aa.tar.gz
Added setting of unique form list values
Diffstat (limited to 'src/command')
-rw-r--r--src/command/commands.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index fc3e5298..5dd5eb11 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1979,21 +1979,33 @@ cmd_room(gchar **args, struct cmd_help_t help)
             } else {
                 form_field_type_t field_type = form_get_field_type(current->form, tag);
                 gboolean valid = FALSE;
+                gboolean added = 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);
+                    if (valid) {
+                        added = form_add_unique_value(current->form, tag, value);
+                        if (added) {
+                            ui_current_print_line("Added %s to %s", value, tag);
+                        } else {
+                            ui_current_print_line("Value %s already selected for %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;
+                case FIELD_JID_MULTI:
+                    added = form_add_unique_value(current->form, tag, value);
+                    if (added) {
+                        ui_current_print_line("Added %s to %s", value, tag);
+                    } else {
+                        ui_current_print_line("JID %s already exists in %s", value, tag);
+                    }
+                    break;
                 default:
                     ui_current_print_line("Add command not valid for field: %s", tag);
                     break;