From 6082ab8778fb3147081a3b4a9a0c929069a69b73 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 2 Jun 2013 20:20:44 +0100 Subject: Implemented /group command with no args (list groups) --- src/command/command.c | 14 +++++++++++++- src/xmpp/roster.c | 6 ++++++ src/xmpp/xmpp.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/command/command.c b/src/command/command.c index 261afb39..e95e3dc0 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -2136,7 +2136,19 @@ _cmd_group(gchar **args, struct cmd_help_t help) // list all groups if (args[0] == NULL) { - cons_show("LIST GROUPS"); + GSList *groups = roster_get_groups(); + GSList *curr = groups; + if (curr != NULL) { + cons_show("Groups:"); + while (curr != NULL) { + cons_show(" %s", curr->data); + curr = g_slist_next(curr); + } + + g_slist_free_full(groups, g_free); + } else { + cons_show("No groups."); + } return TRUE; } diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index c6039ed2..8e8dc328 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -378,6 +378,12 @@ roster_get_contacts(void) return result; } +GSList * +roster_get_groups(void) +{ + return autocomplete_get_list(groups_ac); +} + GSList * roster_get_group(const char * const group) { diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 50518dba..61f07e5e 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -151,5 +151,6 @@ GSList * roster_get_group(const char * const group); void roster_add_to_group(const char * const group, const char * const barejid); void roster_remove_from_group(const char * const group, const char * const barejid); +GSList * roster_get_groups(void); #endif -- cgit 1.4.1-2-gfad0