about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-06-01 23:27:46 +0100
committerJames Booth <boothj5@gmail.com>2013-06-01 23:27:46 +0100
commitd49a01a9c37b6aff82cac6a61269a87b3bb211dd (patch)
tree8e97c6b38329b634dd3b283dc5323a4277460317 /src/command
parent83c41776928a71faa858d509aa6cf8cf451569a7 (diff)
downloadprofani-tty-d49a01a9c37b6aff82cac6a61269a87b3bb211dd.tar.gz
Added roster list when using /roster with no args
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 79e1fdd2..6309ad75 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -276,7 +276,7 @@ static struct cmd_t main_commands[] =
           NULL } } },
 
     { "/roster",
-        _cmd_roster, parse_args_with_freetext, 2, 3,
+        _cmd_roster, parse_args_with_freetext, 0, 3,
         { "/roster nick jid [handle]", "Add or change a contacts handle.",
         { "/roster nick jid [handle]",
           "-------------------------",
@@ -2008,35 +2008,49 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
 static gboolean
 _cmd_roster(gchar **args, struct cmd_help_t help)
 {
+    // show roster
+    if (args[0] == NULL) {
+        GSList *list = roster_get_contacts();
+        cons_show_roster(list);
+        return TRUE;
+    }
+
+    // first arg invalid
     if (strcmp(args[0], "nick") != 0) {
         cons_show("Usage: %s", help.usage);
         return TRUE;
-    } else {
-        char *jid = args[1];
-        char *name = args[2];
-        jabber_conn_status_t conn_status = jabber_get_connection_status();
+    }
 
-        if (conn_status != JABBER_CONNECTED) {
-            cons_show("You are not currently connected.");
-            return TRUE;
-        }
+    if (args[1] == NULL) {
+        cons_show("Usage: %s", help.usage);
+        return TRUE;
+    }
 
-        // contact does not exist
-        PContact contact = roster_get_contact(jid);
-        if (contact == NULL) {
-            cons_show("Contact not found in roster: %s", jid);
-            return TRUE;
-        }
+    char *jid = args[1];
+    char *name = args[2];
+    jabber_conn_status_t conn_status = jabber_get_connection_status();
 
-        roster_change_name(jid, name);
+    if (conn_status != JABBER_CONNECTED) {
+        cons_show("You are not currently connected.");
+        return TRUE;
+    }
 
-        if (name == NULL) {
-            cons_show("Nickname for %s removed.", jid);
-        } else {
-            cons_show("Nickname for %s set to: %s.", jid, name);
-        }
+    // contact does not exist
+    PContact contact = roster_get_contact(jid);
+    if (contact == NULL) {
+        cons_show("Contact not found in roster: %s", jid);
         return TRUE;
     }
+
+    roster_change_name(jid, name);
+
+    if (name == NULL) {
+        cons_show("Nickname for %s removed.", jid);
+    } else {
+        cons_show("Nickname for %s set to: %s.", jid, name);
+    }
+
+    return TRUE;
 }
 
 static gboolean