about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-10 23:51:13 +0000
committerJames Booth <boothj5@gmail.com>2014-11-10 23:51:13 +0000
commitf715c0580c904caababf980e0fef72ae28944424 (patch)
treee90477a22657838c4435422a235c095f922e0933 /src/command
parent497b07c1c3563efdfc147b22bd8afd094caf619a (diff)
downloadprofani-tty-f715c0580c904caababf980e0fef72ae28944424.tar.gz
Added /roster show|hide offline
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c34
-rw-r--r--src/command/commands.c37
2 files changed, 53 insertions, 18 deletions
diff --git a/src/command/command.c b/src/command/command.c
index a8b409d7..e441656d 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -169,17 +169,19 @@ static struct cmd_t command_defs[] =
 
     { "/roster",
         cmd_roster, parse_args_with_freetext, 0, 3, NULL,
-        { "/roster [show|hide|add|remove|nick|clearnick] [jid] [nickname]", "Manage your roster.",
-        { "/roster [show|hide|add|remove|nick|clearnick] [jid] [nickname]",
-          "--------------------------------------------------------------",
+        { "/roster [show|hide|add|remove|nick|clearnick] [offline] [jid] [nickname]", "Manage your roster.",
+        { "/roster [show|hide|add|remove|nick|clearnick] [offline] [jid] [nickname]",
+          "------------------------------------------------------------------------",
           "View, add to, and remove from your roster.",
           "Passing no arguments lists all contacts in your roster.",
-          "The 'show' command will show the roster panel in the console window.",
-          "The 'hide' command will hide the roster panel.",
-          "The 'add' command will add a new item, jid is required, nickname is optional.",
-          "The 'remove' command removes a contact, jid is required.",
-          "The 'nick' command changes a contacts nickname, both jid and nickname are required,",
-          "The 'clearnick' command removes the current nickname, jid is required.",
+          "show         - Show the roster panel in the console window.",
+          "hide         - Hide the roster panel.",
+          "show offline - Show offline contacts in the roster panel.",
+          "hide offline - Hide offline contacts in the roster panel.",
+          "add          - Add a new item, jid is required, nickname is optional.",
+          "remove       - Removes a contact, jid is required.",
+          "nick         - Changes a contacts nickname, both jid and nickname are required,",
+          "clearnick    - Removes the current nickname, jid is required.",
           "",
           "Example : /roster (show your roster)",
           "Example : /roster add someone@contacts.org (add the contact)",
@@ -1039,6 +1041,7 @@ static Autocomplete disco_ac;
 static Autocomplete close_ac;
 static Autocomplete wins_ac;
 static Autocomplete roster_ac;
+static Autocomplete roster_option_ac;
 static Autocomplete group_ac;
 static Autocomplete bookmark_ac;
 static Autocomplete bookmark_property_ac;
@@ -1235,6 +1238,9 @@ cmd_init(void)
     autocomplete_add(roster_ac, "show");
     autocomplete_add(roster_ac, "hide");
 
+    roster_option_ac = autocomplete_new();
+    autocomplete_add(roster_option_ac, "offline");
+
     group_ac = autocomplete_new();
     autocomplete_add(group_ac, "show");
     autocomplete_add(group_ac, "add");
@@ -1404,6 +1410,7 @@ cmd_uninit(void)
     autocomplete_free(close_ac);
     autocomplete_free(wins_ac);
     autocomplete_free(roster_ac);
+    autocomplete_free(roster_option_ac);
     autocomplete_free(group_ac);
     autocomplete_free(bookmark_ac);
     autocomplete_free(bookmark_property_ac);
@@ -1572,6 +1579,7 @@ cmd_reset_autocomplete()
     autocomplete_reset(close_ac);
     autocomplete_reset(wins_ac);
     autocomplete_reset(roster_ac);
+    autocomplete_reset(roster_option_ac);
     autocomplete_reset(group_ac);
     autocomplete_reset(bookmark_ac);
     autocomplete_reset(bookmark_property_ac);
@@ -2000,6 +2008,14 @@ _roster_autocomplete(char *input, int *size)
     if (result != NULL) {
         return result;
     }
+    result = autocomplete_param_with_ac(input, size, "/roster show", roster_option_ac, TRUE);
+    if (result != NULL) {
+        return result;
+    }
+    result = autocomplete_param_with_ac(input, size, "/roster hide", roster_option_ac, TRUE);
+    if (result != NULL) {
+        return result;
+    }
     result = autocomplete_param_with_ac(input, size, "/roster", roster_ac, TRUE);
     if (result != NULL) {
         return result;
diff --git a/src/command/commands.c b/src/command/commands.c
index 877b6857..568cd352 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1332,16 +1332,35 @@ cmd_roster(gchar **args, struct cmd_help_t help)
 
     // show/hide roster
     } else if (g_strcmp0(args[0], "show") == 0) {
-        cons_show("Roster enabled.");
-        prefs_set_boolean(PREF_ROSTER, TRUE);
-        ui_show_roster();
-        return TRUE;
+        if (args[1] == NULL) {
+            cons_show("Roster enabled.");
+            prefs_set_boolean(PREF_ROSTER, TRUE);
+            ui_show_roster();
+            return TRUE;
+        } else if (g_strcmp0(args[1], "offline") == 0) {
+            cons_show("Roster offline enabled");
+            prefs_set_boolean(PREF_ROSTER_OFFLINE, TRUE);
+            ui_roster();
+            return TRUE;
+        } else {
+            cons_show("Usage: %s", help.usage);
+            return TRUE;
+        }
     } else if (g_strcmp0(args[0], "hide") == 0) {
-        cons_show("Roster disabled.");
-        prefs_set_boolean(PREF_ROSTER, FALSE);
-        ui_hide_roster();
-        return TRUE;
-
+        if (args[1] == NULL) {
+            cons_show("Roster disabled.");
+            prefs_set_boolean(PREF_ROSTER, FALSE);
+            ui_hide_roster();
+            return TRUE;
+        } else if (g_strcmp0(args[1], "offline") == 0) {
+            cons_show("Roster offline disabled");
+            prefs_set_boolean(PREF_ROSTER_OFFLINE, FALSE);
+            ui_roster();
+            return TRUE;
+        } else {
+            cons_show("Usage: %s", help.usage);
+            return TRUE;
+        }
     // add contact
     } else if (strcmp(args[0], "add") == 0) {
         char *jid = args[1];