mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
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
This commit is contained in:
parent
c03f936390
commit
1e723970de
@ -2183,6 +2183,16 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
|||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
jabber_conn_status_t conn_status = connection_get_status();
|
jabber_conn_status_t conn_status = connection_get_status();
|
||||||
|
|
||||||
if (conn_status == JABBER_CONNECTED) {
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
@ -2190,13 +2200,13 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
|||||||
if (found) {
|
if (found) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
found = autocomplete_param_with_func(input, "/omemo fingerprint", roster_contact_autocomplete, previous);
|
found = autocomplete_param_with_func(input, "/omemo fingerprint", roster_contact_autocomplete, previous);
|
||||||
if (found) {
|
if (found) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OMEMO
|
#ifdef HAVE_OMEMO
|
||||||
if (window->type == WIN_CHAT) {
|
if (window->type == WIN_CHAT) {
|
||||||
found = autocomplete_param_with_func(input, "/omemo trust", omemo_fingerprint_autocomplete, previous);
|
found = autocomplete_param_with_func(input, "/omemo trust", omemo_fingerprint_autocomplete, previous);
|
||||||
@ -2215,15 +2225,6 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found = autocomplete_param_with_ac(input, "/omemo", omemo_ac, TRUE, previous);
|
found = autocomplete_param_with_ac(input, "/omemo", omemo_ac, TRUE, previous);
|
||||||
|
Loading…
Reference in New Issue
Block a user