about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-02-01 01:11:01 +0000
committerJames Booth <boothj5@gmail.com>2016-02-01 01:11:01 +0000
commitf91b21a1d67f97f2ba55d32358f85df9ffe3d175 (patch)
tree9d97972eabd75927e2f415f634ed2b269c68dc9b /src/command
parent08c1e62e3ca899100758a760452758efab497de6 (diff)
downloadprofani-tty-f91b21a1d67f97f2ba55d32358f85df9ffe3d175.tar.gz
Allow splitting roster rooms by conference server
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c17
-rw-r--r--src/command/commands.c19
2 files changed, 35 insertions, 1 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 5f2f64fb..6191caef 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -271,7 +271,7 @@ static struct cmd_t command_defs[] =
     },
 
     { "/roster",
-        cmd_roster, parse_args_with_freetext, 0, 3, NULL,
+        cmd_roster, parse_args_with_freetext, 0, 4, NULL,
         CMD_TAGS(
             CMD_TAG_ROSTER,
             CMD_TAG_UI)
@@ -288,6 +288,7 @@ static struct cmd_t command_defs[] =
             "/roster room char <char>|none",
             "/roster room private char <char>|none",
             "/roster room position first|last",
+            "/roster room by service|none",
             "/roster room order name|unread",
             "/roster room unread before|after|off",
             "/roster private room|group|off",
@@ -348,6 +349,8 @@ static struct cmd_t command_defs[] =
             { "room private char none",     "Remove private room chat character prefix when displayed with room." },
             { "room position first",        "Show rooms first in roster." },
             { "room position last",         "Show rooms last in roster." },
+            { "room by service",            "Group rooms by chat service." },
+            { "room by none",               "Do not group rooms." },
             { "room order name",            "Order rooms by name." },
             { "room order unread",          "Order rooms by unread messages, and then by name." },
             { "room unread before",         "Show unread message count before room." },
@@ -1948,6 +1951,7 @@ static Autocomplete roster_char_ac;
 static Autocomplete roster_remove_all_ac;
 static Autocomplete roster_room_ac;
 static Autocomplete roster_room_position_ac;
+static Autocomplete roster_room_by_ac;
 static Autocomplete roster_room_order_ac;
 static Autocomplete roster_unread_ac;
 static Autocomplete roster_private_ac;
@@ -2278,10 +2282,15 @@ cmd_init(void)
     roster_room_ac = autocomplete_new();
     autocomplete_add(roster_room_ac, "char");
     autocomplete_add(roster_room_ac, "position");
+    autocomplete_add(roster_room_ac, "by");
     autocomplete_add(roster_room_ac, "order");
     autocomplete_add(roster_room_ac, "unread");
     autocomplete_add(roster_room_ac, "private");
 
+    roster_room_by_ac = autocomplete_new();
+    autocomplete_add(roster_room_by_ac, "service");
+    autocomplete_add(roster_room_by_ac, "none");
+
     roster_room_order_ac = autocomplete_new();
     autocomplete_add(roster_room_order_ac, "name");
     autocomplete_add(roster_room_order_ac, "unread");
@@ -2564,6 +2573,7 @@ cmd_uninit(void)
     autocomplete_free(roster_count_ac);
     autocomplete_free(roster_order_ac);
     autocomplete_free(roster_room_ac);
+    autocomplete_free(roster_room_by_ac);
     autocomplete_free(roster_unread_ac);
     autocomplete_free(roster_room_position_ac);
     autocomplete_free(roster_room_order_ac);
@@ -2778,6 +2788,7 @@ cmd_reset_autocomplete(ProfWin *window)
     autocomplete_reset(roster_count_ac);
     autocomplete_reset(roster_order_ac);
     autocomplete_reset(roster_room_ac);
+    autocomplete_reset(roster_room_by_ac);
     autocomplete_reset(roster_unread_ac);
     autocomplete_reset(roster_room_position_ac);
     autocomplete_reset(roster_room_order_ac);
@@ -3210,6 +3221,10 @@ _roster_autocomplete(ProfWin *window, const char *const input)
     if (result) {
         return result;
     }
+    result = autocomplete_param_with_ac(input, "/roster room by", roster_room_by_ac, TRUE);
+    if (result) {
+        return result;
+    }
     result = autocomplete_param_with_ac(input, "/roster room order", roster_room_order_ac, TRUE);
     if (result) {
         return result;
diff --git a/src/command/commands.c b/src/command/commands.c
index 0a88d2bb..c8c01778 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2565,6 +2565,25 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
                 cons_bad_cmd_usage(command);
                 return TRUE;
             }
+        } else if (g_strcmp0(args[1], "by") == 0) {
+            if (g_strcmp0(args[2], "service") == 0) {
+                cons_show("Grouping rooms by service");
+                prefs_set_string(PREF_ROSTER_ROOMS_BY, "service");
+                if (conn_status == JABBER_CONNECTED) {
+                    rosterwin_roster();
+                }
+                return TRUE;
+            } else if (g_strcmp0(args[2], "none") == 0) {
+                cons_show("Roster room grouping disabled");
+                prefs_set_string(PREF_ROSTER_ROOMS_BY, "none");
+                if (conn_status == JABBER_CONNECTED) {
+                    rosterwin_roster();
+                }
+                return TRUE;
+            } else {
+                cons_bad_cmd_usage(command);
+                return TRUE;
+            }
         } else {
             cons_bad_cmd_usage(command);
             return TRUE;