feat: improve autocomplete for JIDs (#164) #167

Open
jabber.developer wants to merge 2 commits from feat/disco-ac into master
2 changed files with 121 additions and 92 deletions
Showing only changes of commit b7dec705c3 - Show all commits

View File

@@ -1866,12 +1866,14 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
} }
gchar* history_jid_subcmds[] = { "/history verify", "/history export", "/history import" }; gchar* history_jid_subcmds[] = { "/history verify", "/history export", "/history import" };
if (conn_status == JABBER_CONNECTED) {
for (size_t i = 0; i < ARRAY_SIZE(history_jid_subcmds); i++) { for (size_t i = 0; i < ARRAY_SIZE(history_jid_subcmds); i++) {
result = autocomplete_param_with_func(input, history_jid_subcmds[i], roster_barejid_autocomplete, previous, NULL); result = autocomplete_param_with_func(input, history_jid_subcmds[i], roster_barejid_autocomplete, previous, NULL);
if (result) { if (result) {
return result; return result;
} }
} }
}
result = autocomplete_param_with_ac(input, "/history", history_ac, TRUE, previous); result = autocomplete_param_with_ac(input, "/history", history_ac, TRUE, previous);
if (result) { if (result) {
@@ -3735,7 +3737,7 @@ _win_autocomplete(ProfWin* window, const char* const input, gboolean previous)
} }
char* unquoted = strip_arg_quotes(input); char* unquoted = strip_arg_quotes(input);
result = autocomplete_param_with_func(unquoted, "/win", roster_contact_autocomplete, previous, NULL); result = _roster_jid_autocomplete(input, "/win", previous);
free(unquoted); free(unquoted);
return result; return result;
} }
@@ -4230,14 +4232,12 @@ _software_autocomplete(ProfWin* window, const char* const input, gboolean previo
{ {
char* result = NULL; char* result = NULL;
if (window->type == WIN_CHAT) { if (window->type == WIN_CHAT && _is_connected()) {
ProfChatWin* chatwin = (ProfChatWin*)window; ProfChatWin* chatwin = (ProfChatWin*)window;
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
GString* search_str = g_string_new("/software "); auto_gchar gchar* search_str = g_strdup_printf("/software %s", chatwin->barejid);
g_string_append(search_str, chatwin->barejid); result = autocomplete_param_with_func(search_str, "/software", roster_fulljid_autocomplete, previous, NULL);
result = autocomplete_param_with_func(search_str->str, "/software", roster_fulljid_autocomplete, previous, NULL);
g_string_free(search_str, TRUE);
} else if (window->type == WIN_MUC) { } else if (window->type == WIN_MUC) {
ProfMucWin* mucwin = (ProfMucWin*)window; ProfMucWin* mucwin = (ProfMucWin*)window;
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);