diff options
author | James Booth <boothj5@gmail.com> | 2014-09-13 23:45:56 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-13 23:45:56 +0100 |
commit | b52911f7b4de2212dd699eb0419ae4e442497a03 (patch) | |
tree | 9814e34ed4eb80aa4fa683b50d98cceceb0f649a /src/command/commands.c | |
parent | 0239a81c382bcf1e793b35770b9bb5fd45b01836 (diff) | |
download | profani-tty-b52911f7b4de2212dd699eb0419ae4e442497a03.tar.gz |
Added add/remove subcommands to room config
Diffstat (limited to 'src/command/commands.c')
-rw-r--r-- | src/command/commands.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index e7409a3e..81e8660b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1810,6 +1810,8 @@ cmd_room(gchar **args, struct cmd_help_t help) (g_strcmp0(args[0], "config") != 0) && (g_strcmp0(args[0], "submit") != 0) && (g_strcmp0(args[0], "set") != 0) && + (g_strcmp0(args[0], "add") != 0) && + (g_strcmp0(args[0], "remove") != 0) && (g_strcmp0(args[0], "cancel") != 0)) { cons_show("Usage: %s", help.usage); return TRUE; @@ -1819,6 +1821,8 @@ cmd_room(gchar **args, struct cmd_help_t help) if (win_type == WIN_MUC && ((g_strcmp0(args[0], "submit") == 0) || (g_strcmp0(args[0], "cancel") == 0) || + (g_strcmp0(args[0], "add") == 0) || + (g_strcmp0(args[0], "remove") == 0) || (g_strcmp0(args[0], "set") == 0))) { cons_show("Command '/room %s' only allowed in room configuration windows.", args[0]); return TRUE; @@ -1882,6 +1886,8 @@ cmd_room(gchar **args, struct cmd_help_t help) // commands allowed in room config if ((g_strcmp0(args[0], "submit") == 0) || (g_strcmp0(args[0], "cancel") == 0) || + (g_strcmp0(args[0], "add") == 0) || + (g_strcmp0(args[0], "remove") == 0) || (g_strcmp0(args[0], "set") == 0)) { ProfWin *current = wins_get_current(); @@ -1945,12 +1951,60 @@ cmd_room(gchar **args, struct cmd_help_t help) } break; default: - ui_current_print_line("Value %s not valid for field: %s", value, tag); + ui_current_print_line("Set command not valid for field: %s", value, tag); break; } } } + if (g_strcmp0(args[0], "add") == 0) { + char *tag = NULL; + char *value = NULL; + if (args[1] != NULL) { + tag = args[1]; + } else { + ui_current_print_line("/room add command requires a field tag and value"); + g_strfreev(split_recipient); + return TRUE; + } + if (args[2] != NULL) { + value = args[2]; + } else { + ui_current_print_line("/room add command requires a field tag and value"); + g_strfreev(split_recipient); + return TRUE; + } + 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); + } + } + + if (g_strcmp0(args[0], "remove") == 0) { + char *tag = NULL; + char *value = NULL; + if (args[1] != NULL) { + tag = args[1]; + } else { + ui_current_print_line("/room remove command requires a field tag and value"); + g_strfreev(split_recipient); + return TRUE; + } + if (args[2] != NULL) { + value = args[2]; + } else { + ui_current_print_line("/room remove command requires a field tag and value"); + g_strfreev(split_recipient); + return TRUE; + } + 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("Remove Tag: %s, Value: %s", tag, value); + } + } + if ((g_strcmp0(args[0], "submit") == 0) || (g_strcmp0(args[0], "cancel") == 0)) { wins_close_current(); |