about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/cmd_ac.c62
-rw-r--r--src/command/cmd_defs.c184
-rw-r--r--src/command/cmd_funcs.c18
3 files changed, 118 insertions, 146 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 52705d5b..a5568d65 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -71,7 +71,6 @@ static char* _autoconnect_autocomplete(ProfWin *window, const char *const input,
 static char* _account_autocomplete(ProfWin *window, const char *const input, gboolean previous);
 static char* _who_autocomplete(ProfWin *window, const char *const input, gboolean previous);
 static char* _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous);
-static char* _group_autocomplete(ProfWin *window, const char *const input, gboolean previous);
 static char* _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previous);
 static char* _otr_autocomplete(ProfWin *window, const char *const input, gboolean previous);
 static char* _pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous);
@@ -441,6 +440,7 @@ cmd_ac_init(void)
     autocomplete_add(roster_ac, "resource");
     autocomplete_add(roster_ac, "presence");
     autocomplete_add(roster_ac, "private");
+    autocomplete_add(roster_ac, "group");
 
     roster_private_ac = autocomplete_new();
     autocomplete_add(roster_private_ac, "room");
@@ -1559,7 +1559,6 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
     g_hash_table_insert(ac_funcs, "/log",           _log_autocomplete);
     g_hash_table_insert(ac_funcs, "/account",       _account_autocomplete);
     g_hash_table_insert(ac_funcs, "/roster",        _roster_autocomplete);
-    g_hash_table_insert(ac_funcs, "/group",         _group_autocomplete);
     g_hash_table_insert(ac_funcs, "/bookmark",      _bookmark_autocomplete);
     g_hash_table_insert(ac_funcs, "/autoconnect",   _autoconnect_autocomplete);
     g_hash_table_insert(ac_funcs, "/otr",           _otr_autocomplete);
@@ -1788,6 +1787,27 @@ _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous
         if (result) {
             return result;
         }
+
+        result = autocomplete_param_with_func(input, "/roster group show", roster_group_autocomplete, previous);
+        if (result) {
+            return result;
+        }
+        result = autocomplete_param_no_with_func(input, "/roster group add", 5, roster_contact_autocomplete, previous);
+        if (result) {
+            return result;
+        }
+        result = autocomplete_param_no_with_func(input, "/roster group remove", 5, roster_contact_autocomplete, previous);
+        if (result) {
+            return result;
+        }
+        result = autocomplete_param_with_func(input, "/roster group add", roster_group_autocomplete, previous);
+        if (result) {
+            return result;
+        }
+        result = autocomplete_param_with_func(input, "/roster group remove", roster_group_autocomplete, previous);
+        if (result) {
+            return result;
+        }
     }
 
     result = autocomplete_param_with_ac(input, "/roster remove_all", roster_remove_all_ac, TRUE, previous);
@@ -1846,45 +1866,11 @@ _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous
     if (result) {
         return result;
     }
-    result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE, previous);
+    result = autocomplete_param_with_ac(input, "/roster group", group_ac, TRUE, previous);
     if (result) {
         return result;
     }
