1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added autocompletion for /account set <account> otr <policy>

This commit is contained in:
James Booth 2014-05-11 13:48:41 +01:00
parent 015780662e
commit f2ebbdb8de
2 changed files with 25 additions and 5 deletions

View File

@ -1028,6 +1028,7 @@ cmd_init(void)
autocomplete_add(account_set_ac, "password"); autocomplete_add(account_set_ac, "password");
autocomplete_add(account_set_ac, "muc"); autocomplete_add(account_set_ac, "muc");
autocomplete_add(account_set_ac, "nick"); autocomplete_add(account_set_ac, "nick");
autocomplete_add(account_set_ac, "otr");
account_clear_ac = autocomplete_new(); account_clear_ac = autocomplete_new();
autocomplete_add(account_clear_ac, "password"); autocomplete_add(account_clear_ac, "password");
@ -1979,17 +1980,27 @@ _account_autocomplete(char *input, int *size)
gboolean result = FALSE; gboolean result = FALSE;
input[*size] = '\0'; 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)) { if ((strncmp(input, "/account set", 12) == 0) && (result == TRUE)) {
GString *beginning = g_string_new("/account set "); GString *beginning = g_string_new("/account set ");
g_string_append(beginning, args[1]); g_string_append(beginning, args[1]);
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); found = autocomplete_param_with_ac(input, size, beginning->str, account_set_ac);
g_string_free(beginning, TRUE); g_string_free(beginning, TRUE);
if (found != NULL) { if (found != NULL) {
return found; return found;
} }
} }
}
if ((strncmp(input, "/account clear", 14) == 0) && (result == TRUE)) { if ((strncmp(input, "/account clear", 14) == 0) && (result == TRUE)) {
GString *beginning = g_string_new("/account clear "); GString *beginning = g_string_new("/account clear ");

View File

@ -265,6 +265,15 @@ cmd_account(gchar **args, struct cmd_help_t help)
accounts_set_muc_nick(account_name, value); accounts_set_muc_nick(account_name, value);
cons_show("Updated muc nick for account %s: %s", account_name, value); cons_show("Updated muc nick for account %s: %s", account_name, value);
cons_show(""); 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) { } else if (strcmp(property, "status") == 0) {
if (!valid_resource_presence_string(value) && (strcmp(value, "last") != 0)) { if (!valid_resource_presence_string(value) && (strcmp(value, "last") != 0)) {
cons_show("Invalid status: %s", value); cons_show("Invalid status: %s", value);