mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 23:36:21 +00:00
Added /resource autocompletion
This commit is contained in:
@@ -95,6 +95,7 @@ static char * _kick_autocomplete(char *input, int *size);
|
||||
static char * _ban_autocomplete(char *input, int *size);
|
||||
static char * _affiliation_autocomplete(char *input, int *size);
|
||||
static char * _role_autocomplete(char *input, int *size);
|
||||
static char * _resource_autocomplete(char *input, int *size);
|
||||
|
||||
GHashTable *commands = NULL;
|
||||
|
||||
@@ -1092,6 +1093,7 @@ static Autocomplete form_field_multi_ac;
|
||||
static Autocomplete occupants_ac;
|
||||
static Autocomplete occupants_default_ac;
|
||||
static Autocomplete time_ac;
|
||||
static Autocomplete resource_ac;
|
||||
|
||||
/*
|
||||
* Initialise command autocompleter and history
|
||||
@@ -1426,6 +1428,14 @@ cmd_init(void)
|
||||
autocomplete_add(time_ac, "seconds");
|
||||
autocomplete_add(time_ac, "off");
|
||||
|
||||
time_ac = autocomplete_new();
|
||||
autocomplete_add(time_ac, "minutes");
|
||||
autocomplete_add(time_ac, "seconds");
|
||||
|
||||
resource_ac = autocomplete_new();
|
||||
autocomplete_add(resource_ac, "set");
|
||||
autocomplete_add(resource_ac, "off");
|
||||
|
||||
cmd_history_init();
|
||||
}
|
||||
|
||||
@@ -1480,6 +1490,7 @@ cmd_uninit(void)
|
||||
autocomplete_free(occupants_ac);
|
||||
autocomplete_free(occupants_default_ac);
|
||||
autocomplete_free(time_ac);
|
||||
autocomplete_free(resource_ac);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -1651,6 +1662,7 @@ cmd_reset_autocomplete()
|
||||
autocomplete_reset(occupants_ac);
|
||||
autocomplete_reset(occupants_default_ac);
|
||||
autocomplete_reset(time_ac);
|
||||
autocomplete_reset(resource_ac);
|
||||
|
||||
if (ui_current_win_type() == WIN_MUC_CONFIG) {
|
||||
ProfWin *window = wins_get_current();
|
||||
@@ -1659,6 +1671,14 @@ cmd_reset_autocomplete()
|
||||
}
|
||||
}
|
||||
|
||||
if (ui_current_win_type() == WIN_CHAT) {
|
||||
char *recipient = ui_current_recipient();
|
||||
PContact contact = roster_get_contact(recipient);
|
||||
if (contact) {
|
||||
p_contact_resource_ac_reset(contact);
|
||||
}
|
||||
}
|
||||
|
||||
bookmark_autocomplete_reset();
|
||||
}
|
||||
|
||||
@@ -1959,6 +1979,7 @@ _cmd_complete_parameters(char *input, int *size)
|
||||
g_hash_table_insert(ac_funcs, "/ban", _ban_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/affiliation", _affiliation_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/role", _role_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/resource", _resource_autocomplete);
|
||||
|
||||
char parsed[*size+1];
|
||||
i = 0;
|
||||
@@ -2405,6 +2426,32 @@ _theme_autocomplete(char *input, int *size)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
_resource_autocomplete(char *input, int *size)
|
||||
{
|
||||
char *found = NULL;
|
||||
|
||||
ProfWin *current = wins_get_current();
|
||||
if (current && current->type == WIN_CHAT) {
|
||||
char *recipient = ui_current_recipient();
|
||||
PContact contact = roster_get_contact(recipient);
|
||||
if (contact) {
|
||||
Autocomplete ac = p_contact_resource_ac(contact);
|
||||
found = autocomplete_param_with_ac(input, size, "/resource set", ac, FALSE);
|
||||
if (found != NULL) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, size, "/resource", resource_ac, FALSE);
|
||||
if (found != NULL) {
|
||||
return found;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
_form_autocomplete(char *input, int *size)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user