-
-    return NULL;
-}
-
-static char*
-_group_autocomplete(ProfWin *window, const char *const input, gboolean previous)
-{
-    char *result = NULL;
-
-    jabber_conn_status_t conn_status = connection_get_status();
-
-    if (conn_status == JABBER_CONNECTED) {
-        result = autocomplete_param_with_func(input, "/group show", roster_group_autocomplete, previous);
-        if (result) {
-            return result;
-        }
-        result = autocomplete_param_no_with_func(input, "/group add", 4, roster_contact_autocomplete, previous);
-        if (result) {
-            return result;
-        }
-        result = autocomplete_param_no_with_func(input, "/group remove", 4, roster_contact_autocomplete, previous);
-        if (result) {
-            return result;
-        }
-        result = autocomplete_param_with_func(input, "/group add", roster_group_autocomplete, previous);
-        if (result) {
-            return result;
-        }
-        result = autocomplete_param_with_func(input, "/group remove", roster_group_autocomplete, previous);
-        if (result) {
-            return result;
-        }
-    }
-
-    result = autocomplete_param_with_ac(input, "/group", group_ac, TRUE, previous);
+    result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE, previous);
     if (result) {
         return result;
     }
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 95fd64a0..70832552 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -266,7 +266,8 @@ static struct cmd_t command_defs[] =
 
     { "/roster",
         parse_args_with_freetext, 0, 4, NULL,
-        CMD_NOSUBFUNCS
+        CMD_SUBFUNCS(
+            { "group",   cmd_group })
         CMD_MAINFUNC(cmd_roster)
         CMD_TAGS(
             CMD_TAG_ROSTER,
@@ -304,80 +305,87 @@ static struct cmd_t command_defs[] =
             "/roster remove <jid>",
             "/roster remove_all contacts",
             "/roster nick <jid> <nick>",
-            "/roster clearnick <jid>")
+            "/roster clearnick <jid>",
+            "/roster group",
+            "/roster group show <group>",
+            "/roster group add <group> <contat>",
+            "/roster group remove <group> <contact>")
         CMD_DESC(
             "Manage your roster, and roster display settings. "
             "Passing no arguments lists all contacts in your roster.")
         CMD_ARGS(
-            { "online",                     "Show all online contacts in console." },
-            { "show",                       "Show the roster panel." },
-            { "show offline",               "Show offline contacts in roster panel." },
-            { "show resource",              "Show contact's connected resources in roster panel." },
-            { "show presence",              "Show contact's presence in roster panel." },
-            { "show status",                "Show contact's status message in roster panel." },
-            { "show empty",                 "Show empty groups in roster panel." },
-            { "show priority",              "Show resource priority in roster panel." },
-            { "show contacts",              "Show contacts in roster panel." },
-            { "show rooms",                 "Show chat rooms in roster panel." },
-            { "hide",                       "Hide the roster panel." },
-            { "hide offline",               "Hide offline contacts in roster panel." },
-            { "hide resource",              "Hide contact's connected resources in roster panel." },
-            { "hide presence",              "Hide contact's presence in roster panel." },
-            { "hide status",                "Hide contact's status message in roster panel." },
-            { "hide empty",                 "Hide empty groups in roster panel." },
-            { "hide priority",              "Hide resource priority in roster panel." },
-            { "hide contacts",              "Hide contacts in roster panel." },
-            { "hide rooms",                 "Hide chat rooms in roster panel." },
-            { "by group",                   "Group contacts in roster panel by roster group." },
-            { "by presence",                "Group contacts in roster panel by presence." },
-            { "by none",                    "No grouping in roster panel." },
-            { "count unread",               "Show unread message count with roster headers." },
-            { "count items",                "Show item count with roster headers." },
-            { "count off",                  "Do not show any count with roster headers." },
-            { "count zero on",              "Show roster header count when 0." },
-            { "count zero off",             "Hide roster header count when 0." },
-            { "order name",                 "Order roster contacts by name only." },
-            { "order presence",             "Order roster contacts by presence, and then by name." },
-            { "unread before",              "Show unread message count before contact." },
-            { "unread after",               "Show unread message count after contact." },
-            { "unread off",                 "Do not show unread message count for contacts." },
-            { "room char <char>",           "Prefix rooms with specified character." },
-            { "room char none",             "Remove room character prefix." },
-            { "room private char <char>",   "Prefix private room chat with specified character when displayed with room." },
-            { "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." },
-            { "room unread after",          "Show unread message count after room." },
-            { "room unread off",            "Do not show unread message count for rooms." },
-            { "room show server",           "Show the conference server with room JIDs." },
-            { "room hide server",           "Do not show the conference server with room JIDs." },
-            { "private room",               "Show room private chats with the room." },
-            { "private group",              "Show room private chats as a separate roster group." },
-            { "private off",                "Do not show room private chats." },
-            { "private char <char>",        "Prefix private room chats with specified character when displayed in separate group." },
-            { "private char none",          "Remove private room chat character prefix." },
-            { "header char <char>",         "Prefix roster headers with specified character." },
-            { "header char none",           "Remove roster header character prefix." },
-            { "contact char <char>",        "Prefix roster contacts with specified character." },
-            { "contact char none",          "Remove roster contact character prefix." },
-            { "contact indent <indent>",    "Indent contact line by <indent> spaces (0 to 10)." },
-            { "resource char <char>",       "Prefix roster resources with specified character." },
-            { "resource char none",         "Remove roster resource character prefix." },
-            { "resource indent <indent>",   "Indent resource line by <indent> spaces (0 to 10)." },
-            { "resource join on|off",       "Join resource with previous line when only one available resource." },
-            { "presence indent <indent>",   "Indent presence line by <indent> spaces (-1 to 10), a value of -1 will show presence on the previous line." },
-            { "size <percent>",             "Percentage of the screen taken up by the roster (1-99)." },
-            { "wrap on|off",                "Enable or disable line wrapping in roster panel." },
-            { "add <jid> [<nick>]",         "Add a new item to the roster." },
-            { "remove <jid>",               "Removes an item from the roster." },
-            { "remove_all contacts",        "Remove all items from roster." },
-            { "nick <jid> <nick>",          "Change a contacts nickname." },
-            { "clearnick <jid>",            "Removes the current nickname." })
+            { "online",                         "Show all online contacts in console." },
+            { "show",                           "Show the roster panel." },
+            { "show offline",                   "Show offline contacts in roster panel." },
+            { "show resource",                  "Show contact's connected resources in roster panel." },
+            { "show presence",                  "Show contact's presence in roster panel." },
+            { "show status",                    "Show contact's status message in roster panel." },
+            { "show empty",                     "Show empty groups in roster panel." },
+            { "show priority",                  "Show resource priority in roster panel." },
+            { "show contacts",                  "Show contacts in roster panel." },
+            { "show rooms",                     "Show chat rooms in roster panel." },
+            { "hide",                           "Hide the roster panel." },
+            { "hide offline",                   "Hide offline contacts in roster panel." },
+            { "hide resource",                  "Hide contact's connected resources in roster panel." },
+            { "hide presence",                  "Hide contact's presence in roster panel." },
+            { "hide status",                    "Hide contact's status message in roster panel." },
+            { "hide empty",                     "Hide empty groups in roster panel." },
+            { "hide priority",                  "Hide resource priority in roster panel." },
+            { "hide contacts",                  "Hide contacts in roster panel." },
+            { "hide rooms",                     "Hide chat rooms in roster panel." },
+            { "by group",                       "Group contacts in roster panel by roster group." },
+            { "by presence",                    "Group contacts in roster panel by presence." },
+            { "by none",                        "No grouping in roster panel." },
+            { "count unread",                   "Show unread message count with roster headers." },
+            { "count items",                    "Show item count with roster headers." },
+            { "count off",                      "Do not show any count with roster headers." },
+            { "count zero on",                  "Show roster header count when 0." },
+            { "count zero off",                 "Hide roster header count when 0." },
+            { "order name",                     "Order roster contacts by name only." },
+            { "order presence",                 "Order roster contacts by presence, and then by name." },
+            { "unread before",                  "Show unread message count before contact." },
+            { "unread after",                   "Show unread message count after contact." },
+            { "unread off",                     "Do not show unread message count for contacts." },
+            { "room char <char>",               "Prefix rooms with specified character." },
+            { "room char none",                 "Remove room character prefix." },
+            { "room private char <char>",       "Prefix private room chat with specified character when displayed with room." },
+            { "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." },
+            { "room unread after",              "Show unread message count after room." },
+            { "room unread off",                "Do not show unread message count for rooms." },
+            { "room show server",               "Show the conference server with room JIDs." },
+            { "room hide server",               "Do not show the conference server with room JIDs." },
+            { "private room",                   "Show room private chats with the room." },
+            { "private group",                  "Show room private chats as a separate roster group." },
+            { "private off",                    "Do not show room private chats." },
+            { "private char <char>",            "Prefix private room chats with specified character when displayed in separate group." },
+            { "private char none",              "Remove private room chat character prefix." },
+            { "header char <char>",             "Prefix roster headers with specified character." },
+            { "header char none",               "Remove roster header character prefix." },
+            { "contact char <char>",            "Prefix roster contacts with specified character." },
+            { "contact char none",              "Remove roster contact character prefix." },
+            { "contact indent <indent>",        "Indent contact line by <indent> spaces (0 to 10)." },
+            { "resource char <char>",           "Prefix roster resources with specified character." },
+            { "resource char none",             "Remove roster resource character prefix." },
+            { "resource indent <indent>",       "Indent resource line by <indent> spaces (0 to 10)." },
+            { "resource join on|off",           "Join resource with previous line when only one available resource." },
+            { "presence indent <indent>",       "Indent presence line by <indent> spaces (-1 to 10), a value of -1 will show presence on the previous line." },
+            { "size <percent>",                 "Percentage of the screen taken up by the roster (1-99)." },
+            { "wrap on|off",                    "Enable or disable line wrapping in roster panel." },
+            { "add <jid> [<nick>]",             "Add a new item to the roster." },
+            { "remove <jid>",                   "Removes an item from the roster." },
+            { "remove_all contacts",            "Remove all items from roster." },
+            { "nick <jid> <nick>",              "Change a contacts nickname." },
+            { "clearnick <jid>",                "Removes the current nickname." },
+            { "group show <group>",             "List all roster items in a group." },
+            { "group add <group> <contact>",    "Add a contact to a group." },
+            { "group remove <group> <contact>", "Remove a contact from a group." })
         CMD_EXAMPLES(
             "/roster",
             "/roster add someone@contacts.org",
@@ -385,7 +393,12 @@ static struct cmd_t command_defs[] =
             "/roster remove someone@contacts.org",
             "/roster nick myfriend@chat.org \"My Friend\"",
             "/roster clearnick kai@server.com",
-            "/roster size 15")
+            "/roster size 15",
+            "/roster group",
+            "/roster group show friends",
+            "/roster group add friends newfriend@server.org",
+            "/roster group add family Brother",
+            "/roster group remove colleagues boss@work.com")
     },
 
     { "/blocked",
@@ -410,33 +423,6 @@ static struct cmd_t command_defs[] =
             "/blocked add profanity@rooms.dismail.de/spammy-user")
     },
 
