From 9a5fe29caa230a5229c26470ef693d2fc102add6 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 8 Jul 2015 20:51:39 +0100 Subject: Changed /roster empty -> /roster remove_all contacts Make it difficult to accidentally use this command. --- src/command/command.c | 51 ++++++++++++++++++++++++++++++-------------------- src/command/commands.c | 6 +++++- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 8ed3a3b6..bfd16b9f 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -190,26 +190,26 @@ static struct cmd_t command_defs[] = "--------------------------", "Manage your roster, and roster display settings.", "", - "command - online|show|hide|by|size|add|remove|nick|clearnick", - "", - "online : Show all online contacts in your roster.", - "show : Show the roster panel.", - "show offline : Show offline contacts in the roster panel.", - "show resource : Show contact's connected resources in the roster panel.", - "show empty : When grouping by presence, show empty presence groups", - "hide : Hide the roster panel.", - "hide offline : Hide offline contacts in the roster panel.", - "hide resource : Hide contact's connected resources in the roster panel.", - "hide empty : When grouping by presence, hide empty presence groups", - "by group : Group contacts in the roster panel by roster group.", - "by presence : Group contacts in the roster panel by presence.", - "by none : No grouping in the roster panel.", - "size : Percentage of the screen taken up by the roster (1-99).", - "add jid [nick] : Add a new item to the roster.", - "remove jid : Removes an item from the roster.", - "empty : Remove all items from roster." - "nick jid nick : Change a contacts nickname.", - "clearnick jid : Removes the current nickname.", + "command - online|show|hide|by|size|add|remove|remove_all|nick|clearnick", + "", + "online : Show all online contacts in your roster.", + "show : Show the roster panel.", + "show offline : Show offline contacts in the roster panel.", + "show resource : Show contact's connected resources in the roster panel.", + "show empty : When grouping by presence, show empty presence groups", + "hide : Hide the roster panel.", + "hide offline : Hide offline contacts in the roster panel.", + "hide resource : Hide contact's connected resources in the roster panel.", + "hide empty : When grouping by presence, hide empty presence groups", + "by group : Group contacts in the roster panel by roster group.", + "by presence : Group contacts in the roster panel by presence.", + "by none : No grouping in the roster panel.", + "size : Percentage of the screen taken up by the roster (1-99).", + "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.", "", "Passing no arguments lists all contacts in your roster.", "", @@ -1217,6 +1217,7 @@ static Autocomplete wins_ac; static Autocomplete roster_ac; static Autocomplete roster_option_ac; static Autocomplete roster_by_ac; +static Autocomplete roster_remove_all_ac; static Autocomplete group_ac; static Autocomplete bookmark_ac; static Autocomplete bookmark_property_ac; @@ -1432,6 +1433,7 @@ cmd_init(void) autocomplete_add(roster_ac, "nick"); autocomplete_add(roster_ac, "clearnick"); autocomplete_add(roster_ac, "remove"); + autocomplete_add(roster_ac, "remove_all"); autocomplete_add(roster_ac, "empty"); autocomplete_add(roster_ac, "show"); autocomplete_add(roster_ac, "hide"); @@ -1448,6 +1450,9 @@ cmd_init(void) autocomplete_add(roster_by_ac, "presence"); autocomplete_add(roster_by_ac, "none"); + roster_remove_all_ac = autocomplete_new(); + autocomplete_add(roster_remove_all_ac, "contacts"); + group_ac = autocomplete_new(); autocomplete_add(group_ac, "show"); autocomplete_add(group_ac, "add"); @@ -1657,6 +1662,7 @@ cmd_uninit(void) autocomplete_free(roster_ac); autocomplete_free(roster_option_ac); autocomplete_free(roster_by_ac); + autocomplete_free(roster_remove_all_ac); autocomplete_free(group_ac); autocomplete_free(bookmark_ac); autocomplete_free(bookmark_property_ac); @@ -1830,6 +1836,7 @@ cmd_reset_autocomplete(ProfWin *window) autocomplete_reset(roster_ac); autocomplete_reset(roster_option_ac); autocomplete_reset(roster_by_ac); + autocomplete_reset(roster_remove_all_ac); autocomplete_reset(group_ac); autocomplete_reset(titlebar_ac); autocomplete_reset(bookmark_ac); @@ -2188,6 +2195,10 @@ _roster_autocomplete(ProfWin *window, const char * const input) if (result) { return result; } + result = autocomplete_param_with_ac(input, "/roster remove_all", roster_remove_all_ac, TRUE); + if (result) { + return result; + } result = autocomplete_param_with_ac(input, "/roster show", roster_option_ac, TRUE); if (result) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index 8c071048..757b8115 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1678,7 +1678,11 @@ cmd_roster(ProfWin *window, gchar **args, struct cmd_help_t help) } return TRUE; - } else if (strcmp(args[0], "empty") == 0) { + } else if (strcmp(args[0], "remove_all") == 0) { + if (g_strcmp0(args[1], "contacts") != 0) { + cons_show("Usage: %s", help.usage); + return TRUE; + } if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); return TRUE; -- cgit 1.4.1-2-gfad0