diff --git a/src/command/command.c b/src/command/command.c index 5b78d3e7..2a9efc0f 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -65,6 +65,7 @@ #include "xmpp/xmpp.h" #include "xmpp/bookmark.h" #include "ui/ui.h" +#include "ui/windows.h" typedef char*(*autocompleter)(char*, int*); @@ -2078,6 +2079,17 @@ _room_autocomplete(char *input, int *size) { char *result = NULL; + ProfWin *current = wins_get_current(); + if (current != NULL) { + DataForm *form = current->form; + if (form != NULL) { + result = autocomplete_param_with_ac(input, size, "/room set", form->tag_ac, TRUE); + if (result != NULL) { + return result; + } + } + } + result = autocomplete_param_with_ac(input, size, "/room", room_ac, TRUE); if (result != NULL) { return result; diff --git a/src/xmpp/form.c b/src/xmpp/form.c index d3f588c7..59aa6304 100644 --- a/src/xmpp/form.c +++ b/src/xmpp/form.c @@ -190,6 +190,7 @@ form_create(xmpp_stanza_t * const form_stanza) form->instructions = _get_property(form_stanza, "instructions"); form->var_to_tag = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); form->tag_to_var = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); + form->tag_ac = autocomplete_new(); int tag_num = 1; @@ -210,6 +211,7 @@ form_create(xmpp_stanza_t * const form_stanza) g_string_printf(tag, "field%d", tag_num++); g_hash_table_insert(form->var_to_tag, strdup(field->var), strdup(tag->str)); g_hash_table_insert(form->tag_to_var, strdup(tag->str), strdup(field->var)); + autocomplete_add(form->tag_ac, tag->str); g_string_free(tag, TRUE); field->description = _get_property(field_stanza, "desc"); @@ -363,6 +365,7 @@ _form_destroy(DataForm *form) g_slist_free_full(form->fields, (GDestroyNotify)_free_field); g_hash_table_destroy(form->var_to_tag); g_hash_table_destroy(form->tag_to_var); + autocomplete_free(form->tag_ac); free(form); } } diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 1637e87d..aaa8bbd2 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -40,6 +40,7 @@ #include "config/accounts.h" #include "contact.h" #include "jid.h" +#include "tools/autocomplete.h" #define JABBER_PRIORITY_MIN -128 #define JABBER_PRIORITY_MAX 127 @@ -123,6 +124,7 @@ typedef struct data_form_t { GSList *fields; GHashTable *var_to_tag; GHashTable *tag_to_var; + Autocomplete tag_ac; } DataForm; void jabber_init_module(void);