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:
parent
015780662e
commit
f2ebbdb8de
@ -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,17 +1980,27 @@ _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]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((strncmp(input, "/account clear", 14) == 0) && (result == TRUE)) {
|
||||
GString *beginning = g_string_new("/account clear ");
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user