diff options
author | James Booth <boothj5@gmail.com> | 2014-05-11 15:59:11 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-05-11 15:59:11 +0100 |
commit | 2aa39fc362fd9ab681e86d87eeb7109973416a21 (patch) | |
tree | 6ebcd0eeefb61f182b70aee6dc85944f6c584faa /src | |
parent | 3967b26aea502e9773651a3992925af510ddffa4 (diff) | |
download | profani-tty-2aa39fc362fd9ab681e86d87eeb7109973416a21.tar.gz |
Add contact to /otr policy autocomplete
Diffstat (limited to 'src')
-rw-r--r-- | src/command/command.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/command/command.c b/src/command/command.c index 9015fd2a..65c56ab3 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1803,32 +1803,48 @@ _autoconnect_autocomplete(char *input, int *size) static char * _otr_autocomplete(char *input, int *size) { - char *result = NULL; + char *found = NULL; - result = autocomplete_param_with_func(input, size, "/otr start", roster_find_contact); - if (result != NULL) { - return result; + found = autocomplete_param_with_func(input, size, "/otr start", roster_find_contact); + if (found != NULL) { + return found; } - result = autocomplete_param_with_ac(input, size, "/otr log", otr_log_ac); - if (result != NULL) { - return result; + found = autocomplete_param_with_ac(input, size, "/otr log", otr_log_ac); + if (found != NULL) { + return found; } - result = autocomplete_param_with_ac(input, size, "/otr policy", otr_policy_ac); - if (result != NULL) { - return result; + // /otr policy always user@server.com + gboolean result; + gchar **args = parse_args(input, 3, 3, &result); + if (result && (strcmp(args[0], "policy") == 0)) { + GString *beginning = g_string_new("/otr "); + g_string_append(beginning, args[0]); + g_string_append(beginning, " "); + g_string_append(beginning, args[1]); + + found = autocomplete_param_with_func(input, size, beginning->str, roster_find_contact); + g_string_free(beginning, TRUE); + if (found != NULL) { + return found; + } + } + + found = autocomplete_param_with_ac(input, size, "/otr policy", otr_policy_ac); + if (found != NULL) { + return found; } - result = autocomplete_param_with_func(input, size, "/otr warn", + found = autocomplete_param_with_func(input, size, "/otr warn", prefs_autocomplete_boolean_choice); - if (result != NULL) { - return result; + if (found != NULL) { + return found; } - result = autocomplete_param_with_ac(input, size, "/otr", otr_ac); - if (result != NULL) { - return result; + found = autocomplete_param_with_ac(input, size, "/otr", otr_ac); + if (found != NULL) { + return found; } return NULL; |