diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-06-06 15:58:05 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-06-06 16:01:19 +0200 |
commit | 1e723970ded1579fa7fd06bc0ab7c445fcfd9b5d (patch) | |
tree | 1632c64d638ba6f23fd865f6698498cb14270e97 | |
parent | c03f9363902fbea96c8a2d35c945b52b27c3f701 (diff) | |
download | profani-tty-1e723970ded1579fa7fd06bc0ab7c445fcfd9b5d.tar.gz |
Only complete certain omemo commands if connected
Some of the omemo commands depend on the roster being present. Several of those functions call `assert()` if that's not the case. Modify omemo autocompletion in such a way that only things that don't need the roster will be completed. Only works on first level. When typing `/omemo` it will still complete to `/omemo start` but not offer suggestions for that, but print a message that you need to be connected. Fix https://github.com/profanity-im/profanity/issues/1117
-rw-r--r-- | src/command/cmd_ac.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 5d1dff12..7e3837bc 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -2183,47 +2183,48 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous) { char *found = NULL; - jabber_conn_status_t conn_status = connection_get_status(); - - if (conn_status == JABBER_CONNECTED) { - found = autocomplete_param_with_func(input, "/omemo start", roster_contact_autocomplete, previous); - if (found) { - return found; - } + found = autocomplete_param_with_ac(input, "/omemo log", omemo_log_ac, TRUE, previous); + if (found) { + return found; } - found = autocomplete_param_with_func(input, "/omemo fingerprint", roster_contact_autocomplete, previous); + found = autocomplete_param_with_ac(input, "/omemo policy", omemo_policy_ac, TRUE, previous); if (found) { return found; } -#ifdef HAVE_OMEMO - if (window->type == WIN_CHAT) { - found = autocomplete_param_with_func(input, "/omemo trust", omemo_fingerprint_autocomplete, previous); - if (found) { - return found; - } - } else { - found = autocomplete_param_with_func(input, "/omemo trust", roster_contact_autocomplete, previous); + jabber_conn_status_t conn_status = connection_get_status(); + + if (conn_status == JABBER_CONNECTED) { + found = autocomplete_param_with_func(input, "/omemo start", roster_contact_autocomplete, previous); if (found) { return found; } - found = autocomplete_param_no_with_func(input, "/omemo trust", 4, omemo_fingerprint_autocomplete, previous); + found = autocomplete_param_with_func(input, "/omemo fingerprint", roster_contact_autocomplete, previous); if (found) { return found; } - } -#endif - found = autocomplete_param_with_ac(input, "/omemo log", omemo_log_ac, TRUE, previous); - if (found) { - return found; - } - found = autocomplete_param_with_ac(input, "/omemo policy", omemo_policy_ac, TRUE, previous); - if (found) { - return found; +#ifdef HAVE_OMEMO + if (window->type == WIN_CHAT) { + found = autocomplete_param_with_func(input, "/omemo trust", omemo_fingerprint_autocomplete, previous); + if (found) { + return found; + } + } else { + found = autocomplete_param_with_func(input, "/omemo trust", roster_contact_autocomplete, previous); + if (found) { + return found; + } + + found = autocomplete_param_no_with_func(input, "/omemo trust", 4, omemo_fingerprint_autocomplete, previous); + if (found) { + return found; + } + } +#endif } found = autocomplete_param_with_ac(input, "/omemo", omemo_ac, TRUE, previous); |