diff options
Diffstat (limited to 'src/command/cmd_ac.c')
-rw-r--r-- | src/command/cmd_ac.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 8e53bb10..5ecdfbe7 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -98,6 +98,7 @@ static char* _sendfile_autocomplete(ProfWin *window, const char *const input, gb static char* _blocked_autocomplete(ProfWin *window, const char *const input, gboolean previous); static char* _tray_autocomplete(ProfWin *window, const char *const input, gboolean previous); static char* _presence_autocomplete(ProfWin *window, const char *const input, gboolean previous); +static char* _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous); static char* _script_autocomplete_func(const char *const prefix, gboolean previous); @@ -161,6 +162,7 @@ static Autocomplete alias_ac; static Autocomplete aliases_ac; static Autocomplete join_property_ac; static Autocomplete room_ac; +static Autocomplete rooms_ac; static Autocomplete affiliation_ac; static Autocomplete role_ac; static Autocomplete privilege_cmd_ac; @@ -591,6 +593,10 @@ cmd_ac_init(void) autocomplete_add(room_ac, "destroy"); autocomplete_add(room_ac, "config"); + rooms_ac = autocomplete_new(); + autocomplete_add(rooms_ac, "service"); + autocomplete_add(rooms_ac, "match"); + affiliation_ac = autocomplete_new(); autocomplete_add(affiliation_ac, "owner"); autocomplete_add(affiliation_ac, "admin"); @@ -1005,6 +1011,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(aliases_ac); autocomplete_reset(join_property_ac); autocomplete_reset(room_ac); + autocomplete_reset(rooms_ac); autocomplete_reset(affiliation_ac); autocomplete_reset(role_ac); autocomplete_reset(privilege_cmd_ac); @@ -1124,6 +1131,7 @@ cmd_ac_uninit(void) autocomplete_free(aliases_ac); autocomplete_free(join_property_ac); autocomplete_free(room_ac); + autocomplete_free(rooms_ac); autocomplete_free(affiliation_ac); autocomplete_free(role_ac); autocomplete_free(privilege_cmd_ac); @@ -1395,6 +1403,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ g_hash_table_insert(ac_funcs, "/blocked", _blocked_autocomplete); g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete); g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); + g_hash_table_insert(ac_funcs, "/rooms", _rooms_autocomplete); int len = strlen(input); char parsed[len+1]; @@ -3090,3 +3099,37 @@ _presence_autocomplete(ProfWin *window, const char *const input, gboolean previo return NULL; } +static char* +_rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous) +{ + char *found = NULL; + gboolean result = FALSE; + + gchar **args = parse_args(input, 0, 4, &result); + + if (result) { + gboolean space_at_end = g_str_has_suffix(input, " "); + int num_args = g_strv_length(args); + if (num_args <= 1) { + found = autocomplete_param_with_ac(input, "/rooms", rooms_ac, TRUE, previous); + if (found) { + g_strfreev(args); + return found; + } + } + if ((num_args == 2 && space_at_end) || (num_args == 3 && !space_at_end)) { + GString *beginning = g_string_new("/rooms"); + g_string_append_printf(beginning, " %s %s", args[0], args[1]); + found = autocomplete_param_with_ac(input, beginning->str, rooms_ac, TRUE, previous); + g_string_free(beginning, TRUE); + if (found) { + g_strfreev(args); + return found; + } + } + } + + g_strfreev(args); + + return NULL; +} \ No newline at end of file |