From d49a01a9c37b6aff82cac6a61269a87b3bb211dd Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 1 Jun 2013 23:27:46 +0100 Subject: Added roster list when using /roster with no args --- src/command/command.c | 56 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'src/command') 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 -- cgit 1.4.1-2-gfad0