diff options
author | James Booth <boothj5@gmail.com> | 2014-05-11 13:48:41 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-05-11 13:48:41 +0100 |
commit | f2ebbdb8de2725eae21419f18dce3f4ecffb6687 (patch) | |
tree | 14e3da1051d5a6a4073b2a3c82460f3024221d8f | |
parent | 015780662edad1ff959ed3451a38a446cadb9e75 (diff) | |
download | profani-tty-f2ebbdb8de2725eae21419f18dce3f4ecffb6687.tar.gz |
Added autocompletion for /account set <account> otr <policy>
-rw-r--r-- | src/command/command.c | 21 | ||||
-rw-r--r-- | src/command/commands.c | 9 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/command/command.c b/src/command/command.c index 3b111c55..a46c1548 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1028,6 +1028,7 @@ cmd_init(void) autocomplete_add(account_set_ac, "password"); autocomplete_add(account_set_ac, "muc"); autocomplete_add(account_set_ac, "nick"); + autocomplete_add(account_set_ac, "otr"); account_clear_ac = autocomplete_new(); autocomplete_add(account_clear_ac, "password"); @@ -1979,15 +1980,25 @@ _account_autocomplete(char *input, int *size) gboolean result = FALSE; input[*size] = '\0'; - gchar **args = parse_args(input, 3, 3, &result); + gchar **args = parse_args(input, 3, 4, &result); if ((strncmp(input, "/account set", 12) == 0) && (result == TRUE)) { GString *beginning = g_string_new("/account set "); g_string_append(beginning, args[1]); - found = autocomplete_param_with_ac(input, size, beginning->str, account_set_ac); - g_string_free(beginning, TRUE); - if (found != NULL) { - return found; + if ((g_strv_length(args) > 3) && (g_strcmp0(args[2], "otr")) == 0) { + g_string_append(beginning, " "); + g_string_append(beginning, args[2]); + found = autocomplete_param_with_ac(input, size, beginning->str, otr_policy_ac); + g_string_free(beginning, TRUE); + if (found != NULL) { + return found; + } + } else { + found = autocomplete_param_with_ac(input, size, beginning->str, account_set_ac); + g_string_free(beginning, TRUE); + if (found != NULL) { + return found; + } } } diff --git a/src/command/commands.c b/src/command/commands.c index b46815bb..d2232155 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -265,6 +265,15 @@ cmd_account(gchar **args, struct cmd_help_t help) accounts_set_muc_nick(account_name, value); cons_show("Updated muc nick for account %s: %s", account_name, value); cons_show(""); + } else if (strcmp(property, "otr") == 0) { + if ((g_strcmp0(value, "manual") != 0) + && (g_strcmp0(value, "opportunistic") != 0) + && (g_strcmp0(value, "always") != 0)) { + cons_show("Invalid setting."); + } else { + cons_show("Updated OTR policy for account %s: %s", account_name, value); + cons_show(""); + } } else if (strcmp(property, "status") == 0) { if (!valid_resource_presence_string(value) && (strcmp(value, "last") != 0)) { cons_show("Invalid status: %s", value); |