-    { "/group",
-        parse_args_with_freetext, 0, 3, NULL,
-        CMD_NOSUBFUNCS
-        CMD_MAINFUNC(cmd_group)
-        CMD_TAGS(
-            CMD_TAG_ROSTER,
-            CMD_TAG_UI)
-        CMD_SYN(
-            "/group",
-            "/group show <group>",
-            "/group add <group> <contat>",
-            "/group remove <group> <contact>")
-        CMD_DESC(
-            "View, add to, and remove from roster groups. "
-            "Passing no argument will list all roster groups.")
-        CMD_ARGS(
-            { "show <group>",             "List all roster items in a group." },
-            { "add <group> <contact>",    "Add a contact to a group." },
-            { "remove <group> <contact>", "Remove a contact from a group." })
-        CMD_EXAMPLES(
-            "/group",
-            "/group show friends",
-            "/group add friends newfriend@server.org",
-            "/group add family Brother",
-            "/group remove colleagues boss@work.com")
-    },
-
     { "/info",
         parse_args, 0, 1, NULL,
         CMD_NOSUBFUNCS
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 4c0b238a..ccf5c62e 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -2230,7 +2230,7 @@ cmd_group(ProfWin *window, const char *const command, gchar **args)
     }
 
     // list all groups
-    if (args[0] == NULL) {
+    if (args[1] == NULL) {
         GList *groups = roster_get_groups();
         GList *curr = groups;
         if (curr) {
@@ -2248,8 +2248,8 @@ cmd_group(ProfWin *window, const char *const command, gchar **args)
     }
 
     // show contacts in group
-    if (strcmp(args[0], "show") == 0) {
-        char *group = args[1];
+    if (strcmp(args[1], "show") == 0) {
+        char *group = args[2];
         if (group == NULL) {
             cons_bad_cmd_usage(command);
             return TRUE;
@@ -2261,9 +2261,9 @@ cmd_group(ProfWin *window, const char *const command, gchar **args)
     }
 
     // add contact to group
-    if (strcmp(args[0], "add") == 0) {
-        char *group = args[1];
-        char *contact = args[2];
+    if (strcmp(args[1], "add") == 0) {
+        char *group = args[2];
+        char *contact = args[3];
 
         if ((group == NULL) || (contact == NULL)) {
             cons_bad_cmd_usage(command);
@@ -2292,9 +2292,9 @@ cmd_group(ProfWin *window, const char *const command, gchar **args)
     }
 
     // remove contact from group
-    if (strcmp(args[0], "remove") == 0) {
-        char *group = args[1];
-        char *contact = args[2];
+    if (strcmp(args[1], "remove") == 0) {
+        char *group = args[2];
+        char *contact = args[3];
 
         if ((group == NULL) || (contact == NULL)) {
             cons_bad_cmd_usage(command);