From 778a495fbd708fbb1ac9c6f9eb3c4890a4a51bc3 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 9 Oct 2014 13:16:36 +0100 Subject: Added /occupants commands, unfinished --- src/command/command.c | 9 +++++++++ src/command/commands.c | 29 +++++++++++++++++++++++++++++ src/command/commands.h | 1 + 3 files changed, 39 insertions(+) (limited to 'src/command') diff --git a/src/command/command.c b/src/command/command.c index b4fc5645..f09c8298 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -317,6 +317,15 @@ static struct cmd_t command_defs[] = "info - Show room details.", NULL } } }, + { "/occupants", + cmd_occupants, parse_args, 1, 1, NULL, + { "/occupants show|hide", "Room configuration.", + { "/occupants show|hide", + "--------------------", + "show - Show the occupants panel in chat rooms.", + "hide - Hide the occupants panel in chat rooms.", + NULL } } }, + { "/form", cmd_form, parse_args, 1, 3, NULL, { "/form show|submit|cancel|set|add|remove|help [tag] [value]", "Form manipulation.", diff --git a/src/command/commands.c b/src/command/commands.c index ff202df4..f3f9e4eb 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2326,6 +2326,35 @@ cmd_room(gchar **args, struct cmd_help_t help) return TRUE; } +gboolean +cmd_occupants(gchar **args, struct cmd_help_t help) +{ + jabber_conn_status_t conn_status = jabber_get_connection_status(); + + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } + + win_type_t win_type = ui_current_win_type(); + if (win_type != WIN_MUC) { + cons_show("Command '/occupants' does not apply to this window."); + return TRUE; + } + + char *room = ui_current_recipient(); + + if (g_strcmp0(args[0], "show") == 0) { + ui_room_show_occupants(room); + } else if (g_strcmp0(args[0], "hide") == 0) { + ui_room_hide_occupants(room); + } else { + cons_show("Usage: %s", help.usage); + } + + return TRUE; +} + gboolean cmd_rooms(gchar **args, struct cmd_help_t help) { diff --git a/src/command/commands.h b/src/command/commands.h index 528c78aa..0145cfd8 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -126,5 +126,6 @@ gboolean cmd_alias(gchar **args, struct cmd_help_t help); gboolean cmd_xmlconsole(gchar **args, struct cmd_help_t help); gboolean cmd_ping(gchar **args, struct cmd_help_t help); gboolean cmd_form(gchar **args, struct cmd_help_t help); +gboolean cmd_occupants(gchar **args, struct cmd_help_t help); #endif -- cgit 1.4.1-2-gfad0