about summary refs log tree commit diff stats
path: root/src/command/cmd_ac.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2018-02-05 21:40:32 +0000
committerJames Booth <boothj5@gmail.com>2018-02-05 21:40:32 +0000
commitcba17faf3dd9cb845a8f5734a213a7c708e8a05f (patch)
tree63d551c2c92768096a3064b8096d7efcc7688624 /src/command/cmd_ac.c
parente6d9a243cd2e2a1e1f3a0f89744b5d2d2d0e51e6 (diff)
downloadprofani-tty-cba17faf3dd9cb845a8f5734a213a7c708e8a05f.tar.gz
Add /rooms service autocompletion
Diffstat (limited to 'src/command/cmd_ac.c')
-rw-r--r--src/command/cmd_ac.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index a0226d31..bb6e9cd6 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -940,6 +940,7 @@ cmd_ac_reset(ProfWin *window)
     }
 
     muc_invites_reset_ac();
+    muc_confserver_reset_ac();
     accounts_reset_all_search();
     accounts_reset_enabled_search();
     tlscerts_reset_ac();
@@ -3133,17 +3134,21 @@ _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous)
                 return found;
             }
         }
-        if ((num_args == 1 && g_strcmp0(args[0], "cache") == 0 && space_at_end) || 
-                (num_args == 2 && g_strcmp0(args[0], "cache") == 0)) {
-            found = autocomplete_param_with_ac(input, "/rooms cache", rooms_cache_ac, TRUE, previous);
+        if ((num_args == 1 && g_strcmp0(args[0], "service") == 0 && space_at_end) ||
+                (num_args == 2 && g_strcmp0(args[0], "service") == 0 && !space_at_end)) {
+            found = autocomplete_param_with_func(input, "/rooms service", muc_confserver_find, previous);
             if (found) {
                 g_strfreev(args);
                 return found;
             }
         }
-        if ((num_args >= 2) && g_strcmp0(args[0], "cache") == 0) {
-            g_strfreev(args);
-            return NULL;
+        if ((num_args == 1 && g_strcmp0(args[0], "cache") == 0 && space_at_end) ||
+                (num_args == 2 && g_strcmp0(args[0], "cache") == 0 && !space_at_end)) {
+            found = autocomplete_param_with_ac(input, "/rooms cache", rooms_cache_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");
@@ -3155,9 +3160,24 @@ _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous)
                 return found;
             }
         }
+        if ((num_args == 3 && g_strcmp0(args[2], "service") == 0 && space_at_end) ||
+                (num_args == 4 && g_strcmp0(args[2], "service") == 0 && !space_at_end)) {
+            GString *beginning = g_string_new("/rooms");
+            g_string_append_printf(beginning, " %s %s %s", args[0], args[1], args[2]);
+            found = autocomplete_param_with_func(input, beginning->str, muc_confserver_find, previous);
+            g_string_free(beginning, TRUE);
+            if (found) {
+                g_strfreev(args);
+                return found;
+            }
+        }
+        if ((num_args >= 2) && g_strcmp0(args[0], "cache") == 0) {
+            g_strfreev(args);
+            return NULL;
+        }
     }
 
     g_strfreev(args);
 
     return NULL;
-}
\ No newline at end of file
+}